| OLD | NEW |
| 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 "chrome/browser/extensions/extension_service.h" | |
| 8 #include "chrome/browser/renderer_host/browser_render_process_host.h" | 7 #include "chrome/browser/renderer_host/browser_render_process_host.h" |
| 9 #include "chrome/common/url_constants.h" | 8 #include "chrome/common/url_constants.h" |
| 10 #include "content/browser/browsing_instance.h" | 9 #include "content/browser/browsing_instance.h" |
| 11 #include "content/browser/content_browser_client.h" | 10 #include "content/browser/content_browser_client.h" |
| 12 #include "content/browser/webui/web_ui_factory.h" | 11 #include "content/browser/webui/web_ui_factory.h" |
| 13 #include "content/common/notification_service.h" | 12 #include "content/common/notification_service.h" |
| 14 #include "content/common/content_client.h" | 13 #include "content/common/content_client.h" |
| 15 #include "net/base/registry_controlled_domain.h" | 14 #include "net/base/registry_controlled_domain.h" |
| 16 | 15 |
| 17 // We treat javascript:, about:crash, about:hang, and about:shorthang as the | 16 // We treat javascript:, about:crash, about:hang, and about:shorthang as the |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 | 182 |
| 184 // If the schemes differ, they aren't part of the same site. | 183 // If the schemes differ, they aren't part of the same site. |
| 185 if (url1.scheme() != url2.scheme()) | 184 if (url1.scheme() != url2.scheme()) |
| 186 return false; | 185 return false; |
| 187 | 186 |
| 188 return net::RegistryControlledDomainService::SameDomainOrHost(url1, url2); | 187 return net::RegistryControlledDomainService::SameDomainOrHost(url1, url2); |
| 189 } | 188 } |
| 190 | 189 |
| 191 /*static*/ | 190 /*static*/ |
| 192 GURL SiteInstance::GetEffectiveURL(Profile* profile, const GURL& url) { | 191 GURL SiteInstance::GetEffectiveURL(Profile* profile, const GURL& url) { |
| 193 if (!profile || !profile->GetExtensionService()) | 192 return content::GetContentClient()->browser()->GetEffectiveURL(profile, url); |
| 194 return url; | |
| 195 | |
| 196 const Extension* extension = | |
| 197 profile->GetExtensionService()->GetExtensionByWebExtent(url); | |
| 198 if (extension) { | |
| 199 // If the URL is part of an extension's web extent, convert it to an | |
| 200 // extension URL. | |
| 201 return extension->GetResourceURL(url.path()); | |
| 202 } else { | |
| 203 return url; | |
| 204 } | |
| 205 } | 193 } |
| 206 | 194 |
| 207 /*static*/ | 195 /*static*/ |
| 208 RenderProcessHost::Type SiteInstance::RendererTypeForURL(const GURL& url) { | 196 RenderProcessHost::Type SiteInstance::RendererTypeForURL(const GURL& url) { |
| 209 if (!url.is_valid()) | 197 if (!url.is_valid()) |
| 210 return RenderProcessHost::TYPE_NORMAL; | 198 return RenderProcessHost::TYPE_NORMAL; |
| 211 | 199 |
| 212 if (url.SchemeIs(chrome::kExtensionScheme)) | 200 if (url.SchemeIs(chrome::kExtensionScheme)) |
| 213 return RenderProcessHost::TYPE_EXTENSION; | 201 return RenderProcessHost::TYPE_EXTENSION; |
| 214 | 202 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 229 } | 217 } |
| 230 | 218 |
| 231 void SiteInstance::Observe(NotificationType type, | 219 void SiteInstance::Observe(NotificationType type, |
| 232 const NotificationSource& source, | 220 const NotificationSource& source, |
| 233 const NotificationDetails& details) { | 221 const NotificationDetails& details) { |
| 234 DCHECK(type == NotificationType::RENDERER_PROCESS_TERMINATED); | 222 DCHECK(type == NotificationType::RENDERER_PROCESS_TERMINATED); |
| 235 RenderProcessHost* rph = Source<RenderProcessHost>(source).ptr(); | 223 RenderProcessHost* rph = Source<RenderProcessHost>(source).ptr(); |
| 236 if (rph == process_) | 224 if (rph == process_) |
| 237 process_ = NULL; | 225 process_ = NULL; |
| 238 } | 226 } |
| OLD | NEW |