diff options
author | joi@chromium.org <joi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-18 13:39:02 +0000 |
---|---|---|
committer | joi@chromium.org <joi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-18 13:39:02 +0000 |
commit | 72daaa97d67f7c722eaf9eabf125427506ee8d45 (patch) | |
tree | 23e2d82b58b9e48061283ba6f2045f4b3864b668 /chrome/browser | |
parent | 9e855c0a40e07fa78d9abb4961b35e750627caf4 (diff) | |
download | chromium_src-72daaa97d67f7c722eaf9eabf125427506ee8d45.zip chromium_src-72daaa97d67f7c722eaf9eabf125427506ee8d45.tar.gz chromium_src-72daaa97d67f7c722eaf9eabf125427506ee8d45.tar.bz2 |
Hide BrowsingInstance from all but SiteInstance, as intended by design.
See comment on BrowsingInstance class that explains it should only be
visible to SiteInstance. By restoring this design, we also eliminate
one Chrome->Content dependency.
TBR=ben@chromium.org
BUG=98716
Review URL: http://codereview.chromium.org/9221017
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@118090 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/DEPS | 1 | ||||
-rw-r--r-- | chrome/browser/chrome_content_browser_client.cc | 7 | ||||
-rw-r--r-- | chrome/browser/debugger/devtools_window.cc | 1 | ||||
-rw-r--r-- | chrome/browser/extensions/extension_host.cc | 3 | ||||
-rw-r--r-- | chrome/browser/extensions/extension_process_manager.cc | 35 | ||||
-rw-r--r-- | chrome/browser/extensions/extension_process_manager.h | 12 | ||||
-rw-r--r-- | chrome/browser/renderer_host/chrome_render_view_host_observer.cc | 5 | ||||
-rw-r--r-- | chrome/browser/tab_contents/background_contents.cc | 5 | ||||
-rw-r--r-- | chrome/browser/ui/gtk/web_intent_picker_gtk.cc | 3 | ||||
-rw-r--r-- | chrome/browser/ui/webui/options/extension_settings_handler.cc | 3 |
10 files changed, 33 insertions, 42 deletions
diff --git a/chrome/browser/DEPS b/chrome/browser/DEPS index 6d18dd7..b214a79 100644 --- a/chrome/browser/DEPS +++ b/chrome/browser/DEPS @@ -30,6 +30,7 @@ include_rules = [ # TODO(jam): this needs to be removed, and only use content/public. BUG=98716 "+content/browser", "-content/browser/browser_process_sub_thread.h", + "-content/browser/browsing_instance.h", "-content/browser/download/download_manager_impl.h", "-content/browser/download/download_resource_handler.h", "-content/browser/download/save_file_manager.h", diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc index 5ea9707..f1196ad 100644 --- a/chrome/browser/chrome_content_browser_client.cc +++ b/chrome/browser/chrome_content_browser_client.cc @@ -66,7 +66,6 @@ #include "chrome/common/render_messages.h" #include "chrome/common/url_constants.h" #include "content/browser/browser_url_handler.h" -#include "content/browser/browsing_instance.h" #include "content/browser/child_process_security_policy.h" #include "content/browser/gpu/gpu_data_manager.h" #include "content/browser/gpu/gpu_process_host.h" @@ -326,7 +325,7 @@ void ChromeContentBrowserClient::RenderViewHostCreated( SiteInstance* site_instance = render_view_host->site_instance(); Profile* profile = Profile::FromBrowserContext( - site_instance->browsing_instance()->browser_context()); + site_instance->GetBrowserContext()); new ChromeRenderViewHostObserver(render_view_host, profile->GetNetworkPredictor()); @@ -488,7 +487,7 @@ void ChromeContentBrowserClient::SiteInstanceGotProcess( CHECK(site_instance->HasProcess()); Profile* profile = Profile::FromBrowserContext( - site_instance->browsing_instance()->browser_context()); + site_instance->GetBrowserContext()); ExtensionService* service = profile->GetExtensionService(); if (!service) return; @@ -517,7 +516,7 @@ void ChromeContentBrowserClient::SiteInstanceDeleting( return; Profile* profile = Profile::FromBrowserContext( - site_instance->browsing_instance()->browser_context()); + site_instance->GetBrowserContext()); ExtensionService* service = profile->GetExtensionService(); if (!service) return; diff --git a/chrome/browser/debugger/devtools_window.cc b/chrome/browser/debugger/devtools_window.cc index c775d95..a5a0c7f 100644 --- a/chrome/browser/debugger/devtools_window.cc +++ b/chrome/browser/debugger/devtools_window.cc @@ -31,7 +31,6 @@ #include "chrome/common/pref_names.h" #include "chrome/common/render_messages.h" #include "chrome/common/url_constants.h" -#include "content/browser/browsing_instance.h" #include "content/browser/in_process_webkit/session_storage_namespace.h" #include "content/browser/load_notification_details.h" #include "content/browser/renderer_host/render_view_host.h" diff --git a/chrome/browser/extensions/extension_host.cc b/chrome/browser/extensions/extension_host.cc index 578bf7e..ff07d8a 100644 --- a/chrome/browser/extensions/extension_host.cc +++ b/chrome/browser/extensions/extension_host.cc @@ -31,7 +31,6 @@ #include "chrome/common/extensions/extension_messages.h" #include "chrome/common/render_messages.h" #include "chrome/common/url_constants.h" -#include "content/browser/browsing_instance.h" #include "content/browser/renderer_host/render_view_host.h" #include "content/browser/site_instance.h" #include "content/browser/tab_contents/tab_contents_view.h" @@ -123,7 +122,7 @@ ExtensionHost::ExtensionHost(const Extension* extension, : extension_(extension), extension_id_(extension->id()), profile_(Profile::FromBrowserContext( - site_instance->browsing_instance()->browser_context())), + site_instance->GetBrowserContext())), render_view_host_(NULL), did_stop_loading_(false), document_element_available_(false), diff --git a/chrome/browser/extensions/extension_process_manager.cc b/chrome/browser/extensions/extension_process_manager.cc index 6b91f33..62f965f 100644 --- a/chrome/browser/extensions/extension_process_manager.cc +++ b/chrome/browser/extensions/extension_process_manager.cc @@ -7,7 +7,6 @@ #include "chrome/browser/extensions/extension_process_manager.h" #include "chrome/browser/ui/browser_window.h" -#include "content/browser/browsing_instance.h" #include "chrome/browser/extensions/extension_event_router.h" #if defined(OS_MACOSX) #include "chrome/browser/extensions/extension_host_mac.h" @@ -96,7 +95,7 @@ ExtensionProcessManager* ExtensionProcessManager::Create(Profile* profile) { } ExtensionProcessManager::ExtensionProcessManager(Profile* profile) - : browsing_instance_(new BrowsingInstance(profile)) { + : site_instance_(SiteInstance::CreateSiteInstance(profile)) { Profile* original_profile = profile->GetOriginalProfile(); registrar_.Add(this, chrome::NOTIFICATION_EXTENSIONS_READY, content::Source<Profile>(original_profile)); @@ -156,9 +155,7 @@ ExtensionHost* ExtensionProcessManager::CreateViewHost( // A NULL browser may only be given for pop-up views. DCHECK(browser || (!browser && view_type == chrome::VIEW_TYPE_EXTENSION_POPUP)); - Profile* profile = - Profile::FromBrowserContext(browsing_instance_->browser_context()); - ExtensionService* service = profile->GetExtensionService(); + ExtensionService* service = GetProfile()->GetExtensionService(); if (service) { const Extension* extension = service->extensions()->GetByID(url.host()); @@ -226,8 +223,7 @@ void ExtensionProcessManager::OpenOptionsPage(const Extension* extension, // Force the options page to open in non-OTR window, because it won't be // able to save settings from OTR. if (!browser || browser->profile()->IsOffTheRecord()) { - Profile* profile = - Profile::FromBrowserContext(browsing_instance_->browser_context()); + Profile* profile = GetProfile(); browser = Browser::GetOrCreateTabbedBrowser(profile->GetOriginalProfile()); } @@ -283,7 +279,7 @@ void ExtensionProcessManager::UnregisterRenderViewHost( } SiteInstance* ExtensionProcessManager::GetSiteInstanceForURL(const GURL& url) { - return browsing_instance_->GetSiteInstanceForURL(url); + return site_instance_->GetRelatedSiteInstance(url); } bool ExtensionProcessManager::HasExtensionHost(ExtensionHost* host) const { @@ -293,8 +289,7 @@ bool ExtensionProcessManager::HasExtensionHost(ExtensionHost* host) const { void ExtensionProcessManager::OnExtensionIdle(const std::string& extension_id) { ExtensionHost* host = GetBackgroundHostForExtension(extension_id); if (host && !HasVisibleViews(extension_id)) { - Profile* profile = - Profile::FromBrowserContext(browsing_instance_->browser_context()); + Profile* profile = GetProfile(); if (!profile->GetExtensionEventRouter()->HasInFlightEvents(extension_id)) CloseBackgroundHost(host); } @@ -381,9 +376,13 @@ void ExtensionProcessManager::Observe( } } +Profile* ExtensionProcessManager::GetProfile() const { + return Profile::FromBrowserContext(site_instance_->GetBrowserContext()); +} + void ExtensionProcessManager::OnExtensionHostCreated(ExtensionHost* host, bool is_background) { - DCHECK_EQ(browsing_instance_->browser_context(), host->profile()); + DCHECK_EQ(site_instance_->GetBrowserContext(), host->profile()); all_hosts_.insert(host); if (is_background) @@ -455,9 +454,7 @@ void IncognitoExtensionProcessManager::CreateBackgroundHost( SiteInstance* IncognitoExtensionProcessManager::GetSiteInstanceForURL( const GURL& url) { - Profile* profile = - Profile::FromBrowserContext(browsing_instance_->browser_context()); - ExtensionService* service = profile->GetExtensionService(); + ExtensionService* service = GetProfile()->GetExtensionService(); if (service) { const Extension* extension = service->extensions()->GetExtensionOrAppByURL( ExtensionURLInfo(url)); @@ -470,9 +467,7 @@ SiteInstance* IncognitoExtensionProcessManager::GetSiteInstanceForURL( bool IncognitoExtensionProcessManager::IsIncognitoEnabled( const Extension* extension) { // Keep in sync with duplicate in extension_info_map.cc. - Profile* profile = - Profile::FromBrowserContext(browsing_instance_->browser_context()); - ExtensionService* service = profile->GetExtensionService(); + ExtensionService* service = GetProfile()->GetExtensionService(); return service && service->IsIncognitoEnabled(extension->id()); } @@ -489,13 +484,11 @@ void IncognitoExtensionProcessManager::Observe( // incognito window. Watch for new browsers and create the hosts if // it matches our profile. Browser* browser = content::Source<Browser>(source).ptr(); - if (browser->profile() == browsing_instance_->browser_context()) { + if (browser->profile() == site_instance_->GetBrowserContext()) { // On Chrome OS, a login screen is implemented as a browser. // This browser has no extension service. In this case, // service will be NULL. - Profile* profile = - Profile::FromBrowserContext(browsing_instance_->browser_context()); - ExtensionService* service = profile->GetExtensionService(); + ExtensionService* service = GetProfile()->GetExtensionService(); if (service && service->is_ready()) CreateBackgroundHostsForProfileStartup(this, service->extensions()); } diff --git a/chrome/browser/extensions/extension_process_manager.h b/chrome/browser/extensions/extension_process_manager.h index 484d36b..743fd55 100644 --- a/chrome/browser/extensions/extension_process_manager.h +++ b/chrome/browser/extensions/extension_process_manager.h @@ -17,7 +17,6 @@ #include "content/public/browser/notification_registrar.h" class Browser; -class BrowsingInstance; class Extension; class ExtensionHost; class GURL; @@ -110,6 +109,10 @@ class ExtensionProcessManager : public content::NotificationObserver { const content::NotificationSource& source, const content::NotificationDetails& details) OVERRIDE; + // Gets the profile associated with site_instance_ and all other + // related SiteInstances. + Profile* GetProfile() const; + content::NotificationRegistrar registrar_; // The set of all ExtensionHosts managed by this process manager. @@ -118,9 +121,10 @@ class ExtensionProcessManager : public content::NotificationObserver { // The set of running viewless background extensions. ExtensionHostSet background_hosts_; - // The BrowsingInstance shared by all extensions in this profile. This - // controls process grouping. - scoped_refptr<BrowsingInstance> browsing_instance_; + // A SiteInstance related to the SiteInstance for all extensions in + // this profile. We create it in such a way that a new + // browsing instance is created. This controls process grouping. + scoped_refptr<SiteInstance> site_instance_; private: // Contains all extension-related RenderViewHost instances for all extensions. diff --git a/chrome/browser/renderer_host/chrome_render_view_host_observer.cc b/chrome/browser/renderer_host/chrome_render_view_host_observer.cc index 8f1f1f1..0b05faa 100644 --- a/chrome/browser/renderer_host/chrome_render_view_host_observer.cc +++ b/chrome/browser/renderer_host/chrome_render_view_host_observer.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -14,7 +14,6 @@ #include "chrome/common/extensions/extension_messages.h" #include "chrome/common/render_messages.h" #include "chrome/common/url_constants.h" -#include "content/browser/browsing_instance.h" #include "content/browser/child_process_security_policy.h" #include "content/browser/renderer_host/render_view_host_delegate.h" #include "content/browser/renderer_host/render_view_host.h" @@ -27,7 +26,7 @@ ChromeRenderViewHostObserver::ChromeRenderViewHostObserver( predictor_(predictor) { SiteInstance* site_instance = render_view_host->site_instance(); profile_ = Profile::FromBrowserContext( - site_instance->browsing_instance()->browser_context()); + site_instance->GetBrowserContext()); InitRenderViewHostForExtensions(); } diff --git a/chrome/browser/tab_contents/background_contents.cc b/chrome/browser/tab_contents/background_contents.cc index 11d0741..f799a9c 100644 --- a/chrome/browser/tab_contents/background_contents.cc +++ b/chrome/browser/tab_contents/background_contents.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -13,7 +13,6 @@ #include "chrome/common/extensions/extension_constants.h" #include "chrome/common/url_constants.h" #include "chrome/common/chrome_view_type.h" -#include "content/browser/browsing_instance.h" #include "content/browser/renderer_host/render_view_host.h" #include "content/browser/site_instance.h" #include "content/public/browser/notification_service.h" @@ -27,7 +26,7 @@ BackgroundContents::BackgroundContents(SiteInstance* site_instance, Delegate* delegate) : delegate_(delegate) { profile_ = Profile::FromBrowserContext( - site_instance->browsing_instance()->browser_context()); + site_instance->GetBrowserContext()); // TODO(rafaelw): Implement correct session storage. web_contents_.reset(WebContents::Create( diff --git a/chrome/browser/ui/gtk/web_intent_picker_gtk.cc b/chrome/browser/ui/gtk/web_intent_picker_gtk.cc index 8fc07cd..c22e5eb 100644 --- a/chrome/browser/ui/gtk/web_intent_picker_gtk.cc +++ b/chrome/browser/ui/gtk/web_intent_picker_gtk.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -22,7 +22,6 @@ #include "chrome/browser/ui/intents/web_intent_picker_controller.h" #include "chrome/browser/ui/intents/web_intent_picker_delegate.h" #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" -#include "content/browser/browsing_instance.h" #include "content/browser/renderer_host/render_view_host.h" #include "content/browser/renderer_host/render_widget_host_view_gtk.h" #include "content/browser/site_instance.h" diff --git a/chrome/browser/ui/webui/options/extension_settings_handler.cc b/chrome/browser/ui/webui/options/extension_settings_handler.cc index 8365f3a..b2c07fa 100644 --- a/chrome/browser/ui/webui/options/extension_settings_handler.cc +++ b/chrome/browser/ui/webui/options/extension_settings_handler.cc @@ -31,7 +31,6 @@ #include "chrome/common/extensions/extension.h" #include "chrome/common/pref_names.h" #include "chrome/common/url_constants.h" -#include "content/browser/browsing_instance.h" #include "content/browser/renderer_host/render_view_host.h" #include "content/browser/site_instance.h" #include "content/browser/tab_contents/tab_contents_view.h" @@ -597,7 +596,7 @@ void ExtensionSettingsHandler::Observe( case content::NOTIFICATION_RENDER_VIEW_HOST_CREATED: source_profile = Profile::FromBrowserContext( content::Source<RenderViewHost>(source)->site_instance()-> - browsing_instance()->browser_context()); + GetBrowserContext()); if (!profile->IsSameProfile(source_profile)) return; MaybeUpdateAfterNotification(); |