Index: components/signin/core/common/profile_management_switches.cc |
diff --git a/components/signin/core/common/profile_management_switches.cc b/components/signin/core/common/profile_management_switches.cc |
index 4fa7e03ce623592263f509b213cbc149d08a73d4..ad405bd3010357e88683043eb4ee0da5ad1f5540 100644 |
--- a/components/signin/core/common/profile_management_switches.cc |
+++ b/components/signin/core/common/profile_management_switches.cc |
@@ -12,41 +12,86 @@ namespace { |
const char kNewProfileManagementFieldTrialName[] = "NewProfileManagement"; |
-bool CheckProfileManagementFlag(std::string command_switch, bool active_state) { |
- // Individiual flag settings take precedence. |
- if (CommandLine::ForCurrentProcess()->HasSwitch(command_switch)) { |
- return true; |
+// Different state of new profile management/identity consistency. The code |
+// below assumes the order of the values in this enum. That is, new profile |
+// management is included in consistent identity. |
+enum State { |
+ STATE_NONE, |
+ STATE_NEW_PROFILE_MANAGEMENT, |
+ STATE_CONSISTENT_IDENTITY |
+}; |
+ |
+State GetProcessState() { |
+ // Get the full name of the field trial so that the underlying mechanism |
+ // is properly initialize. |
+ std::string trial_type = |
+ base::FieldTrialList::FindFullName(kNewProfileManagementFieldTrialName); |
+ |
+ // Find the state of both command line args. |
+ bool is_new_profile_management = |
+ CommandLine::ForCurrentProcess()->HasSwitch( |
+ switches::kNewProfileManagement); |
+ bool is_consistent_identity = |
+ CommandLine::ForCurrentProcess()->HasSwitch( |
+ switches::kConsistentIdentity); |
+ |
+ State state = STATE_NONE; |
+ |
+ // If both command line args are set, disable the field trial completely |
+ // since the assigned group is undefined. Otherwise use the state of the |
+ // command line flag specified. If neither command line arg is specified, |
+ // see if the group was set from the server. |
+ if (is_new_profile_management && is_consistent_identity) { |
+ base::FieldTrial* field_trial = |
+ base::FieldTrialList::Find(kNewProfileManagementFieldTrialName); |
+ if (field_trial) |
+ field_trial->Disable(); |
+ } else if (is_new_profile_management) { |
+ return STATE_NEW_PROFILE_MANAGEMENT; |
+ } else if (is_consistent_identity) { |
+ return STATE_CONSISTENT_IDENTITY; |
} |
- // --new-profile-management flag always affects all switches. |
- if (CommandLine::ForCurrentProcess()->HasSwitch( |
- switches::kNewProfileManagement)) { |
- return active_state; |
+ if (state == STATE_NONE && !trial_type.empty()) { |
+ if (trial_type == "Enabled") { |
+ state = STATE_NEW_PROFILE_MANAGEMENT; |
+ } else if (trial_type == "ConsistentIdentity") { |
+ state = STATE_CONSISTENT_IDENTITY; |
+ } |
} |
- // NewProfileManagement experiment acts like above flag. |
- std::string trial_type = |
- base::FieldTrialList::FindFullName(kNewProfileManagementFieldTrialName); |
- if (!trial_type.empty()) { |
- if (trial_type == "Enabled") |
- return active_state; |
- if (trial_type == "Disabled") |
- return !active_state; |
+ return state; |
+} |
+ |
+bool CheckFlag(std::string command_switch, State max_state, bool active_state) { |
guohui
2014/05/28 18:27:23
as discussed offline, this should be the min_state
Roger Tawa OOO till Jul 10th
2014/05/29 01:23:12
Yeah, not sure how I reversed the condition. At t
|
+ // Individiual flag settings take precedence. |
+ if (CommandLine::ForCurrentProcess()->HasSwitch(command_switch)) { |
+ return true; |
} |
- return false; |
+ State state = GetProcessState(); |
+ return state == STATE_NONE |
+ ? false : (state <= max_state ? active_state : !active_state); |
} |
} // namespace |
namespace switches { |
+bool IsConsistentIdentity() { |
+ return GetProcessState() >= STATE_CONSISTENT_IDENTITY; |
+} |
+ |
bool IsEnableWebBasedSignin() { |
- return CheckProfileManagementFlag(switches::kEnableWebBasedSignin, false); |
+ return CheckFlag(switches::kEnableWebBasedSignin, |
+ STATE_NEW_PROFILE_MANAGEMENT, |
+ false); |
} |
bool IsExtensionsMultiAccount() { |
- return CheckProfileManagementFlag(switches::kExtensionsMultiAccount, true); |
+ return CheckFlag(switches::kExtensionsMultiAccount, |
+ STATE_NEW_PROFILE_MANAGEMENT, |
+ true); |
} |
bool IsFastUserSwitching() { |
@@ -58,7 +103,9 @@ bool IsFastUserSwitching() { |
} |
bool IsGoogleProfileInfo() { |
- return CheckProfileManagementFlag(switches::kGoogleProfileInfo, true); |
+ return CheckFlag(switches::kGoogleProfileInfo, |
+ STATE_NEW_PROFILE_MANAGEMENT, |
+ true); |
} |
bool IsNewAvatarMenu() { |
@@ -68,7 +115,7 @@ bool IsNewAvatarMenu() { |
} |
bool IsNewProfileManagement() { |
- return CheckProfileManagementFlag(switches::kNewProfileManagement, true); |
+ return GetProcessState() >= STATE_NEW_PROFILE_MANAGEMENT; |
} |
bool IsNewProfileManagementPreviewEnabled() { |