diff options
author | ananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-25 19:52:33 +0000 |
---|---|---|
committer | ananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-25 19:52:33 +0000 |
commit | b658359fcbccccd57bb5448519ab3f9b1ff35531 (patch) | |
tree | c72659685d2bdbe6151a7e2af704772bc0ee2b70 | |
parent | 5f5b937c2065a1028f5402474199043ce11f8858 (diff) | |
download | chromium_src-b658359fcbccccd57bb5448519ab3f9b1ff35531.zip chromium_src-b658359fcbccccd57bb5448519ab3f9b1ff35531.tar.gz chromium_src-b658359fcbccccd57bb5448519ab3f9b1ff35531.tar.bz2 |
Define the public interface for content browser SiteInstance. This interface is implemented by the SiteInstanceImpl class which lives
in content\browser\site_instance.cc/.h.
Changes as part of creating a content API.
BUG=98716
TEST=No change in functionality. Hopefully it all compiles and works.
Review URL: http://codereview.chromium.org/8515027
Review URL: https://chromiumcodereview.appspot.com/9146028
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@119102 0039d316-1c4b-4281-b951-d872f2087c98
78 files changed, 587 insertions, 423 deletions
diff --git a/chrome/browser/DEPS b/chrome/browser/DEPS index 10d70d2..3f49adc5 100644 --- a/chrome/browser/DEPS +++ b/chrome/browser/DEPS @@ -112,7 +112,6 @@ include_rules = [ "+content/browser/renderer_host/test_render_view_host.h", "+content/browser/resource_context.h", "+content/browser/sensors/sensors_provider.h", - "+content/browser/site_instance.h", "+content/browser/speech/speech_input_manager.h", "+content/browser/speech/speech_input_preferences.h", "+content/browser/speech/speech_recognizer.h", diff --git a/chrome/browser/background/background_contents_service.cc b/chrome/browser/background/background_contents_service.cc index f1308eb..b90d52c 100644 --- a/chrome/browser/background/background_contents_service.cc +++ b/chrome/browser/background/background_contents_service.cc @@ -7,6 +7,7 @@ #include "base/basictypes.h" #include "base/bind.h" #include "base/command_line.h" +#include "base/message_loop.h" #include "base/string_util.h" #include "base/utf_string_conversions.h" #include "base/values.h" @@ -27,12 +28,13 @@ #include "chrome/common/extensions/extension.h" #include "chrome/common/extensions/extension_constants.h" #include "chrome/common/pref_names.h" -#include "content/browser/site_instance.h" #include "content/public/browser/notification_service.h" +#include "content/public/browser/site_instance.h" #include "content/public/browser/web_contents.h" #include "grit/generated_resources.h" #include "ui/base/l10n/l10n_util.h" +using content::SiteInstance; using content::WebContents; namespace { @@ -448,7 +450,7 @@ void BackgroundContentsService::LoadBackgroundContents( DVLOG(1) << "Loading background content url: " << url; BackgroundContents* contents = CreateBackgroundContents( - SiteInstance::CreateSiteInstanceForURL(profile, url), + SiteInstance::CreateForURL(profile, url), MSG_ROUTING_NONE, profile, frame_name, diff --git a/chrome/browser/background/background_contents_service.h b/chrome/browser/background/background_contents_service.h index b45112c..457d0ab 100644 --- a/chrome/browser/background/background_contents_service.h +++ b/chrome/browser/background/background_contents_service.h @@ -74,7 +74,7 @@ class BackgroundContentsService : private content::NotificationObserver, // A BACKGROUND_CONTENTS_OPENED notification will be generated with the passed // |frame_name| and |application_id| values, using the passed |profile| as the // Source.. - BackgroundContents* CreateBackgroundContents(SiteInstance* site, + BackgroundContents* CreateBackgroundContents(content::SiteInstance* site, int route_id, Profile* profile, const string16& frame_name, diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc index a13bb15..a37af6f 100644 --- a/chrome/browser/chrome_content_browser_client.cc +++ b/chrome/browser/chrome_content_browser_client.cc @@ -71,12 +71,12 @@ #include "content/browser/plugin_process_host.h" #include "content/browser/renderer_host/render_view_host.h" #include "content/browser/resource_context.h" -#include "content/browser/site_instance.h" #include "content/browser/ssl/ssl_cert_error_handler.h" #include "content/browser/ssl/ssl_client_auth_handler.h" #include "content/browser/worker_host/worker_process_host.h" #include "content/public/browser/browser_main_parts.h" #include "content/public/browser/render_process_host.h" +#include "content/public/browser/site_instance.h" #include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents_view.h" #include "grit/generated_resources.h" @@ -133,6 +133,7 @@ using content::AccessTokenStore; using content::BrowserThread; +using content::SiteInstance; using content::WebContents; namespace { @@ -485,20 +486,20 @@ void ChromeContentBrowserClient::SiteInstanceGotProcess( const Extension* extension = service->extensions()->GetExtensionOrAppByURL(ExtensionURLInfo( - site_instance->site())); + site_instance->GetSite())); if (!extension) return; service->process_map()->Insert(extension->id(), site_instance->GetProcess()->GetID(), - site_instance->id()); + site_instance->GetId()); BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, base::Bind(&ExtensionInfoMap::RegisterExtensionProcess, profile->GetExtensionInfoMap(), extension->id(), site_instance->GetProcess()->GetID(), - site_instance->id())); + site_instance->GetId())); } void ChromeContentBrowserClient::SiteInstanceDeleting( @@ -514,20 +515,20 @@ void ChromeContentBrowserClient::SiteInstanceDeleting( const Extension* extension = service->extensions()->GetExtensionOrAppByURL( - ExtensionURLInfo(site_instance->site())); + ExtensionURLInfo(site_instance->GetSite())); if (!extension) return; service->process_map()->Remove(extension->id(), site_instance->GetProcess()->GetID(), - site_instance->id()); + site_instance->GetId()); BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, base::Bind(&ExtensionInfoMap::UnregisterExtensionProcess, profile->GetExtensionInfoMap(), extension->id(), site_instance->GetProcess()->GetID(), - site_instance->id())); + site_instance->GetId())); } bool ChromeContentBrowserClient::ShouldSwapProcessesForNavigation( @@ -1346,7 +1347,7 @@ WebPreferences ChromeContentBrowserClient::GetWebkitPrefs(RenderViewHost* rvh) { ExtensionService* service = profile->GetExtensionService(); if (service) { const Extension* extension = service->extensions()->GetByID( - rvh->site_instance()->site().host()); + rvh->site_instance()->GetSite().host()); extension_webkit_preferences::SetPreferences( extension, rvh->delegate()->GetRenderViewType(), &web_prefs); } diff --git a/chrome/browser/chrome_content_browser_client.h b/chrome/browser/chrome_content_browser_client.h index 9e49232..7f74616 100644 --- a/chrome/browser/chrome_content_browser_client.h +++ b/chrome/browser/chrome_content_browser_client.h @@ -31,8 +31,10 @@ class ChromeContentBrowserClient : public content::ContentBrowserClient { virtual bool IsHandledURL(const GURL& url) OVERRIDE; virtual bool IsSuitableHost(content::RenderProcessHost* process_host, const GURL& url) OVERRIDE; - virtual void SiteInstanceGotProcess(SiteInstance* site_instance) OVERRIDE; - virtual void SiteInstanceDeleting(SiteInstance* site_instance) OVERRIDE; + virtual void SiteInstanceGotProcess( + content::SiteInstance* site_instance) OVERRIDE; + virtual void SiteInstanceDeleting(content::SiteInstance* site_instance) + OVERRIDE; virtual bool ShouldSwapProcessesForNavigation(const GURL& current_url, const GURL& new_url) OVERRIDE; virtual std::string GetCanonicalEncodingNameByAliasName( diff --git a/chrome/browser/chromeos/login/html_page_screen.cc b/chrome/browser/chromeos/login/html_page_screen.cc index 5a51742..ef4f5ae 100644 --- a/chrome/browser/chromeos/login/html_page_screen.cc +++ b/chrome/browser/chromeos/login/html_page_screen.cc @@ -12,10 +12,11 @@ #include "chrome/browser/chromeos/login/screen_observer.h" #include "chrome/browser/profiles/profile_manager.h" #include "content/browser/renderer_host/render_view_host.h" -#include "content/browser/site_instance.h" +#include "content/public/browser/site_instance.h" #include "googleurl/src/gurl.h" #include "ui/views/events/event.h" +using content::SiteInstance; using content::WebContents; namespace chromeos { @@ -50,8 +51,7 @@ void HTMLPageScreen::Refresh() { StartTimeoutTimer(); GURL url(url_); Profile* profile = ProfileManager::GetDefaultProfile(); - view()->InitDOM(profile, - SiteInstance::CreateSiteInstanceForURL(profile, url)); + view()->InitDOM(profile, SiteInstance::CreateForURL(profile, url)); view()->SetWebContentsDelegate(this); view()->LoadURL(url); } diff --git a/chrome/browser/chromeos/login/registration_screen.cc b/chrome/browser/chromeos/login/registration_screen.cc index c994284..9f0d599 100644 --- a/chrome/browser/chromeos/login/registration_screen.cc +++ b/chrome/browser/chromeos/login/registration_screen.cc @@ -13,13 +13,14 @@ #include "chrome/common/url_constants.h" #include "content/browser/child_process_security_policy.h" #include "content/browser/renderer_host/render_view_host.h" -#include "content/browser/site_instance.h" +#include "content/public/browser/site_instance.h" #include "content/public/browser/web_contents.h" #include "googleurl/src/gurl.h" #include "net/url_request/url_request_about_job.h" #include "net/url_request/url_request_filter.h" using content::OpenURLParams; +using content::SiteInstance; using content::WebContents; namespace chromeos { @@ -69,8 +70,7 @@ void RegistrationScreen::Refresh() { StartTimeoutTimer(); GURL url(kRegistrationHostPageUrl); Profile* profile = ProfileManager::GetDefaultProfile(); - view()->InitDOM(profile, - SiteInstance::CreateSiteInstanceForURL(profile, url)); + view()->InitDOM(profile, SiteInstance::CreateForURL(profile, url)); view()->SetWebContentsDelegate(this); view()->LoadURL(url); } diff --git a/chrome/browser/chromeos/login/web_page_view.cc b/chrome/browser/chromeos/login/web_page_view.cc index 938b11b..a9690c1 100644 --- a/chrome/browser/chromeos/login/web_page_view.cc +++ b/chrome/browser/chromeos/login/web_page_view.cc @@ -13,6 +13,7 @@ #include "chrome/browser/chromeos/login/rounded_rect_painter.h" #include "chrome/browser/profiles/profile.h" #include "content/browser/child_process_security_policy.h" +#include "content/public/browser/site_instance.h" #include "content/public/browser/web_contents.h" #include "content/public/browser/web_ui.h" #include "content/public/common/bindings_policy.h" @@ -29,6 +30,7 @@ #include "ui/views/controls/throbber.h" using base::TimeDelta; +using content::SiteInstance; using views::Label; using views::View; diff --git a/chrome/browser/chromeos/login/web_page_view.h b/chrome/browser/chromeos/login/web_page_view.h index b14b82f..90b036c 100644 --- a/chrome/browser/chromeos/login/web_page_view.h +++ b/chrome/browser/chromeos/login/web_page_view.h @@ -16,6 +16,7 @@ class Profile; namespace content { +class SiteInstance; class WebContentsDelegate; } @@ -50,7 +51,7 @@ class WebPageView : public views::View { // Initialize the DOM view, creating the contents. This should be // called once the view has been added to a container. - void InitDOM(Profile* profile, SiteInstance* site_instance); + void InitDOM(Profile* profile, content::SiteInstance* site_instance); // Loads the given URL into the page. // You must have previously called Init() and SetWebContentsDelegate. diff --git a/chrome/browser/extensions/extension_file_browser_private_api.cc b/chrome/browser/extensions/extension_file_browser_private_api.cc index 76cfff2..cf1e1ba 100644 --- a/chrome/browser/extensions/extension_file_browser_private_api.cc +++ b/chrome/browser/extensions/extension_file_browser_private_api.cc @@ -34,9 +34,9 @@ #include "chrome/common/pref_names.h" #include "content/browser/child_process_security_policy.h" #include "content/browser/renderer_host/render_view_host.h" -#include "content/browser/site_instance.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/render_process_host.h" +#include "content/public/browser/site_instance.h" #include "content/public/browser/web_contents.h" #include "googleurl/src/gurl.h" #include "grit/generated_resources.h" @@ -50,6 +50,7 @@ #include "webkit/fileapi/file_system_util.h" using content::BrowserThread; +using content::SiteInstance; using content::WebContents; namespace { @@ -729,7 +730,8 @@ class ExecuteTasksFileBrowserFunction::ExecuteTasksFileSystemCallbackDispatcher Extension::GetBaseURLFromExtensionId(target_extension_id_); ExtensionProcessManager* manager = profile_->GetExtensionProcessManager(); - SiteInstance* site_instance = manager->GetSiteInstanceForURL(extension_url); + SiteInstance* site_instance = manager->GetSiteInstanceForURL( + extension_url); if (!site_instance || !site_instance->HasProcess()) return; content::RenderProcessHost* process = site_instance->GetProcess(); diff --git a/chrome/browser/extensions/extension_host.cc b/chrome/browser/extensions/extension_host.cc index c6914ea..d2d5c7d 100644 --- a/chrome/browser/extensions/extension_host.cc +++ b/chrome/browser/extensions/extension_host.cc @@ -32,11 +32,11 @@ #include "chrome/common/render_messages.h" #include "chrome/common/url_constants.h" #include "content/browser/renderer_host/render_view_host.h" -#include "content/browser/site_instance.h" #include "content/public/browser/content_browser_client.h" #include "content/public/browser/native_web_keyboard_event.h" #include "content/public/browser/notification_service.h" #include "content/public/browser/render_process_host.h" +#include "content/public/browser/site_instance.h" #include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents_view.h" #include "grit/browser_resources.h" @@ -53,6 +53,7 @@ using WebKit::WebDragOperation; using WebKit::WebDragOperationsMask; using content::OpenURLParams; +using content::SiteInstance; using content::WebContents; // Helper class that rate-limits the creation of renderer processes for diff --git a/chrome/browser/extensions/extension_host.h b/chrome/browser/extensions/extension_host.h index 4b9263d..17701f1 100644 --- a/chrome/browser/extensions/extension_host.h +++ b/chrome/browser/extensions/extension_host.h @@ -31,11 +31,11 @@ class Browser; class Extension; class PrefsTabHelper; class RenderWidgetHostView; -class SiteInstance; struct WebPreferences; namespace content { class RenderProcessHost; +class SiteInstance; } // This class is the browser component of an extension component's RenderView. @@ -49,7 +49,8 @@ class ExtensionHost : public content::WebContentsDelegate, public: class ProcessCreationQueue; - ExtensionHost(const Extension* extension, SiteInstance* site_instance, + ExtensionHost(const Extension* extension, + content::SiteInstance* site_instance, const GURL& url, content::ViewType host_type); virtual ~ExtensionHost(); diff --git a/chrome/browser/extensions/extension_host_mac.h b/chrome/browser/extensions/extension_host_mac.h index f2f7c1e..e755be2 100644 --- a/chrome/browser/extensions/extension_host_mac.h +++ b/chrome/browser/extensions/extension_host_mac.h @@ -14,7 +14,8 @@ class RenderWidgetHostView; // now that ExtensionHost is restructured to rely on TabContents. class ExtensionHostMac : public ExtensionHost { public: - ExtensionHostMac(const Extension* extension, SiteInstance* site_instance, + ExtensionHostMac(const Extension* extension, + content::SiteInstance* site_instance, const GURL& url, content::ViewType host_type) : ExtensionHost(extension, site_instance, url, host_type) {} virtual ~ExtensionHostMac(); diff --git a/chrome/browser/extensions/extension_message_service.cc b/chrome/browser/extensions/extension_message_service.cc index 8c3ad18..097e2f6 100644 --- a/chrome/browser/extensions/extension_message_service.cc +++ b/chrome/browser/extensions/extension_message_service.cc @@ -18,12 +18,13 @@ #include "chrome/common/extensions/extension_messages.h" #include "content/browser/child_process_security_policy.h" #include "content/browser/renderer_host/render_view_host.h" -#include "content/browser/site_instance.h" #include "content/public/browser/notification_service.h" #include "content/public/browser/notification_types.h" #include "content/public/browser/render_process_host.h" +#include "content/public/browser/site_instance.h" #include "content/public/browser/web_contents.h" +using content::SiteInstance; using content::WebContents; // Since we have 2 ports for every channel, we just index channels by half the diff --git a/chrome/browser/extensions/extension_process_manager.cc b/chrome/browser/extensions/extension_process_manager.cc index 9271541..9e824db 100644 --- a/chrome/browser/extensions/extension_process_manager.cc +++ b/chrome/browser/extensions/extension_process_manager.cc @@ -22,17 +22,18 @@ #include "chrome/common/extensions/extension.h" #include "chrome/common/url_constants.h" #include "content/browser/renderer_host/render_view_host.h" -#include "content/browser/site_instance.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/notification_service.h" #include "content/public/browser/render_process_host.h" #include "content/public/browser/render_view_host_delegate.h" +#include "content/public/browser/site_instance.h" #include "content/public/browser/web_contents.h" #include "content/public/common/renderer_preferences.h" using content::BrowserThread; using content::OpenURLParams; using content::Referrer; +using content::SiteInstance; namespace { @@ -94,7 +95,7 @@ ExtensionProcessManager* ExtensionProcessManager::Create(Profile* profile) { } ExtensionProcessManager::ExtensionProcessManager(Profile* profile) - : site_instance_(SiteInstance::CreateSiteInstance(profile)) { + : site_instance_(SiteInstance::Create(profile)) { Profile* original_profile = profile->GetOriginalProfile(); registrar_.Add(this, chrome::NOTIFICATION_EXTENSIONS_READY, content::Source<Profile>(original_profile)); @@ -280,7 +281,8 @@ void ExtensionProcessManager::UnregisterRenderViewHost( all_extension_views_.erase(render_view_host); } -SiteInstance* ExtensionProcessManager::GetSiteInstanceForURL(const GURL& url) { +SiteInstance* ExtensionProcessManager::GetSiteInstanceForURL( + const GURL& url) { return site_instance_->GetRelatedSiteInstance(url); } @@ -303,7 +305,7 @@ bool ExtensionProcessManager::HasVisibleViews(const std::string& extension_id) { for (std::set<RenderViewHost*>::const_iterator it = views.begin(); it != views.end(); ++it) { const RenderViewHost* host = *it; - if (host->site_instance()->site().host() == extension_id && + if (host->site_instance()->GetSite().host() == extension_id && host->delegate()->GetRenderViewType() != chrome::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) { return true; diff --git a/chrome/browser/extensions/extension_process_manager.h b/chrome/browser/extensions/extension_process_manager.h index 743fd55..41f7c60 100644 --- a/chrome/browser/extensions/extension_process_manager.h +++ b/chrome/browser/extensions/extension_process_manager.h @@ -22,7 +22,10 @@ class ExtensionHost; class GURL; class Profile; class RenderViewHost; + +namespace content { class SiteInstance; +}; // Manages dynamic state of running Chromium extensions. There is one instance // of this class per Profile. OTR Profiles have a separate instance that keeps @@ -69,7 +72,7 @@ class ExtensionProcessManager : public content::NotificationObserver { // Returns the SiteInstance that the given URL belongs to. // TODO(aa): This only returns correct results for extensions and packaged // apps, not hosted apps. - virtual SiteInstance* GetSiteInstanceForURL(const GURL& url); + virtual content::SiteInstance* GetSiteInstanceForURL(const GURL& url); // Registers a RenderViewHost as hosting a given extension. void RegisterRenderViewHost(RenderViewHost* render_view_host, @@ -124,7 +127,7 @@ class ExtensionProcessManager : public content::NotificationObserver { // 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_; + scoped_refptr<content::SiteInstance> site_instance_; private: // Contains all extension-related RenderViewHost instances for all extensions. diff --git a/chrome/browser/extensions/extension_process_manager_unittest.cc b/chrome/browser/extensions/extension_process_manager_unittest.cc index 025fb4c1..bdd8d96 100644 --- a/chrome/browser/extensions/extension_process_manager_unittest.cc +++ b/chrome/browser/extensions/extension_process_manager_unittest.cc @@ -5,10 +5,13 @@ #include "chrome/browser/extensions/extension_process_manager.h" #include "chrome/browser/extensions/extension_error_reporter.h" #include "chrome/test/base/testing_profile.h" -#include "content/browser/site_instance.h" +#include "content/public/browser/render_process_host.h" +#include "content/public/browser/site_instance.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/platform_test.h" +using content::SiteInstance; + namespace { // make the test a PlatformTest to setup autorelease pools properly on mac diff --git a/chrome/browser/extensions/isolated_app_browsertest.cc b/chrome/browser/extensions/isolated_app_browsertest.cc index 43941c6..dc5bc2b 100644 --- a/chrome/browser/extensions/isolated_app_browsertest.cc +++ b/chrome/browser/extensions/isolated_app_browsertest.cc @@ -13,9 +13,9 @@ #include "chrome/common/chrome_switches.h" #include "chrome/common/url_constants.h" #include "chrome/test/base/ui_test_utils.h" -#include "content/browser/site_instance.h" #include "content/browser/renderer_host/render_view_host.h" #include "content/public/browser/render_process_host.h" +#include "content/public/browser/site_instance.h" #include "content/public/browser/web_contents.h" #include "net/base/mock_host_resolver.h" diff --git a/chrome/browser/notifications/balloon_host.cc b/chrome/browser/notifications/balloon_host.cc index e5590f9..aa2eb47 100644 --- a/chrome/browser/notifications/balloon_host.cc +++ b/chrome/browser/notifications/balloon_host.cc @@ -16,17 +16,18 @@ #include "chrome/common/url_constants.h" #include "chrome/common/chrome_view_type.h" #include "content/browser/renderer_host/render_view_host.h" -#include "content/browser/site_instance.h" #include "content/public/browser/navigation_controller.h" #include "content/public/browser/notification_service.h" #include "content/public/browser/notification_source.h" #include "content/public/browser/render_process_host.h" +#include "content/public/browser/site_instance.h" #include "content/public/browser/web_contents.h" #include "content/public/common/bindings_policy.h" #include "content/public/common/renderer_preferences.h" #include "ipc/ipc_message.h" #include "webkit/glue/webpreferences.h" +using content::SiteInstance; using content::WebContents; BalloonHost::BalloonHost(Balloon* balloon) @@ -36,7 +37,7 @@ BalloonHost::BalloonHost(Balloon* balloon) enable_web_ui_(false), ALLOW_THIS_IN_INITIALIZER_LIST( extension_function_dispatcher_(balloon_->profile(), this)) { - site_instance_ = SiteInstance::CreateSiteInstanceForURL( + site_instance_ = SiteInstance::CreateForURL( balloon_->profile(), balloon_->notification().content_url()); } diff --git a/chrome/browser/notifications/balloon_host.h b/chrome/browser/notifications/balloon_host.h index 710961a5..f05d53e 100644 --- a/chrome/browser/notifications/balloon_host.h +++ b/chrome/browser/notifications/balloon_host.h @@ -19,7 +19,10 @@ class Balloon; class Browser; + +namespace content { class SiteInstance; +}; class BalloonHost : public content::WebContentsDelegate, public content::WebContentsObserver, @@ -89,7 +92,7 @@ class BalloonHost : public content::WebContentsDelegate, bool should_notify_on_disconnect_; // Site instance for the balloon/profile, to be used for opening new links. - scoped_refptr<SiteInstance> site_instance_; + scoped_refptr<content::SiteInstance> site_instance_; // A flag to enable Web UI. bool enable_web_ui_; 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 adefdb6..26cd431 100644 --- a/chrome/browser/renderer_host/chrome_render_view_host_observer.cc +++ b/chrome/browser/renderer_host/chrome_render_view_host_observer.cc @@ -16,9 +16,11 @@ #include "chrome/common/url_constants.h" #include "content/browser/child_process_security_policy.h" #include "content/browser/renderer_host/render_view_host.h" -#include "content/browser/site_instance.h" #include "content/public/browser/notification_service.h" #include "content/public/browser/render_view_host_delegate.h" +#include "content/public/browser/site_instance.h" + +using content::SiteInstance; ChromeRenderViewHostObserver::ChromeRenderViewHostObserver( RenderViewHost* render_view_host, chrome_browser_net::Predictor* predictor) @@ -133,7 +135,7 @@ const Extension* ChromeRenderViewHostObserver::GetExtension() { // (excluding bookmark apps) will have a chrome-extension:// URL for their // site, so we can ignore that wrinkle here. SiteInstance* site_instance = render_view_host()->site_instance(); - const GURL& site = site_instance->site(); + const GURL& site = site_instance->GetSite(); if (!site.SchemeIs(chrome::kExtensionScheme)) return NULL; diff --git a/chrome/browser/tab_contents/background_contents.cc b/chrome/browser/tab_contents/background_contents.cc index f799a9c..16d3dfe 100644 --- a/chrome/browser/tab_contents/background_contents.cc +++ b/chrome/browser/tab_contents/background_contents.cc @@ -14,11 +14,12 @@ #include "chrome/common/url_constants.h" #include "chrome/common/chrome_view_type.h" #include "content/browser/renderer_host/render_view_host.h" -#include "content/browser/site_instance.h" #include "content/public/browser/notification_service.h" +#include "content/public/browser/site_instance.h" #include "content/public/browser/web_contents.h" #include "ui/gfx/rect.h" +using content::SiteInstance; using content::WebContents; BackgroundContents::BackgroundContents(SiteInstance* site_instance, diff --git a/chrome/browser/tab_contents/background_contents.h b/chrome/browser/tab_contents/background_contents.h index 675281e..6f3b9cd 100644 --- a/chrome/browser/tab_contents/background_contents.h +++ b/chrome/browser/tab_contents/background_contents.h @@ -16,7 +16,10 @@ #include "webkit/glue/window_open_disposition.h" class Profile; + +namespace content { class SiteInstance; +}; // This class consumes TabContents. It can host a renderer, but does not // have any visible display. @@ -38,7 +41,7 @@ class BackgroundContents : public content::WebContentsDelegate, virtual ~Delegate() {} }; - BackgroundContents(SiteInstance* site_instance, + BackgroundContents(content::SiteInstance* site_instance, int routing_id, Delegate* delegate); virtual ~BackgroundContents(); diff --git a/chrome/browser/tab_contents/tab_util.cc b/chrome/browser/tab_contents/tab_util.cc index 296df65..09461bee 100644 --- a/chrome/browser/tab_contents/tab_util.cc +++ b/chrome/browser/tab_contents/tab_util.cc @@ -9,11 +9,12 @@ #include "chrome/browser/ui/webui/chrome_web_ui_factory.h" #include "chrome/common/chrome_switches.h" #include "content/browser/renderer_host/render_view_host.h" -#include "content/browser/site_instance.h" #include "content/public/browser/render_view_host_delegate.h" +#include "content/public/browser/site_instance.h" #include "content/public/browser/web_contents.h" #include "googleurl/src/gurl.h" +using content::SiteInstance; using content::WebContents; namespace tab_util { @@ -38,7 +39,7 @@ SiteInstance* GetSiteInstanceForNewTab(WebContents* source_contents, if (ChromeWebUIFactory::GetInstance()->UseWebUIForURL(profile, url) || (service && service->extensions()->GetHostedAppByURL(ExtensionURLInfo(url)))) { - return SiteInstance::CreateSiteInstanceForURL(profile, url); + return SiteInstance::CreateForURL(profile, url); } if (!source_contents) diff --git a/chrome/browser/tab_contents/tab_util.h b/chrome/browser/tab_contents/tab_util.h index 0b14f55..5866e02 100644 --- a/chrome/browser/tab_contents/tab_util.h +++ b/chrome/browser/tab_contents/tab_util.h @@ -8,8 +8,9 @@ class GURL; class Profile; -class SiteInstance; + namespace content { +class SiteInstance; class WebContents; } @@ -24,9 +25,10 @@ content::WebContents* GetWebContentsByID(int render_process_id, // Returns a new SiteInstance for WebUI and app URLs. Returns the SiteInstance // for |source_contents| if it represents the same website as |url|. Returns // NULL otherwise. -SiteInstance* GetSiteInstanceForNewTab(content::WebContents* source_contents, - Profile* profile, - const GURL& url); +content::SiteInstance* GetSiteInstanceForNewTab( + content::WebContents* source_contents, + Profile* profile, + const GURL& url); } // namespace tab_util diff --git a/chrome/browser/tabs/default_tab_handler.cc b/chrome/browser/tabs/default_tab_handler.cc index d7f7ec3..f8f46d70 100644 --- a/chrome/browser/tabs/default_tab_handler.cc +++ b/chrome/browser/tabs/default_tab_handler.cc @@ -7,6 +7,8 @@ #include "chrome/browser/tabs/tab_strip_model.h" #include "chrome/browser/ui/browser.h" +using content::SiteInstance; + //////////////////////////////////////////////////////////////////////////////// // DefaultTabHandler, public: diff --git a/chrome/browser/tabs/default_tab_handler.h b/chrome/browser/tabs/default_tab_handler.h index d5e7e8d..a866a4a 100644 --- a/chrome/browser/tabs/default_tab_handler.h +++ b/chrome/browser/tabs/default_tab_handler.h @@ -42,7 +42,7 @@ class DefaultTabHandler : public TabHandler, Profile* profile, content::PageTransition transition, bool defer_load, - SiteInstance* instance) const OVERRIDE; + content::SiteInstance* instance) const OVERRIDE; virtual bool CanDuplicateContentsAt(int index) OVERRIDE; virtual void DuplicateContentsAt(int index) OVERRIDE; virtual void CloseFrameAfterDragSession() OVERRIDE; diff --git a/chrome/browser/tabs/tab_strip_model_delegate.h b/chrome/browser/tabs/tab_strip_model_delegate.h index 1c8e00e..0f552fd 100644 --- a/chrome/browser/tabs/tab_strip_model_delegate.h +++ b/chrome/browser/tabs/tab_strip_model_delegate.h @@ -14,10 +14,10 @@ class Browser; class DockInfo; class GURL; class Profile; -class SiteInstance; class TabContents; class TabContentsWrapper; namespace content { +class SiteInstance; struct Referrer; } namespace gfx { @@ -72,7 +72,7 @@ class TabStripModelDelegate { Profile* profile, content::PageTransition transition, bool defer_load, - SiteInstance* instance) const = 0; + content::SiteInstance* instance) const = 0; // Returns whether some contents can be duplicated. virtual bool CanDuplicateContentsAt(int index) = 0; diff --git a/chrome/browser/tabs/tab_strip_model_unittest.cc b/chrome/browser/tabs/tab_strip_model_unittest.cc index 3a12732..681cc34 100644 --- a/chrome/browser/tabs/tab_strip_model_unittest.cc +++ b/chrome/browser/tabs/tab_strip_model_unittest.cc @@ -43,6 +43,7 @@ using content::BrowserThread; using content::NavigationController; +using content::SiteInstance; using content::WebContents; using testing::_; diff --git a/chrome/browser/tabs/test_tab_strip_model_delegate.cc b/chrome/browser/tabs/test_tab_strip_model_delegate.cc index f7955f6..f87201c 100644 --- a/chrome/browser/tabs/test_tab_strip_model_delegate.cc +++ b/chrome/browser/tabs/test_tab_strip_model_delegate.cc @@ -9,6 +9,8 @@ #include "chrome/browser/ui/tabs/dock_info.h" #include "ui/gfx/rect.h" +using content::SiteInstance; + TestTabStripModelDelegate::TestTabStripModelDelegate() { } diff --git a/chrome/browser/tabs/test_tab_strip_model_delegate.h b/chrome/browser/tabs/test_tab_strip_model_delegate.h index 15f0b5c..486ea56 100644 --- a/chrome/browser/tabs/test_tab_strip_model_delegate.h +++ b/chrome/browser/tabs/test_tab_strip_model_delegate.h @@ -31,7 +31,7 @@ class TestTabStripModelDelegate : public TabStripModelDelegate { Profile* profile, content::PageTransition transition, bool defer_load, - SiteInstance* instance) const OVERRIDE; + content::SiteInstance* instance) const OVERRIDE; virtual bool CanDuplicateContentsAt(int index) OVERRIDE; virtual void DuplicateContentsAt(int index) OVERRIDE; virtual void CloseFrameAfterDragSession() OVERRIDE; diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc index 731cfb7..ecfcaa5 100644 --- a/chrome/browser/ui/browser.cc +++ b/chrome/browser/ui/browser.cc @@ -148,7 +148,6 @@ #include "content/browser/child_process_security_policy.h" #include "content/browser/host_zoom_map.h" #include "content/browser/renderer_host/render_view_host.h" -#include "content/browser/site_instance.h" #include "content/browser/tab_contents/interstitial_page.h" #include "content/public/browser/devtools_manager.h" #include "content/public/browser/download_item.h" @@ -159,6 +158,7 @@ #include "content/public/browser/notification_details.h" #include "content/public/browser/notification_service.h" #include "content/public/browser/plugin_service.h" +#include "content/public/browser/site_instance.h" #include "content/public/browser/user_metrics.h" #include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents_view.h" @@ -221,6 +221,7 @@ using content::NavigationEntry; using content::OpenURLParams; using content::PluginService; using content::Referrer; +using content::SiteInstance; using content::SSLStatus; using content::UserMetricsAction; using content::WebContents; diff --git a/chrome/browser/ui/browser.h b/chrome/browser/ui/browser.h index 60abc8f..89151e2 100644 --- a/chrome/browser/ui/browser.h +++ b/chrome/browser/ui/browser.h @@ -774,7 +774,7 @@ class Browser : public TabHandlerDelegate, // all its supporting objects and observers. static TabContentsWrapper* TabContentsFactory(Profile* profile, - SiteInstance* site_instance, + content::SiteInstance* site_instance, int routing_id, const content::WebContents* base_web_contents, SessionStorageNamespace* session_storage_namespace); @@ -800,7 +800,7 @@ class Browser : public TabHandlerDelegate, Profile* profile, content::PageTransition transition, bool defer_load, - SiteInstance* instance) const; + content::SiteInstance* instance) const; virtual bool CanDuplicateContentsAt(int index); virtual void DuplicateContentsAt(int index); virtual void CloseFrameAfterDragSession(); @@ -1293,7 +1293,7 @@ class Browser : public TabHandlerDelegate, // Creates a BackgroundContents if appropriate; return true if one was // created. bool MaybeCreateBackgroundContents(int route_id, - SiteInstance* site, + content::SiteInstance* site, const GURL& opener_url, const string16& frame_name); diff --git a/chrome/browser/ui/browser_navigator.cc b/chrome/browser/ui/browser_navigator.cc index c8fa8a9..1c099d6 100644 --- a/chrome/browser/ui/browser_navigator.cc +++ b/chrome/browser/ui/browser_navigator.cc @@ -32,7 +32,6 @@ #include "chrome/common/url_constants.h" #include "content/browser/browser_url_handler.h" #include "content/browser/renderer_host/render_view_host.h" -#include "content/browser/site_instance.h" #include "content/public/browser/notification_service.h" #include "content/public/browser/render_view_host_delegate.h" #include "content/public/browser/web_contents.h" diff --git a/chrome/browser/ui/cocoa/fullscreen_exit_bubble_controller_unittest.mm b/chrome/browser/ui/cocoa/fullscreen_exit_bubble_controller_unittest.mm index 0bdb82e..1228f97 100644 --- a/chrome/browser/ui/cocoa/fullscreen_exit_bubble_controller_unittest.mm +++ b/chrome/browser/ui/cocoa/fullscreen_exit_bubble_controller_unittest.mm @@ -12,12 +12,13 @@ #include "chrome/browser/ui/cocoa/cocoa_profile_test.h" #include "chrome/common/chrome_notification_types.h" #include "chrome/test/base/ui_test_utils.h" -#include "content/browser/site_instance.h" #include "content/public/browser/notification_service.h" +#include "content/public/browser/site_instance.h" #include "content/public/browser/web_contents.h" #include "testing/gtest_mac.h" #include "ui/base/accelerators/accelerator_cocoa.h" +using content::SiteInstance; using content::WebContents; @interface FullscreenExitBubbleController(JustForTesting) @@ -47,7 +48,7 @@ class FullscreenExitBubbleControllerTest : public CocoaProfileTest { CocoaProfileTest::SetUp(); ASSERT_TRUE(profile()); - site_instance_ = SiteInstance::CreateSiteInstance(profile()); + site_instance_ = SiteInstance::Create(profile()); controller_.reset( [[FullscreenExitBubbleController alloc] initWithOwner:nil browser:browser() diff --git a/chrome/browser/ui/cocoa/tabpose_window_unittest.mm b/chrome/browser/ui/cocoa/tabpose_window_unittest.mm index e0263fa..82b7ccb 100644 --- a/chrome/browser/ui/cocoa/tabpose_window_unittest.mm +++ b/chrome/browser/ui/cocoa/tabpose_window_unittest.mm @@ -8,16 +8,18 @@ #import "chrome/browser/ui/browser_window.h" #include "chrome/browser/ui/cocoa/cocoa_profile_test.h" #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" -#include "content/browser/site_instance.h" +#include "content/public/browser/site_instance.h" #include "testing/gtest/include/gtest/gtest.h" +using content::SiteInstance; + class TabposeWindowTest : public CocoaProfileTest { public: virtual void SetUp() { CocoaProfileTest::SetUp(); ASSERT_TRUE(profile()); - site_instance_ = SiteInstance::CreateSiteInstance(profile()); + site_instance_ = SiteInstance::Create(profile()); } void AppendTabToStrip() { diff --git a/chrome/browser/ui/cocoa/tabs/tab_strip_controller_unittest.mm b/chrome/browser/ui/cocoa/tabs/tab_strip_controller_unittest.mm index 173b4e6..063a815 100644 --- a/chrome/browser/ui/cocoa/tabs/tab_strip_controller_unittest.mm +++ b/chrome/browser/ui/cocoa/tabs/tab_strip_controller_unittest.mm @@ -14,11 +14,12 @@ #import "chrome/browser/ui/cocoa/tabs/tab_view.h" #import "chrome/browser/ui/cocoa/tabs/tab_controller.h" #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" -#include "content/browser/site_instance.h" +#include "content/public/browser/site_instance.h" #include "content/public/browser/web_contents.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/platform_test.h" +using content::SiteInstance; using content::WebContents; @interface TestTabStripControllerDelegate @@ -168,7 +169,7 @@ class TabStripControllerTest : public CocoaProfileTest { // the tab strip. TEST_F(TabStripControllerTest, AddRemoveTabs) { EXPECT_TRUE(model_->empty()); - SiteInstance* instance = SiteInstance::CreateSiteInstance(profile()); + SiteInstance* instance = SiteInstance::Create(profile()); TabContentsWrapper* tab_contents = Browser::TabContentsFactory(profile(), instance, MSG_ROUTING_NONE, NULL, NULL); @@ -192,14 +193,14 @@ TEST_F(TabStripControllerTest, Notifications) { TEST_F(TabStripControllerTest, CorrectToolTipText) { // Create tab 1. - SiteInstance* instance = SiteInstance::CreateSiteInstance(profile()); + SiteInstance* instance = SiteInstance::Create(profile()); TabContentsWrapper* tab_contents = Browser::TabContentsFactory(profile(), instance, MSG_ROUTING_NONE, NULL, NULL); model_->AppendTabContents(tab_contents, true); // Create tab 2. - SiteInstance* instance2 = SiteInstance::CreateSiteInstance(profile()); + SiteInstance* instance2 = SiteInstance::Create(profile()); TabContentsWrapper* tab_contents2 = Browser::TabContentsFactory(profile(), instance2, MSG_ROUTING_NONE, NULL, NULL); diff --git a/chrome/browser/ui/views/dom_view.cc b/chrome/browser/ui/views/dom_view.cc index 87aaa45..9335a714 100644 --- a/chrome/browser/ui/views/dom_view.cc +++ b/chrome/browser/ui/views/dom_view.cc @@ -7,9 +7,11 @@ #include "chrome/browser/profiles/profile.h" #include "chrome/browser/renderer_preferences_util.h" #include "chrome/browser/ui/views/tab_contents/tab_contents_view_views.h" +#include "content/public/browser/site_instance.h" #include "content/public/browser/web_contents.h" #include "ui/views/focus/focus_manager.h" +using content::SiteInstance; using content::WebContents; // static diff --git a/chrome/browser/ui/views/dom_view.h b/chrome/browser/ui/views/dom_view.h index f9d45e9..e9b5f4b 100644 --- a/chrome/browser/ui/views/dom_view.h +++ b/chrome/browser/ui/views/dom_view.h @@ -16,7 +16,10 @@ #include "ui/views/events/event.h" class Profile; + +namespace content { class SiteInstance; +}; class DOMView : public views::NativeViewHost { public: @@ -34,7 +37,7 @@ class DOMView : public views::NativeViewHost { // // If |instance| is not null, then the view will be loaded in the same // process as the given instance. - bool Init(Profile* profile, SiteInstance* instance); + bool Init(Profile* profile, content::SiteInstance* instance); // Loads the given URL into the page. You must have previously called Init(). void LoadURL(const GURL& url); @@ -57,7 +60,7 @@ class DOMView : public views::NativeViewHost { // Returns new allocated TabContents instance, caller is responsible deleting. // Override in derived classes to replace TabContents with derivative. virtual content::WebContents* CreateTabContents( - Profile* profile, SiteInstance* instance); + Profile* profile, content::SiteInstance* instance); scoped_ptr<TabContentsWrapper> dom_contents_; diff --git a/chrome/browser/ui/virtual_keyboard/virtual_keyboard_manager.cc b/chrome/browser/ui/virtual_keyboard/virtual_keyboard_manager.cc index 1e69bcd..a10b088 100644 --- a/chrome/browser/ui/virtual_keyboard/virtual_keyboard_manager.cc +++ b/chrome/browser/ui/virtual_keyboard/virtual_keyboard_manager.cc @@ -19,8 +19,8 @@ #include "chrome/common/chrome_notification_types.h" #include "chrome/common/extensions/extension_messages.h" #include "chrome/common/url_constants.h" -#include "content/browser/site_instance.h" #include "content/public/browser/notification_service.h" +#include "content/public/browser/site_instance.h" #include "content/public/browser/web_contents_observer.h" #include "ui/base/animation/animation_delegate.h" #include "ui/base/animation/slide_animation.h" @@ -193,8 +193,7 @@ KeyboardWidget::KeyboardWidget() // Setup the DOM view to host the keyboard. Profile* profile = ProfileManager::GetDefaultProfile(); - dom_view_->Init(profile, - SiteInstance::CreateSiteInstanceForURL(profile, keyboard_url_)); + dom_view_->Init(profile, SiteInstance::CreateForURL(profile, keyboard_url_)); dom_view_->LoadURL(keyboard_url_); dom_view_->SetVisible(true); SetContentsView(dom_view_); diff --git a/chrome/browser/ui/webui/options/extension_settings_handler.cc b/chrome/browser/ui/webui/options/extension_settings_handler.cc index 9229c71..cf99cb2 100644 --- a/chrome/browser/ui/webui/options/extension_settings_handler.cc +++ b/chrome/browser/ui/webui/options/extension_settings_handler.cc @@ -32,7 +32,6 @@ #include "chrome/common/pref_names.h" #include "chrome/common/url_constants.h" #include "content/browser/renderer_host/render_view_host.h" -#include "content/browser/site_instance.h" #include "content/public/browser/notification_service.h" #include "content/public/browser/notification_types.h" #include "content/public/browser/web_contents.h" diff --git a/chrome/browser/ui/webui/web_ui_unittest.cc b/chrome/browser/ui/webui/web_ui_unittest.cc index fc9bbc8..2d80485 100644 --- a/chrome/browser/ui/webui/web_ui_unittest.cc +++ b/chrome/browser/ui/webui/web_ui_unittest.cc @@ -8,14 +8,15 @@ #include "chrome/browser/ui/tab_contents/test_tab_contents_wrapper.h" #include "chrome/common/url_constants.h" #include "chrome/test/base/testing_profile.h" -#include "content/browser/site_instance.h" #include "content/browser/tab_contents/test_tab_contents.h" #include "content/public/browser/navigation_controller.h" +#include "content/public/browser/site_instance.h" #include "content/test/test_browser_thread.h" #include "testing/gtest/include/gtest/gtest.h" using content::BrowserThread; using content::NavigationController; +using content::SiteInstance; using content::WebContents; class WebUITest : public TabContentsWrapperTestHarness { @@ -170,7 +171,7 @@ TEST_F(WebUITest, FocusOnNavigate) { // Setup. |tc| will be used to track when we try to focus the location bar. TabContentsForFocusTest* tc = new TabContentsForFocusTest( contents()->GetBrowserContext(), - SiteInstance::CreateSiteInstance(contents()->GetBrowserContext())); + SiteInstance::Create(contents()->GetBrowserContext())); tc->GetController().CopyStateFrom(controller()); SetContents(tc); int page_id = 200; diff --git a/content/browser/browsing_instance.cc b/content/browser/browsing_instance.cc index 4809dd76..a03d873 100644 --- a/content/browser/browsing_instance.cc +++ b/content/browser/browsing_instance.cc @@ -6,13 +6,15 @@ #include "base/command_line.h" #include "base/logging.h" -#include "content/browser/site_instance.h" +#include "content/browser/site_instance_impl.h" #include "content/public/browser/browser_context.h" #include "content/public/browser/content_browser_client.h" #include "content/public/browser/web_ui_factory.h" #include "content/public/common/content_switches.h" #include "content/public/common/url_constants.h" +using content::SiteInstance; + // static base::LazyInstance< BrowsingInstance::ContextSiteInstanceMap, @@ -56,8 +58,8 @@ bool BrowsingInstance::ShouldUseProcessPerSite(const GURL& url) { BrowsingInstance::SiteInstanceMap* BrowsingInstance::GetSiteInstanceMap( content::BrowserContext* browser_context, const GURL& url) { - if (!ShouldUseProcessPerSite(SiteInstance::GetEffectiveURL(browser_context, - url))) { + if (!ShouldUseProcessPerSite( + SiteInstanceImpl::GetEffectiveURL(browser_context, url))) { // Not using process-per-site, so use a map specific to this instance. return &site_instance_map_; } @@ -69,7 +71,7 @@ BrowsingInstance::SiteInstanceMap* BrowsingInstance::GetSiteInstanceMap( bool BrowsingInstance::HasSiteInstance(const GURL& url) { std::string site = - SiteInstance::GetSiteForURL(browser_context_, url) + SiteInstanceImpl::GetSiteForURL(browser_context_, url) .possibly_invalid_spec(); SiteInstanceMap* map = GetSiteInstanceMap(browser_context_, url); @@ -79,7 +81,7 @@ bool BrowsingInstance::HasSiteInstance(const GURL& url) { SiteInstance* BrowsingInstance::GetSiteInstanceForURL(const GURL& url) { std::string site = - SiteInstance::GetSiteForURL(browser_context_, url) + SiteInstanceImpl::GetSiteForURL(browser_context_, url) .possibly_invalid_spec(); SiteInstanceMap* map = GetSiteInstanceMap(browser_context_, url); @@ -89,7 +91,7 @@ SiteInstance* BrowsingInstance::GetSiteInstanceForURL(const GURL& url) { } // No current SiteInstance for this site, so let's create one. - SiteInstance* instance = new SiteInstance(this); + SiteInstanceImpl* instance = new SiteInstanceImpl(this); // Set the site of this new SiteInstance, which will register it with us. instance->SetSite(url); @@ -97,9 +99,10 @@ SiteInstance* BrowsingInstance::GetSiteInstanceForURL(const GURL& url) { } void BrowsingInstance::RegisterSiteInstance(SiteInstance* site_instance) { - DCHECK(site_instance->browsing_instance_ == this); - DCHECK(site_instance->has_site()); - std::string site = site_instance->site().possibly_invalid_spec(); + DCHECK(static_cast<SiteInstanceImpl*>(site_instance)-> + browsing_instance_ == this); + DCHECK(static_cast<SiteInstanceImpl*>(site_instance)->HasSite()); + std::string site = site_instance->GetSite().possibly_invalid_spec(); // Only register if we don't have a SiteInstance for this site already. // It's possible to have two SiteInstances point to the same site if two @@ -107,7 +110,7 @@ void BrowsingInstance::RegisterSiteInstance(SiteInstance* site_instance) { // register them until DidNavigate.) If there is a previously existing // SiteInstance for this site, we just won't register the new one. SiteInstanceMap* map = GetSiteInstanceMap(browser_context_, - site_instance->site()); + site_instance->GetSite()); SiteInstanceMap::iterator i = map->find(site); if (i == map->end()) { // Not previously registered, so register it. @@ -116,9 +119,10 @@ void BrowsingInstance::RegisterSiteInstance(SiteInstance* site_instance) { } void BrowsingInstance::UnregisterSiteInstance(SiteInstance* site_instance) { - DCHECK(site_instance->browsing_instance_ == this); - DCHECK(site_instance->has_site()); - std::string site = site_instance->site().possibly_invalid_spec(); + DCHECK(static_cast<SiteInstanceImpl*>(site_instance)-> + browsing_instance_ == this); + DCHECK(static_cast<SiteInstanceImpl*>(site_instance)->HasSite()); + std::string site = site_instance->GetSite().possibly_invalid_spec(); // Only unregister the SiteInstance if it is the same one that is registered // for the site. (It might have been an unregistered SiteInstance. See the @@ -139,9 +143,10 @@ void BrowsingInstance::UnregisterSiteInstance(SiteInstance* site_instance) { } } -bool BrowsingInstance::RemoveSiteInstanceFromMap(SiteInstanceMap* map, - const std::string& site, - SiteInstance* site_instance) { +bool BrowsingInstance::RemoveSiteInstanceFromMap( + SiteInstanceMap* map, + const std::string& site, + SiteInstance* site_instance) { SiteInstanceMap::iterator i = map->find(site); if (i != map->end() && i->second == site_instance) { // Matches, so erase it. diff --git a/content/browser/browsing_instance.h b/content/browser/browsing_instance.h index d3baf8a..f32b3d5 100644 --- a/content/browser/browsing_instance.h +++ b/content/browser/browsing_instance.h @@ -12,10 +12,11 @@ #include "content/common/content_export.h" class GURL; -class SiteInstance; +class SiteInstanceImpl; namespace content { class BrowserContext; +class SiteInstance; } /////////////////////////////////////////////////////////////////////////////// @@ -80,19 +81,20 @@ class CONTENT_EXPORT BrowsingInstance // Get the SiteInstance responsible for rendering the given URL. Should // create a new one if necessary, but should not create more than one // SiteInstance per site. - SiteInstance* GetSiteInstanceForURL(const GURL& url); + content::SiteInstance* GetSiteInstanceForURL(const GURL& url); // Adds the given SiteInstance to our map, to ensure that we do not create // another SiteInstance for the same site. - void RegisterSiteInstance(SiteInstance* site_instance); + void RegisterSiteInstance(content::SiteInstance* site_instance); // Removes the given SiteInstance from our map, after all references to it // have been deleted. This means it is safe to create a new SiteInstance // if the user later visits a page from this site, within this // BrowsingInstance. - void UnregisterSiteInstance(SiteInstance* site_instance); + void UnregisterSiteInstance(content::SiteInstance* site_instance); - friend class SiteInstance; + friend class SiteInstanceImpl; + friend class content::SiteInstance; friend class base::RefCounted<BrowsingInstance>; @@ -101,7 +103,7 @@ class CONTENT_EXPORT BrowsingInstance private: // Map of site to SiteInstance, to ensure we only have one SiteInstance per - typedef base::hash_map<std::string, SiteInstance*> SiteInstanceMap; + typedef base::hash_map<std::string, content::SiteInstance*> SiteInstanceMap; // Map of BrowserContext to SiteInstanceMap, for use in the process-per-site // model. @@ -120,7 +122,7 @@ class CONTENT_EXPORT BrowsingInstance // Utility routine which removes the passed SiteInstance from the passed // SiteInstanceMap. bool RemoveSiteInstanceFromMap(SiteInstanceMap* map, const std::string& site, - SiteInstance* site_instance); + content::SiteInstance* site_instance); // Common browser context to which all SiteInstances in this BrowsingInstance // must belong. @@ -128,7 +130,7 @@ class CONTENT_EXPORT BrowsingInstance // Map of site to SiteInstance, to ensure we only have one SiteInstance per // site. The site string should be the possibly_invalid_spec() of a GURL - // obtained with SiteInstance::GetSiteForURL. Note that this map may not + // obtained with SiteInstanceImpl::GetSiteForURL. Note that this map may not // contain every active SiteInstance, because a race exists where two // SiteInstances can be assigned to the same site. This is ok in rare cases. // This field is only used if we are not using process-per-site. diff --git a/content/browser/child_process_security_policy.cc b/content/browser/child_process_security_policy.cc index eeeac3f..4a305b1 100644 --- a/content/browser/child_process_security_policy.cc +++ b/content/browser/child_process_security_policy.cc @@ -10,13 +10,15 @@ #include "base/platform_file.h" #include "base/stl_util.h" #include "base/string_util.h" +#include "content/browser/site_instance_impl.h" #include "content/public/browser/content_browser_client.h" -#include "content/browser/site_instance.h" #include "content/public/common/bindings_policy.h" #include "content/public/common/url_constants.h" #include "googleurl/src/gurl.h" #include "net/url_request/url_request.h" +using content::SiteInstance; + static const int kReadFilePermissions = base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ | @@ -103,7 +105,7 @@ class ChildProcessSecurityPolicy::SecurityState { bool CanUseCookiesForOrigin(const GURL& gurl) { if (origin_lock_.is_empty()) return true; - GURL site_gurl = SiteInstance::GetSiteForURL(NULL, gurl); + GURL site_gurl = SiteInstanceImpl::GetSiteForURL(NULL, gurl); return origin_lock_ == site_gurl; } @@ -478,7 +480,7 @@ bool ChildProcessSecurityPolicy::CanUseCookiesForOrigin(int child_id, void ChildProcessSecurityPolicy::LockToOrigin(int child_id, const GURL& gurl) { // "gurl" can be currently empty in some cases, such as file://blah. - DCHECK(SiteInstance::GetSiteForURL(NULL, gurl) == gurl); + DCHECK(SiteInstanceImpl::GetSiteForURL(NULL, gurl) == gurl); base::AutoLock lock(lock_); SecurityStateMap::iterator state = security_state_.find(child_id); DCHECK(state != security_state_.end()); diff --git a/content/browser/debugger/render_view_devtools_agent_host.cc b/content/browser/debugger/render_view_devtools_agent_host.cc index 7aad562..943930f 100644 --- a/content/browser/debugger/render_view_devtools_agent_host.cc +++ b/content/browser/debugger/render_view_devtools_agent_host.cc @@ -10,7 +10,7 @@ #include "content/browser/debugger/render_view_devtools_agent_host.h" #include "content/browser/renderer_host/render_process_host_impl.h" #include "content/browser/renderer_host/render_view_host.h" -#include "content/browser/site_instance.h" +#include "content/browser/site_instance_impl.h" #include "content/browser/tab_contents/tab_contents.h" #include "content/common/devtools_messages.h" #include "content/public/browser/content_browser_client.h" diff --git a/content/browser/renderer_host/render_view_host.cc b/content/browser/renderer_host/render_view_host.cc index 921bd94f..47a2b63 100644 --- a/content/browser/renderer_host/render_view_host.cc +++ b/content/browser/renderer_host/render_view_host.cc @@ -26,7 +26,6 @@ #include "content/browser/renderer_host/render_process_host_impl.h" #include "content/browser/renderer_host/render_widget_host.h" #include "content/browser/renderer_host/render_widget_host_view.h" -#include "content/browser/site_instance.h" #include "content/common/desktop_notification_messages.h" #include "content/common/drag_messages.h" #include "content/common/speech_input_messages.h" @@ -58,6 +57,7 @@ using base::TimeDelta; using content::BrowserMessageFilter; using content::BrowserThread; using content::RenderViewHostDelegate; +using content::SiteInstance; using content::UserMetricsAction; using WebKit::WebConsoleMessage; using WebKit::WebDragOperation; @@ -110,7 +110,7 @@ RenderViewHost::RenderViewHost(SiteInstance* instance, int routing_id, SessionStorageNamespace* session_storage) : RenderWidgetHost(instance->GetProcess(), routing_id), - instance_(instance), + instance_(static_cast<SiteInstanceImpl*>(instance)), delegate_(delegate), waiting_for_drag_context_response_(false), enabled_bindings_(0), diff --git a/content/browser/renderer_host/render_view_host.h b/content/browser/renderer_host/render_view_host.h index e766d24..aa12e85 100644 --- a/content/browser/renderer_host/render_view_host.h +++ b/content/browser/renderer_host/render_view_host.h @@ -16,6 +16,7 @@ #include "base/process_util.h" #include "base/values.h" #include "content/browser/renderer_host/render_widget_host.h" +#include "content/browser/site_instance_impl.h" #include "content/common/content_export.h" #include "content/public/browser/notification_observer.h" #include "content/public/common/stop_find_action.h" @@ -34,7 +35,6 @@ class FilePath; class GURL; class PowerSaveBlocker; class SessionStorageNamespace; -class SiteInstance; class SkBitmap; class ViewMsg_Navigate; struct ContextMenuParams; @@ -139,13 +139,13 @@ class CONTENT_EXPORT RenderViewHost : public RenderWidgetHost { // tab contentses to share the same session storage (part of the WebStorage // spec) space. This is useful when restoring tabs, but most callers should // pass in NULL which will cause a new SessionStorageNamespace to be created. - RenderViewHost(SiteInstance* instance, + RenderViewHost(content::SiteInstance* instance, content::RenderViewHostDelegate* delegate, int routing_id, SessionStorageNamespace* session_storage_namespace); virtual ~RenderViewHost(); - SiteInstance* site_instance() const { return instance_; } + content::SiteInstance* site_instance() const { return instance_; } content::RenderViewHostDelegate* delegate() const { return delegate_; } void set_delegate(content::RenderViewHostDelegate* d) { CHECK(d); // http://crbug.com/82827 @@ -612,7 +612,7 @@ class CONTENT_EXPORT RenderViewHost : public RenderWidgetHost { // The SiteInstance associated with this RenderViewHost. All pages drawn // in this RenderViewHost are part of this SiteInstance. Should not change // over time. - scoped_refptr<SiteInstance> instance_; + scoped_refptr<SiteInstanceImpl> instance_; // Our delegate, which wants to know about changes in the RenderView. content::RenderViewHostDelegate* delegate_; diff --git a/content/browser/renderer_host/render_view_host_factory.cc b/content/browser/renderer_host/render_view_host_factory.cc index 3e7fe70..f54ac09 100644 --- a/content/browser/renderer_host/render_view_host_factory.cc +++ b/content/browser/renderer_host/render_view_host_factory.cc @@ -7,6 +7,8 @@ #include "base/logging.h" #include "content/browser/renderer_host/render_view_host.h" +using content::SiteInstance; + // static RenderViewHostFactory* RenderViewHostFactory::factory_ = NULL; diff --git a/content/browser/renderer_host/render_view_host_factory.h b/content/browser/renderer_host/render_view_host_factory.h index f63a1e7..96a64df 100644 --- a/content/browser/renderer_host/render_view_host_factory.h +++ b/content/browser/renderer_host/render_view_host_factory.h @@ -11,10 +11,10 @@ class RenderViewHost; class SessionStorageNamespace; -class SiteInstance; namespace content { class RenderViewHostDelegate; +class SiteInstance; } // A factory for creating RenderViewHosts. There is a global factory function @@ -25,7 +25,7 @@ class RenderViewHostFactory { // Creates a RenderViewHost using the currently registered factory, or the // default one if no factory is registered. Ownership of the returned // pointer will be passed to the caller. - static RenderViewHost* Create(SiteInstance* instance, + static RenderViewHost* Create(content::SiteInstance* instance, content::RenderViewHostDelegate* delegate, int routing_id, SessionStorageNamespace* session_storage); @@ -42,7 +42,7 @@ class RenderViewHostFactory { // You can derive from this class and specify an implementation for this // function to create a different kind of RenderViewHost for testing. virtual RenderViewHost* CreateRenderViewHost( - SiteInstance* instance, + content::SiteInstance* instance, content::RenderViewHostDelegate* delegate, int routing_id, SessionStorageNamespace* session_storage_namespace) = 0; diff --git a/content/browser/renderer_host/render_view_host_manager_browsertest.cc b/content/browser/renderer_host/render_view_host_manager_browsertest.cc index 5565ece..2d05866 100644 --- a/content/browser/renderer_host/render_view_host_manager_browsertest.cc +++ b/content/browser/renderer_host/render_view_host_manager_browsertest.cc @@ -9,7 +9,7 @@ #include "chrome/test/base/in_process_browser_test.h" #include "chrome/test/base/ui_test_utils.h" #include "content/browser/renderer_host/render_view_host.h" -#include "content/browser/site_instance.h" +#include "content/browser/site_instance_impl.h" #include "content/browser/tab_contents/tab_contents.h" #include "content/public/browser/notification_details.h" #include "content/public/browser/notification_observer.h" @@ -20,6 +20,8 @@ #include "net/base/net_util.h" #include "net/test/test_server.h" +using content::SiteInstance; + class RenderViewHostManagerTest : public InProcessBrowserTest { public: RenderViewHostManagerTest() { diff --git a/content/browser/renderer_host/test_render_view_host.cc b/content/browser/renderer_host/test_render_view_host.cc index 3237881..764ee86 100644 --- a/content/browser/renderer_host/test_render_view_host.cc +++ b/content/browser/renderer_host/test_render_view_host.cc @@ -6,7 +6,7 @@ #include "content/browser/browser_url_handler.h" #include "content/browser/renderer_host/test_backing_store.h" #include "content/browser/renderer_host/test_render_view_host.h" -#include "content/browser/site_instance.h" +#include "content/browser/site_instance_impl.h" #include "content/browser/tab_contents/navigation_controller_impl.h" #include "content/browser/tab_contents/navigation_entry_impl.h" #include "content/browser/tab_contents/test_tab_contents.h" @@ -23,6 +23,7 @@ using content::NavigationController; using content::NavigationEntry; using content::RenderViewHostDelegate; +using content::SiteInstance; using webkit::forms::PasswordForm; void InitNavigateParams(ViewHostMsg_FrameNavigate_Params* params, @@ -312,7 +313,8 @@ RenderViewHost* TestRenderViewHostFactory::CreateRenderViewHost( int routing_id, SessionStorageNamespace* session_storage) { // See declaration of render_process_host_factory_ below. - instance->set_render_process_host_factory(render_process_host_factory_); + static_cast<SiteInstanceImpl*>(instance)-> + set_render_process_host_factory(render_process_host_factory_); return new TestRenderViewHost(instance, delegate, routing_id); } @@ -370,8 +372,7 @@ TestTabContents* RenderViewHostTestHarness::CreateTestTabContents() { browser_context_.reset(new TestBrowserContext()); // This will be deleted when the TabContents goes away. - SiteInstance* instance = - SiteInstance::CreateSiteInstance(browser_context_.get()); + SiteInstance* instance = SiteInstance::Create(browser_context_.get()); return new TestTabContents(browser_context_.get(), instance); } diff --git a/content/browser/renderer_host/test_render_view_host.h b/content/browser/renderer_host/test_render_view_host.h index 3afffc5..783536b 100644 --- a/content/browser/renderer_host/test_render_view_host.h +++ b/content/browser/renderer_host/test_render_view_host.h @@ -21,13 +21,13 @@ namespace content { class BrowserContext; class NavigationController; class RenderProcessHostFactory; +class SiteInstance; } namespace gfx { class Rect; } -class SiteInstance; class TestTabContents; struct ViewHostMsg_FrameNavigate_Params; @@ -175,7 +175,7 @@ class TestRenderViewHost : public RenderViewHost { static TestRenderViewHost* GetPendingForController( content::NavigationController* controller); - TestRenderViewHost(SiteInstance* instance, + TestRenderViewHost(content::SiteInstance* instance, content::RenderViewHostDelegate* delegate, int routing_id); virtual ~TestRenderViewHost(); @@ -276,7 +276,7 @@ class TestRenderViewHostFactory : public RenderViewHostFactory { virtual void set_render_process_host_factory( content::RenderProcessHostFactory* rph_factory); virtual RenderViewHost* CreateRenderViewHost( - SiteInstance* instance, + content::SiteInstance* instance, content::RenderViewHostDelegate* delegate, int routing_id, SessionStorageNamespace* session_storage) OVERRIDE; diff --git a/content/browser/site_instance.cc b/content/browser/site_instance_impl.cc index 9fecc16..feb5402 100644 --- a/content/browser/site_instance.cc +++ b/content/browser/site_instance_impl.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "content/browser/site_instance.h" +#include "content/browser/site_instance_impl.h" #include "base/command_line.h" #include "content/browser/browsing_instance.h" @@ -16,6 +16,8 @@ #include "content/public/common/url_constants.h" #include "net/base/registry_controlled_domain.h" +using content::SiteInstance; + static bool IsURLSameAsAnySiteInstance(const GURL& url) { if (!url.is_valid()) return false; @@ -29,9 +31,9 @@ static bool IsURLSameAsAnySiteInstance(const GURL& url) { content::GetContentClient()->browser()->IsURLSameAsAnySiteInstance(url); } -int32 SiteInstance::next_site_instance_id_ = 1; +int32 SiteInstanceImpl::next_site_instance_id_ = 1; -SiteInstance::SiteInstance(BrowsingInstance* browsing_instance) +SiteInstanceImpl::SiteInstanceImpl(BrowsingInstance* browsing_instance) : id_(next_site_instance_id_++), browsing_instance_(browsing_instance), render_process_host_factory_(NULL), @@ -43,21 +45,26 @@ SiteInstance::SiteInstance(BrowsingInstance* browsing_instance) content::NotificationService::AllBrowserContextsAndSources()); } -SiteInstance::~SiteInstance() { +SiteInstanceImpl::~SiteInstanceImpl() { content::GetContentClient()->browser()->SiteInstanceDeleting(this); // Now that no one is referencing us, we can safely remove ourselves from // the BrowsingInstance. Any future visits to a page from this site // (within the same BrowsingInstance) can safely create a new SiteInstance. if (has_site_) - browsing_instance_->UnregisterSiteInstance(this); + browsing_instance_->UnregisterSiteInstance( + static_cast<SiteInstance*>(this)); +} + +int32 SiteInstanceImpl::GetId() { + return id_; } -bool SiteInstance::HasProcess() const { +bool SiteInstanceImpl::HasProcess() const { return (process_ != NULL); } -content::RenderProcessHost* SiteInstance::GetProcess() { +content::RenderProcessHost* SiteInstanceImpl::GetProcess() { // TODO(erikkay) It would be nice to ensure that the renderer type had been // properly set before we get here. The default tab creation case winds up // with no site set at this point, so it will default to TYPE_NORMAL. This @@ -93,7 +100,7 @@ content::RenderProcessHost* SiteInstance::GetProcess() { return process_; } -void SiteInstance::SetSite(const GURL& url) { +void SiteInstanceImpl::SetSite(const GURL& url) { // A SiteInstance's site should not change. // TODO(creis): When following links or script navigations, we can currently // render pages from other sites in this SiteInstance. This will eventually @@ -116,15 +123,23 @@ void SiteInstance::SetSite(const GURL& url) { LockToOrigin(); } -bool SiteInstance::HasRelatedSiteInstance(const GURL& url) { +const GURL& SiteInstanceImpl::GetSite() const { + return site_; +} + +bool SiteInstanceImpl::HasSite() const { + return has_site_; +} + +bool SiteInstanceImpl::HasRelatedSiteInstance(const GURL& url) { return browsing_instance_->HasSiteInstance(url); } -SiteInstance* SiteInstance::GetRelatedSiteInstance(const GURL& url) { +SiteInstance* SiteInstanceImpl::GetRelatedSiteInstance(const GURL& url) { return browsing_instance_->GetSiteInstanceForURL(url); } -bool SiteInstance::HasWrongProcessForURL(const GURL& url) const { +bool SiteInstanceImpl::HasWrongProcessForURL(const GURL& url) const { // Having no process isn't a problem, since we'll assign it correctly. if (!HasProcess()) return false; @@ -141,18 +156,17 @@ bool SiteInstance::HasWrongProcessForURL(const GURL& url) const { process_, browsing_instance_->browser_context(), site_url); } -content::BrowserContext* SiteInstance::GetBrowserContext() const { +content::BrowserContext* SiteInstanceImpl::GetBrowserContext() const { return browsing_instance_->browser_context(); } /*static*/ -SiteInstance* SiteInstance::CreateSiteInstance( - content::BrowserContext* browser_context) { - return new SiteInstance(new BrowsingInstance(browser_context)); +SiteInstance* SiteInstance::Create(content::BrowserContext* browser_context) { + return new SiteInstanceImpl(new BrowsingInstance(browser_context)); } /*static*/ -SiteInstance* SiteInstance::CreateSiteInstanceForURL( +SiteInstance* SiteInstance::CreateForURL( content::BrowserContext* browser_context, const GURL& url) { // This BrowsingInstance may be deleted if it returns an existing // SiteInstance. @@ -162,9 +176,9 @@ SiteInstance* SiteInstance::CreateSiteInstanceForURL( } /*static*/ -GURL SiteInstance::GetSiteForURL(content::BrowserContext* browser_context, - const GURL& real_url) { - GURL url = GetEffectiveURL(browser_context, real_url); +GURL SiteInstanceImpl::GetSiteForURL(content::BrowserContext* browser_context, + const GURL& real_url) { + GURL url = SiteInstanceImpl::GetEffectiveURL(browser_context, real_url); // URLs with no host should have an empty site. GURL site; @@ -199,9 +213,10 @@ GURL SiteInstance::GetSiteForURL(content::BrowserContext* browser_context, /*static*/ bool SiteInstance::IsSameWebSite(content::BrowserContext* browser_context, - const GURL& real_url1, const GURL& real_url2) { - GURL url1 = GetEffectiveURL(browser_context, real_url1); - GURL url2 = GetEffectiveURL(browser_context, real_url2); + const GURL& real_url1, + const GURL& real_url2) { + GURL url1 = SiteInstanceImpl::GetEffectiveURL(browser_context, real_url1); + GURL url2 = SiteInstanceImpl::GetEffectiveURL(browser_context, real_url2); // We infer web site boundaries based on the registered domain name of the // top-level page and the scheme. We do not pay attention to the port if @@ -226,15 +241,16 @@ bool SiteInstance::IsSameWebSite(content::BrowserContext* browser_context, } /*static*/ -GURL SiteInstance::GetEffectiveURL(content::BrowserContext* browser_context, - const GURL& url) { +GURL SiteInstanceImpl::GetEffectiveURL( + content::BrowserContext* browser_context, + const GURL& url) { return content::GetContentClient()->browser()-> GetEffectiveURL(browser_context, url); } -void SiteInstance::Observe(int type, - const content::NotificationSource& source, - const content::NotificationDetails& details) { +void SiteInstanceImpl::Observe(int type, + const content::NotificationSource& source, + const content::NotificationDetails& details) { DCHECK(type == content::NOTIFICATION_RENDERER_PROCESS_TERMINATED); content::RenderProcessHost* rph = content::Source<content::RenderProcessHost>(source).ptr(); @@ -242,7 +258,7 @@ void SiteInstance::Observe(int type, process_ = NULL; } -void SiteInstance::LockToOrigin() { +void SiteInstanceImpl::LockToOrigin() { const CommandLine& command_line = *CommandLine::ForCurrentProcess(); if (command_line.HasSwitch(switches::kEnableStrictSiteIsolation)) { ChildProcessSecurityPolicy* policy = diff --git a/content/browser/site_instance_impl.h b/content/browser/site_instance_impl.h new file mode 100644 index 0000000..bee9383 --- /dev/null +++ b/content/browser/site_instance_impl.h @@ -0,0 +1,119 @@ +// 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. + +#ifndef CONTENT_BROWSER_SITE_INSTANCE_IMPL_H_ +#define CONTENT_BROWSER_SITE_INSTANCE_IMPL_H_ +#pragma once + +#include "content/browser/renderer_host/render_process_host_impl.h" +#include "content/common/content_export.h" +#include "content/public/browser/notification_observer.h" +#include "content/public/browser/notification_registrar.h" +#include "content/public/browser/site_instance.h" +#include "googleurl/src/gurl.h" + +namespace content { +class RenderProcessHostFactory; +} + +class CONTENT_EXPORT SiteInstanceImpl : public content::SiteInstance, + public content::NotificationObserver { + public: + // content::SiteInstance interface overrides. + virtual int32 GetId() OVERRIDE; + virtual bool HasProcess() const OVERRIDE; + virtual content::RenderProcessHost* GetProcess() OVERRIDE; + virtual const GURL& GetSite() const OVERRIDE; + virtual SiteInstance* GetRelatedSiteInstance(const GURL& url) OVERRIDE; + virtual content::BrowserContext* GetBrowserContext() const OVERRIDE; + + // Set the web site that this SiteInstance is rendering pages for. + // This includes the scheme and registered domain, but not the port. If the + // URL does not have a valid registered domain, then the full hostname is + // stored. + void SetSite(const GURL& url); + bool HasSite() const; + + // Returns whether there is currently a related SiteInstance (registered with + // BrowsingInstance) for the site of the given url. If so, we should try to + // avoid dedicating an unused SiteInstance to it (e.g., in a new tab). + bool HasRelatedSiteInstance(const GURL& url); + + // Returns whether this SiteInstance has a process that is the wrong type for + // the given URL. If so, the browser should force a process swap when + // navigating to the URL. + bool HasWrongProcessForURL(const GURL& url) const; + + // Sets the factory used to create new RenderProcessHosts. This will also be + // passed on to SiteInstances spawned by this one. + // The factory must outlive the SiteInstance; ownership is not transferred. It + // may be NULL, in which case the default BrowserRenderProcessHost will be + // created (this is the behavior if you don't call this function). + void set_render_process_host_factory( + content::RenderProcessHostFactory* rph_factory) { + render_process_host_factory_ = rph_factory; + } + + // Returns the site for the given URL, which includes only the scheme and + // registered domain. Returns an empty GURL if the URL has no host. + static GURL GetSiteForURL(content::BrowserContext* context, const GURL& url); + + protected: + friend class BrowsingInstance; + friend class content::SiteInstance; + + // Virtual to allow tests to extend it. + virtual ~SiteInstanceImpl(); + + // Create a new SiteInstance. Protected to give access to BrowsingInstance + // and tests; most callers should use Create or GetRelatedSiteInstance + // instead. + explicit SiteInstanceImpl(BrowsingInstance* browsing_instance); + + private: + // Get the effective URL for the given actual URL. + static GURL GetEffectiveURL(content::BrowserContext* browser_context, + const GURL& url); + + // content::NotificationObserver implementation. + virtual void Observe(int type, + const content::NotificationSource& source, + const content::NotificationDetails& details) OVERRIDE; + + // Used to restrict a process' origin access rights. + void LockToOrigin(); + + // The next available SiteInstance ID. + static int32 next_site_instance_id_; + + // A unique ID for this SiteInstance. + int32 id_; + + content::NotificationRegistrar registrar_; + + // BrowsingInstance to which this SiteInstance belongs. + scoped_refptr<BrowsingInstance> browsing_instance_; + + // Factory for new RenderProcessHosts, not owned by this class. NULL indiactes + // that the default BrowserRenderProcessHost should be created. + const content::RenderProcessHostFactory* render_process_host_factory_; + + // Current RenderProcessHost that is rendering pages for this SiteInstance. + // This pointer will only change once the RenderProcessHost is destructed. It + // will still remain the same even if the process crashes, since in that + // scenario the RenderProcessHost remains the same. + content::RenderProcessHost* process_; + + // The web site that this SiteInstance is rendering pages for. + GURL site_; + + // Whether SetSite has been called. + bool has_site_; + + FRIEND_TEST_ALL_PREFIXES(RenderViewHostManagerTest, NewTabPageProcesses); + + DISALLOW_COPY_AND_ASSIGN(SiteInstanceImpl); +}; + +#endif // CONTENT_BROWSER_SITE_INSTANCE_IMPL_H_ diff --git a/content/browser/site_instance_unittest.cc b/content/browser/site_instance_impl_unittest.cc index f436471..f45baf7 100644 --- a/content/browser/site_instance_unittest.cc +++ b/content/browser/site_instance_impl_unittest.cc @@ -12,7 +12,7 @@ #include "content/browser/renderer_host/render_process_host_impl.h" #include "content/browser/renderer_host/render_view_host.h" #include "content/browser/renderer_host/test_render_view_host.h" -#include "content/browser/site_instance.h" +#include "content/browser/site_instance_impl.h" #include "content/browser/tab_contents/navigation_entry_impl.h" #include "content/browser/tab_contents/tab_contents.h" #include "content/browser/webui/empty_web_ui_factory.h" @@ -27,6 +27,7 @@ using content::BrowserThread; using content::BrowserThreadImpl; using content::NavigationEntry; using content::NavigationEntryImpl; +using content::SiteInstance; namespace { @@ -152,7 +153,7 @@ class TestBrowsingInstance : public BrowsingInstance { int* delete_counter_; }; -class TestSiteInstance : public SiteInstance { +class TestSiteInstance : public SiteInstanceImpl { public: static TestSiteInstance* CreateTestSiteInstance( content::BrowserContext* browser_context, @@ -165,7 +166,7 @@ class TestSiteInstance : public SiteInstance { private: TestSiteInstance(BrowsingInstance* browsing_instance, int* delete_counter) - : SiteInstance(browsing_instance), delete_counter_(delete_counter) {} + : SiteInstanceImpl(browsing_instance), delete_counter_(delete_counter) {} virtual ~TestSiteInstance() { (*delete_counter_)++; } @@ -248,10 +249,10 @@ TEST_F(SiteInstanceTest, CloneNavigationEntry) { int browsing_delete_counter = 0; const GURL url("test:foo"); - SiteInstance* instance1 = + SiteInstanceImpl* instance1 = TestSiteInstance::CreateTestSiteInstance(NULL, &site_delete_counter1, &browsing_delete_counter); - SiteInstance* instance2 = + SiteInstanceImpl* instance2 = TestSiteInstance::CreateTestSiteInstance(NULL, &site_delete_counter2, &browsing_delete_counter); @@ -284,14 +285,14 @@ TEST_F(SiteInstanceTest, GetProcess) { // Ensure that GetProcess returns a process. scoped_ptr<TestBrowserContext> browser_context(new TestBrowserContext()); scoped_ptr<content::RenderProcessHost> host1; - scoped_refptr<SiteInstance> instance( - SiteInstance::CreateSiteInstance(browser_context.get())); + scoped_refptr<SiteInstanceImpl> instance(static_cast<SiteInstanceImpl*>( + SiteInstance::Create(browser_context.get()))); host1.reset(instance->GetProcess()); EXPECT_TRUE(host1.get() != NULL); // Ensure that GetProcess creates a new process. - scoped_refptr<SiteInstance> instance2( - SiteInstance::CreateSiteInstance(browser_context.get())); + scoped_refptr<SiteInstanceImpl> instance2(static_cast<SiteInstanceImpl*>( + SiteInstance::Create(browser_context.get()))); scoped_ptr<content::RenderProcessHost> host2(instance2->GetProcess()); EXPECT_TRUE(host2.get() != NULL); EXPECT_NE(host1.get(), host2.get()); @@ -299,14 +300,15 @@ TEST_F(SiteInstanceTest, GetProcess) { // Test to ensure SetSite and site() work properly. TEST_F(SiteInstanceTest, SetSite) { - scoped_refptr<SiteInstance> instance(SiteInstance::CreateSiteInstance(NULL)); - EXPECT_FALSE(instance->has_site()); - EXPECT_TRUE(instance->site().is_empty()); + scoped_refptr<SiteInstanceImpl> instance(static_cast<SiteInstanceImpl*>( + SiteInstance::Create(NULL))); + EXPECT_FALSE(instance->HasSite()); + EXPECT_TRUE(instance->GetSite().is_empty()); instance->SetSite(GURL("http://www.google.com/index.html")); - EXPECT_EQ(GURL("http://google.com"), instance->site()); + EXPECT_EQ(GURL("http://google.com"), instance->GetSite()); - EXPECT_TRUE(instance->has_site()); + EXPECT_TRUE(instance->HasSite()); } // Test to ensure GetSiteForURL properly returns sites for URLs. @@ -314,28 +316,29 @@ TEST_F(SiteInstanceTest, GetSiteForURL) { // Pages are irrelevant. GURL test_url = GURL("http://www.google.com/index.html"); EXPECT_EQ(GURL("http://google.com"), - SiteInstance::GetSiteForURL(NULL, test_url)); + SiteInstanceImpl::GetSiteForURL(NULL, test_url)); // Ports are irrlevant. test_url = GURL("https://www.google.com:8080"); EXPECT_EQ(GURL("https://google.com"), - SiteInstance::GetSiteForURL(NULL, test_url)); + SiteInstanceImpl::GetSiteForURL(NULL, test_url)); // Javascript URLs have no site. test_url = GURL("javascript:foo();"); - EXPECT_EQ(GURL(), SiteInstance::GetSiteForURL(NULL, test_url)); + EXPECT_EQ(GURL(), SiteInstanceImpl::GetSiteForURL(NULL, test_url)); test_url = GURL("http://foo/a.html"); - EXPECT_EQ(GURL("http://foo"), SiteInstance::GetSiteForURL(NULL, test_url)); + EXPECT_EQ(GURL("http://foo"), SiteInstanceImpl::GetSiteForURL( + NULL, test_url)); test_url = GURL("file:///C:/Downloads/"); - EXPECT_EQ(GURL(), SiteInstance::GetSiteForURL(NULL, test_url)); + EXPECT_EQ(GURL(), SiteInstanceImpl::GetSiteForURL(NULL, test_url)); // TODO(creis): Do we want to special case file URLs to ensure they have // either no site or a special "file://" site? We currently return // "file://home/" as the site, which seems broken. // test_url = GURL("file://home/"); - // EXPECT_EQ(GURL(), SiteInstance::GetSiteForURL(NULL, test_url)); + // EXPECT_EQ(GURL(), SiteInstanceImpl::GetSiteForURL(NULL, test_url)); } // Test of distinguishing URLs from different sites. Most of this logic is @@ -368,8 +371,8 @@ TEST_F(SiteInstanceTest, IsSameWebSite) { // The URLs specified by the ContentBrowserClient should also be treated as // same site. EXPECT_TRUE(SiteInstance::IsSameWebSite(NULL, url_crash, url_foo)); - EXPECT_TRUE( - SiteInstance::IsSameWebSite(NULL, url_browser_specified, url_foo)); + EXPECT_TRUE(SiteInstance::IsSameWebSite(NULL, url_browser_specified, + url_foo)); } // Test to ensure that there is only one SiteInstance per site in a given @@ -381,14 +384,16 @@ TEST_F(SiteInstanceTest, OneSiteInstancePerSite) { browsing_instance->set_use_process_per_site(false); const GURL url_a1("http://www.google.com/1.html"); - scoped_refptr<SiteInstance> site_instance_a1( - browsing_instance->GetSiteInstanceForURL(url_a1)); + scoped_refptr<SiteInstanceImpl> site_instance_a1( + static_cast<SiteInstanceImpl*>( + browsing_instance->GetSiteInstanceForURL(url_a1))); EXPECT_TRUE(site_instance_a1.get() != NULL); // A separate site should create a separate SiteInstance. const GURL url_b1("http://www.yahoo.com/"); - scoped_refptr<SiteInstance> site_instance_b1( - browsing_instance->GetSiteInstanceForURL(url_b1)); + scoped_refptr<SiteInstanceImpl> site_instance_b1( + static_cast<SiteInstanceImpl*>( + browsing_instance->GetSiteInstanceForURL(url_b1))); EXPECT_NE(site_instance_a1.get(), site_instance_b1.get()); // Getting the new SiteInstance from the BrowsingInstance and from another @@ -409,8 +414,9 @@ TEST_F(SiteInstanceTest, OneSiteInstancePerSite) { new TestBrowsingInstance(NULL, &delete_counter); browsing_instance2->set_use_process_per_site(false); // Ensure the new SiteInstance is ref counted so that it gets deleted. - scoped_refptr<SiteInstance> site_instance_a2_2( - browsing_instance2->GetSiteInstanceForURL(url_a2)); + scoped_refptr<SiteInstanceImpl> site_instance_a2_2( + static_cast<SiteInstanceImpl*>( + browsing_instance2->GetSiteInstanceForURL(url_a2))); EXPECT_NE(site_instance_a1.get(), site_instance_a2_2.get()); // Should be able to see that we do have SiteInstances. @@ -439,14 +445,16 @@ TEST_F(SiteInstanceTest, OneSiteInstancePerSiteInBrowserContext) { browsing_instance->set_use_process_per_site(true); const GURL url_a1("http://www.google.com/1.html"); - scoped_refptr<SiteInstance> site_instance_a1( - browsing_instance->GetSiteInstanceForURL(url_a1)); + scoped_refptr<SiteInstanceImpl> site_instance_a1( + static_cast<SiteInstanceImpl*>( + browsing_instance->GetSiteInstanceForURL(url_a1))); EXPECT_TRUE(site_instance_a1.get() != NULL); // A separate site should create a separate SiteInstance. const GURL url_b1("http://www.yahoo.com/"); - scoped_refptr<SiteInstance> site_instance_b1( - browsing_instance->GetSiteInstanceForURL(url_b1)); + scoped_refptr<SiteInstanceImpl> site_instance_b1( + static_cast<SiteInstanceImpl*>( + browsing_instance->GetSiteInstanceForURL(url_b1))); EXPECT_NE(site_instance_a1.get(), site_instance_b1.get()); // Getting the new SiteInstance from the BrowsingInstance and from another @@ -479,8 +487,9 @@ TEST_F(SiteInstanceTest, OneSiteInstancePerSiteInBrowserContext) { new TestBrowsingInstance(browser_context.get(), &delete_counter); browsing_instance3->set_use_process_per_site(true); // Ensure the new SiteInstance is ref counted so that it gets deleted. - scoped_refptr<SiteInstance> site_instance_a2_3( - browsing_instance3->GetSiteInstanceForURL(url_a2)); + scoped_refptr<SiteInstanceImpl> site_instance_a2_3( + static_cast<SiteInstanceImpl*>( + browsing_instance3->GetSiteInstanceForURL(url_a2))); EXPECT_NE(site_instance_a1.get(), site_instance_a2_3.get()); // Should be able to see that we do have SiteInstances. @@ -502,9 +511,11 @@ TEST_F(SiteInstanceTest, OneSiteInstancePerSiteInBrowserContext) { // browsing_instances will be deleted when their SiteInstances are deleted } -static SiteInstance* CreateSiteInstance( +static SiteInstanceImpl* CreateSiteInstance( content::RenderProcessHostFactory* factory, const GURL& url) { - SiteInstance* instance = SiteInstance::CreateSiteInstanceForURL(NULL, url); + SiteInstanceImpl* instance = + reinterpret_cast<SiteInstanceImpl*>( + SiteInstance::CreateForURL(NULL, url)); instance->set_render_process_host_factory(factory); return instance; } @@ -522,14 +533,14 @@ TEST_F(SiteInstanceTest, ProcessSharingByType) { hosts.push_back(new MockRenderProcessHost(NULL)); // Create some extension instances and make sure they share a process. - scoped_refptr<SiteInstance> extension1_instance( + scoped_refptr<SiteInstanceImpl> extension1_instance( CreateSiteInstance(&rph_factory, - GURL(kPrivilegedScheme + std::string("://foo/bar")))); + GURL(kPrivilegedScheme + std::string("://foo/bar")))); set_privileged_process_id(extension1_instance->GetProcess()->GetID()); - scoped_refptr<SiteInstance> extension2_instance( + scoped_refptr<SiteInstanceImpl> extension2_instance( CreateSiteInstance(&rph_factory, - GURL(kPrivilegedScheme + std::string("://baz/bar")))); + GURL(kPrivilegedScheme + std::string("://baz/bar")))); scoped_ptr<content::RenderProcessHost> extension_host( extension1_instance->GetProcess()); @@ -537,11 +548,13 @@ TEST_F(SiteInstanceTest, ProcessSharingByType) { extension2_instance->GetProcess()); // Create some WebUI instances and make sure they share a process. - scoped_refptr<SiteInstance> webui1_instance(CreateSiteInstance(&rph_factory, + scoped_refptr<SiteInstanceImpl> webui1_instance(CreateSiteInstance( + &rph_factory, GURL(chrome::kChromeUIScheme + std::string("://newtab")))); policy->GrantWebUIBindings(webui1_instance->GetProcess()->GetID()); - scoped_refptr<SiteInstance> webui2_instance(CreateSiteInstance(&rph_factory, + scoped_refptr<SiteInstanceImpl> webui2_instance(CreateSiteInstance( + &rph_factory, GURL(chrome::kChromeUIScheme + std::string("://history")))); scoped_ptr<content::RenderProcessHost> dom_host( @@ -564,14 +577,14 @@ TEST_F(SiteInstanceTest, ProcessSharingByType) { TEST_F(SiteInstanceTest, HasWrongProcessForURL) { scoped_ptr<TestBrowserContext> browser_context(new TestBrowserContext()); scoped_ptr<content::RenderProcessHost> host; - scoped_refptr<SiteInstance> instance( - SiteInstance::CreateSiteInstance(browser_context.get())); + scoped_refptr<SiteInstanceImpl> instance(static_cast<SiteInstanceImpl*>( + SiteInstance::Create(browser_context.get()))); - EXPECT_FALSE(instance->has_site()); - EXPECT_TRUE(instance->site().is_empty()); + EXPECT_FALSE(instance->HasSite()); + EXPECT_TRUE(instance->GetSite().is_empty()); instance->SetSite(GURL("http://evernote.com/")); - EXPECT_TRUE(instance->has_site()); + EXPECT_TRUE(instance->HasSite()); // Check prior to "assigning" a process to the instance, which is expected // to return false due to not being attached to any process yet. diff --git a/content/browser/ssl/ssl_policy.cc b/content/browser/ssl/ssl_policy.cc index 4b22e683..8bdcb10 100644 --- a/content/browser/ssl/ssl_policy.cc +++ b/content/browser/ssl/ssl_policy.cc @@ -12,7 +12,7 @@ #include "base/string_util.h" #include "content/browser/renderer_host/render_process_host_impl.h" #include "content/browser/renderer_host/render_view_host.h" -#include "content/browser/site_instance.h" +#include "content/browser/site_instance_impl.h" #include "content/browser/ssl/ssl_cert_error_handler.h" #include "content/browser/ssl/ssl_request_info.h" #include "content/browser/tab_contents/navigation_entry_impl.h" @@ -25,6 +25,7 @@ #include "webkit/glue/resource_type.h" using content::NavigationEntryImpl; +using content::SiteInstance; using content::SSLStatus; namespace { diff --git a/content/browser/tab_contents/interstitial_page.cc b/content/browser/tab_contents/interstitial_page.cc index 8f67b82..19f1643 100644 --- a/content/browser/tab_contents/interstitial_page.cc +++ b/content/browser/tab_contents/interstitial_page.cc @@ -16,7 +16,7 @@ #include "content/browser/renderer_host/render_view_host.h" #include "content/browser/renderer_host/render_widget_host_view.h" #include "content/browser/renderer_host/resource_dispatcher_host.h" -#include "content/browser/site_instance.h" +#include "content/browser/site_instance_impl.h" #include "content/browser/tab_contents/navigation_controller_impl.h" #include "content/browser/tab_contents/navigation_entry_impl.h" #include "content/browser/tab_contents/tab_contents.h" @@ -39,6 +39,7 @@ using content::NavigationController; using content::NavigationEntry; using content::NavigationEntryImpl; using content::RenderViewHostDelegate; +using content::SiteInstance; using content::WebContents; using content::WebContentsView; using WebKit::WebDragOperation; @@ -429,7 +430,7 @@ WebContents* InterstitialPage::tab() const { RenderViewHost* InterstitialPage::CreateRenderViewHost() { RenderViewHost* render_view_host = new RenderViewHost( - SiteInstance::CreateSiteInstance(tab()->GetBrowserContext()), + SiteInstance::Create(tab()->GetBrowserContext()), this, MSG_ROUTING_NONE, kInvalidSessionStorageNamespaceId); return render_view_host; } diff --git a/content/browser/tab_contents/navigation_controller_impl.cc b/content/browser/tab_contents/navigation_controller_impl.cc index 3c5ddee..05dbda2 100644 --- a/content/browser/tab_contents/navigation_controller_impl.cc +++ b/content/browser/tab_contents/navigation_controller_impl.cc @@ -14,7 +14,7 @@ #include "content/browser/child_process_security_policy.h" #include "content/browser/in_process_webkit/session_storage_namespace.h" #include "content/browser/renderer_host/render_view_host.h" // Temporary -#include "content/browser/site_instance.h" +#include "content/browser/site_instance_impl.h" #include "content/browser/tab_contents/interstitial_page.h" #include "content/browser/tab_contents/navigation_entry_impl.h" #include "content/browser/tab_contents/tab_contents.h" @@ -37,6 +37,7 @@ using content::GlobalRequestID; using content::NavigationController; using content::NavigationEntry; using content::NavigationEntryImpl; +using content::SiteInstance; using content::UserMetricsAction; using content::WebContents; @@ -291,7 +292,7 @@ bool NavigationControllerImpl::IsInitialNavigation() { } NavigationEntryImpl* NavigationControllerImpl::GetEntryWithPageID( - SiteInstance* instance, int32 page_id) const { + SiteInstance* instance, int32 page_id) const { int index = GetEntryIndexWithPageID(instance, page_id); return (index != -1) ? entries_[index].get() : NULL; } @@ -724,7 +725,7 @@ content::NavigationType NavigationControllerImpl::ClassifyNavigation( temp.append(base::IntToString(entries_[i]->GetPageID())); temp.append("_"); if (entries_[i]->site_instance()) - temp.append(base::IntToString(entries_[i]->site_instance()->id())); + temp.append(base::IntToString(entries_[i]->site_instance()->GetId())); else temp.append("N"); if (entries_[i]->site_instance() != tab_contents_->GetSiteInstance()) @@ -813,7 +814,8 @@ void NavigationControllerImpl::RendererDidNavigateToNewPage( new_entry->SetReferrer(params.referrer); new_entry->SetPageID(params.page_id); new_entry->SetTransitionType(params.transition); - new_entry->set_site_instance(tab_contents_->GetSiteInstance()); + new_entry->set_site_instance( + static_cast<SiteInstanceImpl*>(tab_contents_->GetSiteInstance())); new_entry->SetHasPostData(params.is_post); InsertOrReplaceEntry(new_entry, *did_replace_entry); @@ -841,7 +843,8 @@ void NavigationControllerImpl::RendererDidNavigateToExistingPage( UpdateVirtualURLToURL(entry, params.url); DCHECK(entry->site_instance() == NULL || entry->site_instance() == tab_contents_->GetSiteInstance()); - entry->set_site_instance(tab_contents_->GetSiteInstance()); + entry->set_site_instance( + static_cast<SiteInstanceImpl*>(tab_contents_->GetSiteInstance())); entry->SetHasPostData(params.is_post); @@ -1248,7 +1251,8 @@ void NavigationControllerImpl::NavigateToPendingEntry(ReloadType reload_type) { // navigations to restored entries in TabContents::OnGoToEntryAtOffset. if (pending_entry_ && !pending_entry_->site_instance() && pending_entry_->restore_type() != NavigationEntryImpl::RESTORE_NONE) { - pending_entry_->set_site_instance(tab_contents_->GetPendingSiteInstance()); + pending_entry_->set_site_instance(static_cast<SiteInstanceImpl*>( + tab_contents_->GetPendingSiteInstance())); pending_entry_->set_restore_type(NavigationEntryImpl::RESTORE_NONE); } } diff --git a/content/browser/tab_contents/navigation_controller_impl.h b/content/browser/tab_contents/navigation_controller_impl.h index b8567f2..6c41b7e 100644 --- a/content/browser/tab_contents/navigation_controller_impl.h +++ b/content/browser/tab_contents/navigation_controller_impl.h @@ -14,13 +14,13 @@ #include "content/public/browser/navigation_controller.h" #include "content/public/browser/navigation_type.h" -class SiteInstance; class TabContents; struct ViewHostMsg_FrameNavigate_Params; namespace content { class NavigationEntryImpl; struct LoadCommittedDetails; +class SiteInstance; } class CONTENT_EXPORT NavigationControllerImpl @@ -100,13 +100,14 @@ class CONTENT_EXPORT NavigationControllerImpl // Return the index of the entry with the corresponding instance and page_id, // or -1 if not found. - int GetEntryIndexWithPageID(SiteInstance* instance, + int GetEntryIndexWithPageID(content::SiteInstance* instance, int32 page_id) const; // Return the entry with the corresponding instance and page_id, or NULL if // not found. - content::NavigationEntryImpl* GetEntryWithPageID(SiteInstance* instance, - int32 page_id) const; + content::NavigationEntryImpl* GetEntryWithPageID( + content::SiteInstance* instance, + int32 page_id) const; // Transient entry ----------------------------------------------------------- diff --git a/content/browser/tab_contents/navigation_controller_impl_unittest.cc b/content/browser/tab_contents/navigation_controller_impl_unittest.cc index 340a19d..c99e5a5 100644 --- a/content/browser/tab_contents/navigation_controller_impl_unittest.cc +++ b/content/browser/tab_contents/navigation_controller_impl_unittest.cc @@ -17,7 +17,7 @@ // #include "chrome/browser/sessions/session_service_test_helper.h" // #include "chrome/browser/sessions/session_types.h" #include "content/browser/renderer_host/test_render_view_host.h" -#include "content/browser/site_instance.h" +#include "content/browser/site_instance_impl.h" #include "content/browser/tab_contents/navigation_controller_impl.h" #include "content/browser/tab_contents/navigation_entry_impl.h" #include "content/browser/tab_contents/tab_contents.h" @@ -37,6 +37,7 @@ using base::Time; using content::NavigationController; using content::NavigationEntry; using content::NavigationEntryImpl; +using content::SiteInstance; using content::WebContents; // NavigationControllerTest ---------------------------------------------------- @@ -760,8 +761,9 @@ TEST_F(NavigationControllerTest, Back_OtherBackPending) { // We know all the entries have the same site instance, so we can just grab // a random one for looking up other entries. - SiteInstance* site_instance = NavigationEntryImpl::FromNavigationEntry( - controller.GetLastCommittedEntry())->site_instance(); + SiteInstance* site_instance = + NavigationEntryImpl::FromNavigationEntry( + controller.GetLastCommittedEntry())->site_instance(); // That second URL should be the last committed and it should have gotten the // new title. @@ -1578,7 +1580,7 @@ TEST_F(NavigationControllerTest, RestoreNavigate) { EXPECT_EQ(url, NavigationEntryImpl::FromNavigationEntry( our_controller.GetLastCommittedEntry())->site_instance()-> - site()); + GetSite()); EXPECT_EQ(NavigationEntryImpl::RESTORE_NONE, NavigationEntryImpl::FromNavigationEntry( our_controller.GetEntryAtIndex(0))->restore_type()); @@ -1658,7 +1660,7 @@ TEST_F(NavigationControllerTest, RestoreNavigateAfterFailure) { EXPECT_EQ(url, NavigationEntryImpl::FromNavigationEntry( our_controller.GetLastCommittedEntry())->site_instance()-> - site()); + GetSite()); EXPECT_EQ(NavigationEntryImpl::RESTORE_NONE, NavigationEntryImpl::FromNavigationEntry( our_controller.GetEntryAtIndex(0))->restore_type()); diff --git a/content/browser/tab_contents/navigation_entry_impl.cc b/content/browser/tab_contents/navigation_entry_impl.cc index e0b924c..f9bc0f7 100644 --- a/content/browser/tab_contents/navigation_entry_impl.cc +++ b/content/browser/tab_contents/navigation_entry_impl.cc @@ -6,12 +6,13 @@ #include "base/string_util.h" #include "base/utf_string_conversions.h" -#include "content/browser/site_instance.h" #include "content/public/common/content_constants.h" #include "content/public/common/url_constants.h" #include "net/base/net_util.h" #include "ui/base/text/text_elider.h" +using content::SiteInstance; + // Use this to get a new unique ID for a NavigationEntry during construction. // The returned ID is guaranteed to be nonzero (which is the "no ID" indicator). static int GetUniqueIDInConstructor() { @@ -46,7 +47,7 @@ NavigationEntryImpl::NavigationEntryImpl() is_renderer_initiated_(false) { } -NavigationEntryImpl::NavigationEntryImpl(SiteInstance* instance, +NavigationEntryImpl::NavigationEntryImpl(SiteInstanceImpl* instance, int page_id, const GURL& url, const Referrer& referrer, @@ -129,7 +130,7 @@ int32 NavigationEntryImpl::GetPageID() const { return page_id_; } -void NavigationEntryImpl::set_site_instance(SiteInstance* site_instance) { +void NavigationEntryImpl::set_site_instance(SiteInstanceImpl* site_instance) { site_instance_ = site_instance; } diff --git a/content/browser/tab_contents/navigation_entry_impl.h b/content/browser/tab_contents/navigation_entry_impl.h index c1c52e5..6d91e4b 100644 --- a/content/browser/tab_contents/navigation_entry_impl.h +++ b/content/browser/tab_contents/navigation_entry_impl.h @@ -8,13 +8,12 @@ #include "base/basictypes.h" #include "base/memory/ref_counted.h" +#include "content/browser/site_instance_impl.h" #include "content/public/browser/favicon_status.h" #include "content/public/browser/global_request_id.h" #include "content/public/browser/navigation_entry.h" #include "content/public/browser/ssl_status.h" -class SiteInstance; - namespace content { class CONTENT_EXPORT NavigationEntryImpl @@ -23,7 +22,7 @@ class CONTENT_EXPORT NavigationEntryImpl static NavigationEntryImpl* FromNavigationEntry(NavigationEntry* entry); NavigationEntryImpl(); - NavigationEntryImpl(SiteInstance* instance, + NavigationEntryImpl(SiteInstanceImpl* instance, int page_id, const GURL& url, const Referrer& referrer, @@ -71,9 +70,9 @@ class CONTENT_EXPORT NavigationEntryImpl // Note that the SiteInstance should usually not be changed after it is set, // but this may happen if the NavigationEntry was cloned and needs to use a // different SiteInstance. - void set_site_instance(SiteInstance* site_instance); - SiteInstance* site_instance() const { - return site_instance_; + void set_site_instance(SiteInstanceImpl* site_instance); + SiteInstanceImpl* site_instance() const { + return site_instance_.get(); } void set_page_type(PageType page_type) { @@ -152,7 +151,7 @@ class CONTENT_EXPORT NavigationEntryImpl // See the accessors above for descriptions. int unique_id_; - scoped_refptr<SiteInstance> site_instance_; + scoped_refptr<SiteInstanceImpl> site_instance_; PageType page_type_; GURL url_; Referrer referrer_; diff --git a/content/browser/tab_contents/navigation_entry_impl_unittest.cc b/content/browser/tab_contents/navigation_entry_impl_unittest.cc index dc8d9e9..425b45b 100644 --- a/content/browser/tab_contents/navigation_entry_impl_unittest.cc +++ b/content/browser/tab_contents/navigation_entry_impl_unittest.cc @@ -5,7 +5,7 @@ #include "base/string16.h" #include "base/string_util.h" #include "base/utf_string_conversions.h" -#include "content/browser/site_instance.h" +#include "content/browser/site_instance_impl.h" #include "content/browser/tab_contents/navigation_entry_impl.h" #include "content/public/browser/ssl_status.h" #include "testing/gtest/include/gtest/gtest.h" @@ -20,7 +20,7 @@ class NavigationEntryTest : public testing::Test { virtual void SetUp() { entry1_.reset(new NavigationEntryImpl); - instance_ = SiteInstance::CreateSiteInstance(NULL); + instance_ = static_cast<SiteInstanceImpl*>(SiteInstance::Create(NULL)); entry2_.reset(new NavigationEntryImpl( instance_, 3, GURL("test:url"), @@ -37,7 +37,7 @@ class NavigationEntryTest : public testing::Test { scoped_ptr<NavigationEntryImpl> entry1_; scoped_ptr<NavigationEntryImpl> entry2_; // SiteInstances are deleted when their NavigationEntries are gone. - SiteInstance* instance_; + SiteInstanceImpl* instance_; }; // Test unique ID accessors diff --git a/content/browser/tab_contents/render_view_host_manager.cc b/content/browser/tab_contents/render_view_host_manager.cc index f2ea2ae..caaad5e 100644 --- a/content/browser/tab_contents/render_view_host_manager.cc +++ b/content/browser/tab_contents/render_view_host_manager.cc @@ -12,7 +12,7 @@ #include "content/browser/renderer_host/render_view_host.h" #include "content/browser/renderer_host/render_view_host_factory.h" #include "content/browser/renderer_host/render_widget_host_view.h" -#include "content/browser/site_instance.h" +#include "content/browser/site_instance_impl.h" #include "content/browser/tab_contents/navigation_controller_impl.h" #include "content/browser/tab_contents/navigation_entry_impl.h" #include "content/browser/webui/web_ui_impl.h" @@ -30,6 +30,7 @@ using content::NavigationController; using content::NavigationEntry; using content::NavigationEntryImpl; +using content::SiteInstance; RenderViewHostManager::RenderViewHostManager( content::RenderViewHostDelegate* render_view_delegate, @@ -66,7 +67,7 @@ void RenderViewHostManager::Init(content::BrowserContext* browser_context, // immediately give this SiteInstance to a RenderViewHost so that it is // ref counted. if (!site_instance) - site_instance = SiteInstance::CreateSiteInstance(browser_context); + site_instance = SiteInstance::Create(browser_context); render_view_host_ = RenderViewHostFactory::Create( site_instance, render_view_delegate_, routing_id, delegate_-> GetControllerForRenderManager().GetSessionStorageNamespace()); @@ -345,7 +346,7 @@ bool RenderViewHostManager::ShouldSwapProcessesForNavigation( // page and one isn't. If there's no cur_entry, check the current RVH's // site, which might already be committed to a Web UI URL (such as the NTP). const GURL& current_url = (cur_entry) ? cur_entry->GetURL() : - render_view_host_->site_instance()->site(); + render_view_host_->site_instance()->GetSite(); content::BrowserContext* browser_context = delegate_->GetControllerForRenderManager().GetBrowserContext(); const content::WebUIFactory* web_ui_factory = @@ -407,26 +408,29 @@ SiteInstance* RenderViewHostManager::GetSiteInstanceForEntry( entry.GetTransitionType() == content::PAGE_TRANSITION_GENERATED) return curr_instance; + SiteInstanceImpl* curr_site_instance = + static_cast<SiteInstanceImpl*>(curr_instance); + // If we haven't used our SiteInstance (and thus RVH) yet, then we can use it // for this entry. We won't commit the SiteInstance to this site until the // navigation commits (in DidNavigate), unless the navigation entry was // restored or it's a Web UI as described below. - if (!curr_instance->has_site()) { + if (!curr_site_instance->HasSite()) { // If we've already created a SiteInstance for our destination, we don't // want to use this unused SiteInstance; use the existing one. (We don't // do this check if the curr_instance has a site, because for now, we want // to compare against the current URL and not the SiteInstance's site. In // this case, there is no current URL, so comparing against the site is ok. // See additional comments below.) - if (curr_instance->HasRelatedSiteInstance(dest_url)) - return curr_instance->GetRelatedSiteInstance(dest_url); + if (curr_site_instance->HasRelatedSiteInstance(dest_url)) + return curr_site_instance->GetRelatedSiteInstance(dest_url); // For extensions, Web UI URLs (such as the new tab page), and apps we do // not want to use the curr_instance if it has no site, since it will have a // RenderProcessHost of PRIV_NORMAL. Create a new SiteInstance for this // URL instead (with the correct process type). - if (curr_instance->HasWrongProcessForURL(dest_url)) - return curr_instance->GetRelatedSiteInstance(dest_url); + if (curr_site_instance->HasWrongProcessForURL(dest_url)) + return curr_site_instance->GetRelatedSiteInstance(dest_url); // Normally the "site" on the SiteInstance is set lazily when the load // actually commits. This is to support better process sharing in case @@ -437,9 +441,9 @@ SiteInstance* RenderViewHostManager::GetSiteInstanceForEntry( // we need to set the site first, otherwise after a restore none of the // pages would share renderers in process-per-site. if (entry.restore_type() != NavigationEntryImpl::RESTORE_NONE) - curr_instance->SetSite(dest_url); + curr_site_instance->SetSite(dest_url); - return curr_instance; + return curr_site_instance; } // Otherwise, only create a new SiteInstance for cross-site navigation. @@ -469,13 +473,14 @@ SiteInstance* RenderViewHostManager::GetSiteInstanceForEntry( // the page to a different same-site URL. (This seems very unlikely in // practice.) const GURL& current_url = (curr_entry) ? curr_entry->GetURL() : - curr_instance->site(); + curr_instance->GetSite(); // Use the current SiteInstance for same site navigations, as long as the // process type is correct. (The URL may have been installed as an app since // the last time we visited it.) if (SiteInstance::IsSameWebSite(browser_context, current_url, dest_url) && - !curr_instance->HasWrongProcessForURL(dest_url)) { + !static_cast<SiteInstanceImpl*>(curr_instance)->HasWrongProcessForURL( + dest_url)) { return curr_instance; } else if (ShouldSwapProcessesForNavigation(curr_entry, &entry)) { // When we're swapping, we need to force the site instance AND browsing @@ -484,7 +489,7 @@ SiteInstance* RenderViewHostManager::GetSiteInstanceForEntry( // Pages), keeping them in the same process. When you navigate away from // that page, we want to explicity ignore that BrowsingInstance and group // this page into the appropriate SiteInstance for its URL. - return SiteInstance::CreateSiteInstanceForURL(browser_context, dest_url); + return SiteInstance::CreateForURL(browser_context, dest_url); } else { // Start the new renderer in a new SiteInstance, but in the current // BrowsingInstance. It is important to immediately give this new @@ -496,7 +501,7 @@ SiteInstance* RenderViewHostManager::GetSiteInstanceForEntry( } bool RenderViewHostManager::CreatePendingRenderView( - const NavigationEntryImpl& entry, SiteInstance* instance) { + const NavigationEntryImpl& entry, SiteInstance* instance) { NavigationEntry* curr_entry = delegate_->GetControllerForRenderManager().GetLastCommittedEntry(); if (curr_entry) { @@ -508,7 +513,7 @@ bool RenderViewHostManager::CreatePendingRenderView( // Check if we've already created an RVH for this SiteInstance. CHECK(instance); RenderViewHostMap::iterator iter = - swapped_out_hosts_.find(instance->id()); + swapped_out_hosts_.find(instance->GetId()); if (iter != swapped_out_hosts_.end()) { // Re-use the existing RenderViewHost, which has already been initialized. // We'll remove it from the list of swapped out hosts if it commits. @@ -613,7 +618,7 @@ void RenderViewHostManager::CommitPending() { content::Details<std::pair<RenderViewHost*, RenderViewHost*> >(&details)); // If the pending view was on the swapped out list, we can remove it. - swapped_out_hosts_.erase(render_view_host_->site_instance()->id()); + swapped_out_hosts_.erase(render_view_host_->site_instance()->GetId()); // If the old RVH is live, we are swapping it out and should keep track of it // in case we navigate back to it. @@ -623,7 +628,7 @@ void RenderViewHostManager::CommitPending() { // sure we don't get different rvh instances for the same site instance // in the same rvhmgr. // TODO(creis): Clean this up. - int32 old_site_instance_id = old_render_view_host->site_instance()->id(); + int32 old_site_instance_id = old_render_view_host->site_instance()->GetId(); RenderViewHostMap::iterator iter = swapped_out_hosts_.find(old_site_instance_id); if (iter != swapped_out_hosts_.end() && @@ -815,6 +820,6 @@ bool RenderViewHostManager::IsSwappedOut(RenderViewHost* rvh) { if (!rvh->site_instance()) return false; - return swapped_out_hosts_.find(rvh->site_instance()->id()) != + return swapped_out_hosts_.find(rvh->site_instance()->GetId()) != swapped_out_hosts_.end(); } diff --git a/content/browser/tab_contents/render_view_host_manager.h b/content/browser/tab_contents/render_view_host_manager.h index ae15dca..027e2ce 100644 --- a/content/browser/tab_contents/render_view_host_manager.h +++ b/content/browser/tab_contents/render_view_host_manager.h @@ -9,7 +9,7 @@ #include "base/basictypes.h" #include "base/logging.h" #include "base/memory/scoped_ptr.h" -#include "content/browser/site_instance.h" +#include "content/browser/site_instance_impl.h" #include "content/common/content_export.h" #include "content/public/browser/notification_observer.h" #include "content/public/browser/notification_registrar.h" @@ -101,7 +101,7 @@ class CONTENT_EXPORT RenderViewHostManager // For arguments, see TabContents constructor. void Init(content::BrowserContext* browser_context, - SiteInstance* site_instance, + content::SiteInstance* site_instance, int routing_id); // Returns the currently active RenderViewHost. @@ -220,14 +220,14 @@ class CONTENT_EXPORT RenderViewHostManager // Returns an appropriate SiteInstance object for the given NavigationEntry, // possibly reusing the current SiteInstance. // Never called if --process-per-tab is used. - SiteInstance* GetSiteInstanceForEntry( + content::SiteInstance* GetSiteInstanceForEntry( const content::NavigationEntryImpl& entry, - SiteInstance* curr_instance); + content::SiteInstance* curr_instance); // Helper method to create a pending RenderViewHost for a cross-site // navigation. bool CreatePendingRenderView(const content::NavigationEntryImpl& entry, - SiteInstance* instance); + content::SiteInstance* instance); // Sets up the necessary state for a new RenderViewHost navigating to the // given entry. diff --git a/content/browser/tab_contents/render_view_host_manager_unittest.cc b/content/browser/tab_contents/render_view_host_manager_unittest.cc index b7f1463..0891743 100644 --- a/content/browser/tab_contents/render_view_host_manager_unittest.cc +++ b/content/browser/tab_contents/render_view_host_manager_unittest.cc @@ -6,7 +6,7 @@ #include "content/browser/browser_url_handler.h" #include "content/browser/mock_content_browser_client.h" #include "content/browser/renderer_host/test_render_view_host.h" -#include "content/browser/site_instance.h" +#include "content/browser/site_instance_impl.h" #include "content/browser/tab_contents/navigation_controller_impl.h" #include "content/browser/tab_contents/navigation_entry_impl.h" #include "content/browser/tab_contents/render_view_host_manager.h" @@ -31,6 +31,7 @@ using content::BrowserThreadImpl; using content::NavigationController; using content::NavigationEntry; using content::NavigationEntryImpl; +using content::SiteInstance; using content::WebContents; using content::WebUIController; @@ -198,8 +199,10 @@ TEST_F(RenderViewHostManagerTest, NewTabPageProcesses) { // The two RVH's should be different in every way. EXPECT_NE(active_rvh()->process(), dest_rvh2->process()); EXPECT_NE(active_rvh()->site_instance(), dest_rvh2->site_instance()); - EXPECT_NE(active_rvh()->site_instance()->browsing_instance_, - dest_rvh2->site_instance()->browsing_instance_); + EXPECT_NE(static_cast<SiteInstanceImpl*>(active_rvh()->site_instance())-> + browsing_instance_, + static_cast<SiteInstanceImpl*>(dest_rvh2->site_instance())-> + browsing_instance_); // Navigate both to the new tab page, and verify that they share a // SiteInstance. @@ -272,8 +275,9 @@ TEST_F(RenderViewHostManagerTest, AlwaysSendEnableViewSourceMode) { // Tests the Init function by checking the initial RenderViewHost. TEST_F(RenderViewHostManagerTest, Init) { // Using TestBrowserContext. - SiteInstance* instance = SiteInstance::CreateSiteInstance(browser_context()); - EXPECT_FALSE(instance->has_site()); + SiteInstanceImpl* instance = + static_cast<SiteInstanceImpl*>(SiteInstance::Create(browser_context())); + EXPECT_FALSE(instance->HasSite()); TestTabContents tab_contents(browser_context(), instance); RenderViewHostManager manager(&tab_contents, &tab_contents); @@ -293,7 +297,7 @@ TEST_F(RenderViewHostManagerTest, Init) { TEST_F(RenderViewHostManagerTest, Navigate) { TestNotificationTracker notifications; - SiteInstance* instance = SiteInstance::CreateSiteInstance(browser_context()); + SiteInstance* instance = SiteInstance::Create(browser_context()); TestTabContents tab_contents(browser_context(), instance); notifications.ListenFor( @@ -325,8 +329,9 @@ TEST_F(RenderViewHostManagerTest, Navigate) { // Commit to SiteInstance should be delayed until RenderView commit. EXPECT_TRUE(host == manager.current_host()); ASSERT_TRUE(host); - EXPECT_FALSE(host->site_instance()->has_site()); - host->site_instance()->SetSite(kUrl1); + EXPECT_FALSE(static_cast<SiteInstanceImpl*>(host->site_instance())-> + HasSite()); + static_cast<SiteInstanceImpl*>(host->site_instance())->SetSite(kUrl1); // 2) Navigate to next site. ------------------------- const GURL kUrl2("http://www.google.com/foo"); @@ -345,7 +350,8 @@ TEST_F(RenderViewHostManagerTest, Navigate) { manager.DidNavigateMainFrame(host); EXPECT_TRUE(host == manager.current_host()); ASSERT_TRUE(host); - EXPECT_TRUE(host->site_instance()->has_site()); + EXPECT_TRUE(static_cast<SiteInstanceImpl*>(host->site_instance())-> + HasSite()); // 3) Cross-site navigate to next site. -------------- const GURL kUrl3("http://webkit.org/"); @@ -366,7 +372,8 @@ TEST_F(RenderViewHostManagerTest, Navigate) { manager.DidNavigateMainFrame(manager.pending_render_view_host()); EXPECT_TRUE(host == manager.current_host()); ASSERT_TRUE(host); - EXPECT_TRUE(host->site_instance()->has_site()); + EXPECT_TRUE(static_cast<SiteInstanceImpl*>(host->site_instance())-> + HasSite()); // Check the pending RenderViewHost has been committed. EXPECT_FALSE(manager.pending_render_view_host()); @@ -382,7 +389,7 @@ TEST_F(RenderViewHostManagerTest, Navigate) { TEST_F(RenderViewHostManagerTest, NavigateWithEarlyReNavigation) { TestNotificationTracker notifications; - SiteInstance* instance = SiteInstance::CreateSiteInstance(browser_context()); + SiteInstance* instance = SiteInstance::Create(browser_context()); TestTabContents tab_contents(browser_context(), instance); notifications.ListenFor( @@ -418,8 +425,9 @@ TEST_F(RenderViewHostManagerTest, NavigateWithEarlyReNavigation) { // Commit to SiteInstance should be delayed until RenderView commit. EXPECT_TRUE(host == manager.current_host()); ASSERT_TRUE(host); - EXPECT_FALSE(host->site_instance()->has_site()); - host->site_instance()->SetSite(kUrl1); + EXPECT_FALSE(static_cast<SiteInstanceImpl*>(host->site_instance())-> + HasSite()); + static_cast<SiteInstanceImpl*>(host->site_instance())->SetSite(kUrl1); // 2) Cross-site navigate to next site. ------------------------- const GURL kUrl2("http://www.example.com"); @@ -502,7 +510,8 @@ TEST_F(RenderViewHostManagerTest, NavigateWithEarlyReNavigation) { manager.DidNavigateMainFrame(host3); EXPECT_TRUE(host3 == manager.current_host()); ASSERT_TRUE(host3); - EXPECT_TRUE(host3->site_instance()->has_site()); + EXPECT_TRUE(static_cast<SiteInstanceImpl*>(host3->site_instance())-> + HasSite()); // Check the pending RenderViewHost has been committed. EXPECT_FALSE(manager.pending_render_view_host()); @@ -515,7 +524,7 @@ TEST_F(RenderViewHostManagerTest, NavigateWithEarlyReNavigation) { TEST_F(RenderViewHostManagerTest, WebUI) { set_should_create_webui(true); BrowserThreadImpl ui_thread(BrowserThread::UI, MessageLoop::current()); - SiteInstance* instance = SiteInstance::CreateSiteInstance(browser_context()); + SiteInstance* instance = SiteInstance::Create(browser_context()); TestTabContents tab_contents(browser_context(), instance); RenderViewHostManager manager(&tab_contents, &tab_contents); @@ -537,8 +546,9 @@ TEST_F(RenderViewHostManagerTest, WebUI) { // as the navigation starts, rather than lazily after it commits, so we don't // try to re-use the SiteInstance/process for non DOM-UI things that may // get loaded in between. - EXPECT_TRUE(host->site_instance()->has_site()); - EXPECT_EQ(kUrl, host->site_instance()->site()); + EXPECT_TRUE(static_cast<SiteInstanceImpl*>(host->site_instance())-> + HasSite()); + EXPECT_EQ(kUrl, host->site_instance()->GetSite()); // The Web UI is committed immediately because the RenderViewHost has not been // used yet. UpdateRendererStateForNavigate() took the short cut path. @@ -555,7 +565,7 @@ TEST_F(RenderViewHostManagerTest, WebUI) { // Regression test for bug 46290. TEST_F(RenderViewHostManagerTest, NonWebUIChromeURLs) { BrowserThreadImpl thread(BrowserThread::UI, &message_loop_); - SiteInstance* instance = SiteInstance::CreateSiteInstance(browser_context()); + SiteInstance* instance = SiteInstance::Create(browser_context()); TestTabContents tab_contents(browser_context(), instance); RenderViewHostManager manager(&tab_contents, &tab_contents); manager.Init(browser_context(), instance, MSG_ROUTING_NONE); diff --git a/content/browser/tab_contents/tab_contents.cc b/content/browser/tab_contents/tab_contents.cc index 073c6e7..b6c4e85 100644 --- a/content/browser/tab_contents/tab_contents.cc +++ b/content/browser/tab_contents/tab_contents.cc @@ -27,7 +27,7 @@ #include "content/browser/renderer_host/render_widget_host_view.h" #include "content/browser/renderer_host/resource_dispatcher_host.h" #include "content/browser/renderer_host/resource_request_details.h" -#include "content/browser/site_instance.h" +#include "content/browser/site_instance_impl.h" #include "content/browser/tab_contents/interstitial_page.h" #include "content/browser/tab_contents/navigation_entry_impl.h" #include "content/browser/tab_contents/provisional_load_details.h" @@ -121,6 +121,7 @@ using content::NavigationEntry; using content::NavigationEntryImpl; using content::OpenURLParams; using content::RenderViewHostDelegate; +using content::SiteInstance; using content::SSLStatus; using content::UserMetricsAction; using content::WebContents; @@ -504,20 +505,20 @@ int32 TabContents::GetMaxPageID() { } int32 TabContents::GetMaxPageIDForSiteInstance(SiteInstance* site_instance) { - if (max_page_ids_.find(site_instance->id()) == max_page_ids_.end()) - max_page_ids_[site_instance->id()] = -1; + if (max_page_ids_.find(site_instance->GetId()) == max_page_ids_.end()) + max_page_ids_[site_instance->GetId()] = -1; - return max_page_ids_[site_instance->id()]; + return max_page_ids_[site_instance->GetId()]; } void TabContents::UpdateMaxPageID(int32 page_id) { UpdateMaxPageIDForSiteInstance(GetSiteInstance(), page_id); } -void TabContents::UpdateMaxPageIDForSiteInstance(SiteInstance* site_instance, - int32 page_id) { +void TabContents::UpdateMaxPageIDForSiteInstance( + SiteInstance* site_instance, int32 page_id) { if (GetMaxPageIDForSiteInstance(site_instance) < page_id) - max_page_ids_[site_instance->id()] = page_id; + max_page_ids_[site_instance->GetId()] = page_id; } void TabContents::CopyMaxPageIDsFrom(TabContents* tab_contents) { @@ -672,7 +673,7 @@ WebContents* TabContents::Clone() { // processes for some reason. TabContents* tc = new TabContents( GetBrowserContext(), - SiteInstance::CreateSiteInstance(GetBrowserContext()), + SiteInstance::Create(GetBrowserContext()), MSG_ROUTING_NONE, this, NULL); tc->GetControllerImpl().CopyStateFrom(controller_); return tc; @@ -878,9 +879,10 @@ bool TabContents::NavigateToEntry( return true; } -void TabContents::SetHistoryLengthAndPrune(const SiteInstance* site_instance, - int history_length, - int32 minimum_page_id) { +void TabContents::SetHistoryLengthAndPrune( + const SiteInstance* site_instance, + int history_length, + int32 minimum_page_id) { // SetHistoryLengthAndPrune doesn't work when there are pending cross-site // navigations. Callers should ensure that this is the case. if (render_manager_.pending_render_view_host()) { @@ -1396,7 +1398,8 @@ void TabContents::OnGoToEntryAtOffset(int offset) { // it in now that we know. This allows us to find the entry when it commits. if (!entry->site_instance() && entry->restore_type() != NavigationEntryImpl::RESTORE_NONE) { - entry->set_site_instance(GetPendingSiteInstance()); + entry->set_site_instance( + static_cast<SiteInstanceImpl*>(GetPendingSiteInstance())); } } } @@ -1735,8 +1738,8 @@ void TabContents::DidNavigate(RenderViewHost* rvh, render_manager_.DidNavigateMainFrame(rvh); // Update the site of the SiteInstance if it doesn't have one yet. - if (!GetSiteInstance()->has_site()) - GetSiteInstance()->SetSite(params.url); + if (!static_cast<SiteInstanceImpl*>(GetSiteInstance())->HasSite()) + static_cast<SiteInstanceImpl*>(GetSiteInstance())->SetSite(params.url); // Need to update MIME type here because it's referred to in // UpdateNavigationCommands() called by RendererDidNavigate() to diff --git a/content/browser/tab_contents/tab_contents.h b/content/browser/tab_contents/tab_contents.h index 16d486b..5dda23e 100644 --- a/content/browser/tab_contents/tab_contents.h +++ b/content/browser/tab_contents/tab_contents.h @@ -35,11 +35,11 @@ class LoadNotificationDetails; class RenderViewHost; class SavePackage; class SessionStorageNamespace; -class SiteInstance; struct ViewHostMsg_DidFailProvisionalLoadWithError_Params; namespace content { class DownloadItem; +class SiteInstance; class WebContentsObserver; class WebContentsDelegate; class WebContentsView; @@ -57,7 +57,7 @@ class CONTENT_EXPORT TabContents public: // See WebContents::Create for a description of these parameters. TabContents(content::BrowserContext* browser_context, - SiteInstance* site_instance, + content::SiteInstance* site_instance, int routing_id, const TabContents* base_tab_contents, SessionStorageNamespace* session_storage_namespace); @@ -72,7 +72,7 @@ class CONTENT_EXPORT TabContents // Updates the max page ID for the given SiteInstance in this TabContents // to be at least |page_id|. - void UpdateMaxPageIDForSiteInstance(SiteInstance* site_instance, + void UpdateMaxPageIDForSiteInstance(content::SiteInstance* site_instance, int32 page_id); // Copy the current map of SiteInstance ID to max page ID from another tab. @@ -140,9 +140,9 @@ class CONTENT_EXPORT TabContents virtual const string16& GetTitle() const OVERRIDE; virtual int32 GetMaxPageID() OVERRIDE; virtual int32 GetMaxPageIDForSiteInstance( - SiteInstance* site_instance) OVERRIDE; - virtual SiteInstance* GetSiteInstance() const OVERRIDE; - virtual SiteInstance* GetPendingSiteInstance() const OVERRIDE; + content::SiteInstance* site_instance) OVERRIDE; + virtual content::SiteInstance* GetSiteInstance() const OVERRIDE; + virtual content::SiteInstance* GetPendingSiteInstance() const OVERRIDE; virtual bool IsLoading() const OVERRIDE; virtual bool IsWaitingForResponse() const OVERRIDE; virtual const net::LoadStateWithParam& GetLoadState() const OVERRIDE; @@ -484,9 +484,10 @@ class CONTENT_EXPORT TabContents // moves the current page_id to the last entry in the list if it's valid. // This is mainly used when a prerendered page is swapped into the current // tab. The method is virtual for testing. - virtual void SetHistoryLengthAndPrune(const SiteInstance* site_instance, - int merge_history_length, - int32 minimum_page_id); + virtual void SetHistoryLengthAndPrune( + const content::SiteInstance* site_instance, + int merge_history_length, + int32 minimum_page_id); // Misc non-view stuff ------------------------------------------------------- diff --git a/content/browser/tab_contents/tab_contents_unittest.cc b/content/browser/tab_contents/tab_contents_unittest.cc index f9b98b0..d943c1f 100644 --- a/content/browser/tab_contents/tab_contents_unittest.cc +++ b/content/browser/tab_contents/tab_contents_unittest.cc @@ -8,7 +8,7 @@ #include "content/browser/renderer_host/render_view_host.h" #include "content/browser/renderer_host/render_widget_host_view.h" #include "content/browser/renderer_host/test_render_view_host.h" -#include "content/browser/site_instance.h" +#include "content/browser/site_instance_impl.h" #include "content/browser/tab_contents/interstitial_page.h" #include "content/browser/tab_contents/navigation_entry_impl.h" #include "content/browser/tab_contents/test_tab_contents.h" @@ -29,6 +29,7 @@ using content::BrowserThread; using content::NavigationEntry; using content::NavigationEntryImpl; +using content::SiteInstance; using content::WebContents; using content::WebUIController; using webkit::forms::PasswordForm; @@ -168,7 +169,7 @@ class TestInterstitialPage : public InterstitialPage { protected: virtual RenderViewHost* CreateRenderViewHost() { return new TestRenderViewHost( - SiteInstance::CreateSiteInstance(tab()->GetBrowserContext()), + SiteInstance::Create(tab()->GetBrowserContext()), this, MSG_ROUTING_NONE); } @@ -278,7 +279,7 @@ TEST_F(TabContentsTest, NTPViewSource) { // Test to ensure UpdateMaxPageID is working properly. TEST_F(TabContentsTest, UpdateMaxPageID) { SiteInstance* instance1 = contents()->GetSiteInstance(); - scoped_refptr<SiteInstance> instance2(SiteInstance::CreateSiteInstance(NULL)); + scoped_refptr<SiteInstance> instance2(SiteInstance::Create(NULL)); // Starts at -1. EXPECT_EQ(-1, contents()->GetMaxPageID()); diff --git a/content/browser/tab_contents/test_tab_contents.cc b/content/browser/tab_contents/test_tab_contents.cc index 0f3352d..bbced34 100644 --- a/content/browser/tab_contents/test_tab_contents.cc +++ b/content/browser/tab_contents/test_tab_contents.cc @@ -10,7 +10,7 @@ #include "content/browser/renderer_host/mock_render_process_host.h" #include "content/browser/renderer_host/render_view_host.h" #include "content/browser/renderer_host/test_render_view_host.h" -#include "content/browser/site_instance.h" +#include "content/browser/site_instance_impl.h" #include "content/browser/tab_contents/navigation_entry_impl.h" #include "content/common/view_messages.h" #include "content/public/common/page_transition_types.h" @@ -18,6 +18,7 @@ #include "webkit/forms/password_form.h" using content::NavigationEntry; +using content::SiteInstance; using content::WebContents; TestTabContents::TestTabContents(content::BrowserContext* browser_context, @@ -86,7 +87,7 @@ bool TestTabContents::CreateRenderViewForRenderManager( WebContents* TestTabContents::Clone() { TabContents* tc = new TestTabContents( GetBrowserContext(), - SiteInstance::CreateSiteInstance(GetBrowserContext())); + SiteInstance::Create(GetBrowserContext())); tc->GetControllerImpl().CopyStateFrom(controller_); return tc; } @@ -148,13 +149,15 @@ void TestTabContents::ExpectSetHistoryLengthAndPrune( int history_length, int32 min_page_id) { expect_set_history_length_and_prune_ = true; - expect_set_history_length_and_prune_site_instance_ = site_instance; + expect_set_history_length_and_prune_site_instance_ = + static_cast<const SiteInstanceImpl*>(site_instance); expect_set_history_length_and_prune_history_length_ = history_length; expect_set_history_length_and_prune_min_page_id_ = min_page_id; } void TestTabContents::SetHistoryLengthAndPrune( - const SiteInstance* site_instance, int history_length, int32 min_page_id) { + const SiteInstance* site_instance, int history_length, + int32 min_page_id) { EXPECT_TRUE(expect_set_history_length_and_prune_); expect_set_history_length_and_prune_ = false; EXPECT_EQ(expect_set_history_length_and_prune_site_instance_, site_instance); diff --git a/content/browser/tab_contents/test_tab_contents.h b/content/browser/tab_contents/test_tab_contents.h index f714f68..7f3a073 100644 --- a/content/browser/tab_contents/test_tab_contents.h +++ b/content/browser/tab_contents/test_tab_contents.h @@ -10,6 +10,7 @@ #include "content/public/common/page_transition_types.h" #include "webkit/glue/webpreferences.h" +class SiteInstanceImpl; class TestRenderViewHost; // Subclass TabContents to ensure it creates TestRenderViewHosts and does @@ -17,7 +18,7 @@ class TestRenderViewHost; class TestTabContents : public TabContents { public: TestTabContents(content::BrowserContext* browser_context, - SiteInstance* instance); + content::SiteInstance* instance); virtual ~TestTabContents(); TestRenderViewHost* pending_rvh() const; @@ -81,22 +82,24 @@ class TestTabContents : public TabContents { // Establish expected arguments for |SetHistoryLengthAndPrune()|. When // |SetHistoryLengthAndPrune()| is called, the arguments are compared // with the expected arguments specified here. - void ExpectSetHistoryLengthAndPrune(const SiteInstance* site_instance, - int history_length, - int32 min_page_id); + void ExpectSetHistoryLengthAndPrune( + const content::SiteInstance* site_instance, + int history_length, + int32 min_page_id); // Compares the arguments passed in with the expected arguments passed in // to |ExpectSetHistoryLengthAndPrune()|. - virtual void SetHistoryLengthAndPrune(const SiteInstance* site_instance, - int history_length, - int32 min_page_id) OVERRIDE; + virtual void SetHistoryLengthAndPrune( + const content::SiteInstance* site_instance, + int history_length, + int32 min_page_id) OVERRIDE; private: content::RenderViewHostDelegate::View* delegate_view_override_; // Expectations for arguments of |SetHistoryLengthAndPrune()|. bool expect_set_history_length_and_prune_; - scoped_refptr<const SiteInstance> + scoped_refptr<const SiteInstanceImpl> expect_set_history_length_and_prune_site_instance_; int expect_set_history_length_and_prune_history_length_; int32 expect_set_history_length_and_prune_min_page_id_; diff --git a/content/content_browser.gypi b/content/content_browser.gypi index e0ba6e8..efbb363 100644 --- a/content/content_browser.gypi +++ b/content/content_browser.gypi @@ -90,6 +90,7 @@ 'public/browser/save_page_type.h', 'public/browser/sensors.h', 'public/browser/sensors_listener.h', + 'public/browser/site_instance.h', 'public/browser/ssl_status.cc', 'public/browser/ssl_status.h', 'public/browser/user_metrics.h', @@ -575,8 +576,8 @@ 'browser/sensors/sensors_provider.h', 'browser/sensors/sensors_provider_impl.cc', 'browser/sensors/sensors_provider_impl.h', - 'browser/site_instance.cc', - 'browser/site_instance.h', + 'browser/site_instance_impl.cc', + 'browser/site_instance_impl.h', 'browser/speech/audio_encoder.cc', 'browser/speech/audio_encoder.h', 'browser/speech/endpointer/endpointer.cc', diff --git a/content/content_tests.gypi b/content/content_tests.gypi index 8870015..9d9cb53 100644 --- a/content/content_tests.gypi +++ b/content/content_tests.gypi @@ -243,7 +243,7 @@ 'browser/renderer_host/resource_queue_unittest.cc', 'browser/renderer_host/text_input_client_mac_unittest.mm', 'browser/resolve_proxy_msg_helper_unittest.cc', - 'browser/site_instance_unittest.cc', + 'browser/site_instance_impl_unittest.cc', 'browser/speech/endpointer/endpointer_unittest.cc', 'browser/speech/speech_recognition_request_unittest.cc', 'browser/speech/speech_recognizer_unittest.cc', diff --git a/content/public/browser/content_browser_client.h b/content/public/browser/content_browser_client.h index c83631b..d008bc0 100644 --- a/content/public/browser/content_browser_client.h +++ b/content/public/browser/content_browser_client.h @@ -23,7 +23,6 @@ class PluginProcessHost; class QuotaPermissionContext; class RenderViewHost; class ResourceDispatcherHost; -class SiteInstance; class SSLCertErrorHandler; class SSLClientAuthHandler; class SkBitmap; @@ -34,6 +33,7 @@ namespace content { class AccessTokenStore; class BrowserMainParts; class RenderProcessHost; +class SiteInstance; class WebContents; class WebContentsView; struct MainFunctionParams; @@ -123,10 +123,11 @@ class ContentBrowserClient { const GURL& site_url) = 0; // Called when a site instance is first associated with a process. - virtual void SiteInstanceGotProcess(SiteInstance* site_instance) = 0; + virtual void SiteInstanceGotProcess( + content::SiteInstance* site_instance) = 0; // Called from a site instance's destructor. - virtual void SiteInstanceDeleting(SiteInstance* site_instance) = 0; + virtual void SiteInstanceDeleting(content::SiteInstance* site_instance) = 0; // Returns true if for the navigation from |current_url| to |new_url|, // processes should be swapped (even if we are in a process model that diff --git a/content/browser/site_instance.h b/content/public/browser/site_instance.h index 2a40762..37c6201 100644 --- a/content/browser/site_instance.h +++ b/content/public/browser/site_instance.h @@ -2,26 +2,23 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CONTENT_BROWSER_RENDERER_HOST_SITE_INSTANCE_H_ -#define CONTENT_BROWSER_RENDERER_HOST_SITE_INSTANCE_H_ +#ifndef CONTENT_PUBLIC_BROWSER_SITE_INSTANCE_H_ +#define CONTENT_PUBLIC_BROWSER_SITE_INSTANCE_H_ #pragma once -#include "content/browser/renderer_host/render_process_host_impl.h" +#include "base/basictypes.h" +#include "base/memory/ref_counted.h" #include "content/common/content_export.h" -#include "content/public/browser/notification_observer.h" -#include "content/public/browser/notification_registrar.h" #include "googleurl/src/gurl.h" class BrowsingInstance; namespace content { class BrowserContext; -class RenderProcessHostFactory; -} +class RenderProcessHost; /////////////////////////////////////////////////////////////////////////////// -// -// SiteInstance class +// SiteInstance interface. // // A SiteInstance is a data structure that is associated with all pages in a // given instance of a web site. Here, a web site is identified by its @@ -53,43 +50,26 @@ class RenderProcessHostFactory; // tabs with no NavigationEntries or in NavigationEntries in the history. // /////////////////////////////////////////////////////////////////////////////// -class CONTENT_EXPORT SiteInstance : public base::RefCounted<SiteInstance>, - public content::NotificationObserver { +class CONTENT_EXPORT SiteInstance : public base::RefCounted<SiteInstance> { public: // Returns a unique ID for this SiteInstance. - int32 id() { return id_; } - - // Sets the factory used to create new RenderProcessHosts. This will also be - // passed on to SiteInstances spawned by this one. - // - // The factory must outlive the SiteInstance; ownership is not transferred. It - // may be NULL, in which case the default BrowserRenderProcessHost will be - // created (this is the behavior if you don't call this function). - void set_render_process_host_factory( - content::RenderProcessHostFactory* rph_factory) { - render_process_host_factory_ = rph_factory; - } + virtual int32 GetId() = 0; // Whether this SiteInstance has a running process associated with it. - bool HasProcess() const; + virtual bool HasProcess() const = 0; // Returns the current process being used to render pages in this // SiteInstance. If the process has crashed or otherwise gone away, then // this method will create a new process and update our host ID accordingly. - content::RenderProcessHost* GetProcess(); + virtual content::RenderProcessHost* GetProcess() = 0; - // Set / Get the web site that this SiteInstance is rendering pages for. - // This includes the scheme and registered domain, but not the port. If the - // URL does not have a valid registered domain, then the full hostname is - // stored. - void SetSite(const GURL& url); - const GURL& site() const { return site_; } - bool has_site() const { return has_site_; } + // Browser context to which this SiteInstance (and all related + // SiteInstances) belongs. + virtual content::BrowserContext* GetBrowserContext() const = 0; - // Returns whether there is currently a related SiteInstance (registered with - // BrowsingInstance) for the site of the given url. If so, we should try to - // avoid dedicating an unused SiteInstance to it (e.g., in a new tab). - bool HasRelatedSiteInstance(const GURL& url); + // Get the web site that this SiteInstance is rendering pages for. + // This includes the scheme and registered domain, but not the port. + virtual const GURL& GetSite() const = 0; // Gets a SiteInstance for the given URL that shares the current // BrowsingInstance, creating a new SiteInstance if necessary. This ensures @@ -100,16 +80,7 @@ class CONTENT_EXPORT SiteInstance : public base::RefCounted<SiteInstance>, // class from the rest of the codebase.) // TODO(creis): This may be an argument to build a pass_refptr<T> class, as // Darin suggests. - SiteInstance* GetRelatedSiteInstance(const GURL& url); - - // Returns whether this SiteInstance has a process that is the wrong type for - // the given URL. If so, the browser should force a process swap when - // navigating to the URL. - bool HasWrongProcessForURL(const GURL& url) const; - - // Browser context to which this SiteInstance (and all related - // SiteInstances) belongs. - content::BrowserContext* GetBrowserContext() const; + virtual SiteInstance* GetRelatedSiteInstance(const GURL& url) = 0; // Factory method to create a new SiteInstance. This will create a new // new BrowsingInstance, so it should only be used when creating a new tab @@ -120,20 +91,15 @@ class CONTENT_EXPORT SiteInstance : public base::RefCounted<SiteInstance>, // // TODO(creis): This may be an argument to build a pass_refptr<T> class, as // Darin suggests. - static SiteInstance* CreateSiteInstance( - content::BrowserContext* browser_context); + static SiteInstance* Create(content::BrowserContext* browser_context); // Factory method to get the appropriate SiteInstance for the given URL, in - // a new BrowsingInstance. Use this instead of CreateSiteInstance when you - // know the URL, since it allows special site grouping rules to be applied - // (for example, to group chrome-ui pages into the same instance). - static SiteInstance* CreateSiteInstanceForURL( + // a new BrowsingInstance. Use this instead of Create when you know the URL, + // since it allows special site grouping rules to be applied (for example, + // to group chrome-ui pages into the same instance). + static SiteInstance* CreateForURL( content::BrowserContext* browser_context, const GURL& url); - // Returns the site for the given URL, which includes only the scheme and - // registered domain. Returns an empty GURL if the URL has no host. - static GURL GetSiteForURL(content::BrowserContext* context, const GURL& url); - // Return whether both URLs are part of the same web site, for the purpose of // assigning them to processes accordingly. The decision is currently based // on the registered domain of the URLs (google.com, bbc.co.uk), as well as @@ -146,59 +112,11 @@ class CONTENT_EXPORT SiteInstance : public base::RefCounted<SiteInstance>, protected: friend class base::RefCounted<SiteInstance>; - friend class BrowsingInstance; - - // Virtual to allow tests to extend it. - virtual ~SiteInstance(); - - // Create a new SiteInstance. Protected to give access to BrowsingInstance - // and tests; most callers should use CreateSiteInstance or - // GetRelatedSiteInstance instead. - explicit SiteInstance(BrowsingInstance* browsing_instance); - - // Get the effective URL for the given actual URL. - static GURL GetEffectiveURL(content::BrowserContext* browser_context, - const GURL& url); - private: - // content::NotificationObserver implementation. - virtual void Observe(int type, - const content::NotificationSource& source, - const content::NotificationDetails& details) OVERRIDE; - - // Used to restrict a process' origin access rights. - void LockToOrigin(); - - // The next available SiteInstance ID. - static int32 next_site_instance_id_; - - // A unique ID for this SiteInstance. - int32 id_; - - content::NotificationRegistrar registrar_; - - // BrowsingInstance to which this SiteInstance belongs. - scoped_refptr<BrowsingInstance> browsing_instance_; - - // Factory for new RenderProcessHosts, not owned by this class. NULL indiactes - // that the default BrowserRenderProcessHost should be created. - const content::RenderProcessHostFactory* render_process_host_factory_; - - // Current RenderProcessHost that is rendering pages for this SiteInstance. - // This pointer will only change once the RenderProcessHost is destructed. It - // will still remain the same even if the process crashes, since in that - // scenario the RenderProcessHost remains the same. - content::RenderProcessHost* process_; - - // The web site that this SiteInstance is rendering pages for. - GURL site_; - - // Whether SetSite has been called. - bool has_site_; - - FRIEND_TEST_ALL_PREFIXES(RenderViewHostManagerTest, NewTabPageProcesses); - - DISALLOW_COPY_AND_ASSIGN(SiteInstance); + SiteInstance() {} + virtual ~SiteInstance() {} }; -#endif // CONTENT_BROWSER_RENDERER_HOST_SITE_INSTANCE_H_ +} // namespace content. + +#endif // CONTENT_PUBLIC_BROWSER_SITE_INSTANCE_H_ diff --git a/content/public/browser/web_contents.h b/content/public/browser/web_contents.h index 393f984..2811e1df 100644 --- a/content/public/browser/web_contents.h +++ b/content/public/browser/web_contents.h @@ -21,7 +21,6 @@ class InterstitialPage; class RenderViewHost; class RenderWidgetHostView; class SessionStorageNamespace; -class SiteInstance; namespace base { class PropertyBag; @@ -44,6 +43,7 @@ class NavigationController; class RenderProcessHost; class WebContentsDelegate; struct RendererPreferences; +class SiteInstance; struct SSLStatus; // TODO(jam): of course we will have to rename WebContentsView etc to use // WebContents. @@ -136,7 +136,8 @@ class WebContents : public PageNavigator { // The max page ID for any page that the given SiteInstance has loaded in // this TabContents. - virtual int32 GetMaxPageIDForSiteInstance(SiteInstance* site_instance) = 0; + virtual int32 GetMaxPageIDForSiteInstance( + SiteInstance* site_instance) = 0; // Returns the SiteInstance associated with the current page. virtual SiteInstance* GetSiteInstance() const = 0; diff --git a/content/shell/shell.h b/content/shell/shell.h index bb2d9f2..c4b09f7 100644 --- a/content/shell/shell.h +++ b/content/shell/shell.h @@ -23,12 +23,11 @@ typedef struct _GtkToolItem GtkToolItem; #endif class GURL; -class SiteInstance; class TabContents; namespace content { - class BrowserContext; +class SiteInstance; // This represents one window of the Content Shell, i.e. all the UI including // buttons and url bar, as well as the web content area. |