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

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: Suppress tests under --site-per-process 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
« no previous file with comments | « content/browser/browsing_instance.h ('k') | content/browser/frame_host/navigator_impl_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/browsing_instance.cc
diff --git a/content/browser/browsing_instance.cc b/content/browser/browsing_instance.cc
index b68a87ccbf69d65c171a5390f3833c7b98cf1ca2..5dd0ca4191fe832c5d4eea078c9cab946a8d397b 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"
@@ -44,9 +45,32 @@ scoped_refptr<SiteInstanceImpl> BrowsingInstance::GetSiteInstanceForURL(
return instance;
}
+scoped_refptr<SiteInstanceImpl>
+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 make_scoped_refptr(default_subframe_site_instance_);
+}
+
void BrowsingInstance::RegisterSiteInstance(SiteInstanceImpl* site_instance) {
DCHECK(site_instance->browsing_instance_.get() == this);
DCHECK(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.
@@ -74,6 +98,8 @@ void BrowsingInstance::UnregisterSiteInstance(SiteInstanceImpl* 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() {
« no previous file with comments | « content/browser/browsing_instance.h ('k') | content/browser/frame_host/navigator_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698