Added BackgroundContentsService to manage lifecycle of BackgroundContents.

If --restore-background-contents flag is passed, stores the URLs of running
BackgroundContents in preferences so they can be re-launched when the browser
restarts.

Moved logic to shutdown background contents into BackgroundContentsService so
we can use this to coordinate when to keep the browser process running.

BUG=43382
TEST=new tests

Review URL: http://codereview.chromium.org/2104018

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@50329 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/browser_process_impl.cc b/chrome/browser/browser_process_impl.cc
index a74f5ab..486dd1e 100644
--- a/chrome/browser/browser_process_impl.cc
+++ b/chrome/browser/browser_process_impl.cc
@@ -576,10 +576,8 @@
       }
   }
 
-  // TODO(atwilson): Uncomment the following two lines to add the "persistence"
-  // switch when the corresponding CL is committed.
-  // if (!new_cl->HasSwitch(switches::kLongLivedExtensions))
-  //  new_cl->AppendSwitch(switches::kLongLivedExtensions);
+  if (!new_cl->HasSwitch(switches::kRestoreBackgroundContents))
+    new_cl->AppendSwitch(switches::kRestoreBackgroundContents);
 
   DLOG(WARNING) << "Shutting down current instance of the browser.";
   BrowserList::CloseAllBrowsersAndExit();