| 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" | 7 #include "chrome/browser/extensions/extension_service.h" |
| 8 #include "chrome/browser/renderer_host/browser_render_process_host.h" | 8 #include "chrome/browser/renderer_host/browser_render_process_host.h" |
| 9 #include "chrome/common/url_constants.h" | 9 #include "chrome/common/url_constants.h" |
| 10 #include "content/browser/browsing_instance.h" | 10 #include "content/browser/browsing_instance.h" |
| 11 #include "content/browser/content_browser_client.h" |
| 11 #include "content/browser/webui/web_ui_factory.h" | 12 #include "content/browser/webui/web_ui_factory.h" |
| 12 #include "content/common/notification_service.h" | 13 #include "content/common/notification_service.h" |
| 14 #include "content/common/content_client.h" |
| 13 #include "net/base/registry_controlled_domain.h" | 15 #include "net/base/registry_controlled_domain.h" |
| 14 | 16 |
| 15 // We treat javascript:, about:crash, about:hang, and about:shorthang as the | 17 // We treat javascript:, about:crash, about:hang, and about:shorthang as the |
| 16 // same site as any URL since they are actually modifiers on existing pages. | 18 // same site as any URL since they are actually modifiers on existing pages. |
| 17 static bool IsURLSameAsAnySiteInstance(const GURL& url) { | 19 static bool IsURLSameAsAnySiteInstance(const GURL& url) { |
| 18 if (!url.is_valid()) | 20 if (!url.is_valid()) |
| 19 return false; | 21 return false; |
| 20 return url.SchemeIs(chrome::kJavaScriptScheme) || | 22 return url.SchemeIs(chrome::kJavaScriptScheme) || |
| 21 url.spec() == chrome::kAboutCrashURL || | 23 url.spec() == chrome::kAboutCrashURL || |
| 22 url.spec() == chrome::kAboutKillURL || | 24 url.spec() == chrome::kAboutKillURL || |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 | 206 |
| 205 /*static*/ | 207 /*static*/ |
| 206 RenderProcessHost::Type SiteInstance::RendererTypeForURL(const GURL& url) { | 208 RenderProcessHost::Type SiteInstance::RendererTypeForURL(const GURL& url) { |
| 207 if (!url.is_valid()) | 209 if (!url.is_valid()) |
| 208 return RenderProcessHost::TYPE_NORMAL; | 210 return RenderProcessHost::TYPE_NORMAL; |
| 209 | 211 |
| 210 if (url.SchemeIs(chrome::kExtensionScheme)) | 212 if (url.SchemeIs(chrome::kExtensionScheme)) |
| 211 return RenderProcessHost::TYPE_EXTENSION; | 213 return RenderProcessHost::TYPE_EXTENSION; |
| 212 | 214 |
| 213 // TODO(erikkay) creis recommends using UseWebUIForURL instead. | 215 // TODO(erikkay) creis recommends using UseWebUIForURL instead. |
| 214 if (WebUIFactory::HasWebUIScheme(url)) | 216 if (content::GetContentClient()->browser()->GetWebUIFactory()-> |
| 217 HasWebUIScheme(url)) { |
| 215 return RenderProcessHost::TYPE_WEBUI; | 218 return RenderProcessHost::TYPE_WEBUI; |
| 219 } |
| 216 | 220 |
| 217 return RenderProcessHost::TYPE_NORMAL; | 221 return RenderProcessHost::TYPE_NORMAL; |
| 218 } | 222 } |
| 219 | 223 |
| 220 RenderProcessHost::Type SiteInstance::GetRendererType() { | 224 RenderProcessHost::Type SiteInstance::GetRendererType() { |
| 221 // We may not have a site at this point, which generally means this is a | 225 // We may not have a site at this point, which generally means this is a |
| 222 // normal navigation. | 226 // normal navigation. |
| 223 if (!has_site_) | 227 if (!has_site_) |
| 224 return RenderProcessHost::TYPE_NORMAL; | 228 return RenderProcessHost::TYPE_NORMAL; |
| 225 | 229 |
| 226 return RendererTypeForURL(site_); | 230 return RendererTypeForURL(site_); |
| 227 } | 231 } |
| 228 | 232 |
| 229 void SiteInstance::Observe(NotificationType type, | 233 void SiteInstance::Observe(NotificationType type, |
| 230 const NotificationSource& source, | 234 const NotificationSource& source, |
| 231 const NotificationDetails& details) { | 235 const NotificationDetails& details) { |
| 232 DCHECK(type == NotificationType::RENDERER_PROCESS_TERMINATED); | 236 DCHECK(type == NotificationType::RENDERER_PROCESS_TERMINATED); |
| 233 RenderProcessHost* rph = Source<RenderProcessHost>(source).ptr(); | 237 RenderProcessHost* rph = Source<RenderProcessHost>(source).ptr(); |
| 234 if (rph == process_) | 238 if (rph == process_) |
| 235 process_ = NULL; | 239 process_ = NULL; |
| 236 } | 240 } |
| OLD | NEW |