OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/common/site_isolation_policy.h" | 5 #include "content/common/site_isolation_policy.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/feature_list.h" | 8 #include "base/feature_list.h" |
9 #include "content/public/common/content_client.h" | |
10 #include "content/public/common/content_features.h" | 9 #include "content/public/common/content_features.h" |
11 #include "content/public/common/content_switches.h" | 10 #include "content/public/common/content_switches.h" |
12 | 11 |
13 namespace content { | 12 namespace content { |
14 | 13 |
15 // static | 14 // static |
16 bool SiteIsolationPolicy::AreCrossProcessFramesPossible() { | 15 bool SiteIsolationPolicy::AreCrossProcessFramesPossible() { |
17 // Before turning this on for Android, input event routing needs to be | |
18 // completed there, and perf regressions in https://crbug.com/690229 need to be | |
19 // investigated. | |
20 #if defined(OS_ANDROID) | |
21 return UseDedicatedProcessesForAllSites() || | |
22 IsTopDocumentIsolationEnabled() || AreIsolatedOriginsEnabled() || | |
23 GetContentClient()->IsSupplementarySiteIsolationModeEnabled() || | |
24 base::FeatureList::IsEnabled(::features::kGuestViewCrossProcessFrames); | |
25 #else | |
26 return true; | 16 return true; |
27 #endif | |
28 } | 17 } |
29 | 18 |
30 // static | 19 // static |
31 bool SiteIsolationPolicy::UseDedicatedProcessesForAllSites() { | 20 bool SiteIsolationPolicy::UseDedicatedProcessesForAllSites() { |
32 return base::CommandLine::ForCurrentProcess()->HasSwitch( | 21 return base::CommandLine::ForCurrentProcess()->HasSwitch( |
33 switches::kSitePerProcess); | 22 switches::kSitePerProcess); |
34 } | 23 } |
35 | 24 |
36 // static | 25 // static |
37 bool SiteIsolationPolicy::IsTopDocumentIsolationEnabled() { | 26 bool SiteIsolationPolicy::IsTopDocumentIsolationEnabled() { |
38 // --site-per-process trumps --top-document-isolation. | 27 // --site-per-process trumps --top-document-isolation. |
39 if (UseDedicatedProcessesForAllSites()) | 28 if (UseDedicatedProcessesForAllSites()) |
40 return false; | 29 return false; |
41 | 30 |
42 return base::FeatureList::IsEnabled(::features::kTopDocumentIsolation); | 31 return base::FeatureList::IsEnabled(::features::kTopDocumentIsolation); |
43 } | 32 } |
44 | 33 |
45 // static | 34 // static |
46 bool SiteIsolationPolicy::AreIsolatedOriginsEnabled() { | 35 bool SiteIsolationPolicy::AreIsolatedOriginsEnabled() { |
47 // TODO(alexmos): This currently assumes that isolated origins are only added | 36 // TODO(alexmos): This currently assumes that isolated origins are only added |
48 // via the command-line switch, which may not be true in the future. Remove | 37 // via the command-line switch, which may not be true in the future. Remove |
49 // this function when AreCrossProcessFramesPossible becomes true on Android | 38 // this function when AreCrossProcessFramesPossible becomes true on Android |
50 // above. | 39 // above. |
51 return base::CommandLine::ForCurrentProcess()->HasSwitch( | 40 return base::CommandLine::ForCurrentProcess()->HasSwitch( |
52 switches::kIsolateOrigins); | 41 switches::kIsolateOrigins); |
53 } | 42 } |
54 | 43 |
55 } // namespace content | 44 } // namespace content |
OLD | NEW |