How do I bypass the "Flash Camera and Microphone Access" pop-up when using Pepper/PPAPI Flash in Chrome (via Selenium)?
Question: Chrome supports two flavors of Flash: NPAPI and PPAPI (Pepper). These two
implementations seem to handle camera and microphone permissions differently.
Specifically, PPAPI (Pepper) does not appear to honor any previous grants of
permission.

With NPAPI, which is the default, the first time I navigate to a Flash site
that requests permission to use the computer's camera and microphone, an Adobe
Flash pop-up asks the user to allow or deny access. I allow access, and this
grant is remembered. The next time I navigate to that site, permission is
granted automatically, without the pop-up.

When I want to test with PPAPI (Pepper) Flash, I specify the "--enable-
bundled-ppapi-flash" and "--disable-npapi" command-line arguments to Chrome.
In this mode, the previous grants are ignored, and the pop-up is displayed
every time. I have not figured out how to detect this in Selenium and click on
"Allow".

Does anyone know how to bypass this pop-up, either by clicking on "Allow", or
by disabling it altogether?

Thanks.

**Update:** I have discovered that non-Pepper Flash stores camera/microphone
permissions in a file called 'settings.sol', stored in a directory specific to
the site requesting access. For example, on Windows, when the host at 1.2.3.4
requests access, the following file is created:

C:\Users[user]\AppData\Roaming\Macromedia\Flash
Player\macromedia.com\support\flashplayer\sys#1.2.3.4\settings.sol

Note the space in "Flash Player". This file is a local shared object, encoded
as AMF. I use the Python pyamf package to create a file that grants permanent
access to a site:

    
    
    from pyamf import sol
    
    permissions = sol.SOL ('1.2.3.4/settings')
    permissions[u'always'] = True
    permissions[u'allow'] = True
    permissions[u'klimit'] = 100
    sol.save (permissions, 'my-settings.sol')
    

When I copy this to the appropriate directory, access is granted
automatically. But again, this does not work for Pepper Flash.

Pepper Flash ignores this directory, and instead gets a new temporary
directory for each instance of Chrome:

C:\Users[user]\AppData\Local\Temp\scoped_dir5976_6686\Default\Pepper
Data\Shockwave Flash\WritableRoot#SharedObje
cts\6DMDJWLP\macromedia.com\support\flashplayer\sys#1.2.3.4\settings.sol

Unfortunately, the directory changes on each invocation. If I could somehow
discover the name of this directory, then I could upload the file before
requesting access.

But I don't know how to discover the name of this directory.


Answer: It turns out that my problem was specific to Selenium, and how I was using
Selenium.

First, back to NPAPI Flash, which stores its permissions on Windows in a
subdirectory under the user directory; for example:

    
    
    C:\Users[user]\AppData\Roaming\Macromedia\Flash  Player\macromedia.com\support\flashplayer\sys
    

Pepper Flash does not use this directory for its permissions, and thus does
not honor the settings stored there. Instead, it stores its permissions files
in a subdirectory that is underneath the Chrome user's data directory.

When I was creating a Chrome browser instance via Selenium, a temporary user
data directory was created for the session For example:

    
    
    C:\Users[user]\AppData\Local\Temp\scoped_dir5976_6686
    

Pepper Flash was storing its permissions files underneath this directory, but
when the browser session ended, this temporary directory was deleted, and the
settings were forgotten.

The solution is simple: when starting Chrome via Selenium, specify the Chrome
user's data directory via a command-line argument:

    
    
    "user-data-dir=C:\\Users\\[user]\AppData\Local\Google\Chrome\User Data"
    

Pepper Flash will then store its permissions in this directory, and because it
is a permanent directory that does not get deleted when the browser session
ends, it will be there for the next instance, and thus the permissions granted
will be remembered.

