Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / chrome_content_browser_client.cc
index 8950f28..3051a16 100644 (file)
@@ -17,7 +17,6 @@
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/utf_string_conversions.h"
 #include "base/threading/sequenced_worker_pool.h"
-#include "chrome/browser/app_mode/app_mode_utils.h"
 #include "chrome/browser/browser_about_handler.h"
 #include "chrome/browser/browser_process.h"
 #include "chrome/browser/browser_shutdown.h"
 #include "chrome/browser/download/download_prefs.h"
 #include "chrome/browser/extensions/api/web_request/web_request_api.h"
 #include "chrome/browser/extensions/browser_permissions_policy_delegate.h"
-#include "chrome/browser/extensions/extension_host.h"
-#include "chrome/browser/extensions/extension_info_map.h"
-#include "chrome/browser/extensions/extension_process_manager.h"
 #include "chrome/browser/extensions/extension_service.h"
-#include "chrome/browser/extensions/extension_system.h"
+#include "chrome/browser/extensions/extension_util.h"
 #include "chrome/browser/extensions/extension_web_ui.h"
 #include "chrome/browser/extensions/extension_webkit_preferences.h"
 #include "chrome/browser/extensions/suggest_permission_util.h"
 #include "chrome/browser/geolocation/chrome_access_token_store.h"
 #include "chrome/browser/google/google_util.h"
-#include "chrome/browser/guestview/adview/adview_guest.h"
-#include "chrome/browser/guestview/guestview_constants.h"
-#include "chrome/browser/guestview/webview/webview_guest.h"
+#include "chrome/browser/guest_view/ad_view/ad_view_guest.h"
+#include "chrome/browser/guest_view/guest_view_base.h"
+#include "chrome/browser/guest_view/guest_view_constants.h"
+#include "chrome/browser/guest_view/guest_view_manager.h"
+#include "chrome/browser/guest_view/web_view/web_view_guest.h"
+#include "chrome/browser/media/cast_transport_host_filter.h"
 #include "chrome/browser/media/media_capture_devices_dispatcher.h"
 #include "chrome/browser/metrics/chrome_browser_main_extra_parts_metrics.h"
 #include "chrome/browser/nacl_host/nacl_browser_delegate_impl.h"
-#include "chrome/browser/nacl_host/nacl_host_message_filter.h"
-#include "chrome/browser/nacl_host/nacl_process_host.h"
 #include "chrome/browser/net/chrome_net_log.h"
 #include "chrome/browser/notifications/desktop_notification_service.h"
 #include "chrome/browser/notifications/desktop_notification_service_factory.h"
@@ -73,6 +70,7 @@
 #include "chrome/browser/search/instant_service_factory.h"
 #include "chrome/browser/search/search.h"
 #include "chrome/browser/search_engines/search_provider_install_state_message_filter.h"
+#include "chrome/browser/signin/principals_message_filter.h"
 #include "chrome/browser/speech/chrome_speech_recognition_manager_delegate.h"
 #include "chrome/browser/speech/tts_message_filter.h"
 #include "chrome/browser/ssl/ssl_add_certificate.h"
 #include "chrome/browser/ui/sync/sync_promo_ui.h"
 #include "chrome/browser/ui/tab_contents/chrome_web_contents_view_delegate.h"
 #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h"
-#include "chrome/browser/user_style_sheet_watcher.h"
-#include "chrome/browser/user_style_sheet_watcher_factory.h"
-#include "chrome/browser/validation_message_message_filter.h"
 #include "chrome/common/chrome_constants.h"
 #include "chrome/common/chrome_paths.h"
 #include "chrome/common/chrome_switches.h"
-#include "chrome/common/chrome_version_info.h"
 #include "chrome/common/env_vars.h"
-#include "chrome/common/extensions/background_info.h"
-#include "chrome/common/extensions/extension.h"
 #include "chrome/common/extensions/extension_process_policy.h"
-#include "chrome/common/extensions/extension_set.h"
 #include "chrome/common/extensions/manifest_handlers/app_isolation_info.h"
-#include "chrome/common/extensions/manifest_handlers/shared_module_info.h"
-#include "chrome/common/extensions/permissions/permissions_data.h"
-#include "chrome/common/extensions/permissions/socket_permission.h"
-#include "chrome/common/extensions/web_accessible_resources_handler.h"
 #include "chrome/common/logging_chrome.h"
 #include "chrome/common/pepper_permission_util.h"
 #include "chrome/common/pref_names.h"
 #include "chrome/common/url_constants.h"
 #include "chrome/installer/util/google_update_settings.h"
 #include "chromeos/chromeos_constants.h"
+#include "components/cdm/browser/cdm_message_filter_android.h"
+#include "components/cloud_devices/common/cloud_devices_switches.h"
 #include "components/nacl/browser/nacl_browser.h"
+#include "components/nacl/browser/nacl_host_message_filter.h"
+#include "components/nacl/browser/nacl_process_host.h"
 #include "components/nacl/common/nacl_process_type.h"
-#include "components/translate/common/translate_switches.h"
+#include "components/nacl/common/nacl_switches.h"
+#include "components/signin/core/common/profile_management_switches.h"
+#include "components/translate/core/common/translate_switches.h"
 #include "components/user_prefs/pref_registry_syncable.h"
 #include "content/public/browser/browser_child_process_host.h"
 #include "content/public/browser/browser_main_parts.h"
 #include "content/public/browser/browser_url_handler.h"
 #include "content/public/browser/child_process_data.h"
 #include "content/public/browser/child_process_security_policy.h"
+#include "content/public/browser/render_frame_host.h"
 #include "content/public/browser/render_process_host.h"
 #include "content/public/browser/render_view_host.h"
 #include "content/public/browser/resource_context.h"
 #include "content/public/browser/site_instance.h"
 #include "content/public/browser/web_contents.h"
-#include "content/public/browser/web_contents_view.h"
 #include "content/public/common/child_process_host.h"
 #include "content/public/common/content_descriptors.h"
 #include "content/public/common/url_utils.h"
+#include "extensions/browser/extension_host.h"
+#include "extensions/browser/extension_message_filter.h"
+#include "extensions/browser/extension_registry.h"
+#include "extensions/browser/extension_system.h"
+#include "extensions/browser/info_map.h"
+#include "extensions/browser/process_manager.h"
+#include "extensions/browser/process_map.h"
 #include "extensions/browser/view_type_utils.h"
 #include "extensions/common/constants.h"
+#include "extensions/common/extension.h"
+#include "extensions/common/extension_set.h"
+#include "extensions/common/manifest_handlers/background_info.h"
+#include "extensions/common/manifest_handlers/shared_module_info.h"
+#include "extensions/common/manifest_handlers/web_accessible_resources_info.h"
+#include "extensions/common/permissions/permissions_data.h"
+#include "extensions/common/permissions/socket_permission.h"
 #include "extensions/common/switches.h"
 #include "grit/generated_resources.h"
 #include "grit/ui_resources.h"
-#include "net/base/escape.h"
 #include "net/base/mime_util.h"
 #include "net/cookies/canonical_cookie.h"
 #include "net/cookies/cookie_options.h"
 #include "net/ssl/ssl_cert_request_info.h"
 #include "ppapi/host/ppapi_host.h"
+#include "ppapi/shared_impl/ppapi_switches.h"
 #include "ui/base/l10n/l10n_util.h"
 #include "ui/base/resource/resource_bundle.h"
-#include "ui/message_center/message_center_util.h"
 #include "webkit/browser/fileapi/external_mount_points.h"
 #include "webkit/common/webpreferences.h"
 
 #if defined(OS_WIN)
+#include "base/win/windows_version.h"
 #include "chrome/browser/chrome_browser_main_win.h"
 #include "sandbox/win/src/sandbox_policy.h"
 #elif defined(OS_MACOSX)
 #include "components/breakpad/app/breakpad_mac.h"
 #elif defined(OS_CHROMEOS)
 #include "chrome/browser/chromeos/chrome_browser_main_chromeos.h"
-#include "chrome/browser/chromeos/drive/file_system_backend_delegate.h"
+#include "chrome/browser/chromeos/drive/fileapi/file_system_backend_delegate.h"
+#include "chrome/browser/chromeos/file_system_provider/fileapi/backend_delegate.h"
 #include "chrome/browser/chromeos/fileapi/file_system_backend.h"
+#include "chrome/browser/chromeos/fileapi/mtp_file_system_backend_delegate.h"
 #include "chrome/browser/chromeos/login/startup_utils.h"
 #include "chrome/browser/chromeos/login/user_manager.h"
 #include "chrome/browser/chromeos/system/input_device_settings.h"
 #elif defined(OS_LINUX)
 #include "chrome/browser/chrome_browser_main_linux.h"
 #elif defined(OS_ANDROID)
+#include "chrome/browser/android/new_tab_page_url_handler.h"
 #include "chrome/browser/android/webapps/single_tab_mode_tab_helper.h"
 #include "chrome/browser/chrome_browser_main_android.h"
-#include "chrome/browser/media/encrypted_media_message_filter_android.h"
 #include "chrome/common/descriptors_android.h"
 #include "components/breakpad/browser/crash_dump_manager_android.h"
 #elif defined(OS_POSIX)
 #include "ui/gfx/android/device_display_info.h"
 #endif
 
-#if defined(USE_NSS)
-#include "chrome/browser/ui/crypto_module_password_dialog.h"
-#endif
-
 #if !defined(OS_CHROMEOS)
-#include "chrome/browser/signin/signin_manager.h"
+#include "chrome/browser/signin/chrome_signin_client.h"
+#include "chrome/browser/signin/chrome_signin_client_factory.h"
 #include "chrome/browser/signin/signin_manager_factory.h"
+#include "components/signin/core/browser/signin_manager.h"
 #endif
 
 #if !defined(OS_ANDROID)
 #include "chrome/browser/media/webrtc_logging_handler_host.h"
 #endif
 
-#if defined(ENABLE_INPUT_SPEECH)
-#include "chrome/browser/speech/chrome_speech_recognition_manager_delegate_bubble_ui.h"
-#endif
-
-#if defined(FILE_MANAGER_EXTENSION)
+#if defined(OS_CHROMEOS)
 #include "chrome/browser/chromeos/file_manager/app_id.h"
 #endif
 
-#if defined(TOOLKIT_GTK)
-#include "chrome/browser/ui/gtk/chrome_browser_main_extra_parts_gtk.h"
-#endif
-
 #if defined(TOOLKIT_VIEWS)
 #include "chrome/browser/ui/views/chrome_browser_main_extra_parts_views.h"
 #endif
 #include "chrome/browser/spellchecker/spellcheck_message_filter.h"
 #endif
 
-using WebKit::WebWindowFeatures;
+#if defined(ENABLE_SERVICE_DISCOVERY)
+#include "chrome/browser/local_discovery/storage/privet_filesystem_backend.h"
+#endif
+
+using blink::WebWindowFeatures;
 using base::FileDescriptor;
 using content::AccessTokenStore;
 using content::BrowserChildProcessHostIterator;
 using content::BrowserThread;
 using content::BrowserURLHandler;
 using content::ChildProcessSecurityPolicy;
