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

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

Issue 378743002: Navigation transitions: Place transition page in same process as destination page. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix clang build. Created 6 years, 4 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/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_impl.h" 9 #include "content/browser/child_process_security_policy_impl.h"
10 #include "content/browser/frame_host/debug_urls.h" 10 #include "content/browser/frame_host/debug_urls.h"
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 const GURL& url) { 234 const GURL& url) {
235 // This BrowsingInstance may be deleted if it returns an existing 235 // This BrowsingInstance may be deleted if it returns an existing
236 // SiteInstance. 236 // SiteInstance.
237 scoped_refptr<BrowsingInstance> instance( 237 scoped_refptr<BrowsingInstance> instance(
238 new BrowsingInstance(browser_context)); 238 new BrowsingInstance(browser_context));
239 return instance->GetSiteInstanceForURL(url); 239 return instance->GetSiteInstanceForURL(url);
240 } 240 }
241 241
242 /*static*/ 242 /*static*/
243 bool SiteInstance::IsSameWebSite(BrowserContext* browser_context, 243 bool SiteInstance::IsSameWebSite(BrowserContext* browser_context,
244 const GURL& real_url1, 244 const GURL& real_src_url,
245 const GURL& real_url2) { 245 const GURL& real_dest_url) {
246 GURL url1 = SiteInstanceImpl::GetEffectiveURL(browser_context, real_url1); 246 GURL src_url = SiteInstanceImpl::GetEffectiveURL(browser_context,
247 GURL url2 = SiteInstanceImpl::GetEffectiveURL(browser_context, real_url2); 247 real_src_url);
248 GURL dest_url = SiteInstanceImpl::GetEffectiveURL(browser_context,
249 real_dest_url);
248 250
249 // We infer web site boundaries based on the registered domain name of the 251 // We infer web site boundaries based on the registered domain name of the
250 // top-level page and the scheme. We do not pay attention to the port if 252 // top-level page and the scheme. We do not pay attention to the port if
251 // one is present, because pages served from different ports can still 253 // one is present, because pages served from different ports can still
252 // access each other if they change their document.domain variable. 254 // access each other if they change their document.domain variable.
253 255
254 // Some special URLs will match the site instance of any other URL. This is 256 // Some special URLs will match the site instance of any other URL. This is
255 // done before checking both of them for validity, since we want these URLs 257 // done before checking both of them for validity, since we want these URLs
256 // to have the same site instance as even an invalid one. 258 // to have the same site instance as even an invalid one.
257 if (IsRendererDebugURL(url1) || IsRendererDebugURL(url2)) 259 if (IsRendererDebugURL(src_url) || IsRendererDebugURL(dest_url))
258 return true; 260 return true;
259 261
260 // If either URL is invalid, they aren't part of the same site. 262 // If either URL is invalid, they aren't part of the same site.
261 if (!url1.is_valid() || !url2.is_valid()) 263 if (!src_url.is_valid() || !dest_url.is_valid())
262 return false; 264 return false;
263 265
266 // If the destination url is just a blank page, we treat them as part of the
267 // same site.
268 GURL blank_page(url::kAboutBlankURL);
269 if (dest_url == blank_page)
270 return true;
271
264 // If the schemes differ, they aren't part of the same site. 272 // If the schemes differ, they aren't part of the same site.
265 if (url1.scheme() != url2.scheme()) 273 if (src_url.scheme() != dest_url.scheme())
266 return false; 274 return false;
267 275
268 return net::registry_controlled_domains::SameDomainOrHost( 276 return net::registry_controlled_domains::SameDomainOrHost(
269 url1, 277 src_url,
270 url2, 278 dest_url,
271 net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES); 279 net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES);
272 } 280 }
273 281
274 /*static*/ 282 /*static*/
275 GURL SiteInstance::GetSiteForURL(BrowserContext* browser_context, 283 GURL SiteInstance::GetSiteForURL(BrowserContext* browser_context,
276 const GURL& real_url) { 284 const GURL& real_url) {
277 // TODO(fsamuel, creis): For some reason appID is not recognized as a host. 285 // TODO(fsamuel, creis): For some reason appID is not recognized as a host.
278 if (real_url.SchemeIs(kGuestScheme)) 286 if (real_url.SchemeIs(kGuestScheme))
279 return real_url; 287 return real_url;
280 288
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 340 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
333 if (command_line.HasSwitch(switches::kEnableStrictSiteIsolation) || 341 if (command_line.HasSwitch(switches::kEnableStrictSiteIsolation) ||
334 command_line.HasSwitch(switches::kSitePerProcess)) { 342 command_line.HasSwitch(switches::kSitePerProcess)) {
335 ChildProcessSecurityPolicyImpl* policy = 343 ChildProcessSecurityPolicyImpl* policy =
336 ChildProcessSecurityPolicyImpl::GetInstance(); 344 ChildProcessSecurityPolicyImpl::GetInstance();
337 policy->LockToOrigin(process_->GetID(), site_); 345 policy->LockToOrigin(process_->GetID(), site_);
338 } 346 }
339 } 347 }
340 348
341 } // namespace content 349 } // namespace content
OLDNEW
« no previous file with comments | « chrome/browser/android/content_view_util.cc ('k') | content/browser/site_instance_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698