| Index: content/browser/site_instance_impl.cc
|
| ===================================================================
|
| --- content/browser/site_instance_impl.cc (revision 118703)
|
| +++ content/browser/site_instance_impl.cc (working copy)
|
| @@ -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"
|
| @@ -29,9 +29,9 @@
|
| 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 +43,26 @@
|
| 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<content::SiteInstance*>(this));
|
| }
|
|
|
| -bool SiteInstance::HasProcess() const {
|
| +int32 SiteInstanceImpl::GetId() {
|
| + return id_;
|
| +}
|
| +
|
| +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 +98,7 @@
|
| 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 +121,24 @@
|
| 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) {
|
| +content::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 +155,22 @@
|
| process_, browsing_instance_->browser_context(), site_url);
|
| }
|
|
|
| -content::BrowserContext* SiteInstance::GetBrowserContext() const {
|
| +content::BrowserContext* SiteInstanceImpl::GetBrowserContext() const {
|
| return browsing_instance_->browser_context();
|
| }
|
|
|
| +BrowsingInstance* SiteInstanceImpl::GetBrowsingInstance() const {
|
| + return browsing_instance_;
|
| +}
|
| +
|
| /*static*/
|
| -SiteInstance* SiteInstance::CreateSiteInstance(
|
| +content::SiteInstance* content::SiteInstance::CreateSiteInstance(
|
| content::BrowserContext* browser_context) {
|
| - return new SiteInstance(new BrowsingInstance(browser_context));
|
| + return new SiteInstanceImpl(new BrowsingInstance(browser_context));
|
| }
|
|
|
| /*static*/
|
| -SiteInstance* SiteInstance::CreateSiteInstanceForURL(
|
| +content::SiteInstance* content::SiteInstance::CreateSiteInstanceForURL(
|
| content::BrowserContext* browser_context, const GURL& url) {
|
| // This BrowsingInstance may be deleted if it returns an existing
|
| // SiteInstance.
|
| @@ -162,8 +180,8 @@
|
| }
|
|
|
| /*static*/
|
| -GURL SiteInstance::GetSiteForURL(content::BrowserContext* browser_context,
|
| - const GURL& real_url) {
|
| +GURL content::SiteInstance::GetSiteForURL(
|
| + content::BrowserContext* browser_context, const GURL& real_url) {
|
| GURL url = GetEffectiveURL(browser_context, real_url);
|
|
|
| // URLs with no host should have an empty site.
|
| @@ -198,8 +216,9 @@
|
| }
|
|
|
| /*static*/
|
| -bool SiteInstance::IsSameWebSite(content::BrowserContext* browser_context,
|
| - const GURL& real_url1, const GURL& real_url2) {
|
| +bool content::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);
|
|
|
| @@ -226,15 +245,15 @@
|
| }
|
|
|
| /*static*/
|
| -GURL SiteInstance::GetEffectiveURL(content::BrowserContext* browser_context,
|
| - const GURL& url) {
|
| +GURL content::SiteInstance::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 +261,7 @@
|
| process_ = NULL;
|
| }
|
|
|
| -void SiteInstance::LockToOrigin() {
|
| +void SiteInstanceImpl::LockToOrigin() {
|
| const CommandLine& command_line = *CommandLine::ForCurrentProcess();
|
| if (command_line.HasSwitch(switches::kEnableStrictSiteIsolation)) {
|
| ChildProcessSecurityPolicy* policy =
|
|
|