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