From 03301c0fbdf034fb987e1c1ed1bec7c206dcd27e Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Thu, 15 Oct 2015 13:53:29 +0200 Subject: Add WebGL, WebAudio and Accelerated2dCanvas settings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit These settings were in QtWebKit and are easily added in QtWebEngine. Without the preferences the same could be achieved using command line flags. The defaults are calculated to match what is set in RenderViewHostImpl. Change-Id: I0c80507574ebc3898fc409e47194246fb00abc75 Reviewed-by: Michael BrĂ¼ning --- src/core/web_engine_settings.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/core/web_engine_settings.cpp') diff --git a/src/core/web_engine_settings.cpp b/src/core/web_engine_settings.cpp index 88d8a0c5c..96e87d4f1 100644 --- a/src/core/web_engine_settings.cpp +++ b/src/core/web_engine_settings.cpp @@ -38,6 +38,9 @@ #include "web_contents_adapter.h" #include "type_conversion.h" +#include "base/command_line.h" +#include "content/browser/gpu/gpu_process_host.h" +#include "content/public/common/content_switches.h" #include "content/public/common/web_preferences.h" #include @@ -230,6 +233,16 @@ void WebEngineSettings::initDefaults(bool offTheRecord) m_defaultAttributes.insert(PluginsEnabled, false); m_defaultAttributes.insert(FullScreenSupportEnabled, false); m_defaultAttributes.insert(ScreenCaptureEnabled, false); + // The following defaults matches logic in render_view_host_impl.cc: + base::CommandLine* commandLine = base::CommandLine::ForCurrentProcess(); + bool webGL = content::GpuProcessHost::gpu_enabled() && + !commandLine->HasSwitch(switches::kDisable3DAPIs) && + !commandLine->HasSwitch(switches::kDisableExperimentalWebGL); + bool accelerated2dCanvas = content::GpuProcessHost::gpu_enabled() && + !commandLine->HasSwitch(switches::kDisableAccelerated2dCanvas); + m_defaultAttributes.insert(WebGLEnabled, webGL); + m_defaultAttributes.insert(WebAudioEnabled, false); + m_defaultAttributes.insert(Accelerated2dCanvasEnabled, accelerated2dCanvas); } m_attributes = m_defaultAttributes; @@ -303,6 +316,9 @@ void WebEngineSettings::applySettingsToWebPreferences(content::WebPreferences *p prefs->enable_error_page = testAttribute(ErrorPageEnabled); prefs->plugins_enabled = testAttribute(PluginsEnabled); prefs->fullscreen_supported = testAttribute(FullScreenSupportEnabled); + prefs->accelerated_2d_canvas_enabled = testAttribute(Accelerated2dCanvasEnabled); + prefs->webaudio_enabled = testAttribute(WebAudioEnabled); + prefs->experimental_webgl_enabled = testAttribute(WebGLEnabled); // Fonts settings. prefs->standard_font_family_map[content::kCommonScript] = toString16(fontFamily(StandardFont)); -- cgit v1.2.3