-using content::FileDescriptorInfo;
 using content::QuotaPermissionContext;
+using content::RenderFrameHost;
 using content::RenderViewHost;
 using content::SiteInstance;
 using content::WebContents;
 using extensions::APIPermission;
 using extensions::Extension;
+using extensions::InfoMap;
 using extensions::Manifest;
 using message_center::NotifierId;
 
+#if defined(OS_POSIX)
+using content::FileDescriptorInfo;
+#endif
+
 namespace {
 
 // Cached version of the locale so we can return the locale on the I/O
@@ -263,6 +271,11 @@ namespace {
 base::LazyInstance<std::string> g_io_thread_application_locale;
 
 #if defined(ENABLE_PLUGINS)
+const char* kPredefinedAllowedFileHandleOrigins[] = {
+  "6EAED1924DB611B6EEF2A664BD077BE7EAD33B8F",  // see crbug.com/234789
+  "4EB74897CB187C7633357C2FE832E0AD6A44883A"   // see crbug.com/234789
+};
+
 const char* kPredefinedAllowedSocketOrigins[] = {
   "okddffdblfhhnmhodogpojmfkjmhinfp",  // Test SSH Client
   "pnhechapfaindjhompbnflcldabbghjo",  // HTerm App (SSH Client)
@@ -294,11 +307,9 @@ const char* kPredefinedAllowedSocketOrigins[] = {
 GURL ReplaceURLHostAndPath(const GURL& url,
                            const std::string& host,
                            const std::string& path) {
-  url_canon::Replacements<char> replacements;
-  replacements.SetHost(host.c_str(),
-                       url_parse::Component(0, host.length()));
-  replacements.SetPath(path.c_str(),
-                       url_parse::Component(0, path.length()));
+  url::Replacements<char> replacements;
+  replacements.SetHost(host.c_str(), url::Component(0, host.length()));
+  replacements.SetPath(path.c_str(), url::Component(0, path.length()));
   return url.ReplaceComponents(replacements);
 }
 
@@ -366,11 +377,8 @@ bool HandleWebUI(GURL* url, content::BrowserContext* browser_context) {
   // disabled for security reasons. New tab page explains the reasons, so
   // we redirect user to new tab page.
   if (chromeos::UserManager::Get()->IsLoggedInAsGuest()) {
-    if (url->SchemeIs(chrome::kChromeUIScheme) &&
+    if (url->SchemeIs(content::kChromeUIScheme) &&
         (url->DomainIs(chrome::kChromeUIBookmarksHost) ||
-#if defined(ENABLE_ENHANCED_BOOKMARKS)
-         url->DomainIs(chrome::kChromeUIEnhancedBookmarksHost) ||
-#endif
          url->DomainIs(chrome::kChromeUIHistoryHost))) {
       // Rewrite with new tab URL
       *url = GURL(chrome::kChromeUINewTabURL);
@@ -378,22 +386,13 @@ bool HandleWebUI(GURL* url, content::BrowserContext* browser_context) {
   }
 #endif
 
-  // Special case the new tab page. In older versions of Chrome, the new tab
-  // page was hosted at chrome-internal:<blah>. This might be in people's saved
-  // sessions or bookmarks, so we say any URL with that scheme triggers the new
-  // tab page.
-  if (url->SchemeIs(chrome::kChromeInternalScheme)) {
-    // Rewrite it with the proper new tab URL.
-    *url = GURL(chrome::kChromeUINewTabURL);
-  }
-
   return true;
 }
 
 // Reverse URL handler for Web UI. Maps "chrome://chrome/foo/" to
 // "chrome://foo/".
 bool HandleWebUIReverse(GURL* url, content::BrowserContext* browser_context) {
-  if (!url->is_valid() || !url->SchemeIs(chrome::kChromeUIScheme))
+  if (!url->is_valid() || !url->SchemeIs(content::kChromeUIScheme))
     return false;
 
   return RemoveUberHost(url);
@@ -477,6 +476,7 @@ bool CertMatchesFilter(const net::X509Certificate& cert,
   return false;
 }
 
+#if !defined(OS_ANDROID)
 // Fills |map| with the per-script font prefs under path |map_name|.
 void FillFontFamilyMap(const PrefService* prefs,
                        const char* map_name,
@@ -488,7 +488,7 @@ void FillFontFamilyMap(const PrefService* prefs,
     std::string pref_name = base::StringPrintf("%s.%s", map_name, script);
     std::string font_family = prefs->GetString(pref_name.c_str());
     if (!font_family.empty())
-      (*map)[script] = UTF8ToUTF16(font_family);
+      (*map)[script] = base::UTF8ToUTF16(font_family);
   }
 }
 
@@ -508,7 +508,7 @@ breakpad::CrashHandlerHostLinux* CreateCrashHandlerHost(
 }
 
 int GetCrashSignalFD(const CommandLine& command_line) {
-  if (command_line.HasSwitch(switches::kExtensionProcess)) {
+  if (command_line.HasSwitch(extensions::switches::kExtensionProcess)) {
     static breakpad::CrashHandlerHostLinux* crash_handler = NULL;
     if (!crash_handler)
       crash_handler = CreateCrashHandlerHost("extension");
@@ -549,6 +549,7 @@ int GetCrashSignalFD(const CommandLine& command_line) {
   return -1;
 }
 #endif  // defined(OS_POSIX) && !defined(OS_MACOSX)
+#endif  // !defined(OS_ANDROID)
 
 #if !defined(OS_CHROMEOS)
 GURL GetEffectiveURLForSignin(const GURL& url) {
@@ -576,6 +577,13 @@ void HandleBlockedPopupOnUIThread(const BlockedWindowParams& params) {
   if (!tab)
     return;
 
+  prerender::PrerenderContents* prerender_contents =
+      prerender::PrerenderContents::FromWebContents(tab);
+  if (prerender_contents) {
+    prerender_contents->Destroy(prerender::FINAL_STATUS_CREATE_NEW_WINDOW);
+    return;
+  }
+
   PopupBlockerTabHelper* popup_helper =
       PopupBlockerTabHelper::FromWebContents(tab);
   if (!popup_helper)
@@ -623,6 +631,8 @@ namespace chrome {
 
 ChromeContentBrowserClient::ChromeContentBrowserClient() {
 #if defined(ENABLE_PLUGINS)
+  for (size_t i = 0; i < arraysize(kPredefinedAllowedFileHandleOrigins); ++i)
+    allowed_file_handle_origins_.insert(kPredefinedAllowedFileHandleOrigins[i]);
   for (size_t i = 0; i < arraysize(kPredefinedAllowedSocketOrigins); ++i)
     allowed_socket_origins_.insert(kPredefinedAllowedSocketOrigins[i]);
 #endif
@@ -645,10 +655,6 @@ void ChromeContentBrowserClient::RegisterProfilePrefs(
       prefs::kEnableHyperlinkAuditing,
       true,
       user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
-  registry->RegisterBooleanPref(
-      prefs::kEnableMemoryInfo,
-      false,
-      user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
 }
 
 // static
@@ -695,10 +701,6 @@ content::BrowserMainParts* ChromeContentBrowserClient::CreateBrowserMainParts(
 
   // Construct additional browser parts. Stages are called in the order in
   // which they are added.
-#if defined(TOOLKIT_GTK)
-  main_parts->AddParts(new ChromeBrowserMainExtraPartsGtk());
-#endif
-
 #if defined(TOOLKIT_VIEWS)
   main_parts->AddParts(new ChromeBrowserMainExtraPartsViews());
 #endif
@@ -727,8 +729,13 @@ std::string ChromeContentBrowserClient::GetStoragePartitionIdForSite(
 
   // The partition ID for webview guest processes is the string value of its
   // SiteInstance URL - "chrome-guest://app_id/persist?partition".
-  if (site.SchemeIs(content::kGuestScheme))
+  if (site.SchemeIs(content::kGuestScheme)) {
     partition_id = site.spec();
+  } else if (site.GetOrigin().spec() == kChromeUIChromeSigninURL) {
+    // Chrome signin page has an embedded iframe of extension and web content,
+    // thus it must be isolated from other webUI pages.
+    partition_id = site.GetOrigin().spec();
+  }
 
   DCHECK(IsValidStoragePartitionId(browser_context, partition_id));
   return partition_id;
@@ -757,26 +764,10 @@ void ChromeContentBrowserClient::GetStoragePartitionConfigForSite(
   partition_name->clear();
   *in_memory = false;
 
-  // For the webview tag, we create special guest processes, which host the
-  // tag content separately from the main application that embeds the tag.
-  // A webview tag can specify both the partition name and whether the storage
-  // for that partition should be persisted. Each tag gets a SiteInstance with
-  // a specially formatted URL, based on the application it is hosted by and
-  // the partition requested by it. The format for that URL is:
-  // chrome-guest://partition_domain/persist?partition_name
-  if (site.SchemeIs(content::kGuestScheme)) {
-    // Since guest URLs are only used for packaged apps, there must be an app
-    // id in the URL.
-    CHECK(site.has_host());
-    *partition_domain = site.host();
-    // Since persistence is optional, the path must either be empty or the
-    // literal string.
-    *in_memory = (site.path() != "/persist");
-    // The partition name is user supplied value, which we have encoded when the
-    // URL was created, so it needs to be decoded.
-    *partition_name = net::UnescapeURLComponent(site.query(),
-                                                net::UnescapeRule::NORMAL);
-  } else if (site.SchemeIs(extensions::kExtensionScheme)) {
+  bool success = GuestViewBase::GetGuestPartitionConfigForSite(
+      site, partition_domain, partition_name, in_memory);
+
+  if (!success && site.SchemeIs(extensions::kExtensionScheme)) {
     // If |can_be_default| is false, the caller is stating that the |site|
     // should be parsed as if it had isolated storage. In particular it is
     // important to NOT check ExtensionService for the is_storage_isolated()
@@ -785,18 +776,8 @@ void ChromeContentBrowserClient::GetStoragePartitionConfigForSite(
     // ExtensionService.
     bool is_isolated = !can_be_default;
     if (can_be_default) {
-      const Extension* extension = NULL;
-      Profile* profile = Profile::FromBrowserContext(browser_context);
-      ExtensionService* extension_service =
-          extensions::ExtensionSystem::Get(profile)->extension_service();
-      if (extension_service) {
-        extension =
-            extension_service->extensions()->GetExtensionOrAppByURL(site);
-        if (extension &&
-            extensions::AppIsolationInfo::HasIsolatedStorage(extension)) {
-          is_isolated = true;
-        }
-      }
+      if (extensions::util::SiteHasIsolatedStorage(site, browser_context))
+        is_isolated = true;
     }
 
     if (is_isolated) {
@@ -808,6 +789,10 @@ void ChromeContentBrowserClient::GetStoragePartitionConfigForSite(
       *in_memory = false;
       partition_name->clear();
     }
+  } else if (site.GetOrigin().spec() == kChromeUIChromeSigninURL) {
+    // Chrome signin page has an embedded iframe of extension and web content,
+    // thus it must be isolated from other webUI pages.
+    *partition_domain = chrome::kChromeUIChromeSigninHost;
   }
 
   // Assert that if |can_be_default| is false, the code above must have found a
@@ -845,28 +830,28 @@ void ChromeContentBrowserClient::GuestWebContentsCreated(
     return;
   }
 
-  /// TODO(fsamuel): In the future, certain types of GuestViews won't require
-  // extension bindings. At that point, we should clear |extension_id| instead
-  // of exiting early.
-  if (!service->GetExtensionById(extension_id, false) &&
-      !CommandLine::ForCurrentProcess()->HasSwitch(
-          switches::kEnableBrowserPluginForAllViewTypes)) {
+  /// TODO(fsamuel): In the future, certain types of GuestViewBases won't
+  // require extension bindings. At that point, we should clear |extension_id|
+  // instead of exiting early.
+  if (!extension_id.empty() &&
+      !service->GetExtensionById(extension_id, false)) {
     NOTREACHED();
     return;
   }
 
   if (opener_web_contents) {
-    GuestView* guest = GuestView::FromWebContents(opener_web_contents);
+    GuestViewBase* guest = GuestViewBase::FromWebContents(opener_web_contents);
     if (!guest) {
       NOTREACHED();
       return;
     }
 
-    // Create a new GuestView of the same type as the opener.
-    *guest_delegate =
-        GuestView::Create(guest_web_contents,
-                          extension_id,
-                          guest->GetViewType());
+    // Create a new GuestViewBase of the same type as the opener.
+    *guest_delegate = GuestViewBase::Create(
+        guest_web_contents,
+        extension_id,
+        guest->GetViewType(),
+        guest->AsWeakPtr());
     return;
   }
 
@@ -881,17 +866,17 @@ void ChromeContentBrowserClient::GuestWebContentsCreated(
     return;
 
   *guest_delegate =
-      GuestView::Create(guest_web_contents,
-                        extension_id,
-                        GuestView::GetViewTypeFromString(api_type));
+      GuestViewBase::Create(guest_web_contents,
+                            extension_id,
+                            api_type,
+                            base::WeakPtr<GuestViewBase>());
 }
 
 void ChromeContentBrowserClient::GuestWebContentsAttached(
     WebContents* guest_web_contents,
     WebContents* embedder_web_contents,
     const base::DictionaryValue& extra_params) {
-
-  GuestView* guest = GuestView::FromWebContents(guest_web_contents);
+  GuestViewBase* guest = GuestViewBase::FromWebContents(guest_web_contents);
   if (!guest) {
     // It's ok to return here, since we could be running a browser plugin
     // outside an extension, and don't need to attach a
@@ -902,7 +887,7 @@ void ChromeContentBrowserClient::GuestWebContentsAttached(
   guest->Attach(embedder_web_contents, extra_params);
 }
 
-void ChromeContentBrowserClient::RenderProcessHostCreated(
+void ChromeContentBrowserClient::RenderProcessWillLaunch(
     content::RenderProcessHost* host) {
   int id = host->GetID();
   Profile* profile = Profile::FromBrowserContext(host->GetBrowserContext());
@@ -910,9 +895,11 @@ void ChromeContentBrowserClient::RenderProcessHostCreated(
       profile->GetRequestContextForRenderProcess(id);
 
   host->AddFilter(new ChromeRenderMessageFilter(id, profile, context));
+  host->AddFilter(new extensions::ExtensionMessageFilter(id, profile));
 #if defined(ENABLE_PLUGINS)
   host->AddFilter(new PluginInfoMessageFilter(id, profile));
 #endif
+  host->AddFilter(new cast::CastTransportHostFilter);
 #if defined(ENABLE_PRINTING)
   host->AddFilter(new PrintingMessageFilter(id, profile));
 #endif
@@ -923,27 +910,29 @@ void ChromeContentBrowserClient::RenderProcessHostCreated(
 #if defined(OS_MACOSX)
   host->AddFilter(new SpellCheckMessageFilterMac(id));
 #endif
-  host->AddFilter(new ChromeNetBenchmarkingMessageFilter(
-      id, profile, context));
+  host->AddFilter(new ChromeNetBenchmarkingMessageFilter(profile, context));
   host->AddFilter(new prerender::PrerenderMessageFilter(id, profile));
-  host->AddFilter(new ValidationMessageMessageFilter(id));
   host->AddFilter(new TtsMessageFilter(id, profile));
 #if defined(ENABLE_WEBRTC)
   WebRtcLoggingHandlerHost* webrtc_logging_handler_host =
       new WebRtcLoggingHandlerHost(profile);
+  host->SetWebRtcLogMessageCallback(base::Bind(
+      &WebRtcLoggingHandlerHost::LogMessage, webrtc_logging_handler_host));
   host->AddFilter(webrtc_logging_handler_host);
   host->SetUserData(host, new base::UserDataAdapter<WebRtcLoggingHandlerHost>(
       webrtc_logging_handler_host));
 #endif
 #if !defined(DISABLE_NACL)
-  host->AddFilter(new NaClHostMessageFilter(
+  host->AddFilter(new nacl::NaClHostMessageFilter(
       id, profile->IsOffTheRecord(),
       profile->GetPath(),
       context));
 #endif
 #if defined(OS_ANDROID)
-  host->AddFilter(new EncryptedMediaMessageFilterAndroid());
+  host->AddFilter(new cdm::CdmMessageFilterAndroid());
 #endif
+  if (switches::IsNewProfileManagement())
+    host->AddFilter(new PrincipalsMessageFilter(id));
 
   host->Send(new ChromeViewMsg_SetIsIncognitoProcess(
       profile->IsOffTheRecord()));
@@ -951,7 +940,13 @@ void ChromeContentBrowserClient::RenderProcessHostCreated(
   SendExtensionWebRequestStatusToHost(host);
 
   RendererContentSettingRules rules;
-  GetRendererContentSettingRules(profile->GetHostContentSettingsMap(), &rules);
+  if (host->IsGuest()) {
+    GuestViewBase::GetDefaultContentSettingRules(&rules,
+                                                 profile->IsOffTheRecord());
+  } else {
+    GetRendererContentSettingRules(
+        profile->GetHostContentSettingsMap(), &rules);
+  }
   host->Send(new ChromeViewMsg_SetContentSettingRules(rules));
 }
 
@@ -1047,18 +1042,32 @@ bool ChromeContentBrowserClient::ShouldUseProcessPerSite(
   return true;
 }
 
-// These are treated as WebUI schemes but do not get WebUI bindings.
+// These are treated as WebUI schemes but do not get WebUI bindings. Also,
+// view-source is allowed for these schemes.
 void ChromeContentBrowserClient::GetAdditionalWebUISchemes(
     std::vector<std::string>* additional_schemes) {
   additional_schemes->push_back(chrome::kChromeSearchScheme);
+  additional_schemes->push_back(chrome::kDomDistillerScheme);
+}
+
+void ChromeContentBrowserClient::GetAdditionalWebUIHostsToIgnoreParititionCheck(
+    std::vector<std::string>* hosts) {
+  hosts->push_back(chrome::kChromeUIExtensionIconHost);
+  hosts->push_back(chrome::kChromeUIFaviconHost);
+  hosts->push_back(chrome::kChromeUIThemeHost);
+  hosts->push_back(chrome::kChromeUIThumbnailHost);
+  hosts->push_back(chrome::kChromeUIThumbnailHost2);
+  hosts->push_back(chrome::kChromeUIThumbnailListHost);
 }
 
 net::URLRequestContextGetter*
 ChromeContentBrowserClient::CreateRequestContext(
     content::BrowserContext* browser_context,
-    content::ProtocolHandlerMap* protocol_handlers) {
+    content::ProtocolHandlerMap* protocol_handlers,
+    content::ProtocolHandlerScopedVector protocol_interceptors) {
   Profile* profile = Profile::FromBrowserContext(browser_context);
-  return profile->CreateRequestContext(protocol_handlers);
+  return profile->CreateRequestContext(protocol_handlers,
+                                       protocol_interceptors.Pass());
 }
 
 net::URLRequestContextGetter*
@@ -1066,10 +1075,14 @@ ChromeContentBrowserClient::CreateRequestContextForStoragePartition(
     content::BrowserContext* browser_context,
     const base::FilePath& partition_path,
     bool in_memory,
-    content::ProtocolHandlerMap* protocol_handlers) {
+    content::ProtocolHandlerMap* protocol_handlers,
+    content::ProtocolHandlerScopedVector protocol_interceptors) {
   Profile* profile = Profile::FromBrowserContext(browser_context);
   return profile->CreateRequestContextForStoragePartition(
-      partition_path, in_memory, protocol_handlers);
+      partition_path,
+      in_memory,
+      protocol_handlers,
+      protocol_interceptors.Pass());
 }
 
 bool ChromeContentBrowserClient::IsHandledURL(const GURL& url) {
@@ -1095,8 +1108,8 @@ bool ChromeContentBrowserClient::CanCommitURL(
   if (new_extension &&
       new_extension->is_hosted_app() &&
       new_extension->id() == extension_misc::kWebStoreAppId &&
-      !service->process_map()->Contains(new_extension->id(),
-                                        process_host->GetID())) {
+      !extensions::ProcessMap::Get(profile)->
+          Contains(new_extension->id(), process_host->GetID())) {
     return false;
   }
 
@@ -1131,6 +1144,17 @@ bool ChromeContentBrowserClient::ShouldAllowOpenURL(
             extension, url.path()))
       return false;
   }
+
+  // Do not allow chrome://chrome-signin navigate to other chrome:// URLs, since
+  // the signin page may host untrusted web content.
+  if (from_url.GetOrigin().spec() == chrome::kChromeUIChromeSigninURL &&
+      url.SchemeIs(content::kChromeUIScheme) &&
+      url.host() != chrome::kChromeUIChromeSigninHost) {
+    VLOG(1) << "Blocked navigation to " << url.spec() << " from "
+            << chrome::kChromeUIChromeSigninURL;
+    return false;
+  }
+
   return true;
 }
 
@@ -1158,14 +1182,15 @@ bool ChromeContentBrowserClient::IsSuitableHost(
   }
 
 #if !defined(OS_CHROMEOS)
-  SigninManager* signin_manager = SigninManagerFactory::GetForProfile(profile);
-  if (signin_manager && signin_manager->IsSigninProcess(process_host->GetID()))
+  ChromeSigninClient* signin_client =
+      ChromeSigninClientFactory::GetForProfile(profile);
+  if (signin_client && signin_client->IsSigninProcess(process_host->GetID()))
     return SigninManager::IsWebBasedSigninFlowURL(site_url);
 #endif
 
   ExtensionService* service =
       extensions::ExtensionSystem::Get(profile)->extension_service();
-  extensions::ProcessMap* process_map = service->process_map();
+  extensions::ProcessMap* process_map = extensions::ProcessMap::Get(profile);
 
   // Don't allow the Task Manager to share a process with anything else.
   // Otherwise it can affect the renderers it is observing.
@@ -1222,9 +1247,9 @@ bool ChromeContentBrowserClient::ShouldTryToUseExistingProcessHost(
   std::vector<Profile*> profiles = g_browser_process->profile_manager()->
       GetLoadedProfiles();
   for (size_t i = 0; i < profiles.size(); ++i) {
-    ExtensionProcessManager* epm =
+    extensions::ProcessManager* epm =
         extensions::ExtensionSystem::Get(profiles[i])->process_manager();
-    for (ExtensionProcessManager::const_iterator iter =
+    for (extensions::ProcessManager::const_iterator iter =
              epm->background_hosts().begin();
          iter != epm->background_hosts().end(); ++iter) {
       const extensions::ExtensionHost* host = *iter;
@@ -1264,13 +1289,14 @@ void ChromeContentBrowserClient::SiteInstanceGotProcess(
   // for signin URLs. The signin process will be cleared from SigninManager
   // when the renderer is destroyed.
   if (SigninManager::IsWebBasedSigninFlowURL(site_instance->GetSiteURL())) {
-    SigninManager* signin_manager =
-        SigninManagerFactory::GetForProfile(profile);
-    if (signin_manager)
-      signin_manager->SetSigninProcess(site_instance->GetProcess()->GetID());
+    ChromeSigninClient* signin_client =
+        ChromeSigninClientFactory::GetForProfile(profile);
+    if (signin_client)
+      signin_client->SetSigninProcess(site_instance->GetProcess()->GetID());
     BrowserThread::PostTask(
-        BrowserThread::IO, FROM_HERE,
-        base::Bind(&ExtensionInfoMap::SetSigninProcess,
+        BrowserThread::IO,
+        FROM_HERE,
+        base::Bind(&InfoMap::SetSigninProcess,
                    extensions::ExtensionSystem::Get(profile)->info_map(),
                    site_instance->GetProcess()->GetID()));
   }
@@ -1286,12 +1312,15 @@ void ChromeContentBrowserClient::SiteInstanceGotProcess(
   if (!extension)
     return;
 
-  service->process_map()->Insert(extension->id(),
-                                 site_instance->GetProcess()->GetID(),
-                                 site_instance->GetId());
+  extensions::ProcessMap::Get(profile)
+      ->Insert(extension->id(),
+               site_instance->GetProcess()->GetID(),
+               site_instance->GetId());
+
   BrowserThread::PostTask(
-      BrowserThread::IO, FROM_HERE,
-      base::Bind(&ExtensionInfoMap::RegisterExtensionProcess,
+      BrowserThread::IO,
+      FROM_HERE,
+      base::Bind(&InfoMap::RegisterExtensionProcess,
                  extensions::ExtensionSystem::Get(profile)->info_map(),
                  extension->id(),
                  site_instance->GetProcess()->GetID(),
@@ -1315,42 +1344,56 @@ void ChromeContentBrowserClient::SiteInstanceDeleting(
   if (!extension)
     return;
 
-  service->process_map()->Remove(extension->id(),
-                                 site_instance->GetProcess()->GetID(),
-                                 site_instance->GetId());
+  extensions::ProcessMap::Get(profile)
+      ->Remove(extension->id(),
+               site_instance->GetProcess()->GetID(),
+               site_instance->GetId());
+
   BrowserThread::PostTask(
-      BrowserThread::IO, FROM_HERE,
-      base::Bind(&ExtensionInfoMap::UnregisterExtensionProcess,
+      BrowserThread::IO,
+      FROM_HERE,
+      base::Bind(&InfoMap::UnregisterExtensionProcess,
                  extensions::ExtensionSystem::Get(profile)->info_map(),
                  extension->id(),
                  site_instance->GetProcess()->GetID(),
                  site_instance->GetId()));
 }
 
-bool ChromeContentBrowserClient::ShouldSwapProcessesForNavigation(
+void ChromeContentBrowserClient::WorkerProcessCreated(
     SiteInstance* site_instance,
-    const GURL& current_url,
-    const GURL& new_url) {
-  if (current_url.is_empty()) {
-    // Always choose a new process when navigating to extension URLs. The
-    // process grouping logic will combine all of a given extension's pages
-    // into the same process.
-    if (new_url.SchemeIs(extensions::kExtensionScheme))
-      return true;
-
-    return false;
-  }
+    int worker_process_id) {
+  extensions::ExtensionRegistry* extension_registry =
+      extensions::ExtensionRegistry::Get(site_instance->GetBrowserContext());
+  if (!extension_registry)
+    return;
+  const Extension* extension =
+      extension_registry->enabled_extensions().GetExtensionOrAppByURL(
+        site_instance->GetSiteURL());
+  if (!extension)
+    return;
+  extensions::ExtensionSystem* extension_system =
+      extensions::ExtensionSystem::Get(site_instance->GetBrowserContext());
+  extension_system->info_map()->RegisterExtensionWorkerProcess(
+      extension->id(),
+      worker_process_id,
+      site_instance->GetId());
+}
 
-  // Also, we must switch if one is an extension and the other is not the exact
-  // same extension.
-  if (current_url.SchemeIs(extensions::kExtensionScheme) ||
-      new_url.SchemeIs(extensions::kExtensionScheme)) {
-    if (current_url.GetOrigin() != new_url.GetOrigin())
-      return true;
-  }
+void ChromeContentBrowserClient::WorkerProcessTerminated(
+    SiteInstance* site_instance,
+    int worker_process_id) {
+  extensions::ExtensionSystem* extension_system =
+      extensions::ExtensionSystem::Get(site_instance->GetBrowserContext());
+  extension_system->info_map()->UnregisterExtensionWorkerProcess(
+      worker_process_id);
+}
 
-  // The checks below only matter if we can retrieve which extensions are
-  // installed.
+bool ChromeContentBrowserClient::ShouldSwapBrowsingInstancesForNavigation(
+    SiteInstance* site_instance,
+    const GURL& current_url,
+    const GURL& new_url) {
+  // If we don't have an ExtensionService, then rely on the SiteInstance logic
+  // in RenderFrameHostManager to decide when to swap.
   Profile* profile =
       Profile::FromBrowserContext(site_instance->GetBrowserContext());
   ExtensionService* service =
@@ -1358,23 +1401,42 @@ bool ChromeContentBrowserClient::ShouldSwapProcessesForNavigation(
   if (!service)
     return false;
 
-  // We must swap if the URL is for an extension and we are not using an
-  // extension process.
+  // We must use a new BrowsingInstance (forcing a process swap and disabling
+  // scripting by existing tabs) if one of the URLs is an extension and the
+  // other is not the exact same extension.
+  //
+  // We ignore hosted apps here so that other tabs in their BrowsingInstance can
+  // use postMessage with them.  (The exception is the Chrome Web Store, which
+  // is a hosted app that requires its own BrowsingInstance.)  Navigations
+  // to/from a hosted app will still trigger a SiteInstance swap in
+  // RenderFrameHostManager.
+  const Extension* current_extension =
+      service->extensions()->GetExtensionOrAppByURL(current_url);
+  if (current_extension &&
+      current_extension->is_hosted_app() &&
+      current_extension->id() != extension_misc::kWebStoreAppId)
+    current_extension = NULL;
+
   const Extension* new_extension =
       service->extensions()->GetExtensionOrAppByURL(new_url);
-  // Ignore all hosted apps except the Chrome Web Store, since they do not
-  // require their own BrowsingInstance (e.g., postMessage is ok).
   if (new_extension &&
       new_extension->is_hosted_app() &&
       new_extension->id() != extension_misc::kWebStoreAppId)
     new_extension = NULL;
+
+  // First do a process check.  We should force a BrowsingInstance swap if the
+  // current process doesn't know about new_extension, even if current_extension
+  // is somehow the same as new_extension.
+  extensions::ProcessMap* process_map = extensions::ProcessMap::Get(profile);
   if (new_extension &&
       site_instance->HasProcess() &&
-      !service->process_map()->Contains(new_extension->id(),
-                                        site_instance->GetProcess()->GetID()))
+      !process_map->Contains(
+          new_extension->id(), site_instance->GetProcess()->GetID()))
     return true;
 
-  return false;
+  // Otherwise, swap BrowsingInstances if current_extension and new_extension
+  // differ.
+  return current_extension != new_extension;
 }
 
 bool ChromeContentBrowserClient::ShouldSwapProcessesForRedirect(
@@ -1417,12 +1479,20 @@ void ChromeContentBrowserClient::AppendExtraCommandLineSwitches(
   const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess();
 
   static const char* const kCommonSwitchNames[] = {
-    switches::kChromeFrame,
+    switches::kUserAgent,
     switches::kUserDataDir,  // Make logs go to the right file.
   };
   command_line->CopySwitchesFrom(browser_command_line, kCommonSwitchNames,
                                  arraysize(kCommonSwitchNames));
 
+#if defined(ENABLE_IPC_FUZZER)
+  static const char* const kIpcFuzzerSwitches[] = {
+    switches::kIpcFuzzerTestcase,
+  };
+  command_line->CopySwitchesFrom(browser_command_line, kIpcFuzzerSwitches,
+                                 arraysize(kIpcFuzzerSwitches));
+#endif
+
   if (process_type == switches::kRendererProcess) {
 #if defined(OS_CHROMEOS)
     const std::string& login_profile =
@@ -1434,14 +1504,9 @@ void ChromeContentBrowserClient::AppendExtraCommandLineSwitches(
 #endif
 
 #if defined(ENABLE_WEBRTC)
-    if (VersionInfo::GetChannel() <= VersionInfo::CHANNEL_DEV) {
-      static const char* const kWebRtcDevSwitchNames[] = {
-        switches::kDisableWebRtcEncryption,
-      };
-      command_line->CopySwitchesFrom(browser_command_line,
-                                     kWebRtcDevSwitchNames,
-                                     arraysize(kWebRtcDevSwitchNames));
-    }
+    MaybeCopyDisableWebRtcEncryptionSwitch(command_line,
+                                           browser_command_line,
+                                           VersionInfo::GetChannel());
 #endif
 
     content::RenderProcessHost* process =
@@ -1449,13 +1514,9 @@ void ChromeContentBrowserClient::AppendExtraCommandLineSwitches(
     if (process) {
       Profile* profile = Profile::FromBrowserContext(
           process->GetBrowserContext());
-      ExtensionService* extension_service =
-          extensions::ExtensionSystem::Get(profile)->extension_service();
-      if (extension_service) {
-        extensions::ProcessMap* process_map = extension_service->process_map();
-        if (process_map && process_map->Contains(process->GetID()))
-          command_line->AppendSwitch(switches::kExtensionProcess);
-      }
+
+      if (extensions::ProcessMap::Get(profile)->Contains(process->GetID()))
+        command_line->AppendSwitch(extensions::switches::kExtensionProcess);
 
       PrefService* prefs = profile->GetPrefs();
       // Currently this pref is only registered if applied via a policy.
@@ -1483,53 +1544,108 @@ void ChromeContentBrowserClient::AppendExtraCommandLineSwitches(
         command_line->AppendSwitch(switches::kInstantProcess);
 
 #if !defined(OS_CHROMEOS)
-      SigninManager* signin_manager =
-          SigninManagerFactory::GetForProfile(profile);
-      if (signin_manager && signin_manager->IsSigninProcess(process->GetID()))
+      ChromeSigninClient* signin_client =
+          ChromeSigninClientFactory::GetForProfile(profile);
+      if (signin_client && signin_client->IsSigninProcess(process->GetID()))
         command_line->AppendSwitch(switches::kSigninProcess);
 #endif
     }
 
-    if (message_center::IsRichNotificationEnabled())
-      command_line->AppendSwitch(switches::kDisableHTMLNotifications);
+    {
+      // Enable auto-reload if this session is in the field trial or the user
+      // explicitly enabled it.
+      bool hard_enabled =
+          browser_command_line.HasSwitch(switches::kEnableOfflineAutoReload);
+      bool hard_disabled =
+          browser_command_line.HasSwitch(switches::kDisableOfflineAutoReload);
+      if (hard_enabled) {
+        command_line->AppendSwitch(switches::kEnableOfflineAutoReload);
+      } else if (!hard_disabled) {
+        chrome::VersionInfo::Channel channel =
+          chrome::VersionInfo::GetChannel();
+#if defined(OS_ANDROID) || defined(OS_IOS)
+        chrome::VersionInfo::Channel kForceChannel =
+            chrome::VersionInfo::CHANNEL_DEV;
+#else
+        chrome::VersionInfo::Channel kForceChannel =
+            chrome::VersionInfo::CHANNEL_CANARY;
+#endif
+        std::string group =
+            base::FieldTrialList::FindFullName("AutoReloadExperiment");
+        if (channel <= kForceChannel || group == "Enabled")
+          command_line->AppendSwitch(switches::kEnableOfflineAutoReload);
+      }
+    }
+
+    {
+      // Enable load stale cache if this session is in the field trial, one
+      // of the forced on channels, or the user explicitly enabled it.
+      // Note that as far as the renderer  is concerned, the feature is
+      // enabled if-and-only-if the kEnableOfflineLoadStaleCache flag
+      // is on the command line; the yes/no/default behavior is only
+      // at the browser command line level.
+
+      // Command line switches override
+      if (browser_command_line.HasSwitch(
+              switches::kEnableOfflineLoadStaleCache)) {
+        command_line->AppendSwitch(switches::kEnableOfflineLoadStaleCache);
+      } else if (!browser_command_line.HasSwitch(
+          switches::kDisableOfflineLoadStaleCache)) {
+        std::string group =
+            base::FieldTrialList::FindFullName("LoadStaleCacheExperiment");
+        chrome::VersionInfo::Channel channel =
+            chrome::VersionInfo::GetChannel();
+#if defined(OS_ANDROID) || defined(OS_IOS)
+        chrome::VersionInfo::Channel forceChannel =
+            chrome::VersionInfo::CHANNEL_DEV;
+#else
+        chrome::VersionInfo::Channel forceChannel =
+            chrome::VersionInfo::CHANNEL_CANARY;
+#endif
+
+        if (channel <= forceChannel || group == "Enabled")
+          command_line->AppendSwitch(switches::kEnableOfflineLoadStaleCache);
+      }
+    }
 
     // Please keep this in alphabetical order.
     static const char* const kSwitchNames[] = {
-      autofill::switches::kDisableInteractiveAutocomplete,
+      autofill::switches::kDisableIgnoreAutocompleteOff,
       autofill::switches::kDisablePasswordGeneration,
-      autofill::switches::kEnableExperimentalFormFilling,
-      autofill::switches::kEnableInteractiveAutocomplete,
       autofill::switches::kEnablePasswordGeneration,
-      autofill::switches::kNoAutofillNecessaryForPasswordGeneration,
+      autofill::switches::kLocalHeuristicsOnlyForPasswordGeneration,
+      extensions::switches::kAllowHTTPBackgroundPage,
       extensions::switches::kAllowLegacyExtensionManifests,
-      extensions::switches::kAllowScriptingGallery,
       extensions::switches::kEnableExperimentalExtensionApis,
       extensions::switches::kExtensionsOnChromeURLs,
-      switches::kAllowHTTPBackgroundPage,
+      extensions::switches::kWhitelistedExtensionID,
       // TODO(victorhsieh): remove the following flag once we move PPAPI FileIO
       // to browser.
       switches::kAllowNaClFileHandleAPI,
       switches::kAppsCheckoutURL,
       switches::kAppsGalleryURL,
-      switches::kCloudPrintServiceURL,
-      switches::kDebugPrint,
+      switches::kCloudPrintURL,
+      switches::kCloudPrintXmppEndpoint,
       switches::kDisableBundledPpapiFlash,
       switches::kDisableExtensionsResourceWhitelist,
       switches::kDisablePnacl,
       switches::kDisableScriptedPrintThrottling,
       switches::kEnableAdview,
-      switches::kEnableAdviewSrcAttribute,
       switches::kEnableAppWindowControls,
       switches::kEnableBenchmarking,
       switches::kEnableNaCl,
+      switches::kEnableNaClDebug,
+      switches::kEnableNaClNonSfiMode,
       switches::kEnableNetBenchmarking,
+      switches::kEnableStreamlinedHostedApps,
       switches::kEnableWatchdog,
+      switches::kEnableWebBasedSignin,
       switches::kMemoryProfiling,
       switches::kMessageLoopHistogrammer,
       switches::kNoJsRandomness,
+      switches::kOutOfProcessPdf,
       switches::kPlaybackMode,
       switches::kPpapiFlashArgs,
-      switches::kPpapiFlashInProcess,
       switches::kPpapiFlashPath,
       switches::kPpapiFlashVersion,
       switches::kProfilingAtStart,
@@ -1537,7 +1653,6 @@ void ChromeContentBrowserClient::AppendExtraCommandLineSwitches(
       switches::kProfilingFlush,
       switches::kRecordMode,
       switches::kSilentDumpOnDCHECK,
-      switches::kWhitelistedExtensionID,
       translate::switches::kTranslateSecurityOrigin,
     };
 
@@ -1545,10 +1660,10 @@ void ChromeContentBrowserClient::AppendExtraCommandLineSwitches(
                                    arraysize(kSwitchNames));
   } else if (process_type == switches::kUtilityProcess) {
     static const char* const kSwitchNames[] = {
+      extensions::switches::kAllowHTTPBackgroundPage,
       extensions::switches::kEnableExperimentalExtensionApis,
       extensions::switches::kExtensionsOnChromeURLs,
-      switches::kAllowHTTPBackgroundPage,
-      switches::kWhitelistedExtensionID,
+      extensions::switches::kWhitelistedExtensionID,
     };
 
     command_line->CopySwitchesFrom(browser_command_line, kSwitchNames,
@@ -1568,7 +1683,7 @@ void ChromeContentBrowserClient::AppendExtraCommandLineSwitches(
     static const char* const kSwitchNames[] = {
       // Load (in-process) Pepper plugins in-process in the zygote pre-sandbox.
       switches::kDisableBundledPpapiFlash,
-      switches::kPpapiFlashInProcess,
+      switches::kNaClDangerousNoSandboxNonSfi,
       switches::kPpapiFlashPath,
       switches::kPpapiFlashVersion,
     };
@@ -1623,7 +1738,7 @@ bool ChromeContentBrowserClient::AllowGetCookie(
     const net::CookieList& cookie_list,
     content::ResourceContext* context,
     int render_process_id,
-    int render_view_id) {
+    int render_frame_id) {
   DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
   ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
   bool allow = io_data->GetCookieSettings()->
@@ -1632,7 +1747,7 @@ bool ChromeContentBrowserClient::AllowGetCookie(
   BrowserThread::PostTask(
       BrowserThread::UI, FROM_HERE,
       base::Bind(&TabSpecificContentSettings::CookiesRead, render_process_id,
-                 render_view_id, url, first_party, cookie_list, !allow));
+                 render_frame_id, url, first_party, cookie_list, !allow, true));
   return allow;
 }
 
@@ -1642,7 +1757,7 @@ bool ChromeContentBrowserClient::AllowSetCookie(
     const std::string& cookie_line,
     content::ResourceContext* context,
     int render_process_id,
-    int render_view_id,
+    int render_frame_id,
     net::CookieOptions* options) {
   DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
   ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
@@ -1652,7 +1767,7 @@ bool ChromeContentBrowserClient::AllowSetCookie(
   BrowserThread::PostTask(
       BrowserThread::UI, FROM_HERE,
       base::Bind(&TabSpecificContentSettings::CookieChanged, render_process_id,
-                 render_view_id, url, first_party, cookie_line, *options,
+                 render_frame_id, url, first_party, cookie_line, *options,
                  !allow));
   return allow;
 }
@@ -1671,11 +1786,11 @@ bool ChromeContentBrowserClient::AllowSaveLocalState(
 
 bool ChromeContentBrowserClient::AllowWorkerDatabase(
     const GURL& url,
-    const string16& name,
-    const string16& display_name,
+    const base::string16& name,
+    const base::string16& display_name,
     unsigned long estimated_size,
     content::ResourceContext* context,
-    const std::vector<std::pair<int, int> >& render_views) {
+    const std::vector<std::pair<int, int> >& render_frames) {
   DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
   ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
   CookieSettings* cookie_settings = io_data->GetCookieSettings();
@@ -1683,7 +1798,7 @@ bool ChromeContentBrowserClient::AllowWorkerDatabase(
 
   // Record access to database for potential display in UI.
   std::vector<std::pair<int, int> >::const_iterator i;
-  for (i = render_views.begin(); i != render_views.end(); ++i) {
+  for (i = render_frames.begin(); i != render_frames.end(); ++i) {
     BrowserThread::PostTask(
         BrowserThread::UI, FROM_HERE,
         base::Bind(&TabSpecificContentSettings::WebDatabaseAccessed,
@@ -1696,7 +1811,7 @@ bool ChromeContentBrowserClient::AllowWorkerDatabase(
 bool ChromeContentBrowserClient::AllowWorkerFileSystem(
     const GURL& url,
     content::ResourceContext* context,
-    const std::vector<std::pair<int, int> >& render_views) {
+    const std::vector<std::pair<int, int> >& render_frames) {
   DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
   ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
   CookieSettings* cookie_settings = io_data->GetCookieSettings();
@@ -1704,7 +1819,7 @@ bool ChromeContentBrowserClient::AllowWorkerFileSystem(
 
   // Record access to file system for potential display in UI.
   std::vector<std::pair<int, int> >::const_iterator i;
-  for (i = render_views.begin(); i != render_views.end(); ++i) {
+  for (i = render_frames.begin(); i != render_frames.end(); ++i) {
     BrowserThread::PostTask(
         BrowserThread::UI, FROM_HERE,
         base::Bind(&TabSpecificContentSettings::FileSystemAccessed,
@@ -1716,9 +1831,9 @@ bool ChromeContentBrowserClient::AllowWorkerFileSystem(
 
 bool ChromeContentBrowserClient::AllowWorkerIndexedDB(
     const GURL& url,
-    const string16& name,
+    const base::string16& name,
     content::ResourceContext* context,
-    const std::vector<std::pair<int, int> >& render_views) {
+    const std::vector<std::pair<int, int> >& render_frames) {
   DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
   ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
   CookieSettings* cookie_settings = io_data->GetCookieSettings();
@@ -1726,7 +1841,7 @@ bool ChromeContentBrowserClient::AllowWorkerIndexedDB(
 
   // Record access to IndexedDB for potential display in UI.
   std::vector<std::pair<int, int> >::const_iterator i;
-  for (i = render_views.begin(); i != render_views.end(); ++i) {
+  for (i = render_frames.begin(); i != render_frames.end(); ++i) {
     BrowserThread::PostTask(
         BrowserThread::UI, FROM_HERE,
         base::Bind(&TabSpecificContentSettings::IndexedDBAccessed,
@@ -1755,7 +1870,7 @@ ChromeContentBrowserClient::CreateQuotaPermissionContext() {
 
 void ChromeContentBrowserClient::AllowCertificateError(
     int render_process_id,
-    int render_view_id,
+    int render_frame_id,
     int cert_error,
     const net::SSLInfo& ssl_info,
     const GURL& request_url,
@@ -1774,28 +1889,25 @@ void ChromeContentBrowserClient::AllowCertificateError(
   }
 
   // If the tab is being prerendered, cancel the prerender and the request.
-  WebContents* tab = tab_util::GetWebContentsByID(
-      render_process_id, render_view_id);
+  content::RenderFrameHost* render_frame_host =
+      content::RenderFrameHost::FromID(render_process_id, render_frame_id);
+  WebContents* tab = WebContents::FromRenderFrameHost(render_frame_host);
   if (!tab) {
     NOTREACHED();
     return;
   }
-  prerender::PrerenderManager* prerender_manager =
-      prerender::PrerenderManagerFactory::GetForProfile(
-          Profile::FromBrowserContext(tab->GetBrowserContext()));
-  if (prerender_manager && prerender_manager->IsWebContentsPrerendering(tab,
-                                                                        NULL)) {
-    if (prerender_manager->prerender_tracker()->TryCancel(
-            render_process_id, render_view_id,
-            prerender::FINAL_STATUS_SSL_ERROR)) {
-      *result = content::CERTIFICATE_REQUEST_RESULT_TYPE_CANCEL;
-      return;
-    }
+
+  prerender::PrerenderContents* prerender_contents =
+      prerender::PrerenderContents::FromWebContents(tab);
+  if (prerender_contents) {
+    prerender_contents->Destroy(prerender::FINAL_STATUS_SSL_ERROR);
+    *result = content::CERTIFICATE_REQUEST_RESULT_TYPE_CANCEL;
+    return;
   }
 
 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION)
-  captive_portal::CaptivePortalTabHelper* captive_portal_tab_helper =
-      captive_portal::CaptivePortalTabHelper::FromWebContents(tab);
+  CaptivePortalTabHelper* captive_portal_tab_helper =
+      CaptivePortalTabHelper::FromWebContents(tab);
   if (captive_portal_tab_helper)
     captive_portal_tab_helper->OnSSLCertError(ssl_info);
 #endif
@@ -1807,23 +1919,33 @@ void ChromeContentBrowserClient::AllowCertificateError(
 
 void ChromeContentBrowserClient::SelectClientCertificate(
     int render_process_id,
-    int render_view_id,
+    int render_frame_id,
     const net::HttpNetworkSession* network_session,
     net::SSLCertRequestInfo* cert_request_info,
     const base::Callback<void(net::X509Certificate*)>& callback) {
-  WebContents* tab = tab_util::GetWebContentsByID(
-      render_process_id, render_view_id);
+  content::RenderFrameHost* rfh = content::RenderFrameHost::FromID(
+      render_process_id, render_frame_id);
+  WebContents* tab = WebContents::FromRenderFrameHost(rfh);
   if (!tab) {
     NOTREACHED();
     return;
   }
 
-  GURL requesting_url("https://" + cert_request_info->host_and_port);
-  DCHECK(requesting_url.is_valid()) << "Invalid URL string: https://"
-                                    << cert_request_info->host_and_port;
+  prerender::PrerenderContents* prerender_contents =
+      prerender::PrerenderContents::FromWebContents(tab);
+  if (prerender_contents) {
+    prerender_contents->Destroy(
+        prerender::FINAL_STATUS_SSL_CLIENT_CERTIFICATE_REQUESTED);
+    return;
+  }
+
+  GURL requesting_url("https://" + cert_request_info->host_and_port.ToString());
+  DCHECK(requesting_url.is_valid())
+      << "Invalid URL string: https://"
+      << cert_request_info->host_and_port.ToString();
 
   Profile* profile = Profile::FromBrowserContext(tab->GetBrowserContext());
-  scoped_ptr<Value> filter(
+  scoped_ptr<base::Value> filter(
       profile->GetHostContentSettingsMap()->GetWebsiteSetting(
           requesting_url,
           requesting_url,
@@ -1832,9 +1954,9 @@ void ChromeContentBrowserClient::SelectClientCertificate(
 
   if (filter.get()) {
     // Try to automatically select a client certificate.
-    if (filter->IsType(Value::TYPE_DICTIONARY)) {
-      DictionaryValue* filter_dict =
-          static_cast<DictionaryValue*>(filter.get());
+    if (filter->IsType(base::Value::TYPE_DICTIONARY)) {
+      base::DictionaryValue* filter_dict =
+          static_cast<base::DictionaryValue*>(filter.get());
 
       const std::vector<scoped_refptr<net::X509Certificate> >&
           all_client_certs = cert_request_info->client_certs;
@@ -1879,33 +2001,25 @@ content::MediaObserver* ChromeContentBrowserClient::GetMediaObserver() {
 
 void ChromeContentBrowserClient::RequestDesktopNotificationPermission(
     const GURL& source_origin,
-    int callback_context,
-    int render_process_id,
-    int render_view_id) {
+    content::RenderFrameHost* render_frame_host,
+    base::Closure& callback) {
 #if defined(ENABLE_NOTIFICATIONS)
-  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
-  WebContents* contents =
-      tab_util::GetWebContentsByID(render_process_id, render_view_id);
-  if (!contents) {
-    NOTREACHED();
-    return;
-  }
-
   // Skip showing the infobar if the request comes from an extension, and that
   // extension has the 'notify' permission. (If the extension does not have the
   // permission, the user will still be prompted.)
-  Profile* profile = Profile::FromBrowserContext(contents->GetBrowserContext());
-  ExtensionInfoMap* extension_info_map =
+  Profile* profile = Profile::FromBrowserContext(
+      render_frame_host->GetSiteInstance()->GetBrowserContext());
+  InfoMap* extension_info_map =
       extensions::ExtensionSystem::Get(profile)->info_map();
   DesktopNotificationService* notification_service =
       DesktopNotificationServiceFactory::GetForProfile(profile);
   const Extension* extension = NULL;
   if (extension_info_map) {
-    ExtensionSet extensions;
+    extensions::ExtensionSet extensions;
     extension_info_map->GetExtensionsWithAPIPermissionForSecurityOrigin(
-        source_origin, render_process_id,
+        source_origin, render_frame_host->GetProcess()->GetID(),
         extensions::APIPermission::kNotification, &extensions);
-    for (ExtensionSet::const_iterator iter = extensions.begin();
+    for (extensions::ExtensionSet::const_iterator iter = extensions.begin();
          iter != extensions.end(); ++iter) {
       if (notification_service->IsNotifierEnabled(NotifierId(
               NotifierId::APPLICATION, (*iter)->id()))) {
@@ -1914,104 +2028,76 @@ void ChromeContentBrowserClient::RequestDesktopNotificationPermission(
       }
     }
   }
-  RenderViewHost* rvh =
-      RenderViewHost::FromID(render_process_id, render_view_id);
   if (IsExtensionWithPermissionOrSuggestInConsole(
-      APIPermission::kNotification, extension, rvh)) {
-    if (rvh)
-      rvh->DesktopNotificationPermissionRequestDone(callback_context);
+          APIPermission::kNotification, extension,
+          render_frame_host->GetRenderViewHost())) {
+    callback.Run();
     return;
   }
 
-  notification_service->RequestPermission(source_origin, render_process_id,
-      render_view_id, callback_context, contents);
+  notification_service->RequestPermission(
+      source_origin, render_frame_host, callback);
 #else
   NOTIMPLEMENTED();
 #endif
 }
 
-WebKit::WebNotificationPresenter::Permission
+blink::WebNotificationPresenter::Permission
     ChromeContentBrowserClient::CheckDesktopNotificationPermission(
         const GURL& source_origin,
         content::ResourceContext* context,
         int render_process_id) {
 #if defined(ENABLE_NOTIFICATIONS)
   DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
-  // Sometimes a notification may be invoked during the shutdown.
-  // See http://crbug.com/256638
-  if (browser_shutdown::IsTryingToQuit())
-    return WebKit::WebNotificationPresenter::PermissionNotAllowed;
 
   ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
-
-  DesktopNotificationService* notification_service =
-      io_data->GetNotificationService();
-  if (notification_service) {
-    ExtensionInfoMap* extension_info_map = io_data->GetExtensionInfoMap();
-    ExtensionSet extensions;
-    extension_info_map->GetExtensionsWithAPIPermissionForSecurityOrigin(
-        source_origin, render_process_id,
-        extensions::APIPermission::kNotification, &extensions);
-    for (ExtensionSet::const_iterator iter = extensions.begin();
-         iter != extensions.end(); ++iter) {
-      NotifierId notifier_id(NotifierId::APPLICATION, (*iter)->id());
-      if (notification_service->IsNotifierEnabled(notifier_id))
-        return WebKit::WebNotificationPresenter::PermissionAllowed;
-    }
-
-    return notification_service->HasPermission(source_origin);
-  }
-
-  return WebKit::WebNotificationPresenter::PermissionNotAllowed;
+  InfoMap* extension_info_map = io_data->GetExtensionInfoMap();
+
+  // We want to see if there is an extension that hasn't been manually disabled
+  // that has the notifications permission and applies to this security origin.
+  // First, get the list of extensions with permission for the origin.
+  extensions::ExtensionSet extensions;
+  extension_info_map->GetExtensionsWithAPIPermissionForSecurityOrigin(
+      source_origin, render_process_id,
+      extensions::APIPermission::kNotification, &extensions);
+  for (extensions::ExtensionSet::const_iterator iter = extensions.begin();
+       iter != extensions.end(); ++iter) {
+    // Then, check to see if it's been disabled by the user.
+    if (!extension_info_map->AreNotificationsDisabled((*iter)->id()))
+      return blink::WebNotificationPresenter::PermissionAllowed;
+  }
+
+  // No enabled extensions exist, so check the normal host content settings.
+  HostContentSettingsMap* host_content_settings_map =
+      io_data->GetHostContentSettingsMap();
+  ContentSetting setting = host_content_settings_map->GetContentSetting(
+      source_origin,
+      source_origin,
+      CONTENT_SETTINGS_TYPE_NOTIFICATIONS,
+      NO_RESOURCE_IDENTIFIER);
+
+  if (setting == CONTENT_SETTING_ALLOW)
+    return blink::WebNotificationPresenter::PermissionAllowed;
+  if (setting == CONTENT_SETTING_BLOCK)
+    return blink::WebNotificationPresenter::PermissionDenied;
+  return blink::WebNotificationPresenter::PermissionNotAllowed;
 #else
-  return WebKit::WebNotificationPresenter::PermissionAllowed;
+  return blink::WebNotificationPresenter::PermissionAllowed;
 #endif
 }
 
 void ChromeContentBrowserClient::ShowDesktopNotification(
     const content::ShowDesktopNotificationHostMsgParams& params,
-    int render_process_id,
-    int render_view_id,
-    bool worker) {
+    RenderFrameHost* render_frame_host,
+    content::DesktopNotificationDelegate* delegate,
+    base::Closure* cancel_callback) {
 #if defined(ENABLE_NOTIFICATIONS)
-  RenderViewHost* rvh = RenderViewHost::FromID(
-      render_process_id, render_view_id);
-  if (!rvh) {
-    NOTREACHED();
-    return;
-  }
-
-  content::RenderProcessHost* process = rvh->GetProcess();
+  content::RenderProcessHost* process = render_frame_host->GetProcess();
   Profile* profile = Profile::FromBrowserContext(process->GetBrowserContext());
   DesktopNotificationService* service =
       DesktopNotificationServiceFactory::GetForProfile(profile);
   service->ShowDesktopNotification(
-    params, render_process_id, render_view_id,
-    worker ? DesktopNotificationService::WorkerNotification :
-        DesktopNotificationService::PageNotification);
-#else
-  NOTIMPLEMENTED();
-#endif
-}
-
-void ChromeContentBrowserClient::CancelDesktopNotification(
-    int render_process_id,
-    int render_view_id,
-    int notification_id) {
-#if defined(ENABLE_NOTIFICATIONS)
-  RenderViewHost* rvh = RenderViewHost::FromID(
-      render_process_id, render_view_id);
-  if (!rvh) {
-    NOTREACHED();
-    return;
-  }
-
-  content::RenderProcessHost* process = rvh->GetProcess();
-  Profile* profile = Profile::FromBrowserContext(process->GetBrowserContext());
-  DesktopNotificationService* service =
-      DesktopNotificationServiceFactory::GetForProfile(profile);
-  service->CancelDesktopNotification(
-      render_process_id, render_view_id, notification_id);
+      params, render_frame_host, delegate, cancel_callback);
 #else
   NOTIMPLEMENTED();
 #endif
@@ -2038,7 +2124,7 @@ bool ChromeContentBrowserClient::CanCreateWindow(
   *no_javascript_access = false;
 
   ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
-  ExtensionInfoMap* map = io_data->GetExtensionInfoMap();
+  InfoMap* map = io_data->GetExtensionInfoMap();
 
   // If the opener is trying to create a background window but doesn't have
   // the appropriate permission, fail the attempt.
@@ -2064,20 +2150,6 @@ bool ChromeContentBrowserClient::CanCreateWindow(
     return true;
   }
 
-  // No new browser window (popup or tab) in app mode.
-  if (container_type == WINDOW_CONTAINER_TYPE_NORMAL &&
-      chrome::IsRunningInForcedAppMode()) {
-    return false;
-  }
-
-  if (g_browser_process->prerender_tracker() &&
-      g_browser_process->prerender_tracker()->TryCancelOnIOThread(
-          render_process_id,
-          opener_id,
-          prerender::FINAL_STATUS_CREATE_NEW_WINDOW)) {
-    return false;
-  }
-
   if (is_guest)
     return true;
 
@@ -2138,13 +2210,7 @@ void ChromeContentBrowserClient::ResourceDispatcherHostCreated() {
 // TODO(tommi): Rename from Get to Create.
 content::SpeechRecognitionManagerDelegate*
     ChromeContentBrowserClient::GetSpeechRecognitionManagerDelegate() {
-#if defined(ENABLE_INPUT_SPEECH)
-  return new speech::ChromeSpeechRecognitionManagerDelegateBubbleUI();
-#else
-  // Platforms who don't implement x-webkit-speech (a.k.a INPUT_SPEECH) just
-  // need the base delegate without the bubble UI.
   return new speech::ChromeSpeechRecognitionManagerDelegate();
-#endif
 }
 
 net::NetLog* ChromeContentBrowserClient::GetNetLog() {
@@ -2201,10 +2267,11 @@ void ChromeContentBrowserClient::OverrideWebkitPrefs(
       prefs->GetBoolean(prefs::kWebKitDomPasteEnabled);
   web_prefs->shrinks_standalone_images_to_fit =
       prefs->GetBoolean(prefs::kWebKitShrinksStandaloneImagesToFit);
-  const DictionaryValue* inspector_settings =
+  const base::DictionaryValue* inspector_settings =
       prefs->GetDictionary(prefs::kWebKitInspectorSettings);
   if (inspector_settings) {
-    for (DictionaryValue::Iterator iter(*inspector_settings); !iter.IsAtEnd();
+    for (base::DictionaryValue::Iterator iter(*inspector_settings);
+         !iter.IsAtEnd();
          iter.Advance()) {
       std::string value;
       if (iter.value().GetAsString(&value)) {
@@ -2229,8 +2296,6 @@ void ChromeContentBrowserClient::OverrideWebkitPrefs(
   if (prefs->GetBoolean(prefs::kDisable3DAPIs))
     web_prefs->experimental_webgl_enabled = false;
 
-  web_prefs->memory_info_enabled =
-      prefs->GetBoolean(prefs::kEnableMemoryInfo);
   web_prefs->allow_displaying_insecure_content =
       prefs->GetBoolean(prefs::kWebKitAllowDisplayingInsecureContent);
   web_prefs->allow_running_insecure_content =
@@ -2250,21 +2315,6 @@ void ChromeContentBrowserClient::OverrideWebkitPrefs(
   web_prefs->password_echo_enabled = browser_defaults::kPasswordEchoEnabled;
 #endif
 
-#if defined(OS_ANDROID)
-  web_prefs->user_style_sheet_enabled = false;
-#else
-  // The user stylesheet watcher may not exist in a testing profile.
-  UserStyleSheetWatcher* user_style_sheet_watcher =
-      UserStyleSheetWatcherFactory::GetForProfile(profile).get();
-  if (user_style_sheet_watcher) {
-    web_prefs->user_style_sheet_enabled = true;
-    web_prefs->user_style_sheet_location =
-        user_style_sheet_watcher->user_style_sheet();
-  } else {
-    web_prefs->user_style_sheet_enabled = false;
-  }
-#endif
-
   web_prefs->asynchronous_spell_checking_enabled = true;
   web_prefs->unified_textchecker_enabled = true;
 
@@ -2290,37 +2340,18 @@ void ChromeContentBrowserClient::OverrideWebkitPrefs(
   ExtensionService* service =
       extensions::ExtensionSystem::Get(profile)->extension_service();
   if (service) {
-    const GURL& url = rvh->GetSiteInstance()->GetSiteURL();
-    const Extension* extension = service->extensions()->GetByID(url.host());
+    const GURL& site_url = rvh->GetSiteInstance()->GetSiteURL();
+    const Extension* extension =
+        service->extensions()->GetByID(site_url.host());
     // Ensure that we are only granting extension preferences to URLs with
     // the correct scheme. Without this check, chrome-guest:// schemes used by
     // webview tags as well as hosts that happen to match the id of an
     // installed extension would get the wrong preferences.
-    if (url.SchemeIs(extensions::kExtensionScheme)) {
+    if (site_url.SchemeIs(extensions::kExtensionScheme)) {
       extension_webkit_preferences::SetPreferences(
           extension, view_type, web_prefs);
     }
   }
-
-  if (view_type == extensions::VIEW_TYPE_NOTIFICATION) {
-    web_prefs->allow_scripts_to_close_windows = true;
-  } else if (view_type == extensions::VIEW_TYPE_BACKGROUND_CONTENTS) {
-    // Disable all kinds of acceleration for background pages.
-    // See http://crbug.com/96005 and http://crbug.com/96006
-    web_prefs->force_compositing_mode = false;
-    web_prefs->accelerated_compositing_enabled = false;
-  }
-
-#if defined(FILE_MANAGER_EXTENSION)
-  // Override the default of suppressing HW compositing for WebUI pages for the
-  // file manager, which is implemented using WebUI but wants HW acceleration
-  // for video decode & render.
-  if (url.SchemeIs(extensions::kExtensionScheme) &&
-      url.host() == file_manager::kFileManagerAppId) {
-    web_prefs->accelerated_compositing_enabled = true;
-    web_prefs->accelerated_2d_canvas_enabled = true;
-  }
-#endif
 }
 
 void ChromeContentBrowserClient::UpdateInspectorSetting(
@@ -2330,9 +2361,9 @@ void ChromeContentBrowserClient::UpdateInspectorSetting(
   DictionaryPrefUpdate update(
       Profile::FromBrowserContext(browser_context)->GetPrefs(),
       prefs::kWebKitInspectorSettings);
-  DictionaryValue* inspector_settings = update.Get();
-  inspector_settings->SetWithoutPathExpansion(key,
-                                              Value::CreateStringValue(value));
+  base::DictionaryValue* inspector_settings = update.Get();
+  inspector_settings->SetWithoutPathExpansion(
+      key, base::Value::CreateStringValue(value));
 }
 
 void ChromeContentBrowserClient::BrowserURLHandlerCreated(
@@ -2349,9 +2380,15 @@ void ChromeContentBrowserClient::BrowserURLHandlerCreated(
   handler->AddHandlerPair(&WillHandleBrowserAboutURL,
                           BrowserURLHandler::null_handler());
 
+#if defined(OS_ANDROID)
+  // Handler to rewrite chrome://newtab on Android.
+  handler->AddHandlerPair(&chrome::android::HandleAndroidNewTabURL,
+                          BrowserURLHandler::null_handler());
+#else
   // Handler to rewrite chrome://newtab for InstantExtended.
   handler->AddHandlerPair(&chrome::HandleNewTabURLRewrite,
                           &chrome::HandleNewTabURLReverseRewrite);
+#endif
 
   // chrome: & friends.
   handler->AddHandlerPair(&HandleWebUI, &HandleWebUIReverse);
@@ -2399,7 +2436,8 @@ content::BrowserPpapiHost*
         int plugin_process_id) {
   BrowserChildProcessHostIterator iter(PROCESS_TYPE_NACL_LOADER);
   while (!iter.Done()) {
-    NaClProcessHost* host = static_cast<NaClProcessHost*>(iter.GetDelegate());
+    nacl::NaClProcessHost* host = static_cast<nacl::NaClProcessHost*>(
+        iter.GetDelegate());
     if (host->process() &&
         host->process()->GetData().id == plugin_process_id) {
       // Found the plugin.
@@ -2410,30 +2448,6 @@ content::BrowserPpapiHost*
   return NULL;
 }
 
-bool ChromeContentBrowserClient::SupportsBrowserPlugin(
-    content::BrowserContext* browser_context, const GURL& site_url) {
-  if (CommandLine::ForCurrentProcess()->HasSwitch(
-          switches::kEnableBrowserPluginForAllViewTypes))
-    return true;
-
-  if (content::HasWebUIScheme(site_url))
-    return true;
-
-  Profile* profile = Profile::FromBrowserContext(browser_context);
-  ExtensionService* service =
-      extensions::ExtensionSystem::Get(profile)->extension_service();
-  if (!service)
-    return false;
-
-  const Extension* extension =
-      service->extensions()->GetExtensionOrAppByURL(site_url);
-  if (!extension)
-    return false;
-
-  return extension->HasAPIPermission(APIPermission::kWebView) ||
-         extension->HasAPIPermission(APIPermission::kAdView);
-}
-
 bool ChromeContentBrowserClient::AllowPepperSocketAPI(
     content::BrowserContext* browser_context,
     const GURL& url,
@@ -2441,7 +2455,7 @@ bool ChromeContentBrowserClient::AllowPepperSocketAPI(
     const content::SocketPermissionRequest* params) {
 #if defined(ENABLE_PLUGINS)
   Profile* profile = Profile::FromBrowserContext(browser_context);
-  const ExtensionSet* extension_set = NULL;
+  const extensions::ExtensionSet* extension_set = NULL;
   if (profile) {
     extension_set = extensions::ExtensionSystem::Get(profile)->
         extension_service()->extensions();
@@ -2494,10 +2508,19 @@ void ChromeContentBrowserClient::GetAdditionalAllowedSchemesForFileSystem(
     std::vector<std::string>* additional_allowed_schemes) {
   ContentBrowserClient::GetAdditionalAllowedSchemesForFileSystem(
       additional_allowed_schemes);
-  additional_allowed_schemes->push_back(kChromeUIScheme);
+  additional_allowed_schemes->push_back(content::kChromeDevToolsScheme);
+  additional_allowed_schemes->push_back(content::kChromeUIScheme);
   additional_allowed_schemes->push_back(extensions::kExtensionScheme);
 }
 
+void ChromeContentBrowserClient::GetURLRequestAutoMountHandlers(
+    std::vector<fileapi::URLRequestAutoMountHandler>* handlers) {
+#if !defined(OS_ANDROID)
+  handlers->push_back(
+      base::Bind(MediaFileSystemBackend::AttemptAutoMountForURLRequest));
+#endif  // OS_ANDROID
+}
+
 void ChromeContentBrowserClient::GetAdditionalFileSystemBackends(
     content::BrowserContext* browser_context,
     const base::FilePath& storage_partition_path,
@@ -2513,12 +2536,13 @@ void ChromeContentBrowserClient::GetAdditionalFileSystemBackends(
   fileapi::ExternalMountPoints* external_mount_points =
       content::BrowserContext::GetMountPoints(browser_context);
   DCHECK(external_mount_points);
-  chromeos::FileSystemBackend* backend =
-      new chromeos::FileSystemBackend(
-          new drive::FileSystemBackendDelegate(browser_context),
-          browser_context->GetSpecialStoragePolicy(),
-          external_mount_points,
-          fileapi::ExternalMountPoints::GetSystemInstance());
+  chromeos::FileSystemBackend* backend = new chromeos::FileSystemBackend(
+      new drive::FileSystemBackendDelegate,
+      new chromeos::file_system_provider::BackendDelegate,
+      new chromeos::MTPFileSystemBackendDelegate(storage_partition_path),
+      browser_context->GetSpecialStoragePolicy(),
+      external_mount_points,
+      fileapi::ExternalMountPoints::GetSystemInstance());
   backend->AddSystemMountPoints();
   DCHECK(backend->CanHandleType(fileapi::kFileSystemTypeExternal));
   additional_backends->push_back(backend);
@@ -2527,6 +2551,16 @@ void ChromeContentBrowserClient::GetAdditionalFileSystemBackends(
   additional_backends->push_back(
       new sync_file_system::SyncFileSystemBackend(
           Profile::FromBrowserContext(browser_context)));
+
+#if defined(ENABLE_SERVICE_DISCOVERY)
+  if (CommandLine::ForCurrentProcess()->HasSwitch(
+          switches::kEnablePrivetStorage)) {
+    additional_backends->push_back(
+        new local_discovery::PrivetFileSystemBackend(
+            fileapi::ExternalMountPoints::GetSystemInstance(),
+            browser_context));
+  }
+#endif
 }
 
 #if defined(OS_POSIX) && !defined(OS_MACOSX)
@@ -2539,39 +2573,38 @@ void ChromeContentBrowserClient::GetAdditionalMappedFilesForChildProcess(
   PathService::Get(ui::DIR_RESOURCE_PAKS_ANDROID, &data_path);
   DCHECK(!data_path.empty());
 
-  int flags = base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ;
+  int flags = base::File::FLAG_OPEN | base::File::FLAG_READ;
   base::FilePath chrome_resources_pak =
       data_path.AppendASCII("chrome_100_percent.pak");
-  base::PlatformFile f =
-      base::CreatePlatformFile(chrome_resources_pak, flags, NULL, NULL);
-  DCHECK(f != base::kInvalidPlatformFileValue);
+  base::File file(chrome_resources_pak, flags);
+  DCHECK(file.IsValid());
   mappings->push_back(FileDescriptorInfo(kAndroidChrome100PercentPakDescriptor,
-                                         FileDescriptor(f, true)));
+                                         FileDescriptor(file.Pass())));
 
   const std::string locale = GetApplicationLocale();
   base::FilePath locale_pak = ResourceBundle::GetSharedInstance().
       GetLocaleFilePath(locale, false);
-  f = base::CreatePlatformFile(locale_pak, flags, NULL, NULL);
-  DCHECK(f != base::kInvalidPlatformFileValue);
+  file.Initialize(locale_pak, flags);
+  DCHECK(file.IsValid());
   mappings->push_back(FileDescriptorInfo(kAndroidLocalePakDescriptor,
-                                         FileDescriptor(f, true)));
+                                         FileDescriptor(file.Pass())));
 
   base::FilePath resources_pack_path;
   PathService::Get(chrome::FILE_RESOURCES_PACK, &resources_pack_path);
-  f = base::CreatePlatformFile(resources_pack_path, flags, NULL, NULL);
-  DCHECK(f != base::kInvalidPlatformFileValue);
+  file.Initialize(resources_pack_path, flags);
+  DCHECK(file.IsValid());
   mappings->push_back(FileDescriptorInfo(kAndroidUIResourcesPakDescriptor,
-                                         FileDescriptor(f, true)));
+                                         FileDescriptor(file.Pass())));
 
   if (breakpad::IsCrashReporterEnabled()) {
-    f = breakpad::CrashDumpManager::GetInstance()->CreateMinidumpFile(
-        child_process_id);
-    if (f == base::kInvalidPlatformFileValue) {
+    file = breakpad::CrashDumpManager::GetInstance()->CreateMinidumpFile(
+               child_process_id);
+    if (file.IsValid()) {
+      mappings->push_back(FileDescriptorInfo(kAndroidMinidumpDescriptor,
+                                             FileDescriptor(file.Pass())));
+    } else {
       LOG(ERROR) << "Failed to create file for minidump, crash reporting will "
                  "be disabled for this process.";
-    } else {
-      mappings->push_back(FileDescriptorInfo(kAndroidMinidumpDescriptor,
-                                             FileDescriptor(f, true)));
     }
   }
 
@@ -2619,21 +2652,12 @@ void ChromeContentBrowserClient::PreSpawnRenderer(
 }
 #endif
 
-#if defined(USE_NSS)
-crypto::CryptoModuleBlockingPasswordDelegate*
-    ChromeContentBrowserClient::GetCryptoPasswordDelegate(
-        const GURL& url) {
-  return chrome::NewCryptoModuleBlockingDialogDelegate(
-      chrome::kCryptoModulePasswordKeygen, url.host());
-}
-#endif
-
 bool ChromeContentBrowserClient::IsPluginAllowedToCallRequestOSFileHandle(
     content::BrowserContext* browser_context,
     const GURL& url) {
 #if defined(ENABLE_PLUGINS)
   Profile* profile = Profile::FromBrowserContext(browser_context);
-  const ExtensionSet* extension_set = NULL;
+  const extensions::ExtensionSet* extension_set = NULL;
   if (profile) {
     extension_set = extensions::ExtensionSystem::Get(profile)->
         extension_service()->extensions();
@@ -2649,4 +2673,45 @@ bool ChromeContentBrowserClient::IsPluginAllowedToCallRequestOSFileHandle(
 #endif
 }
 
+bool ChromeContentBrowserClient::IsPluginAllowedToUseDevChannelAPIs() {
+#if defined(ENABLE_PLUGINS)
+  // Allow access for tests.
+  if (CommandLine::ForCurrentProcess()->HasSwitch(
+          switches::kEnablePepperTesting)) {
+    return true;
+  }
+
+  chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel();
+  // Allow dev channel APIs to be used on "Canary", "Dev", and "Unknown"
+  // releases of Chrome. Permitting "Unknown" allows these APIs to be used on
+  // Chromium builds as well.
+  return channel <= chrome::VersionInfo::CHANNEL_DEV;
+#else
+  return false;
+#endif
+}
+
+#if defined(ENABLE_WEBRTC)
+void ChromeContentBrowserClient::MaybeCopyDisableWebRtcEncryptionSwitch(
+    CommandLine* to_command_line,
+    const CommandLine& from_command_line,
+    VersionInfo::Channel channel) {
+#if defined(OS_ANDROID)
+  const VersionInfo::Channel kMaxDisableEncryptionChannel =
+      VersionInfo::CHANNEL_BETA;
+#else
+  const VersionInfo::Channel kMaxDisableEncryptionChannel =
+      VersionInfo::CHANNEL_DEV;
+#endif
+  if (channel <= kMaxDisableEncryptionChannel) {
+    static const char* const kWebRtcDevSwitchNames[] = {
+      switches::kDisableWebRtcEncryption,
+    };
+    to_command_line->CopySwitchesFrom(from_command_line,
+                                      kWebRtcDevSwitchNames,
+                                      arraysize(kWebRtcDevSwitchNames));
+  }
+}
+#endif  // defined(ENABLE_WEBRTC)
+
 }  // namespace chrome