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/common/url_constants.h" | |
8 #include "content/browser/browsing_instance.h" | 7 #include "content/browser/browsing_instance.h" |
9 #include "content/browser/content_browser_client.h" | 8 #include "content/browser/content_browser_client.h" |
10 #include "content/browser/renderer_host/browser_render_process_host.h" | 9 #include "content/browser/renderer_host/browser_render_process_host.h" |
11 #include "content/browser/webui/web_ui_factory.h" | 10 #include "content/browser/webui/web_ui_factory.h" |
11 #include "content/common/content_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 "content/common/url_constants.h" |
14 #include "net/base/registry_controlled_domain.h" | 14 #include "net/base/registry_controlled_domain.h" |
15 | 15 |
16 // We treat javascript:, about:crash, about:hang, and about:shorthang as the | |
17 // same site as any URL since they are actually modifiers on existing pages. | |
18 static bool IsURLSameAsAnySiteInstance(const GURL& url) { | 16 static bool IsURLSameAsAnySiteInstance(const GURL& url) { |
19 if (!url.is_valid()) | 17 if (!url.is_valid()) |
20 return false; | 18 return false; |
21 return url.SchemeIs(chrome::kJavaScriptScheme) || | 19 |
22 url.spec() == chrome::kAboutCrashURL || | 20 // We treat javascript: and about:crash as the same site as any URL since they |
23 url.spec() == chrome::kAboutKillURL || | 21 // are actually modifiers on existing pages. |
24 url.spec() == chrome::kAboutHangURL || | 22 if (url.SchemeIs(chrome::kJavaScriptScheme) || |
25 url.spec() == chrome::kAboutShorthangURL; | 23 url.spec() == chrome::kAboutCrashURL) { |
24 return true; | |
25 } | |
26 | |
27 const std::set<std::string>* schemes = | |
28 content::GetContentClient()->browser()->GetSchemesSameAsAnySiteInstance(); | |
jam
2011/05/18 22:12:29
instead of getting a set back of urls that the con
Avi (use Gerrit)
2011/05/18 22:13:59
Much better idea, thanks! Will do that.
| |
29 if (!schemes) | |
30 return false; | |
31 | |
32 return schemes->find(url.spec()) != schemes->end(); | |
26 } | 33 } |
27 | 34 |
28 int32 SiteInstance::next_site_instance_id_ = 1; | 35 int32 SiteInstance::next_site_instance_id_ = 1; |
29 | 36 |
30 SiteInstance::SiteInstance(BrowsingInstance* browsing_instance) | 37 SiteInstance::SiteInstance(BrowsingInstance* browsing_instance) |
31 : id_(next_site_instance_id_++), | 38 : id_(next_site_instance_id_++), |
32 browsing_instance_(browsing_instance), | 39 browsing_instance_(browsing_instance), |
33 render_process_host_factory_(NULL), | 40 render_process_host_factory_(NULL), |
34 process_(NULL), | 41 process_(NULL), |
35 max_page_id_(-1), | 42 max_page_id_(-1), |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
220 } | 227 } |
221 | 228 |
222 void SiteInstance::Observe(NotificationType type, | 229 void SiteInstance::Observe(NotificationType type, |
223 const NotificationSource& source, | 230 const NotificationSource& source, |
224 const NotificationDetails& details) { | 231 const NotificationDetails& details) { |
225 DCHECK(type == NotificationType::RENDERER_PROCESS_TERMINATED); | 232 DCHECK(type == NotificationType::RENDERER_PROCESS_TERMINATED); |
226 RenderProcessHost* rph = Source<RenderProcessHost>(source).ptr(); | 233 RenderProcessHost* rph = Source<RenderProcessHost>(source).ptr(); |
227 if (rph == process_) | 234 if (rph == process_) |
228 process_ = NULL; | 235 process_ = NULL; |
229 } | 236 } |
OLD | NEW |