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