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 "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/metrics/field_trial.h" | 8 #include "base/metrics/field_trial.h" |
9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
10 #include "components/signin/core/common/signin_switches.h" | 10 #include "components/signin/core/common/signin_switches.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 }; | 24 }; |
25 | 25 |
26 State GetProcessState() { | 26 State GetProcessState() { |
27 // Disables the new avatar menu if the web-based signin is turned on, because | 27 // Disables the new avatar menu if the web-based signin is turned on, because |
28 // the new avatar menu always uses the inline signin, which may break some | 28 // the new avatar menu always uses the inline signin, which may break some |
29 // SAML users. | 29 // SAML users. |
30 if (switches::IsEnableWebBasedSignin()) | 30 if (switches::IsEnableWebBasedSignin()) |
31 return STATE_OLD_AVATAR_MENU; | 31 return STATE_OLD_AVATAR_MENU; |
32 | 32 |
33 // Find the state of both command line args. | 33 // Find the state of both command line args. |
34 bool is_new_avatar_menu = | 34 bool is_new_avatar_menu = base::CommandLine::ForCurrentProcess()->HasSwitch( |
35 CommandLine::ForCurrentProcess()->HasSwitch( | 35 switches::kEnableNewAvatarMenu); |
36 switches::kEnableNewAvatarMenu); | |
37 bool is_new_profile_management = | 36 bool is_new_profile_management = |
38 CommandLine::ForCurrentProcess()->HasSwitch( | 37 base::CommandLine::ForCurrentProcess()->HasSwitch( |
39 switches::kEnableNewProfileManagement); | 38 switches::kEnableNewProfileManagement); |
40 bool is_consistent_identity = | 39 bool is_consistent_identity = |
41 CommandLine::ForCurrentProcess()->HasSwitch( | 40 base::CommandLine::ForCurrentProcess()->HasSwitch( |
42 switches::kEnableAccountConsistency); | 41 switches::kEnableAccountConsistency); |
43 bool not_new_avatar_menu = | 42 bool not_new_avatar_menu = base::CommandLine::ForCurrentProcess()->HasSwitch( |
44 CommandLine::ForCurrentProcess()->HasSwitch( | 43 switches::kDisableNewAvatarMenu); |
45 switches::kDisableNewAvatarMenu); | |
46 bool not_new_profile_management = | 44 bool not_new_profile_management = |
47 CommandLine::ForCurrentProcess()->HasSwitch( | 45 base::CommandLine::ForCurrentProcess()->HasSwitch( |
48 switches::kDisableNewProfileManagement); | 46 switches::kDisableNewProfileManagement); |
49 bool not_consistent_identity = | 47 bool not_consistent_identity = |
50 CommandLine::ForCurrentProcess()->HasSwitch( | 48 base::CommandLine::ForCurrentProcess()->HasSwitch( |
51 switches::kDisableAccountConsistency); | 49 switches::kDisableAccountConsistency); |
52 int count_args = (is_new_avatar_menu ? 1 : 0) + | 50 int count_args = (is_new_avatar_menu ? 1 : 0) + |
53 (is_new_profile_management ? 1 : 0) + | 51 (is_new_profile_management ? 1 : 0) + |
54 (is_consistent_identity ? 1 : 0) + | 52 (is_consistent_identity ? 1 : 0) + |
55 (not_new_avatar_menu ? 1 : 0) + | 53 (not_new_avatar_menu ? 1 : 0) + |
56 (not_new_profile_management ? 1 : 0) + | 54 (not_new_profile_management ? 1 : 0) + |
57 (not_consistent_identity ? 1 : 0); | 55 (not_consistent_identity ? 1 : 0); |
58 bool invalid_commandline = count_args > 1; | 56 bool invalid_commandline = count_args > 1; |
59 | 57 |
60 // At most only one of the command line args should be specified, otherwise | 58 // At most only one of the command line args should be specified, otherwise |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 } else { | 107 } else { |
110 state = STATE_OLD_AVATAR_MENU; | 108 state = STATE_OLD_AVATAR_MENU; |
111 } | 109 } |
112 } | 110 } |
113 | 111 |
114 return state; | 112 return state; |
115 } | 113 } |
116 | 114 |
117 bool CheckFlag(std::string command_switch, State min_state) { | 115 bool CheckFlag(std::string command_switch, State min_state) { |
118 // Individiual flag settings take precedence. | 116 // Individiual flag settings take precedence. |
119 if (CommandLine::ForCurrentProcess()->HasSwitch(command_switch)) | 117 if (base::CommandLine::ForCurrentProcess()->HasSwitch(command_switch)) |
120 return true; | 118 return true; |
121 | 119 |
122 return GetProcessState() >= min_state; | 120 return GetProcessState() >= min_state; |
123 } | 121 } |
124 | 122 |
125 } // namespace | 123 } // namespace |
126 | 124 |
127 namespace switches { | 125 namespace switches { |
128 | 126 |
129 bool IsEnableAccountConsistency() { | 127 bool IsEnableAccountConsistency() { |
130 return GetProcessState() >= STATE_ACCOUNT_CONSISTENCY; | 128 return GetProcessState() >= STATE_ACCOUNT_CONSISTENCY; |
131 } | 129 } |
132 | 130 |
133 bool IsEnableWebBasedSignin() { | 131 bool IsEnableWebBasedSignin() { |
134 return CommandLine::ForCurrentProcess()->HasSwitch( | 132 return base::CommandLine::ForCurrentProcess()->HasSwitch( |
135 switches::kEnableWebBasedSignin) && !IsEnableWebviewBasedSignin(); | 133 switches::kEnableWebBasedSignin) && |
| 134 !IsEnableWebviewBasedSignin(); |
136 } | 135 } |
137 | 136 |
138 bool IsEnableWebviewBasedSignin() { | 137 bool IsEnableWebviewBasedSignin() { |
139 return CommandLine::ForCurrentProcess()->HasSwitch( | 138 return base::CommandLine::ForCurrentProcess()->HasSwitch( |
140 switches::kEnableWebviewBasedSignin); | 139 switches::kEnableWebviewBasedSignin); |
141 } | 140 } |
142 | 141 |
143 bool IsExtensionsMultiAccount() { | 142 bool IsExtensionsMultiAccount() { |
144 return CheckFlag(switches::kExtensionsMultiAccount, | 143 return CheckFlag(switches::kExtensionsMultiAccount, |
145 STATE_NEW_PROFILE_MANAGEMENT); | 144 STATE_NEW_PROFILE_MANAGEMENT); |
146 } | 145 } |
147 | 146 |
148 bool IsFastUserSwitching() { | 147 bool IsFastUserSwitching() { |
149 return CommandLine::ForCurrentProcess()->HasSwitch( | 148 return base::CommandLine::ForCurrentProcess()->HasSwitch( |
150 switches::kFastUserSwitching); | 149 switches::kFastUserSwitching); |
151 } | 150 } |
152 | 151 |
153 bool IsGoogleProfileInfo() { | 152 bool IsGoogleProfileInfo() { |
154 return CheckFlag(switches::kGoogleProfileInfo, STATE_NEW_AVATAR_MENU); | 153 return CheckFlag(switches::kGoogleProfileInfo, STATE_NEW_AVATAR_MENU); |
155 } | 154 } |
156 | 155 |
157 bool IsNewAvatarMenu() { | 156 bool IsNewAvatarMenu() { |
158 // NewAvatarMenu is only available on desktop. | 157 // NewAvatarMenu is only available on desktop. |
159 #if defined(OS_ANDROID) || defined(OS_IOS) || defined(OS_CHROMEOS) | 158 #if defined(OS_ANDROID) || defined(OS_IOS) || defined(OS_CHROMEOS) |
(...skipping 26 matching lines...) Expand all Loading... |
186 command_line->AppendSwitch(switches::kEnableNewProfileManagement); | 185 command_line->AppendSwitch(switches::kEnableNewProfileManagement); |
187 DCHECK(!command_line->HasSwitch(switches::kDisableNewProfileManagement)); | 186 DCHECK(!command_line->HasSwitch(switches::kDisableNewProfileManagement)); |
188 } | 187 } |
189 | 188 |
190 void EnableAccountConsistencyForTesting(base::CommandLine* command_line) { | 189 void EnableAccountConsistencyForTesting(base::CommandLine* command_line) { |
191 command_line->AppendSwitch(switches::kEnableAccountConsistency); | 190 command_line->AppendSwitch(switches::kEnableAccountConsistency); |
192 DCHECK(!command_line->HasSwitch(switches::kDisableAccountConsistency)); | 191 DCHECK(!command_line->HasSwitch(switches::kDisableAccountConsistency)); |
193 } | 192 } |
194 | 193 |
195 } // namespace switches | 194 } // namespace switches |
OLD | NEW |