OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/site_details.h" | 5 #include "chrome/browser/site_details.h" |
6 | 6 |
7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
8 #include "content/public/browser/browser_thread.h" | 8 #include "content/public/browser/browser_thread.h" |
9 #include "content/public/browser/render_process_host.h" | 9 #include "content/public/browser/render_process_host.h" |
10 | |
11 #if defined(ENABLE_EXTENSIONS) | |
12 #include "extensions/browser/extension_registry.h" | |
10 #include "extensions/common/constants.h" | 13 #include "extensions/common/constants.h" |
14 #include "extensions/common/extension.h" | |
15 #endif | |
11 | 16 |
12 using content::BrowserThread; | 17 using content::BrowserThread; |
13 using content::RenderProcessHost; | 18 using content::RenderProcessHost; |
14 using content::SiteInstance; | 19 using content::SiteInstance; |
15 using content::WebContents; | 20 using content::WebContents; |
16 | 21 |
17 namespace { | 22 namespace { |
18 | 23 |
19 bool ShouldIsolate(IsolationScenarioType policy, const GURL& site) { | 24 bool ShouldIsolate(content::BrowserContext* browser_context, |
25 IsolationScenarioType policy, | |
26 const GURL& site) { | |
20 switch (policy) { | 27 switch (policy) { |
21 case ISOLATE_ALL_SITES: | 28 case ISOLATE_ALL_SITES: |
22 return true; | 29 return true; |
23 case ISOLATE_HTTPS_SITES: | 30 case ISOLATE_HTTPS_SITES: |
24 // Note: For estimation purposes "isolate https sites" is really | 31 // Note: For estimation purposes "isolate https sites" is really |
25 // implemented as "isolate non-http sites". This means that, for example, | 32 // implemented as "isolate non-http sites". This means that, for example, |
26 // the New Tab Page gets counted as two processes under this policy, and | 33 // the New Tab Page gets counted as two processes under this policy, and |
27 // extensions are isolated as well. | 34 // extensions are isolated as well. |
28 return !site.SchemeIs(url::kHttpScheme); | 35 return !site.SchemeIs(url::kHttpScheme); |
29 case ISOLATE_EXTENSIONS: | 36 case ISOLATE_EXTENSIONS: { |
30 return site.SchemeIs(extensions::kExtensionScheme); | 37 #if !defined(ENABLE_EXTENSIONS) |
38 return false; | |
39 #else | |
40 if (!site.SchemeIs(extensions::kExtensionScheme)) | |
41 return false; | |
42 extensions::ExtensionRegistry* registry = | |
43 extensions::ExtensionRegistry::Get(browser_context); | |
44 const extensions::Extension* extension = | |
45 registry->enabled_extensions().GetExtensionOrAppByURL(site); | |
46 return extension && !extension->is_hosted_app(); | |
Charlie Reis
2015/10/12 23:13:28
This is fairly similar to ChromeContentBrowserClie
ncarter (slow)
2015/10/13 20:22:11
I'd thought about this too, and think that duplica
| |
47 #endif | |
48 } | |
31 } | 49 } |
32 NOTREACHED(); | 50 NOTREACHED(); |
33 return true; | 51 return true; |
34 } | 52 } |
35 | 53 |
36 } // namespace | 54 } // namespace |
37 | 55 |
38 IsolationScenario::IsolationScenario() : policy(ISOLATE_ALL_SITES) {} | 56 IsolationScenario::IsolationScenario() : policy(ISOLATE_ALL_SITES) {} |
39 | 57 |
40 IsolationScenario::~IsolationScenario() {} | 58 IsolationScenario::~IsolationScenario() {} |
41 | 59 |
42 void IsolationScenario::CollectSiteInfoForScenario(SiteInstance* primary, | 60 void IsolationScenario::CollectSiteInfoForScenario(SiteInstance* primary, |
43 const GURL& site) { | 61 const GURL& site) { |
44 const GURL& isolated = ShouldIsolate(policy, site) ? site : GURL("http://"); | 62 const GURL& isolated = |
63 ShouldIsolate(primary->GetBrowserContext(), policy, site) | |
64 ? site | |
65 : GURL("http://"); | |
45 sites.insert(isolated); | 66 sites.insert(isolated); |
46 browsing_instance_site_map[primary->GetId()].insert(isolated); | 67 browsing_instance_site_map[primary->GetId()].insert(isolated); |
47 } | 68 } |
48 | 69 |
49 SiteData::SiteData() { | 70 SiteData::SiteData() { |
50 scenarios[ISOLATE_ALL_SITES].policy = ISOLATE_ALL_SITES; | 71 scenarios[ISOLATE_ALL_SITES].policy = ISOLATE_ALL_SITES; |
51 scenarios[ISOLATE_HTTPS_SITES].policy = ISOLATE_HTTPS_SITES; | 72 scenarios[ISOLATE_HTTPS_SITES].policy = ISOLATE_HTTPS_SITES; |
52 scenarios[ISOLATE_EXTENSIONS].policy = ISOLATE_EXTENSIONS; | 73 scenarios[ISOLATE_EXTENSIONS].policy = ISOLATE_EXTENSIONS; |
53 } | 74 } |
54 | 75 |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
169 UMA_HISTOGRAM_COUNTS_100( | 190 UMA_HISTOGRAM_COUNTS_100( |
170 "SiteIsolation.IsolateAllSitesTotalProcessCountEstimate", | 191 "SiteIsolation.IsolateAllSitesTotalProcessCountEstimate", |
171 process_count_estimate[ISOLATE_ALL_SITES] + non_renderer_process_count); | 192 process_count_estimate[ISOLATE_ALL_SITES] + non_renderer_process_count); |
172 UMA_HISTOGRAM_COUNTS_100( | 193 UMA_HISTOGRAM_COUNTS_100( |
173 "SiteIsolation.IsolateHttpsSitesTotalProcessCountEstimate", | 194 "SiteIsolation.IsolateHttpsSitesTotalProcessCountEstimate", |
174 process_count_estimate[ISOLATE_HTTPS_SITES] + non_renderer_process_count); | 195 process_count_estimate[ISOLATE_HTTPS_SITES] + non_renderer_process_count); |
175 UMA_HISTOGRAM_COUNTS_100( | 196 UMA_HISTOGRAM_COUNTS_100( |
176 "SiteIsolation.IsolateExtensionsTotalProcessCountEstimate", | 197 "SiteIsolation.IsolateExtensionsTotalProcessCountEstimate", |
177 process_count_estimate[ISOLATE_EXTENSIONS] + non_renderer_process_count); | 198 process_count_estimate[ISOLATE_EXTENSIONS] + non_renderer_process_count); |
178 } | 199 } |
OLD | NEW |