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_macros.h" | 7 #include "base/metrics/histogram_macros.h" |
8 #include "content/public/browser/browser_thread.h" | 8 #include "content/public/browser/browser_thread.h" |
9 #include "content/public/browser/render_frame_host.h" | 9 #include "content/public/browser/render_frame_host.h" |
10 #include "content/public/browser/render_process_host.h" | 10 #include "content/public/browser/render_process_host.h" |
| 11 #include "extensions/features/features.h" |
11 #include "url/origin.h" | 12 #include "url/origin.h" |
12 | 13 |
13 #if defined(ENABLE_EXTENSIONS) | 14 #if BUILDFLAG(ENABLE_EXTENSIONS) |
14 #include "extensions/browser/extension_registry.h" | 15 #include "extensions/browser/extension_registry.h" |
15 #include "extensions/common/constants.h" | 16 #include "extensions/common/constants.h" |
16 #include "extensions/common/extension.h" | 17 #include "extensions/common/extension.h" |
17 #endif | 18 #endif |
18 | 19 |
19 using content::BrowserContext; | 20 using content::BrowserContext; |
20 using content::BrowserThread; | 21 using content::BrowserThread; |
21 using content::RenderFrameHost; | 22 using content::RenderFrameHost; |
22 using content::RenderProcessHost; | 23 using content::RenderProcessHost; |
23 using content::SiteInstance; | 24 using content::SiteInstance; |
24 using content::WebContents; | 25 using content::WebContents; |
25 | 26 |
26 namespace { | 27 namespace { |
27 | 28 |
28 bool ShouldIsolate(BrowserContext* browser_context, | 29 bool ShouldIsolate(BrowserContext* browser_context, |
29 const IsolationScenario& scenario, | 30 const IsolationScenario& scenario, |
30 const GURL& site) { | 31 const GURL& site) { |
31 switch (scenario.policy) { | 32 switch (scenario.policy) { |
32 case ISOLATE_NOTHING: | 33 case ISOLATE_NOTHING: |
33 return false; | 34 return false; |
34 case ISOLATE_ALL_SITES: | 35 case ISOLATE_ALL_SITES: |
35 return true; | 36 return true; |
36 case ISOLATE_HTTPS_SITES: | 37 case ISOLATE_HTTPS_SITES: |
37 // Note: For estimation purposes "isolate https sites" is really | 38 // Note: For estimation purposes "isolate https sites" is really |
38 // implemented as "isolate non-http sites". This means that, for example, | 39 // implemented as "isolate non-http sites". This means that, for example, |
39 // the New Tab Page gets counted as two processes under this policy, and | 40 // the New Tab Page gets counted as two processes under this policy, and |
40 // extensions are isolated as well. | 41 // extensions are isolated as well. |
41 return !site.SchemeIs(url::kHttpScheme); | 42 return !site.SchemeIs(url::kHttpScheme); |
42 case ISOLATE_EXTENSIONS: { | 43 case ISOLATE_EXTENSIONS: { |
43 #if !defined(ENABLE_EXTENSIONS) | 44 #if !BUILDFLAG(ENABLE_EXTENSIONS) |
44 return false; | 45 return false; |
45 #else | 46 #else |
46 if (!site.SchemeIs(extensions::kExtensionScheme)) | 47 if (!site.SchemeIs(extensions::kExtensionScheme)) |
47 return false; | 48 return false; |
48 extensions::ExtensionRegistry* registry = | 49 extensions::ExtensionRegistry* registry = |
49 extensions::ExtensionRegistry::Get(browser_context); | 50 extensions::ExtensionRegistry::Get(browser_context); |
50 const extensions::Extension* extension = | 51 const extensions::Extension* extension = |
51 registry->enabled_extensions().GetExtensionOrAppByURL(site); | 52 registry->enabled_extensions().GetExtensionOrAppByURL(site); |
52 return extension && !extension->is_hosted_app(); | 53 return extension && !extension->is_hosted_app(); |
53 #endif | 54 #endif |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 UMA_HISTOGRAM_COUNTS_100( | 284 UMA_HISTOGRAM_COUNTS_100( |
284 "SiteIsolation.IsolateExtensionsProcessCountLowerBound", | 285 "SiteIsolation.IsolateExtensionsProcessCountLowerBound", |
285 process_count_lower_bound[ISOLATE_EXTENSIONS]); | 286 process_count_lower_bound[ISOLATE_EXTENSIONS]); |
286 UMA_HISTOGRAM_COUNTS_100( | 287 UMA_HISTOGRAM_COUNTS_100( |
287 "SiteIsolation.IsolateExtensionsProcessCountEstimate", | 288 "SiteIsolation.IsolateExtensionsProcessCountEstimate", |
288 process_count_estimate[ISOLATE_EXTENSIONS]); | 289 process_count_estimate[ISOLATE_EXTENSIONS]); |
289 UMA_HISTOGRAM_COUNTS_100( | 290 UMA_HISTOGRAM_COUNTS_100( |
290 "SiteIsolation.IsolateExtensionsTotalProcessCountEstimate", | 291 "SiteIsolation.IsolateExtensionsTotalProcessCountEstimate", |
291 process_count_estimate[ISOLATE_EXTENSIONS] + non_renderer_process_count); | 292 process_count_estimate[ISOLATE_EXTENSIONS] + non_renderer_process_count); |
292 } | 293 } |
OLD | NEW |