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 3 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
25 changes: 25 additions & 0 deletions appshell/cefclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "config.h"

CefRefPtr<ClientHandler> g_handler;
bool g_force_enable_acc = false;

CefRefPtr<CefBrowser> AppGetBrowser() {
if (!g_handler.get())
Expand All @@ -32,6 +33,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 +106,14 @@ void AppGetSettings(CefSettings& settings, CefRefPtr<CefCommandLine> command_lin
// Set product version, which gets added to the User Agent string
CefString(&settings.product_version) = versionStr;
}

// 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;

}
19 changes: 19 additions & 0 deletions appshell/client_app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
#include "appshell/appshell_extension_handler.h"
#include "appshell/appshell_helpers.h"

extern bool g_force_enable_acc;

ClientApp::ClientApp() {
CreateRenderDelegates(render_delegates_);
}
Expand All @@ -42,6 +44,23 @@ void ClientApp::OnContextCreated(CefRefPtr<CefBrowser> browser,
(*it)->OnContextCreated(this, browser, frame, context);
}

void ClientApp::OnBeforeCommandLineProcessing(
const CefString& process_type,
CefRefPtr<CefCommandLine> command_line)
{
// 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");
}

void ClientApp::OnBeforeChildProcessLaunch(
CefRefPtr<CefCommandLine> command_line)
{
if (!g_force_enable_acc)
command_line->AppendSwitch("disable-renderer-accessibility");
}

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