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

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: Fix up tests. Necessary rebase to obtain browsertest util behavior change. 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..69799a5c38374e305827f8d9db0d0c770f185994 100644
--- a/content/browser/browsing_instance.cc
+++ b/content/browser/browsing_instance.cc
@@ -7,6 +7,7 @@
#include "base/command_line.h"
#include "base/logging.h"
#include "content/browser/site_instance_impl.h"
+#include "content/common/site_isolation_policy.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/content_browser_client.h"
#include "content/public/common/content_switches.h"
@@ -36,7 +37,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 +45,31 @@ SiteInstance* BrowsingInstance::GetSiteInstanceForURL(const GURL& url) {
return instance;
}
+SiteInstance* BrowsingInstance::GetDefaultSubframeSiteInstance() {
+ // This should only be used for --top-document-isolation mode.
+ CHECK(SiteIsolationPolicy::IsTopDocumentIsolationEnabled());
+ 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"));
+ default_subframe_site_instance_ = instance;
+ }
+
+ return default_subframe_site_instance_;
+}
+
void BrowsingInstance::RegisterSiteInstance(SiteInstance* site_instance) {
DCHECK(static_cast<SiteInstanceImpl*>(site_instance)
dcheng 2016/03/29 08:09:16 Unrelated to this CL, but is there a reason Regist
ncarter (slow) 2016/03/29 16:28:33 Done locally, will upload with other reviewer fixe
ncarter (slow) 2016/03/29 23:30:57 Done.
->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 +99,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