From 947bb39009488a26b69afe3ac8e44c50ff41812b Mon Sep 17 00:00:00 2001 From: "nasko@chromium.org" Date: Mon, 28 Oct 2013 18:03:15 +0000 Subject: [PATCH] Move GetWebkitPrefs from WebContentsImpl to RenderViewHostImpl. GetWebkitPrefs needs to move away from WebContentsImpl, so InterstitialPageImpl can remove its dependency on WebContentsImpl. Also, it doesn't use anything specific to WebContents, but it is for a RenderViewHost, so it makes sense to move there. BUG=304341 Review URL: https://codereview.chromium.org/45313003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@231358 0039d316-1c4b-4281-b951-d872f2087c98 --- .../browser/renderer_host/render_view_host_impl.cc | 227 ++++++++++++++++++++ .../browser/renderer_host/render_view_host_impl.h | 3 + .../browser/web_contents/interstitial_page_impl.cc | 2 +- content/browser/web_contents/web_contents_impl.cc | 231 +-------------------- content/browser/web_contents/web_contents_impl.h | 4 - 5 files changed, 233 insertions(+), 234 deletions(-) diff --git a/content/browser/renderer_host/render_view_host_impl.cc b/content/browser/renderer_host/render_view_host_impl.cc index 92c3d368d526..8018d57b1975 100644 --- a/content/browser/renderer_host/render_view_host_impl.cc +++ b/content/browser/renderer_host/render_view_host_impl.cc @@ -20,11 +20,16 @@ #include "base/stl_util.h" #include "base/strings/string_util.h" #include "base/strings/utf_string_conversions.h" +#include "base/sys_info.h" #include "base/time/time.h" #include "base/values.h" +#include "cc/base/switches.h" #include "content/browser/child_process_security_policy_impl.h" #include "content/browser/cross_site_request_manager.h" #include "content/browser/dom_storage/session_storage_namespace_impl.h" +#include "content/browser/gpu/compositor_util.h" +#include "content/browser/gpu/gpu_data_manager_impl.h" +#include "content/browser/gpu/gpu_process_host.h" #include "content/browser/gpu/gpu_surface_tracker.h" #include "content/browser/host_zoom_map_impl.h" #include "content/browser/loader/resource_dispatcher_host_impl.h" @@ -65,8 +70,12 @@ #include "content/public/common/url_constants.h" #include "content/public/common/url_utils.h" #include "net/base/net_util.h" +#include "net/base/network_change_notifier.h" #include "net/url_request/url_request_context_getter.h" #include "third_party/skia/include/core/SkBitmap.h" +#include "ui/base/touch/touch_device.h" +#include "ui/base/touch/touch_enabled.h" +#include "ui/base/ui_base_switches.h" #include "ui/gfx/image/image_skia.h" #include "ui/gfx/native_widget_types.h" #include "ui/shell_dialogs/selected_file_info.h" @@ -318,6 +327,224 @@ void RenderViewHostImpl::SyncRendererPrefs() { GetProcess()->GetBrowserContext()))); } +WebPreferences RenderViewHostImpl::GetWebkitPrefs(const GURL& url) { + TRACE_EVENT0("browser", "RenderViewHostImpl::GetWebkitPrefs"); + WebPreferences prefs; + + const CommandLine& command_line = *CommandLine::ForCurrentProcess(); + + prefs.javascript_enabled = + !command_line.HasSwitch(switches::kDisableJavaScript); + prefs.web_security_enabled = + !command_line.HasSwitch(switches::kDisableWebSecurity); + prefs.plugins_enabled = + !command_line.HasSwitch(switches::kDisablePlugins); + prefs.java_enabled = + !command_line.HasSwitch(switches::kDisableJava); + + prefs.remote_fonts_enabled = + !command_line.HasSwitch(switches::kDisableRemoteFonts); + prefs.xslt_enabled = + !command_line.HasSwitch(switches::kDisableXSLT); + prefs.xss_auditor_enabled = + !command_line.HasSwitch(switches::kDisableXSSAuditor); + prefs.application_cache_enabled = + !command_line.HasSwitch(switches::kDisableApplicationCache); + + prefs.local_storage_enabled = + !command_line.HasSwitch(switches::kDisableLocalStorage); + prefs.databases_enabled = + !command_line.HasSwitch(switches::kDisableDatabases); + prefs.webaudio_enabled = + !command_line.HasSwitch(switches::kDisableWebAudio); + + prefs.experimental_webgl_enabled = + GpuProcessHost::gpu_enabled() && + !command_line.HasSwitch(switches::kDisable3DAPIs) && + !command_line.HasSwitch(switches::kDisableExperimentalWebGL); + + prefs.flash_3d_enabled = + GpuProcessHost::gpu_enabled() && + !command_line.HasSwitch(switches::kDisableFlash3d); + prefs.flash_stage3d_enabled = + GpuProcessHost::gpu_enabled() && + !command_line.HasSwitch(switches::kDisableFlashStage3d); + prefs.flash_stage3d_baseline_enabled = + GpuProcessHost::gpu_enabled() && + !command_line.HasSwitch(switches::kDisableFlashStage3d); + + prefs.gl_multisampling_enabled = + !command_line.HasSwitch(switches::kDisableGLMultisampling); + prefs.privileged_webgl_extensions_enabled = + command_line.HasSwitch(switches::kEnablePrivilegedWebGLExtensions); + prefs.site_specific_quirks_enabled = + !command_line.HasSwitch(switches::kDisableSiteSpecificQuirks); + prefs.allow_file_access_from_file_urls = + command_line.HasSwitch(switches::kAllowFileAccessFromFiles); + + prefs.accelerated_compositing_for_overflow_scroll_enabled = false; + if (command_line.HasSwitch(switches::kEnableAcceleratedOverflowScroll)) + prefs.accelerated_compositing_for_overflow_scroll_enabled = true; + if (command_line.HasSwitch(switches::kDisableAcceleratedOverflowScroll)) + prefs.accelerated_compositing_for_overflow_scroll_enabled = false; + + prefs.accelerated_compositing_for_scrollable_frames_enabled = false; + if (command_line.HasSwitch(switches::kEnableAcceleratedScrollableFrames)) + prefs.accelerated_compositing_for_scrollable_frames_enabled = true; + if (command_line.HasSwitch(switches::kDisableAcceleratedScrollableFrames)) + prefs.accelerated_compositing_for_scrollable_frames_enabled = false; + + prefs.composited_scrolling_for_frames_enabled = false; + if (command_line.HasSwitch(switches::kEnableCompositedScrollingForFrames)) + prefs.composited_scrolling_for_frames_enabled = true; + if (command_line.HasSwitch(switches::kDisableCompositedScrollingForFrames)) + prefs.composited_scrolling_for_frames_enabled = false; + + prefs.universal_accelerated_compositing_for_overflow_scroll_enabled = false; + if (command_line.HasSwitch( + switches::kEnableUniversalAcceleratedOverflowScroll)) + prefs.universal_accelerated_compositing_for_overflow_scroll_enabled = true; + if (command_line.HasSwitch( + switches::kDisableUniversalAcceleratedOverflowScroll)) + prefs.universal_accelerated_compositing_for_overflow_scroll_enabled = false; + + prefs.show_paint_rects = + command_line.HasSwitch(switches::kShowPaintRects); + prefs.accelerated_compositing_enabled = + GpuProcessHost::gpu_enabled() && + !command_line.HasSwitch(switches::kDisableAcceleratedCompositing); + prefs.force_compositing_mode = + content::IsForceCompositingModeEnabled() && + !command_line.HasSwitch(switches::kDisableForceCompositingMode); + prefs.accelerated_2d_canvas_enabled = + GpuProcessHost::gpu_enabled() && + !command_line.HasSwitch(switches::kDisableAccelerated2dCanvas); + prefs.antialiased_2d_canvas_disabled = + command_line.HasSwitch(switches::kDisable2dCanvasAntialiasing); + prefs.accelerated_2d_canvas_msaa_sample_count = + atoi(command_line.GetSwitchValueASCII( + switches::kAcceleratedCanvas2dMSAASampleCount).c_str()); + prefs.accelerated_filters_enabled = + GpuProcessHost::gpu_enabled() && + command_line.HasSwitch(switches::kEnableAcceleratedFilters); + prefs.accelerated_compositing_for_3d_transforms_enabled = + prefs.accelerated_compositing_for_animation_enabled = + !command_line.HasSwitch(switches::kDisableAcceleratedLayers); + prefs.accelerated_compositing_for_plugins_enabled = + !command_line.HasSwitch(switches::kDisableAcceleratedPlugins); + prefs.accelerated_compositing_for_video_enabled = + !command_line.HasSwitch(switches::kDisableAcceleratedVideo); + prefs.fullscreen_enabled = + !command_line.HasSwitch(switches::kDisableFullScreen); + prefs.lazy_layout_enabled = + command_line.HasSwitch(switches::kEnableExperimentalWebPlatformFeatures); + prefs.region_based_columns_enabled = + command_line.HasSwitch(switches::kEnableRegionBasedColumns); + prefs.threaded_html_parser = + !command_line.HasSwitch(switches::kDisableThreadedHTMLParser); + prefs.experimental_websocket_enabled = + command_line.HasSwitch(switches::kEnableExperimentalWebSocket); + if (command_line.HasSwitch(cc::switches::kEnablePinchVirtualViewport)) { + prefs.pinch_virtual_viewport_enabled = true; + prefs.pinch_overlay_scrollbar_thickness = 10; + } + prefs.use_solid_color_scrollbars = command_line.HasSwitch( + switches::kEnableOverlayScrollbars); + +#if defined(OS_ANDROID) + prefs.user_gesture_required_for_media_playback = !command_line.HasSwitch( + switches::kDisableGestureRequirementForMediaPlayback); + prefs.user_gesture_required_for_media_fullscreen = !command_line.HasSwitch( + switches::kDisableGestureRequirementForMediaFullscreen); +#endif + + prefs.touch_enabled = ui::AreTouchEventsEnabled(); + prefs.device_supports_touch = prefs.touch_enabled && + ui::IsTouchDevicePresent(); +#if defined(OS_ANDROID) + prefs.device_supports_mouse = false; +#endif + + prefs.pointer_events_max_touch_points = ui::MaxTouchPoints(); + + prefs.touch_adjustment_enabled = + !command_line.HasSwitch(switches::kDisableTouchAdjustment); + prefs.compositor_touch_hit_testing = + !command_line.HasSwitch(cc::switches::kDisableCompositorTouchHitTesting); + +#if defined(OS_MACOSX) || defined(OS_CHROMEOS) + bool default_enable_scroll_animator = true; +#else + bool default_enable_scroll_animator = false; +#endif + prefs.enable_scroll_animator = default_enable_scroll_animator; + if (command_line.HasSwitch(switches::kEnableSmoothScrolling)) + prefs.enable_scroll_animator = true; + if (command_line.HasSwitch(switches::kDisableSmoothScrolling)) + prefs.enable_scroll_animator = false; + + prefs.visual_word_movement_enabled = + command_line.HasSwitch(switches::kEnableVisualWordMovement); + + // Certain GPU features might have been blacklisted. + GpuDataManagerImpl::GetInstance()->UpdateRendererWebPrefs(&prefs); + + if (ChildProcessSecurityPolicyImpl::GetInstance()->HasWebUIBindings( + GetProcess()->GetID())) { + prefs.loads_images_automatically = true; + prefs.javascript_enabled = true; + } + + prefs.is_online = !net::NetworkChangeNotifier::IsOffline(); + +#if !defined(USE_AURA) + // Force accelerated compositing and 2d canvas off for chrome: and about: + // pages (unless it's specifically allowed). + if ((url.SchemeIs(chrome::kChromeUIScheme) || + (url.SchemeIs(chrome::kAboutScheme) && + url.spec() != kAboutBlankURL)) && + !command_line.HasSwitch(switches::kAllowWebUICompositing)) { + prefs.accelerated_compositing_enabled = false; + prefs.accelerated_2d_canvas_enabled = false; + } +#endif + + prefs.fixed_position_creates_stacking_context = !command_line.HasSwitch( + switches::kDisableFixedPositionCreatesStackingContext); + +#if defined(OS_CHROMEOS) + prefs.gesture_tap_highlight_enabled = !command_line.HasSwitch( + switches::kDisableGestureTapHighlight); +#else + prefs.gesture_tap_highlight_enabled = command_line.HasSwitch( + switches::kEnableGestureTapHighlight); +#endif + + prefs.number_of_cpu_cores = base::SysInfo::NumberOfProcessors(); + + prefs.viewport_enabled = command_line.HasSwitch(switches::kEnableViewport); + + prefs.deferred_image_decoding_enabled = + command_line.HasSwitch(switches::kEnableDeferredImageDecoding) || + cc::switches::IsImplSidePaintingEnabled(); + + prefs.spatial_navigation_enabled = command_line.HasSwitch( + switches::kEnableSpatialNavigation); + + GetContentClient()->browser()->OverrideWebkitPrefs(this, url, &prefs); + + // Disable compositing in guests until we have compositing path implemented + // for guests. + bool guest_compositing_enabled = !command_line.HasSwitch( + switches::kDisableBrowserPluginCompositing); + if (GetProcess()->IsGuest() && !guest_compositing_enabled) { + prefs.force_compositing_mode = false; + prefs.accelerated_compositing_enabled = false; + } + + return prefs; +} + void RenderViewHostImpl::Navigate(const ViewMsg_Navigate_Params& params) { TRACE_EVENT0("renderer_host", "RenderViewHostImpl::Navigate"); // Browser plugin guests are not allowed to navigate outside web-safe schemes, diff --git a/content/browser/renderer_host/render_view_host_impl.h b/content/browser/renderer_host/render_view_host_impl.h index 3ac045d9aeba..bafe1ebd13fd 100644 --- a/content/browser/renderer_host/render_view_host_impl.h +++ b/content/browser/renderer_host/render_view_host_impl.h @@ -242,6 +242,9 @@ class CONTENT_EXPORT RenderViewHostImpl return render_view_termination_status_; } + // Returns the content specific prefs for this RenderViewHost. + WebPreferences GetWebkitPrefs(const GURL& url); + // Sends the given navigation message. Use this rather than sending it // yourself since this does the internal bookkeeping described below. This // function takes ownership of the provided message pointer. diff --git a/content/browser/web_contents/interstitial_page_impl.cc b/content/browser/web_contents/interstitial_page_impl.cc index ece0059514c9..44d28e187daa 100644 --- a/content/browser/web_contents/interstitial_page_impl.cc +++ b/content/browser/web_contents/interstitial_page_impl.cc @@ -465,7 +465,7 @@ WebPreferences InterstitialPageImpl::GetWebkitPrefs() { if (!enabled()) return WebPreferences(); - return WebContentsImpl::GetWebkitPrefs(render_view_host_, url_); + return render_view_host_->GetWebkitPrefs(url_); } void InterstitialPageImpl::RenderWidgetDeleted( diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc index ea394e666c2a..8121293d0c80 100644 --- a/content/browser/web_contents/web_contents_impl.cc +++ b/content/browser/web_contents/web_contents_impl.cc @@ -16,9 +16,7 @@ #include "base/strings/string_number_conversions.h" #include "base/strings/string_util.h" #include "base/strings/utf_string_conversions.h" -#include "base/sys_info.h" #include "base/time/time.h" -#include "cc/base/switches.h" #include "content/browser/browser_plugin/browser_plugin_embedder.h" #include "content/browser/browser_plugin/browser_plugin_guest.h" #include "content/browser/browser_plugin/browser_plugin_guest_manager.h" @@ -29,9 +27,6 @@ #include "content/browser/download/download_stats.h" #include "content/browser/download/mhtml_generation_manager.h" #include "content/browser/download/save_package.h" -#include "content/browser/gpu/compositor_util.h" -#include "content/browser/gpu/gpu_data_manager_impl.h" -#include "content/browser/gpu/gpu_process_host.h" #include "content/browser/host_zoom_map_impl.h" #include "content/browser/loader/resource_dispatcher_host_impl.h" #include "content/browser/message_port_message_filter.h" @@ -80,15 +75,11 @@ #include "content/public/common/url_constants.h" #include "net/base/mime_util.h" #include "net/base/net_util.h" -#include "net/base/network_change_notifier.h" #include "net/http/http_cache.h" #include "net/http/http_transaction_factory.h" #include "net/url_request/url_request_context.h" #include "net/url_request/url_request_context_getter.h" #include "ui/base/layout.h" -#include "ui/base/touch/touch_device.h" -#include "ui/base/touch/touch_enabled.h" -#include "ui/base/ui_base_switches.h" #include "ui/gfx/display.h" #include "ui/gfx/screen.h" #include "ui/gl/gl_switches.h" @@ -472,225 +463,6 @@ BrowserPluginGuest* WebContentsImpl::CreateGuest( return new_contents->browser_plugin_guest_.get(); } -WebPreferences WebContentsImpl::GetWebkitPrefs(RenderViewHost* rvh, - const GURL& url) { - TRACE_EVENT0("browser", "WebContentsImpl::GetWebkitPrefs"); - WebPreferences prefs; - - const CommandLine& command_line = *CommandLine::ForCurrentProcess(); - - prefs.javascript_enabled = - !command_line.HasSwitch(switches::kDisableJavaScript); - prefs.web_security_enabled = - !command_line.HasSwitch(switches::kDisableWebSecurity); - prefs.plugins_enabled = - !command_line.HasSwitch(switches::kDisablePlugins); - prefs.java_enabled = - !command_line.HasSwitch(switches::kDisableJava); - - prefs.remote_fonts_enabled = - !command_line.HasSwitch(switches::kDisableRemoteFonts); - prefs.xslt_enabled = - !command_line.HasSwitch(switches::kDisableXSLT); - prefs.xss_auditor_enabled = - !command_line.HasSwitch(switches::kDisableXSSAuditor); - prefs.application_cache_enabled = - !command_line.HasSwitch(switches::kDisableApplicationCache); - - prefs.local_storage_enabled = - !command_line.HasSwitch(switches::kDisableLocalStorage); - prefs.databases_enabled = - !command_line.HasSwitch(switches::kDisableDatabases); - prefs.webaudio_enabled = - !command_line.HasSwitch(switches::kDisableWebAudio); - - prefs.experimental_webgl_enabled = - GpuProcessHost::gpu_enabled() && - !command_line.HasSwitch(switches::kDisable3DAPIs) && - !command_line.HasSwitch(switches::kDisableExperimentalWebGL); - - prefs.flash_3d_enabled = - GpuProcessHost::gpu_enabled() && - !command_line.HasSwitch(switches::kDisableFlash3d); - prefs.flash_stage3d_enabled = - GpuProcessHost::gpu_enabled() && - !command_line.HasSwitch(switches::kDisableFlashStage3d); - prefs.flash_stage3d_baseline_enabled = - GpuProcessHost::gpu_enabled() && - !command_line.HasSwitch(switches::kDisableFlashStage3d); - - prefs.gl_multisampling_enabled = - !command_line.HasSwitch(switches::kDisableGLMultisampling); - prefs.privileged_webgl_extensions_enabled = - command_line.HasSwitch(switches::kEnablePrivilegedWebGLExtensions); - prefs.site_specific_quirks_enabled = - !command_line.HasSwitch(switches::kDisableSiteSpecificQuirks); - prefs.allow_file_access_from_file_urls = - command_line.HasSwitch(switches::kAllowFileAccessFromFiles); - - prefs.accelerated_compositing_for_overflow_scroll_enabled = false; - if (command_line.HasSwitch(switches::kEnableAcceleratedOverflowScroll)) - prefs.accelerated_compositing_for_overflow_scroll_enabled = true; - if (command_line.HasSwitch(switches::kDisableAcceleratedOverflowScroll)) - prefs.accelerated_compositing_for_overflow_scroll_enabled = false; - - prefs.accelerated_compositing_for_scrollable_frames_enabled = false; - if (command_line.HasSwitch(switches::kEnableAcceleratedScrollableFrames)) - prefs.accelerated_compositing_for_scrollable_frames_enabled = true; - if (command_line.HasSwitch(switches::kDisableAcceleratedScrollableFrames)) - prefs.accelerated_compositing_for_scrollable_frames_enabled = false; - - prefs.composited_scrolling_for_frames_enabled = false; - if (command_line.HasSwitch(switches::kEnableCompositedScrollingForFrames)) - prefs.composited_scrolling_for_frames_enabled = true; - if (command_line.HasSwitch(switches::kDisableCompositedScrollingForFrames)) - prefs.composited_scrolling_for_frames_enabled = false; - - prefs.universal_accelerated_compositing_for_overflow_scroll_enabled = false; - if (command_line.HasSwitch( - switches::kEnableUniversalAcceleratedOverflowScroll)) - prefs.universal_accelerated_compositing_for_overflow_scroll_enabled = true; - if (command_line.HasSwitch( - switches::kDisableUniversalAcceleratedOverflowScroll)) - prefs.universal_accelerated_compositing_for_overflow_scroll_enabled = false; - - prefs.show_paint_rects = - command_line.HasSwitch(switches::kShowPaintRects); - prefs.accelerated_compositing_enabled = - GpuProcessHost::gpu_enabled() && - !command_line.HasSwitch(switches::kDisableAcceleratedCompositing); - prefs.force_compositing_mode = - content::IsForceCompositingModeEnabled() && - !command_line.HasSwitch(switches::kDisableForceCompositingMode); - prefs.accelerated_2d_canvas_enabled = - GpuProcessHost::gpu_enabled() && - !command_line.HasSwitch(switches::kDisableAccelerated2dCanvas); - prefs.antialiased_2d_canvas_disabled = - command_line.HasSwitch(switches::kDisable2dCanvasAntialiasing); - prefs.accelerated_2d_canvas_msaa_sample_count = - atoi(command_line.GetSwitchValueASCII( - switches::kAcceleratedCanvas2dMSAASampleCount).c_str()); - prefs.accelerated_filters_enabled = - GpuProcessHost::gpu_enabled() && - command_line.HasSwitch(switches::kEnableAcceleratedFilters); - prefs.accelerated_compositing_for_3d_transforms_enabled = - prefs.accelerated_compositing_for_animation_enabled = - !command_line.HasSwitch(switches::kDisableAcceleratedLayers); - prefs.accelerated_compositing_for_plugins_enabled = - !command_line.HasSwitch(switches::kDisableAcceleratedPlugins); - prefs.accelerated_compositing_for_video_enabled = - !command_line.HasSwitch(switches::kDisableAcceleratedVideo); - prefs.fullscreen_enabled = - !command_line.HasSwitch(switches::kDisableFullScreen); - prefs.lazy_layout_enabled = - command_line.HasSwitch(switches::kEnableExperimentalWebPlatformFeatures); - prefs.region_based_columns_enabled = - command_line.HasSwitch(switches::kEnableRegionBasedColumns); - prefs.threaded_html_parser = - !command_line.HasSwitch(switches::kDisableThreadedHTMLParser); - prefs.experimental_websocket_enabled = - command_line.HasSwitch(switches::kEnableExperimentalWebSocket); - if (command_line.HasSwitch(cc::switches::kEnablePinchVirtualViewport)) { - prefs.pinch_virtual_viewport_enabled = true; - prefs.pinch_overlay_scrollbar_thickness = 10; - } - prefs.use_solid_color_scrollbars = command_line.HasSwitch( - switches::kEnableOverlayScrollbars); - -#if defined(OS_ANDROID) - prefs.user_gesture_required_for_media_playback = !command_line.HasSwitch( - switches::kDisableGestureRequirementForMediaPlayback); - prefs.user_gesture_required_for_media_fullscreen = !command_line.HasSwitch( - switches::kDisableGestureRequirementForMediaFullscreen); -#endif - - prefs.touch_enabled = ui::AreTouchEventsEnabled(); - prefs.device_supports_touch = prefs.touch_enabled && - ui::IsTouchDevicePresent(); -#if defined(OS_ANDROID) - prefs.device_supports_mouse = false; -#endif - - prefs.pointer_events_max_touch_points = ui::MaxTouchPoints(); - - prefs.touch_adjustment_enabled = - !command_line.HasSwitch(switches::kDisableTouchAdjustment); - prefs.compositor_touch_hit_testing = - !command_line.HasSwitch(cc::switches::kDisableCompositorTouchHitTesting); - -#if defined(OS_MACOSX) || defined(OS_CHROMEOS) - bool default_enable_scroll_animator = true; -#else - bool default_enable_scroll_animator = false; -#endif - prefs.enable_scroll_animator = default_enable_scroll_animator; - if (command_line.HasSwitch(switches::kEnableSmoothScrolling)) - prefs.enable_scroll_animator = true; - if (command_line.HasSwitch(switches::kDisableSmoothScrolling)) - prefs.enable_scroll_animator = false; - - prefs.visual_word_movement_enabled = - command_line.HasSwitch(switches::kEnableVisualWordMovement); - - // Certain GPU features might have been blacklisted. - GpuDataManagerImpl::GetInstance()->UpdateRendererWebPrefs(&prefs); - - if (ChildProcessSecurityPolicyImpl::GetInstance()->HasWebUIBindings( - rvh->GetProcess()->GetID())) { - prefs.loads_images_automatically = true; - prefs.javascript_enabled = true; - } - - prefs.is_online = !net::NetworkChangeNotifier::IsOffline(); - -#if !defined(USE_AURA) - // Force accelerated compositing and 2d canvas off for chrome: and about: - // pages (unless it's specifically allowed). - if ((url.SchemeIs(chrome::kChromeUIScheme) || - (url.SchemeIs(chrome::kAboutScheme) && - url.spec() != kAboutBlankURL)) && - !command_line.HasSwitch(switches::kAllowWebUICompositing)) { - prefs.accelerated_compositing_enabled = false; - prefs.accelerated_2d_canvas_enabled = false; - } -#endif - - prefs.fixed_position_creates_stacking_context = !command_line.HasSwitch( - switches::kDisableFixedPositionCreatesStackingContext); - -#if defined(OS_CHROMEOS) - prefs.gesture_tap_highlight_enabled = !command_line.HasSwitch( - switches::kDisableGestureTapHighlight); -#else - prefs.gesture_tap_highlight_enabled = command_line.HasSwitch( - switches::kEnableGestureTapHighlight); -#endif - - prefs.number_of_cpu_cores = base::SysInfo::NumberOfProcessors(); - - prefs.viewport_enabled = command_line.HasSwitch(switches::kEnableViewport); - - prefs.deferred_image_decoding_enabled = - command_line.HasSwitch(switches::kEnableDeferredImageDecoding) || - cc::switches::IsImplSidePaintingEnabled(); - - prefs.spatial_navigation_enabled = command_line.HasSwitch( - switches::kEnableSpatialNavigation); - - GetContentClient()->browser()->OverrideWebkitPrefs(rvh, url, &prefs); - - // Disable compositing in guests until we have compositing path implemented - // for guests. - bool guest_compositing_enabled = !command_line.HasSwitch( - switches::kDisableBrowserPluginCompositing); - if (rvh->GetProcess()->IsGuest() && !guest_compositing_enabled) { - prefs.force_compositing_mode = false; - prefs.accelerated_compositing_enabled = false; - } - - return prefs; -} - RenderViewHostManager* WebContentsImpl::GetRenderManagerForTesting() { return &render_manager_; } @@ -3550,7 +3322,8 @@ WebPreferences WebContentsImpl::GetWebkitPrefs() { // as it is deprecated and can be out of sync with GetRenderViewHost(). GURL url = controller_.GetActiveEntry() ? controller_.GetActiveEntry()->GetURL() : GURL::EmptyGURL(); - return GetWebkitPrefs(GetRenderViewHost(), url); + + return render_manager_.current_host()->GetWebkitPrefs(url); } int WebContentsImpl::CreateSwappedOutRenderView( diff --git a/content/browser/web_contents/web_contents_impl.h b/content/browser/web_contents/web_contents_impl.h index 2396bd0aa202..d10990dd6e27 100644 --- a/content/browser/web_contents/web_contents_impl.h +++ b/content/browser/web_contents/web_contents_impl.h @@ -97,10 +97,6 @@ class CONTENT_EXPORT WebContentsImpl int guest_instance_id, scoped_ptr extra_params); - // Returns the content specific prefs for the given RVH. - static WebPreferences GetWebkitPrefs( - RenderViewHost* rvh, const GURL& url); - // Creates a swapped out RenderView. This is used by the browser plugin to // create a swapped out RenderView in the embedder render process for the // guest, to expose the guest's window object to the embedder. -- 2.11.4.GIT