blob: 420a4382eaff95fbd43b98250b04c869bba9a885 [file] [log] [blame]
[email protected]144a8102012-01-14 01:05:311// Copyright (c) 2012 The Chromium Authors. All rights reserved.
license.botbf09a502008-08-24 00:55:552// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
initial.commit09911bf2008-07-26 23:55:294
[email protected]b6583592012-01-25 19:52:335#include "content/browser/site_instance_impl.h"
initial.commit09911bf2008-07-26 23:55:296
[email protected]39365212011-02-24 01:01:007#include "content/browser/browsing_instance.h"
[email protected]b9535422012-02-09 01:47:598#include "content/browser/child_process_security_policy_impl.h"
[email protected]c02f1ba2014-02-03 06:53:539#include "content/browser/frame_host/debug_urls.h"
nick9f34e2892016-01-12 21:01:0710#include "content/browser/frame_host/frame_tree_node.h"
[email protected]f3b1a082011-11-18 00:34:3011#include "content/browser/renderer_host/render_process_host_impl.h"
[email protected]4c3a23582012-08-18 08:54:3412#include "content/browser/storage_partition_impl.h"
nickd30fd962015-07-27 21:51:0813#include "content/common/site_isolation_policy.h"
[email protected]87f3c082011-10-19 18:07:4414#include "content/public/browser/content_browser_client.h"
[email protected]f3b1a082011-11-18 00:34:3015#include "content/public/browser/render_process_host_factory.h"
[email protected]41fb79a52012-06-29 16:34:3316#include "content/public/browser/web_ui_controller_factory.h"
[email protected]a1d29162011-10-14 17:14:0317#include "content/public/common/url_constants.h"
[email protected]be28b5f42012-07-20 11:31:2518#include "net/base/registry_controlled_domains/registry_controlled_domain.h"
initial.commit09911bf2008-07-26 23:55:2919
[email protected]46488322012-10-30 03:22:2020namespace content {
[email protected]b6583592012-01-25 19:52:3321
[email protected]3059caa2013-06-06 03:48:4122const RenderProcessHostFactory*
23 SiteInstanceImpl::g_render_process_host_factory_ = NULL;
avib7348942015-12-25 20:57:1024int32_t SiteInstanceImpl::next_site_instance_id_ = 1;
[email protected]992db4c2011-05-12 15:37:1525
[email protected]b6583592012-01-25 19:52:3326SiteInstanceImpl::SiteInstanceImpl(BrowsingInstance* browsing_instance)
[email protected]992db4c2011-05-12 15:37:1527 : id_(next_site_instance_id_++),
creiscce56cd2014-09-29 22:45:2228 active_frame_count_(0),
[email protected]992db4c2011-05-12 15:37:1529 browsing_instance_(browsing_instance),
[email protected]4566f132009-03-12 01:55:1330 process_(NULL),
[email protected]4566f132009-03-12 01:55:1331 has_site_(false) {
32 DCHECK(browsing_instance);
[email protected]4566f132009-03-12 01:55:1333}
34
[email protected]b6583592012-01-25 19:52:3335SiteInstanceImpl::~SiteInstanceImpl() {
[email protected]46488322012-10-30 03:22:2036 GetContentClient()->browser()->SiteInstanceDeleting(this);
[email protected]056ad2a2011-07-12 02:13:5537
[email protected]40bfaf32013-11-19 01:35:4338 if (process_)
39 process_->RemoveObserver(this);
40
initial.commit09911bf2008-07-26 23:55:2941 // Now that no one is referencing us, we can safely remove ourselves from
42 // the BrowsingInstance. Any future visits to a page from this site
43 // (within the same BrowsingInstance) can safely create a new SiteInstance.
44 if (has_site_)
dchengbccd6b82016-03-30 16:24:1945 browsing_instance_->UnregisterSiteInstance(this);
46}
47
48scoped_refptr<SiteInstanceImpl> SiteInstanceImpl::Create(
49 BrowserContext* browser_context) {
50 return make_scoped_refptr(
51 new SiteInstanceImpl(new BrowsingInstance(browser_context)));
52}
53
54scoped_refptr<SiteInstanceImpl> SiteInstanceImpl::CreateForURL(
55 BrowserContext* browser_context,
56 const GURL& url) {
57 // This will create a new SiteInstance and BrowsingInstance.
58 scoped_refptr<BrowsingInstance> instance(
59 new BrowsingInstance(browser_context));
60 return instance->GetSiteInstanceForURL(url);
initial.commit09911bf2008-07-26 23:55:2961}
62
avib7348942015-12-25 20:57:1063int32_t SiteInstanceImpl::GetId() {
[email protected]b6583592012-01-25 19:52:3364 return id_;
65}
66
67bool SiteInstanceImpl::HasProcess() const {
[email protected]41fb79a52012-06-29 16:34:3368 if (process_ != NULL)
69 return true;
70
71 // If we would use process-per-site for this site, also check if there is an
72 // existing process that we would use if GetProcess() were called.
[email protected]46488322012-10-30 03:22:2073 BrowserContext* browser_context =
[email protected]41fb79a52012-06-29 16:34:3374 browsing_instance_->browser_context();
75 if (has_site_ &&
[email protected]1ae93fb12013-06-14 03:38:5676 RenderProcessHost::ShouldUseProcessPerSite(browser_context, site_) &&
[email protected]41fb79a52012-06-29 16:34:3377 RenderProcessHostImpl::GetProcessHostForSite(browser_context, site_)) {
78 return true;
79 }
80
81 return false;
[email protected]5ab79b02010-04-26 16:47:1182}
83
[email protected]41fb79a52012-06-29 16:34:3384RenderProcessHost* SiteInstanceImpl::GetProcess() {
[email protected]08c8ec7e2010-07-11 17:14:4885 // TODO(erikkay) It would be nice to ensure that the renderer type had been
86 // properly set before we get here. The default tab creation case winds up
87 // with no site set at this point, so it will default to TYPE_NORMAL. This
88 // may not be correct, so we'll wind up potentially creating a process that
89 // we then throw away, or worse sharing a process with the wrong process type.
90 // See crbug.com/43448.
91
initial.commit09911bf2008-07-26 23:55:2992 // Create a new process if ours went away or was reused.
[email protected]4566f132009-03-12 01:55:1393 if (!process_) {
[email protected]4c3a23582012-08-18 08:54:3494 BrowserContext* browser_context = browsing_instance_->browser_context();
[email protected]41fb79a52012-06-29 16:34:3395
96 // If we should use process-per-site mode (either in general or for the
97 // given site), then look for an existing RenderProcessHost for the site.
98 bool use_process_per_site = has_site_ &&
[email protected]1ae93fb12013-06-14 03:38:5699 RenderProcessHost::ShouldUseProcessPerSite(browser_context, site_);
[email protected]41fb79a52012-06-29 16:34:33100 if (use_process_per_site) {
101 process_ = RenderProcessHostImpl::GetProcessHostForSite(browser_context,
102 site_);
103 }
104
105 // If not (or if none found), see if we should reuse an existing process.
106 if (!process_ && RenderProcessHostImpl::ShouldTryToUseExistingProcessHost(
107 browser_context, site_)) {
108 process_ = RenderProcessHostImpl::GetExistingProcessHost(browser_context,
109 site_);
110 }
initial.commit09911bf2008-07-26 23:55:29111
112 // Otherwise (or if that fails), create a new one.
[email protected]4566f132009-03-12 01:55:13113 if (!process_) {
[email protected]3059caa2013-06-06 03:48:41114 if (g_render_process_host_factory_) {
115 process_ = g_render_process_host_factory_->CreateRenderProcessHost(
[email protected]f681b072013-06-06 21:53:12116 browser_context, this);
[email protected]a6df5112009-01-21 23:50:15117 } else {
[email protected]4c3a23582012-08-18 08:54:34118 StoragePartitionImpl* partition =
119 static_cast<StoragePartitionImpl*>(
120 BrowserContext::GetStoragePartition(browser_context, this));
[email protected]6eb1a11e2013-10-09 00:54:37121 process_ = new RenderProcessHostImpl(browser_context,
122 partition,
[email protected]6eb1a11e2013-10-09 00:54:37123 site_.SchemeIs(kGuestScheme));
[email protected]a6df5112009-01-21 23:50:15124 }
125 }
[email protected]41fb79a52012-06-29 16:34:33126 CHECK(process_);
[email protected]40bfaf32013-11-19 01:35:43127 process_->AddObserver(this);
[email protected]41fb79a52012-06-29 16:34:33128
129 // If we are using process-per-site, we need to register this process
130 // for the current site so that we can find it again. (If no site is set
131 // at this time, we will register it in SetSite().)
132 if (use_process_per_site) {
133 RenderProcessHostImpl::RegisterProcessHostForSite(browser_context,
134 process_, site_);
135 }
initial.commit09911bf2008-07-26 23:55:29136
naskob8744d22014-08-28 17:07:43137 TRACE_EVENT2("navigation", "SiteInstanceImpl::GetProcess",
138 "site id", id_, "process id", process_->GetID());
[email protected]46488322012-10-30 03:22:20139 GetContentClient()->browser()->SiteInstanceGotProcess(this);
[email protected]6f371442011-11-09 06:45:46140
[email protected]313b80bd2011-11-23 03:49:10141 if (has_site_)
142 LockToOrigin();
initial.commit09911bf2008-07-26 23:55:29143 }
[email protected]4566f132009-03-12 01:55:13144 DCHECK(process_);
initial.commit09911bf2008-07-26 23:55:29145
[email protected]4566f132009-03-12 01:55:13146 return process_;
initial.commit09911bf2008-07-26 23:55:29147}
148
[email protected]b6583592012-01-25 19:52:33149void SiteInstanceImpl::SetSite(const GURL& url) {
naskob8744d22014-08-28 17:07:43150 TRACE_EVENT2("navigation", "SiteInstanceImpl::SetSite",
151 "site id", id_, "url", url.possibly_invalid_spec());
initial.commit09911bf2008-07-26 23:55:29152 // A SiteInstance's site should not change.
153 // TODO(creis): When following links or script navigations, we can currently
154 // render pages from other sites in this SiteInstance. This will eventually
155 // be fixed, but until then, we should still not set the site of a
156 // SiteInstance more than once.
157 DCHECK(!has_site_);
158
159 // Remember that this SiteInstance has been used to load a URL, even if the
160 // URL is invalid.
161 has_site_ = true;
[email protected]4c3a23582012-08-18 08:54:34162 BrowserContext* browser_context = browsing_instance_->browser_context();
[email protected]41fb79a52012-06-29 16:34:33163 site_ = GetSiteForURL(browser_context, url);
initial.commit09911bf2008-07-26 23:55:29164
165 // Now that we have a site, register it with the BrowsingInstance. This
166 // ensures that we won't create another SiteInstance for this site within
167 // the same BrowsingInstance, because all same-site pages within a
168 // BrowsingInstance can script each other.
169 browsing_instance_->RegisterSiteInstance(this);
[email protected]313b80bd2011-11-23 03:49:10170
[email protected]41fb79a52012-06-29 16:34:33171 if (process_) {
[email protected]313b80bd2011-11-23 03:49:10172 LockToOrigin();
[email protected]41fb79a52012-06-29 16:34:33173
174 // Ensure the process is registered for this site if necessary.
[email protected]1ae93fb12013-06-14 03:38:56175 if (RenderProcessHost::ShouldUseProcessPerSite(browser_context, site_)) {
[email protected]41fb79a52012-06-29 16:34:33176 RenderProcessHostImpl::RegisterProcessHostForSite(
177 browser_context, process_, site_);
178 }
179 }
initial.commit09911bf2008-07-26 23:55:29180}
181
[email protected]77ab17312012-09-28 15:34:59182const GURL& SiteInstanceImpl::GetSiteURL() const {
[email protected]b6583592012-01-25 19:52:33183 return site_;
184}
185
186bool SiteInstanceImpl::HasSite() const {
187 return has_site_;
188}
189
190bool SiteInstanceImpl::HasRelatedSiteInstance(const GURL& url) {
initial.commit09911bf2008-07-26 23:55:29191 return browsing_instance_->HasSiteInstance(url);
192}
193
dchengbccd6b82016-03-30 16:24:19194scoped_refptr<SiteInstance> SiteInstanceImpl::GetRelatedSiteInstance(
195 const GURL& url) {
initial.commit09911bf2008-07-26 23:55:29196 return browsing_instance_->GetSiteInstanceForURL(url);
197}
198
[email protected]14392a52012-05-02 20:28:44199bool SiteInstanceImpl::IsRelatedSiteInstance(const SiteInstance* instance) {
[email protected]fc72bb12013-06-02 21:13:46200 return browsing_instance_.get() == static_cast<const SiteInstanceImpl*>(
201 instance)->browsing_instance_.get();
[email protected]14392a52012-05-02 20:28:44202}
203
[email protected]d5072a82014-05-15 05:50:18204size_t SiteInstanceImpl::GetRelatedActiveContentsCount() {
205 return browsing_instance_->active_contents_count();
206}
207
[email protected]f88628d02012-11-11 17:58:59208bool SiteInstanceImpl::HasWrongProcessForURL(const GURL& url) {
[email protected]d292d8a2011-05-25 03:47:11209 // Having no process isn't a problem, since we'll assign it correctly.
[email protected]f88628d02012-11-11 17:58:59210 // Note that HasProcess() may return true if process_ is null, in
211 // process-per-site cases where there's an existing process available.
212 // We want to use such a process in the IsSuitableHost check, so we
213 // may end up assigning process_ in the GetProcess() call below.
214 if (!HasProcess())
[email protected]d292d8a2011-05-25 03:47:11215 return false;
216
[email protected]144a8102012-01-14 01:05:31217 // If the URL to navigate to can be associated with any site instance,
218 // we want to keep it in the same process.
[email protected]c02f1ba2014-02-03 06:53:53219 if (IsRendererDebugURL(url))
[email protected]144a8102012-01-14 01:05:31220 return false;
221
[email protected]88aae972011-12-16 01:14:18222 // If the site URL is an extension (e.g., for hosted apps or WebUI) but the
[email protected]d292d8a2011-05-25 03:47:11223 // process is not (or vice versa), make sure we notice and fix it.
[email protected]2a5221b2011-09-27 23:07:31224 GURL site_url = GetSiteForURL(browsing_instance_->browser_context(), url);
[email protected]88aae972011-12-16 01:14:18225 return !RenderProcessHostImpl::IsSuitableHost(
[email protected]f88628d02012-11-11 17:58:59226 GetProcess(), browsing_instance_->browser_context(), site_url);
[email protected]d292d8a2011-05-25 03:47:11227}
228
nickd30fd962015-07-27 21:51:08229bool SiteInstanceImpl::RequiresDedicatedProcess() {
230 if (!has_site_)
231 return false;
nickcc0d9142015-10-14 16:27:10232 return SiteInstanceImpl::DoesSiteRequireDedicatedProcess(GetBrowserContext(),
233 site_);
nickd30fd962015-07-27 21:51:08234}
235
nick9f34e2892016-01-12 21:01:07236void SiteInstanceImpl::IncrementActiveFrameCount() {
237 active_frame_count_++;
238}
239
240void SiteInstanceImpl::DecrementActiveFrameCount() {
241 if (--active_frame_count_ == 0)
242 FOR_EACH_OBSERVER(Observer, observers_, ActiveFrameCountIsZero(this));
243}
244
[email protected]d5072a82014-05-15 05:50:18245void SiteInstanceImpl::IncrementRelatedActiveContentsCount() {
246 browsing_instance_->increment_active_contents_count();
247}
248
249void SiteInstanceImpl::DecrementRelatedActiveContentsCount() {
250 browsing_instance_->decrement_active_contents_count();
251}
252
nick9f34e2892016-01-12 21:01:07253void SiteInstanceImpl::AddObserver(Observer* observer) {
254 observers_.AddObserver(observer);
255}
256
257void SiteInstanceImpl::RemoveObserver(Observer* observer) {
258 observers_.RemoveObserver(observer);
259}
260
[email protected]3059caa2013-06-06 03:48:41261void SiteInstanceImpl::set_render_process_host_factory(
262 const RenderProcessHostFactory* rph_factory) {
263 g_render_process_host_factory_ = rph_factory;
264}
265
[email protected]4c3a23582012-08-18 08:54:34266BrowserContext* SiteInstanceImpl::GetBrowserContext() const {
[email protected]72daaa92012-01-18 13:39:02267 return browsing_instance_->browser_context();
268}
269
nickcc0d9142015-10-14 16:27:10270// static
dchengbccd6b82016-03-30 16:24:19271scoped_refptr<SiteInstance> SiteInstance::Create(
272 BrowserContext* browser_context) {
273 return SiteInstanceImpl::Create(browser_context);
initial.commit09911bf2008-07-26 23:55:29274}
275
nickcc0d9142015-10-14 16:27:10276// static
dchengbccd6b82016-03-30 16:24:19277scoped_refptr<SiteInstance> SiteInstance::CreateForURL(
278 BrowserContext* browser_context,
279 const GURL& url) {
280 return SiteInstanceImpl::CreateForURL(browser_context, url);
[email protected]d8a96622009-05-07 19:21:16281}
282
nickcc0d9142015-10-14 16:27:10283// static
[email protected]399583b2012-12-11 09:33:42284bool SiteInstance::IsSameWebSite(BrowserContext* browser_context,
[email protected]855d7d572014-08-02 11:18:17285 const GURL& real_src_url,
286 const GURL& real_dest_url) {
287 GURL src_url = SiteInstanceImpl::GetEffectiveURL(browser_context,
288 real_src_url);
289 GURL dest_url = SiteInstanceImpl::GetEffectiveURL(browser_context,
290 real_dest_url);
[email protected]399583b2012-12-11 09:33:42291
292 // We infer web site boundaries based on the registered domain name of the
293 // top-level page and the scheme. We do not pay attention to the port if
294 // one is present, because pages served from different ports can still
295 // access each other if they change their document.domain variable.
296
297 // Some special URLs will match the site instance of any other URL. This is
298 // done before checking both of them for validity, since we want these URLs
299 // to have the same site instance as even an invalid one.
[email protected]855d7d572014-08-02 11:18:17300 if (IsRendererDebugURL(src_url) || IsRendererDebugURL(dest_url))
[email protected]399583b2012-12-11 09:33:42301 return true;
302
303 // If either URL is invalid, they aren't part of the same site.
[email protected]855d7d572014-08-02 11:18:17304 if (!src_url.is_valid() || !dest_url.is_valid())
[email protected]399583b2012-12-11 09:33:42305 return false;
306
[email protected]855d7d572014-08-02 11:18:17307 // If the destination url is just a blank page, we treat them as part of the
308 // same site.
309 GURL blank_page(url::kAboutBlankURL);
310 if (dest_url == blank_page)
311 return true;
312
[email protected]399583b2012-12-11 09:33:42313 // If the schemes differ, they aren't part of the same site.
[email protected]855d7d572014-08-02 11:18:17314 if (src_url.scheme() != dest_url.scheme())
[email protected]399583b2012-12-11 09:33:42315 return false;
316
[email protected]ed32c212013-05-14 20:49:29317 return net::registry_controlled_domains::SameDomainOrHost(
[email protected]855d7d572014-08-02 11:18:17318 src_url,
319 dest_url,
[email protected]aabe1792014-01-30 21:37:46320 net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES);
[email protected]399583b2012-12-11 09:33:42321}
322
nickcc0d9142015-10-14 16:27:10323// static
[email protected]399583b2012-12-11 09:33:42324GURL SiteInstance::GetSiteForURL(BrowserContext* browser_context,
325 const GURL& real_url) {
[email protected]25a9e8e532012-06-22 06:16:28326 // TODO(fsamuel, creis): For some reason appID is not recognized as a host.
[email protected]6eb1a11e2013-10-09 00:54:37327 if (real_url.SchemeIs(kGuestScheme))
[email protected]25a9e8e532012-06-22 06:16:28328 return real_url;
329
[email protected]b6583592012-01-25 19:52:33330 GURL url = SiteInstanceImpl::GetEffectiveURL(browser_context, real_url);
[email protected]3a8eecb2010-04-22 23:56:30331
initial.commit09911bf2008-07-26 23:55:29332 // If the url has a host, then determine the site.
333 if (url.has_host()) {
[email protected]6705b232008-11-26 00:16:51334 // Only keep the scheme and registered domain as given by GetOrigin. This
335 // may also include a port, which we need to drop.
creisf60c2cd2014-12-18 00:41:02336 GURL site = url.GetOrigin();
initial.commit09911bf2008-07-26 23:55:29337
[email protected]6705b232008-11-26 00:16:51338 // Remove port, if any.
339 if (site.has_port()) {
340 GURL::Replacements rep;
341 rep.ClearPort();
342 site = site.ReplaceComponents(rep);
343 }
344
initial.commit09911bf2008-07-26 23:55:29345 // If this URL has a registered domain, we only want to remember that part.
346 std::string domain =
[email protected]ed32c212013-05-14 20:49:29347 net::registry_controlled_domains::GetDomainAndRegistry(
348 url,
[email protected]aabe1792014-01-30 21:37:46349 net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES);
initial.commit09911bf2008-07-26 23:55:29350 if (!domain.empty()) {
351 GURL::Replacements rep;
352 rep.SetHostStr(domain);
353 site = site.ReplaceComponents(rep);
354 }
creisf60c2cd2014-12-18 00:41:02355 return site;
initial.commit09911bf2008-07-26 23:55:29356 }
creisf60c2cd2014-12-18 00:41:02357
358 // If there is no host but there is a scheme, return the scheme.
359 // This is useful for cases like file URLs.
360 if (url.has_scheme())
361 return GURL(url.scheme() + ":");
362
363 // Otherwise the URL should be invalid; return an empty site.
364 DCHECK(!url.is_valid());
365 return GURL();
initial.commit09911bf2008-07-26 23:55:29366}
367
nickcc0d9142015-10-14 16:27:10368// static
[email protected]4c3a23582012-08-18 08:54:34369GURL SiteInstanceImpl::GetEffectiveURL(BrowserContext* browser_context,
370 const GURL& url) {
[email protected]46488322012-10-30 03:22:20371 return GetContentClient()->browser()->
[email protected]3d7474ff2011-07-27 17:47:37372 GetEffectiveURL(browser_context, url);
[email protected]3a8eecb2010-04-22 23:56:30373}
374
nickcc0d9142015-10-14 16:27:10375// static
376bool SiteInstanceImpl::DoesSiteRequireDedicatedProcess(
377 BrowserContext* browser_context,
378 const GURL& effective_url) {
379 // If --site-per-process is enabled, site isolation is enabled everywhere.
380 if (SiteIsolationPolicy::UseDedicatedProcessesForAllSites())
381 return true;
382
383 // Let the content embedder enable site isolation for specific URLs.
384 if (GetContentClient()->IsSupplementarySiteIsolationModeEnabled() &&
385 GetContentClient()->browser()->DoesSiteRequireDedicatedProcess(
386 browser_context, effective_url)) {
387 return true;
388 }
389
390 return false;
391}
392
[email protected]40bfaf32013-11-19 01:35:43393void SiteInstanceImpl::RenderProcessHostDestroyed(RenderProcessHost* host) {
394 DCHECK_EQ(process_, host);
395 process_->RemoveObserver(this);
396 process_ = NULL;
[email protected]4566f132009-03-12 01:55:13397}
[email protected]313b80bd2011-11-23 03:49:10398
nick9f34e2892016-01-12 21:01:07399void SiteInstanceImpl::RenderProcessWillExit(RenderProcessHost* host) {
400 // TODO(nick): http://crbug.com/575400 - RenderProcessWillExit might not serve
401 // any purpose here.
402 FOR_EACH_OBSERVER(Observer, observers_, RenderProcessGone(this));
403}
404
405void SiteInstanceImpl::RenderProcessExited(RenderProcessHost* host,
406 base::TerminationStatus status,
407 int exit_code) {
408 FOR_EACH_OBSERVER(Observer, observers_, RenderProcessGone(this));
409}
410
[email protected]b6583592012-01-25 19:52:33411void SiteInstanceImpl::LockToOrigin() {
nickd30fd962015-07-27 21:51:08412 // TODO(nick): When all sites are isolated, this operation provides strong
413 // protection. If only some sites are isolated, we need additional logic to
414 // prevent the non-isolated sites from requesting resources for isolated
415 // sites. https://crbug.com/509125
nickcc0d9142015-10-14 16:27:10416 if (RequiresDedicatedProcess()) {
lazyboyf5283a42015-06-24 21:53:35417 // Guest processes cannot be locked to its site because guests always have
418 // a fixed SiteInstance. The site of GURLs a guest loads doesn't match that
419 // SiteInstance. So we skip locking the guest process to the site.
420 // TODO(ncarter): Remove this exclusion once we can make origin lock per
421 // RenderFrame routing id.
422 if (site_.SchemeIs(content::kGuestScheme))
423 return;
424
lfg24d083792015-07-17 20:45:35425 // TODO(creis, nick) https://crbug.com/510588 Chrome UI pages use the same
426 // site (chrome://chrome), so they can't be locked because the site being
427 // loaded doesn't match the SiteInstance.
428 if (site_.SchemeIs(content::kChromeUIScheme))
429 return;
430
creise5d6d1732015-08-25 19:47:06431 // TODO(creis, nick): Until we can handle sites with effective URLs at the
432 // call sites of ChildProcessSecurityPolicy::CanAccessDataForOrigin, we
433 // must give the embedder a chance to exempt some sites to avoid process
434 // kills.
nick7d0984c2015-08-29 00:13:46435 if (!GetContentClient()->browser()->ShouldLockToOrigin(
436 browsing_instance_->browser_context(), site_))
creise5d6d1732015-08-25 19:47:06437 return;
438
[email protected]b9535422012-02-09 01:47:59439 ChildProcessSecurityPolicyImpl* policy =
440 ChildProcessSecurityPolicyImpl::GetInstance();
[email protected]313b80bd2011-11-23 03:49:10441 policy->LockToOrigin(process_->GetID(), site_);
442 }
443}
[email protected]46488322012-10-30 03:22:20444
445} // namespace content