Stop disabling force_compositing_mode for background RenderViews.

When a RenderView's WebContents are a VIEW_TYPE_BACKGROUND_CONTENTS or
a VIEW_TYPE_EXTENSION_BACKGROUND_PAGE, the RenderView is in the
background and never visible.

Currently we disable force_compositing_mode to prevent allocating a
GPU context for the view. Since force_compositing_mode is the standard
and we are deleting other code paths, we should stop trying to disable
the setting.

Instead, add a new parameter to the ViewMsg_New IPC for |background|,
and for a RenderView that |is_background|, when the RenderWidget makes
an OutputSurface for the compositor, it creates a new NullOutputSurface
which declares itself as a delegated compositor without a GPU context.
This puts the compositor into a similar state to software compositing,
but since the renderer never presents frames, the OutputSurface
provides no way of getting frames to the browser process.

[email protected], [email protected]
BUG=362165

Review URL: https://codereview.chromium.org/233093006

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@264075 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc
index 8cb6d43..cc2f998c 100644
--- a/content/renderer/render_view_impl.cc
+++ b/content/renderer/render_view_impl.cc
@@ -642,7 +642,8 @@
     : RenderWidget(blink::WebPopupTypeNone,
                    params->screen_info,
                    params->swapped_out,
-                   params->hidden),
+                   params->hidden,
+                   params->never_visible),
       webkit_preferences_(params->webkit_prefs),
       send_content_state_immediately_(false),
       enabled_bindings_(0),
@@ -927,6 +928,7 @@
     bool is_renderer_created,
     bool swapped_out,
     bool hidden,
+    bool never_visible,
     int32 next_page_id,
     const blink::WebScreenInfo& screen_info,
     AccessibilityMode accessibility_mode) {
@@ -942,6 +944,7 @@
                               is_renderer_created,
                               swapped_out,
                               hidden,
+                              never_visible,
                               next_page_id,
                               screen_info,
                               accessibility_mode);
@@ -1507,19 +1510,11 @@
 
   WebUserGestureIndicator::consumeUserGesture();
 
-  WebPreferences transferred_preferences = webkit_preferences_;
-
-  // Unless accelerated compositing has been explicitly disabled from the
-  // command line (e.g. via the blacklist or about:flags) re-enable it for
-  // new views that get spawned by this view. This gets around the issue that
-  // background extension pages disable accelerated compositing via web prefs
-  // but can themselves spawn a visible render view which should be allowed
-  // use gpu acceleration.
-  if (!webkit_preferences_.accelerated_compositing_enabled) {
-    const CommandLine& command_line = *CommandLine::ForCurrentProcess();
-    if (!command_line.HasSwitch(switches::kDisableAcceleratedCompositing))
-      transferred_preferences.accelerated_compositing_enabled = true;
-  }
+  // While this view may be a background extension page, it can spawn a visible
+  // render view. So we just assume that the new one is not another background
+  // page instead of passing on our own value.
+  // TODO(vangelis): Can we tell if the new view will be a background page?
+  bool never_visible = false;
 
   // The initial hidden state for the RenderViewImpl here has to match what the
   // browser will eventually decide for the given disposition. Since we have to
@@ -1529,7 +1524,7 @@
   RenderViewImpl* view = RenderViewImpl::Create(
       routing_id_,
       renderer_preferences_,
-      transferred_preferences,
+      webkit_preferences_,
       routing_id,
       main_frame_routing_id,
       surface_id,
@@ -1538,7 +1533,8 @@
       true,              // is_renderer_created
       false,             // swapped_out
       params.disposition == NEW_BACKGROUND_TAB,  // hidden
-      1,                                         // next_page_id
+      never_visible,
+      1,  // next_page_id
       screen_info_,
       accessibility_mode_);
   view->opened_by_user_gesture_ = params.user_gesture;