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

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

Issue 9147051: Don't swap processes for javascript: URLs. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fixing all variable style issues while at it. Created 8 years, 11 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
« no previous file with comments | « no previous file | content/browser/site_instance_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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.h" 5 #include "content/browser/site_instance.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "content/browser/browsing_instance.h" 8 #include "content/browser/browsing_instance.h"
9 #include "content/browser/child_process_security_policy.h" 9 #include "content/browser/child_process_security_policy.h"
10 #include "content/browser/renderer_host/render_process_host_impl.h" 10 #include "content/browser/renderer_host/render_process_host_impl.h"
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 122
123 SiteInstance* SiteInstance::GetRelatedSiteInstance(const GURL& url) { 123 SiteInstance* SiteInstance::GetRelatedSiteInstance(const GURL& url) {
124 return browsing_instance_->GetSiteInstanceForURL(url); 124 return browsing_instance_->GetSiteInstanceForURL(url);
125 } 125 }
126 126
127 bool SiteInstance::HasWrongProcessForURL(const GURL& url) const { 127 bool SiteInstance::HasWrongProcessForURL(const GURL& url) const {
128 // Having no process isn't a problem, since we'll assign it correctly. 128 // Having no process isn't a problem, since we'll assign it correctly.
129 if (!HasProcess()) 129 if (!HasProcess())
130 return false; 130 return false;
131 131
132 // If the URL to navigate to can be associated with any site instance,
133 // we want to keep it in the same process.
134 if (IsURLSameAsAnySiteInstance(url))
135 return false;
136
132 // If the site URL is an extension (e.g., for hosted apps or WebUI) but the 137 // If the site URL is an extension (e.g., for hosted apps or WebUI) but the
133 // process is not (or vice versa), make sure we notice and fix it. 138 // process is not (or vice versa), make sure we notice and fix it.
134 GURL site_url = GetSiteForURL(browsing_instance_->browser_context(), url); 139 GURL site_url = GetSiteForURL(browsing_instance_->browser_context(), url);
135 return !RenderProcessHostImpl::IsSuitableHost( 140 return !RenderProcessHostImpl::IsSuitableHost(
136 process_, browsing_instance_->browser_context(), site_url); 141 process_, browsing_instance_->browser_context(), site_url);
137 } 142 }
138 143
139 /*static*/ 144 /*static*/
140 SiteInstance* SiteInstance::CreateSiteInstance( 145 SiteInstance* SiteInstance::CreateSiteInstance(
141 content::BrowserContext* browser_context) { 146 content::BrowserContext* browser_context) {
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 240
236 void SiteInstance::LockToOrigin() { 241 void SiteInstance::LockToOrigin() {
237 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 242 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
238 if (command_line.HasSwitch(switches::kEnableStrictSiteIsolation)) { 243 if (command_line.HasSwitch(switches::kEnableStrictSiteIsolation)) {
239 ChildProcessSecurityPolicy* policy = 244 ChildProcessSecurityPolicy* policy =
240 ChildProcessSecurityPolicy::GetInstance(); 245 ChildProcessSecurityPolicy::GetInstance();
241 policy->LockToOrigin(process_->GetID(), site_); 246 policy->LockToOrigin(process_->GetID(), site_);
242 } 247 }
243 } 248 }
244 249
OLDNEW
« no previous file with comments | « no previous file | content/browser/site_instance_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698