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/common/profile_management_switches.h" | 5 #include "chrome/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 "chrome/common/chrome_switches.h" | 9 #include "chrome/common/chrome_switches.h" |
10 | 10 |
11 namespace { | 11 namespace { |
12 | 12 |
13 const char kNewProfileManagementFieldTrialName[] = "NewProfileManagement"; | 13 const char kNewProfileManagementFieldTrialName[] = "NewProfileManagement"; |
14 | 14 |
15 bool CheckProfileManagementFlag(std::string command_switch, bool active_state) { | 15 bool CheckProfileManagementFlag(std::string command_switch, bool active_state) { |
| 16 // Individiual flag settings take precedence. |
| 17 if (CommandLine::ForCurrentProcess()->HasSwitch(command_switch)) { |
| 18 return true; |
| 19 } |
| 20 |
| 21 // --new-profile-management flag always affects all switches. |
| 22 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 23 switches::kNewProfileManagement)) { |
| 24 return active_state; |
| 25 } |
| 26 |
| 27 // NewProfileManagement experiment acts like above flag. |
16 std::string trial_type = | 28 std::string trial_type = |
17 base::FieldTrialList::FindFullName(kNewProfileManagementFieldTrialName); | 29 base::FieldTrialList::FindFullName(kNewProfileManagementFieldTrialName); |
18 if (!trial_type.empty()) { | 30 if (!trial_type.empty()) { |
19 if (trial_type == "Enabled") | 31 if (trial_type == "Enabled") |
20 return active_state; | 32 return active_state; |
21 if (trial_type == "Disabled") | 33 if (trial_type == "Disabled") |
22 return !active_state; | 34 return !active_state; |
23 } | 35 } |
24 return CommandLine::ForCurrentProcess()->HasSwitch(command_switch); | 36 |
| 37 return false; |
25 } | 38 } |
26 | 39 |
27 } // namespace | 40 } // namespace |
28 | 41 |
29 namespace switches { | 42 namespace switches { |
30 | 43 |
31 bool IsEnableWebBasedSignin() { | 44 bool IsEnableWebBasedSignin() { |
32 return CheckProfileManagementFlag(switches::kEnableWebBasedSignin, false); | 45 return CheckProfileManagementFlag(switches::kEnableWebBasedSignin, false); |
33 } | 46 } |
34 | 47 |
35 bool IsGoogleProfileInfo() { | 48 bool IsGoogleProfileInfo() { |
36 return CheckProfileManagementFlag(switches::kGoogleProfileInfo, true); | 49 return CheckProfileManagementFlag(switches::kGoogleProfileInfo, true); |
37 } | 50 } |
38 | 51 |
39 bool IsNewProfileManagement() { | 52 bool IsNewProfileManagement() { |
40 return CheckProfileManagementFlag(switches::kNewProfileManagement, true); | 53 return CheckProfileManagementFlag(switches::kNewProfileManagement, true); |
41 } | 54 } |
42 | 55 |
43 } // namespace switches | 56 } // namespace switches |
OLD | NEW |