Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(134)

Unified Diff: content/browser/browsing_instance.cc

Issue 1797363002: "Top Document Isolation" mode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add missing override Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/browsing_instance.cc
diff --git a/content/browser/browsing_instance.cc b/content/browser/browsing_instance.cc
index 1d5f8953769f92efbc770b3ca88331235d4d8002..7b93401b9e455508eda695b6da933e6dfd0c07df 100644
--- a/content/browser/browsing_instance.cc
+++ b/content/browser/browsing_instance.cc
@@ -36,7 +36,6 @@ SiteInstance* BrowsingInstance::GetSiteInstanceForURL(const GURL& url) {
if (i != site_instance_map_.end())
return i->second;
-
// No current SiteInstance for this site, so let's create one.
SiteInstanceImpl* instance = new SiteInstanceImpl(this);
@@ -45,11 +44,29 @@ SiteInstance* BrowsingInstance::GetSiteInstanceForURL(const GURL& url) {
return instance;
}
+SiteInstance* BrowsingInstance::GetDefaultSubframeSiteInstance() {
Charlie Reis 2016/03/25 19:47:12 Can we put a CHECK(IsTopDocumentIsolationEnabled()
ncarter (slow) 2016/03/28 22:00:28 I made this the stricter variant, CHECK(IsTopDocum
Charlie Reis 2016/03/29 17:17:12 Acknowledged.
+ if (!default_subframe_site_instance_) {
+ SiteInstanceImpl* instance = new SiteInstanceImpl(this);
+ instance->set_is_default_subframe_site_instance();
+ // TODO(nick): This is a hack for now.
+ instance->SetSite(GURL("http://web-subframes.invalid"));
Charlie Reis 2016/03/25 19:47:12 Yeah, we can chat about what to put here long term
ncarter (slow) 2016/03/28 22:00:28 If we rip this out now, the PopupAndRedirection te
+ default_subframe_site_instance_ = instance;
+ }
+
+ return default_subframe_site_instance_;
+}
+
void BrowsingInstance::RegisterSiteInstance(SiteInstance* site_instance) {
DCHECK(static_cast<SiteInstanceImpl*>(site_instance)
->browsing_instance_.get() ==
this);
DCHECK(static_cast<SiteInstanceImpl*>(site_instance)->HasSite());
+
+ // Don't register the default subframe SiteInstance, to prevent it from being
+ // returned by GetSiteInstanceForURL.
+ if (default_subframe_site_instance_ == site_instance)
+ return;
+
std::string site = site_instance->GetSiteURL().possibly_invalid_spec();
// Only register if we don't have a SiteInstance for this site already.
@@ -79,6 +96,8 @@ void BrowsingInstance::UnregisterSiteInstance(SiteInstance* site_instance) {
// Matches, so erase it.
site_instance_map_.erase(i);
}
+ if (default_subframe_site_instance_ == site_instance)
+ default_subframe_site_instance_ = nullptr;
}
BrowsingInstance::~BrowsingInstance() {

Powered by Google App Engine
This is Rietveld 408576698