OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/signin/core/common/profile_management_switches.h" | 5 #include "components/signin/core/common/profile_management_switches.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/feature_list.h" | 10 #include "base/feature_list.h" |
11 #include "base/metrics/field_trial.h" | 11 #include "base/metrics/field_trial.h" |
| 12 #include "build/build_config.h" |
12 #include "components/signin/core/common/signin_switches.h" | 13 #include "components/signin/core/common/signin_switches.h" |
13 | 14 |
14 namespace switches { | 15 namespace switches { |
15 | 16 |
16 AccountConsistencyMethod GetAccountConsistencyMethod() { | 17 AccountConsistencyMethod GetAccountConsistencyMethod() { |
17 #if defined(OS_ANDROID) || defined(OS_IOS) | 18 #if BUILDFLAG(ENABLE_MIRROR) |
18 // Mirror is enabled on Android and iOS. | 19 // Mirror is enabled on Android and iOS. |
19 return AccountConsistencyMethod::kMirror; | 20 return AccountConsistencyMethod::kMirror; |
20 #else | 21 #else |
21 base::CommandLine* cmd = base::CommandLine::ForCurrentProcess(); | 22 base::CommandLine* cmd = base::CommandLine::ForCurrentProcess(); |
22 std::string method = cmd->GetSwitchValueASCII(switches::kAccountConsistency); | 23 std::string method = cmd->GetSwitchValueASCII(switches::kAccountConsistency); |
23 if (method == switches::kAccountConsistencyMirror) | 24 if (method == switches::kAccountConsistencyMirror) |
24 return AccountConsistencyMethod::kMirror; | 25 return AccountConsistencyMethod::kMirror; |
| 26 |
| 27 #if BUILDFLAG(ENABLE_DICE_SUPPORT) |
25 if (method == switches::kAccountConsistencyDice) | 28 if (method == switches::kAccountConsistencyDice) |
26 return AccountConsistencyMethod::kDice; | 29 return AccountConsistencyMethod::kDice; |
| 30 #endif |
| 31 |
27 return AccountConsistencyMethod::kDisabled; | 32 return AccountConsistencyMethod::kDisabled; |
28 #endif // defined(OS_ANDROID) || defined(OS_IOS) | 33 #endif // BUILDFLAG(ENABLE_MIRROR) |
29 } | 34 } |
30 | 35 |
31 bool IsAccountConsistencyMirrorEnabled() { | 36 bool IsAccountConsistencyMirrorEnabled() { |
32 return GetAccountConsistencyMethod() == AccountConsistencyMethod::kMirror; | 37 return GetAccountConsistencyMethod() == AccountConsistencyMethod::kMirror; |
33 } | 38 } |
34 | 39 |
35 bool IsAccountConsistencyDiceEnabled() { | 40 bool IsAccountConsistencyDiceEnabled() { |
36 return GetAccountConsistencyMethod() == AccountConsistencyMethod::kDice; | 41 return GetAccountConsistencyMethod() == AccountConsistencyMethod::kDice; |
37 } | 42 } |
38 | 43 |
39 bool IsExtensionsMultiAccount() { | 44 bool IsExtensionsMultiAccount() { |
40 #if defined(OS_ANDROID) || defined(OS_IOS) | 45 #if defined(OS_ANDROID) || defined(OS_IOS) |
41 NOTREACHED() << "Extensions are not enabled on Android or iOS"; | 46 NOTREACHED() << "Extensions are not enabled on Android or iOS"; |
42 // Account consistency is enabled on Android and iOS. | 47 // Account consistency is enabled on Android and iOS. |
43 return false; | 48 return false; |
44 #endif | 49 #endif |
45 | 50 |
46 return base::CommandLine::ForCurrentProcess()->HasSwitch( | 51 return base::CommandLine::ForCurrentProcess()->HasSwitch( |
47 switches::kExtensionsMultiAccount) || | 52 switches::kExtensionsMultiAccount) || |
48 GetAccountConsistencyMethod() == AccountConsistencyMethod::kMirror; | 53 GetAccountConsistencyMethod() == AccountConsistencyMethod::kMirror; |
49 } | 54 } |
50 | 55 |
51 void EnableAccountConsistencyMirrorForTesting(base::CommandLine* command_line) { | 56 void EnableAccountConsistencyMirrorForTesting(base::CommandLine* command_line) { |
52 #if !defined(OS_ANDROID) && !defined(OS_IOS) | 57 #if !BUILDFLAG(ENABLE_MIRROR) |
53 command_line->AppendSwitchASCII(switches::kAccountConsistency, | 58 command_line->AppendSwitchASCII(switches::kAccountConsistency, |
54 switches::kAccountConsistencyMirror); | 59 switches::kAccountConsistencyMirror); |
55 #endif | 60 #endif |
56 } | 61 } |
57 | 62 |
58 #if !defined(OS_ANDROID) && !defined(OS_IOS) | 63 #if BUILDFLAG(ENABLE_DICE_SUPPORT) |
59 void EnableAccountConsistencyDiceForTesting(base::CommandLine* command_line) { | 64 void EnableAccountConsistencyDiceForTesting(base::CommandLine* command_line) { |
60 command_line->AppendSwitchASCII(switches::kAccountConsistency, | 65 command_line->AppendSwitchASCII(switches::kAccountConsistency, |
61 switches::kAccountConsistencyDice); | 66 switches::kAccountConsistencyDice); |
62 } | 67 } |
63 #endif | 68 #endif |
64 | 69 |
65 } // namespace switches | 70 } // namespace switches |
OLD | NEW |