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

Side by Side Diff: content/browser/site_instance_impl.cc

Issue 2964033002: Disable cross-process navigations in --single-process. (Closed)
Patch Set: Fix condition. Created 3 years, 5 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/site_instance_impl.h" 5 #include "content/browser/site_instance_impl.h"
6 6
7 #include "base/command_line.h"
7 #include "base/macros.h" 8 #include "base/macros.h"
8 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
9 #include "content/browser/browsing_instance.h" 10 #include "content/browser/browsing_instance.h"
10 #include "content/browser/child_process_security_policy_impl.h" 11 #include "content/browser/child_process_security_policy_impl.h"
11 #include "content/browser/frame_host/debug_urls.h" 12 #include "content/browser/frame_host/debug_urls.h"
12 #include "content/browser/frame_host/frame_tree_node.h" 13 #include "content/browser/frame_host/frame_tree_node.h"
13 #include "content/browser/renderer_host/render_process_host_impl.h" 14 #include "content/browser/renderer_host/render_process_host_impl.h"
14 #include "content/browser/storage_partition_impl.h" 15 #include "content/browser/storage_partition_impl.h"
15 #include "content/common/site_isolation_policy.h" 16 #include "content/common/site_isolation_policy.h"
16 #include "content/public/browser/content_browser_client.h" 17 #include "content/public/browser/content_browser_client.h"
17 #include "content/public/browser/render_process_host_factory.h" 18 #include "content/public/browser/render_process_host_factory.h"
18 #include "content/public/browser/web_ui_controller_factory.h" 19 #include "content/public/browser/web_ui_controller_factory.h"
20 #include "content/public/common/content_switches.h"
19 #include "content/public/common/url_constants.h" 21 #include "content/public/common/url_constants.h"
20 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" 22 #include "net/base/registry_controlled_domains/registry_controlled_domain.h"
21 23
22 namespace content { 24 namespace content {
23 25
24 int32_t SiteInstanceImpl::next_site_instance_id_ = 1; 26 int32_t SiteInstanceImpl::next_site_instance_id_ = 1;
25 27
26 SiteInstanceImpl::SiteInstanceImpl(BrowsingInstance* browsing_instance) 28 SiteInstanceImpl::SiteInstanceImpl(BrowsingInstance* browsing_instance)
27 : id_(next_site_instance_id_++), 29 : id_(next_site_instance_id_++),
28 active_frame_count_(0), 30 active_frame_count_(0),
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 browser_context, site_url)) { 410 browser_context, site_url)) {
409 return true; 411 return true;
410 } 412 }
411 413
412 return false; 414 return false;
413 } 415 }
414 416
415 // static 417 // static
416 bool SiteInstanceImpl::ShouldLockToOrigin(BrowserContext* browser_context, 418 bool SiteInstanceImpl::ShouldLockToOrigin(BrowserContext* browser_context,
417 GURL site_url) { 419 GURL site_url) {
420 // Don't lock to origin in --single-process or --process-per-tab modes, since
421 // these modes put cross-site pages into the same process.
422 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
423 switches::kSingleProcess) ||
424 base::CommandLine::ForCurrentProcess()->HasSwitch(
425 switches::kProcessPerTab))
426 return false;
427
418 if (!DoesSiteRequireDedicatedProcess(browser_context, site_url)) 428 if (!DoesSiteRequireDedicatedProcess(browser_context, site_url))
419 return false; 429 return false;
420 430
421 // Guest processes cannot be locked to their site because guests always have 431 // Guest processes cannot be locked to their site because guests always have
422 // a fixed SiteInstance. The site of GURLs a guest loads doesn't match that 432 // a fixed SiteInstance. The site of GURLs a guest loads doesn't match that
423 // SiteInstance. So we skip locking the guest process to the site. 433 // SiteInstance. So we skip locking the guest process to the site.
424 // TODO(ncarter): Remove this exclusion once we can make origin lock per 434 // TODO(ncarter): Remove this exclusion once we can make origin lock per
425 // RenderFrame routing id. 435 // RenderFrame routing id.
426 if (site_url.SchemeIs(content::kGuestScheme)) 436 if (site_url.SchemeIs(content::kGuestScheme))
427 return false; 437 return false;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 // prevent the non-isolated sites from requesting resources for isolated 494 // prevent the non-isolated sites from requesting resources for isolated
485 // sites. https://crbug.com/509125 495 // sites. https://crbug.com/509125
486 if (ShouldLockToOrigin(GetBrowserContext(), site_)) { 496 if (ShouldLockToOrigin(GetBrowserContext(), site_)) {
487 ChildProcessSecurityPolicyImpl* policy = 497 ChildProcessSecurityPolicyImpl* policy =
488 ChildProcessSecurityPolicyImpl::GetInstance(); 498 ChildProcessSecurityPolicyImpl::GetInstance();
489 policy->LockToOrigin(process_->GetID(), site_); 499 policy->LockToOrigin(process_->GetID(), site_);
490 } 500 }
491 } 501 }
492 502
493 } // namespace content 503 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698