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::WebUIFactory::Get()->HasWebUIScheme(url)) |
215 return RenderProcessHost::TYPE_WEBUI; | 217 return RenderProcessHost::TYPE_WEBUI; |
216 | 218 |
217 return RenderProcessHost::TYPE_NORMAL; | 219 return RenderProcessHost::TYPE_NORMAL; |
218 } | 220 } |
219 | 221 |
220 RenderProcessHost::Type SiteInstance::GetRendererType() { | 222 RenderProcessHost::Type SiteInstance::GetRendererType() { |
221 // We may not have a site at this point, which generally means this is a | 223 // We may not have a site at this point, which generally means this is a |
222 // normal navigation. | 224 // normal navigation. |
223 if (!has_site_) | 225 if (!has_site_) |
224 return RenderProcessHost::TYPE_NORMAL; | 226 return RenderProcessHost::TYPE_NORMAL; |
225 | 227 |
226 return RendererTypeForURL(site_); | 228 return RendererTypeForURL(site_); |
227 } | 229 } |
228 | 230 |
229 void SiteInstance::Observe(NotificationType type, | 231 void SiteInstance::Observe(NotificationType type, |
230 const NotificationSource& source, | 232 const NotificationSource& source, |
231 const NotificationDetails& details) { | 233 const NotificationDetails& details) { |
232 DCHECK(type == NotificationType::RENDERER_PROCESS_TERMINATED); | 234 DCHECK(type == NotificationType::RENDERER_PROCESS_TERMINATED); |
233 RenderProcessHost* rph = Source<RenderProcessHost>(source).ptr(); | 235 RenderProcessHost* rph = Source<RenderProcessHost>(source).ptr(); |
234 if (rph == process_) | 236 if (rph == process_) |
235 process_ = NULL; | 237 process_ = NULL; |
236 } | 238 } |
OLD | NEW |