diff --git a/appshell/cefclient.cpp b/appshell/cefclient.cpp index 72777401b..a6bf5aca8 100644 --- a/appshell/cefclient.cpp +++ b/appshell/cefclient.cpp @@ -20,6 +20,10 @@ CefRefPtr g_handler; +#ifdef OS_WIN +bool g_force_enable_acc = false; +#endif + CefRefPtr AppGetBrowser() { if (!g_handler.get()) return NULL; @@ -32,6 +36,20 @@ CefWindowHandle AppGetMainHwnd() { return g_handler->GetMainHwnd(); } +// CefCommandLine::HasSwitch is unable to report the presense of switches, +// in the command line properly. This is a generic function that could be +// used to check for any particular switch, passed as a command line argument. +bool HasSwitch(CefRefPtr command_line , CefString& switch_name) +{ + if (command_line) { + ExtensionString cmdLine = command_line->GetCommandLineString(); + size_t idx = cmdLine.find(switch_name); + return idx > 0 && idx < cmdLine.length(); + } else { + return false; + } +} + // Returns the application settings based on command line arguments. void AppGetSettings(CefSettings& settings, CefRefPtr command_line) { DCHECK(command_line.get()); @@ -91,4 +109,16 @@ void AppGetSettings(CefSettings& settings, CefRefPtr command_lin // Set product version, which gets added to the User Agent string CefString(&settings.product_version) = versionStr; } + +#ifdef OS_WIN + // We disable renderer accessibility by default as it is known to cause performance + // issues. But if any one wants to enable it back, then we need to honor the flag. + + CefString force_acc_switch_name("--force-renderer-accessibility"); + CefString enable_acc_switch_name("--enable-renderer-accessibility"); + + if (HasSwitch(command_line, force_acc_switch_name) || HasSwitch(command_line, enable_acc_switch_name)) + g_force_enable_acc = true; +#endif + } diff --git a/appshell/client_app.cpp b/appshell/client_app.cpp index 828ac8084..82f9a3f7c 100644 --- a/appshell/client_app.cpp +++ b/appshell/client_app.cpp @@ -16,6 +16,10 @@ #include "appshell/appshell_extension_handler.h" #include "appshell/appshell_helpers.h" +#ifdef OS_WIN +extern bool g_force_enable_acc; +#endif + ClientApp::ClientApp() { CreateRenderDelegates(render_delegates_); } @@ -42,6 +46,27 @@ void ClientApp::OnContextCreated(CefRefPtr browser, (*it)->OnContextCreated(this, browser, frame, context); } +void ClientApp::OnBeforeCommandLineProcessing( + const CefString& process_type, + CefRefPtr command_line) +{ + #ifdef OS_WIN + // Check if the user wants to enable renderer accessibility + // and if not, then disable renderer accessibility. + if (!g_force_enable_acc) + command_line->AppendSwitch("disable-renderer-accessibility"); + #endif +} + +void ClientApp::OnBeforeChildProcessLaunch( + CefRefPtr command_line) +{ +#ifdef OS_WIN + if (!g_force_enable_acc) + command_line->AppendSwitch("disable-renderer-accessibility"); +#endif +} + void ClientApp::OnContextReleased(CefRefPtr browser, CefRefPtr frame, CefRefPtr context) { diff --git a/appshell/client_app.h b/appshell/client_app.h index f1a64940c..fa2da0212 100644 --- a/appshell/client_app.h +++ b/appshell/client_app.h @@ -102,6 +102,15 @@ class ClientApp : public CefApp, } virtual CefRefPtr GetRenderProcessHandler() OVERRIDE { return this; } + + virtual CefRefPtr GetBrowserProcessHandler() + OVERRIDE { return this; } + virtual void OnBeforeCommandLineProcessing( + const CefString& process_type, + CefRefPtr command_line); + + virtual void OnBeforeChildProcessLaunch( + CefRefPtr command_line); // CefRenderProcessHandler methods. virtual void OnWebKitInitialized() OVERRIDE;