Skip to content
This repository has been archived by the owner on Sep 2, 2021. It is now read-only.

Forcefully disabling renderer accesibility #660

Merged
merged 4 commits into from
Oct 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions appshell/cefclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@

CefRefPtr<ClientHandler> g_handler;

#ifdef OS_WIN
bool g_force_enable_acc = false;
#endif

CefRefPtr<CefBrowser> AppGetBrowser() {
if (!g_handler.get())
return NULL;
Expand All @@ -32,6 +36,20 @@ CefWindowHandle AppGetMainHwnd() {
return g_handler->GetMainHwnd();
}

// CefCommandLine::HasSwitch is unable to report the presense of switches,
vickramdhawal marked this conversation as resolved.
Show resolved Hide resolved
// 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<CefCommandLine> 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<CefCommandLine> command_line) {
DCHECK(command_line.get());
Expand Down Expand Up @@ -91,4 +109,16 @@ void AppGetSettings(CefSettings& settings, CefRefPtr<CefCommandLine> 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

}
25 changes: 25 additions & 0 deletions appshell/client_app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_);
}
Expand All @@ -42,6 +46,27 @@ void ClientApp::OnContextCreated(CefRefPtr<CefBrowser> browser,
(*it)->OnContextCreated(this, browser, frame, context);
}

void ClientApp::OnBeforeCommandLineProcessing(
const CefString& process_type,
CefRefPtr<CefCommandLine> 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<CefCommandLine> command_line)
{
#ifdef OS_WIN
if (!g_force_enable_acc)
command_line->AppendSwitch("disable-renderer-accessibility");
#endif
}

void ClientApp::OnContextReleased(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefV8Context> context) {
Expand Down
9 changes: 9 additions & 0 deletions appshell/client_app.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,15 @@ class ClientApp : public CefApp,
}
virtual CefRefPtr<CefRenderProcessHandler> GetRenderProcessHandler()
OVERRIDE { return this; }

virtual CefRefPtr<CefBrowserProcessHandler> GetBrowserProcessHandler()
OVERRIDE { return this; }
virtual void OnBeforeCommandLineProcessing(
const CefString& process_type,
CefRefPtr<CefCommandLine> command_line);

virtual void OnBeforeChildProcessLaunch(
CefRefPtr<CefCommandLine> command_line);

// CefRenderProcessHandler methods.
virtual void OnWebKitInitialized() OVERRIDE;
Expand Down