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

Side by Side Diff: chrome/browser/tab_contents/site_instance.cc

Issue 31008: Coalesce more hardcoded schemes to using predefined constants. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "chrome/browser/tab_contents/site_instance.h" 5 #include "chrome/browser/tab_contents/site_instance.h"
6 6
7 #include "chrome/browser/renderer_host/browser_render_process_host.h" 7 #include "chrome/browser/renderer_host/browser_render_process_host.h"
8 #include "chrome/common/url_constants.h"
8 #include "net/base/registry_controlled_domain.h" 9 #include "net/base/registry_controlled_domain.h"
9 10
10 SiteInstance::~SiteInstance() { 11 SiteInstance::~SiteInstance() {
11 // Now that no one is referencing us, we can safely remove ourselves from 12 // Now that no one is referencing us, we can safely remove ourselves from
12 // the BrowsingInstance. Any future visits to a page from this site 13 // the BrowsingInstance. Any future visits to a page from this site
13 // (within the same BrowsingInstance) can safely create a new SiteInstance. 14 // (within the same BrowsingInstance) can safely create a new SiteInstance.
14 if (has_site_) 15 if (has_site_)
15 browsing_instance_->UnregisterSiteInstance(this); 16 browsing_instance_->UnregisterSiteInstance(this);
16 } 17 }
17 18
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 118
118 /*static*/ 119 /*static*/
119 bool SiteInstance::IsSameWebSite(const GURL& url1, const GURL& url2) { 120 bool SiteInstance::IsSameWebSite(const GURL& url1, const GURL& url2) {
120 // We infer web site boundaries based on the registered domain name of the 121 // We infer web site boundaries based on the registered domain name of the
121 // top-level page and the scheme. We do not pay attention to the port if 122 // top-level page and the scheme. We do not pay attention to the port if
122 // one is present, because pages served from different ports can still 123 // one is present, because pages served from different ports can still
123 // access each other if they change their document.domain variable. 124 // access each other if they change their document.domain variable.
124 125
125 // We must treat javascript: URLs as part of the same site, regardless of 126 // We must treat javascript: URLs as part of the same site, regardless of
126 // the site. 127 // the site.
127 if (url1.SchemeIs("javascript") || url2.SchemeIs("javascript")) 128 if (url1.SchemeIs(chrome::kJavaScriptScheme) ||
129 url2.SchemeIs(chrome::kJavaScriptScheme))
128 return true; 130 return true;
129 131
130 // We treat about:crash, about:hang, and about:shorthang as the same site as 132 // We treat about:crash, about:hang, and about:shorthang as the same site as
131 // any URL, since they are used as demos for crashing/hanging a process. 133 // any URL, since they are used as demos for crashing/hanging a process.
132 GURL about_crash = GURL("about:crash"); 134 GURL about_crash = GURL("about:crash");
133 GURL about_hang = GURL("about:hang"); 135 GURL about_hang = GURL("about:hang");
134 GURL about_shorthang = GURL("about:shorthang"); 136 GURL about_shorthang = GURL("about:shorthang");
135 if (url1 == about_crash || url2 == about_crash || 137 if (url1 == about_crash || url2 == about_crash ||
136 url1 == about_hang || url2 == about_hang || 138 url1 == about_hang || url2 == about_hang ||
137 url1 == about_shorthang || url2 == about_shorthang) 139 url1 == about_shorthang || url2 == about_shorthang)
138 return true; 140 return true;
139 141
140 // If either URL is invalid, they aren't part of the same site. 142 // If either URL is invalid, they aren't part of the same site.
141 if (!url1.is_valid() || !url2.is_valid()) { 143 if (!url1.is_valid() || !url2.is_valid()) {
142 return false; 144 return false;
143 } 145 }
144 146
145 // If the schemes differ, they aren't part of the same site. 147 // If the schemes differ, they aren't part of the same site.
146 if (url1.scheme() != url2.scheme()) { 148 if (url1.scheme() != url2.scheme()) {
147 return false; 149 return false;
148 } 150 }
149 151
150 return net::RegistryControlledDomainService::SameDomainOrHost(url1, url2); 152 return net::RegistryControlledDomainService::SameDomainOrHost(url1, url2);
151 } 153 }
152 154
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698