Chromium Code Reviews| 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 c1afca4f4dc6e8a87a96f7f2086e488522811481..9640b6fc4d4f1b42240b456323f93b05cb182585 100644 |
| --- a/components/signin/core/common/profile_management_switches.cc |
| +++ b/components/signin/core/common/profile_management_switches.cc |
| @@ -17,39 +17,45 @@ const char kNewProfileManagementFieldTrialName[] = "NewProfileManagement"; |
| // 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_OLD_AVATAR_MENU, |
| + STATE_NEW_AVATAR_MENU, |
| STATE_NEW_PROFILE_MANAGEMENT, |
| STATE_ACCOUNT_CONSISTENCY |
|
msw
2014/08/01 16:45:14
nit: trailing comma
Mike Lerman
2014/08/01 19:15:00
Done.
|
| }; |
| State GetProcessState() { |
| - // Get the full name of the field trial so that the underlying mechanism |
| - // is properly initialized. |
| - std::string trial_type = |
| - base::FieldTrialList::FindFullName(kNewProfileManagementFieldTrialName); |
| - |
| // Find the state of both command line args. |
| + bool is_new_avatar_menu = |
| + CommandLine::ForCurrentProcess()->HasSwitch( |
| + switches::kEnableNewAvatarMenu); |
| bool is_new_profile_management = |
| CommandLine::ForCurrentProcess()->HasSwitch( |
| switches::kEnableNewProfileManagement); |
| bool is_consistent_identity = |
| CommandLine::ForCurrentProcess()->HasSwitch( |
| switches::kEnableAccountConsistency); |
| + bool not_new_avatar_menu = |
| + CommandLine::ForCurrentProcess()->HasSwitch( |
| + switches::kDisableNewAvatarMenu); |
| bool not_new_profile_management = |
| CommandLine::ForCurrentProcess()->HasSwitch( |
| switches::kDisableNewProfileManagement); |
| bool not_consistent_identity = |
| CommandLine::ForCurrentProcess()->HasSwitch( |
| switches::kDisableAccountConsistency); |
| - int count_args = (is_new_profile_management ? 1 : 0) + |
| + int count_args = (is_new_avatar_menu ? 1 : 0) + |
| + (is_new_profile_management ? 1 : 0) + |
| (is_consistent_identity ? 1 : 0) + |
| + (not_new_avatar_menu ? 1 : 0) + |
| (not_new_profile_management ? 1 : 0) + |
| (not_consistent_identity ? 1 : 0); |
| bool invalid_commandline = count_args > 1; |
| + |
|
msw
2014/08/01 16:45:15
nit: remove extra blank line
Mike Lerman
2014/08/01 19:15:00
Done.
|
| // At most only one of the command line args should be specified, otherwise |
| // the finch group assignment is undefined. If this is the case, disable |
| // the field trial so that data is not collected in the wrong group. |
| + std::string trial_type; |
| if (invalid_commandline) { |
| base::FieldTrial* field_trial = |
| base::FieldTrialList::Find(kNewProfileManagementFieldTrialName); |
| @@ -57,24 +63,33 @@ State GetProcessState() { |
| field_trial->Disable(); |
| trial_type.clear(); |
| + } else { |
| + // Since the experiment is not being disabled, get the full name of the |
| + // field trial which will initialize the underlying mechanism. |
| + trial_type = |
| + base::FieldTrialList::FindFullName(kNewProfileManagementFieldTrialName); |
| } |
| + // Forcing the old avatar menu takes precedent over other args. |
| // Enable command line args take precedent over disable command line args. |
| // Consistent identity args take precedent over new profile management args. |
| - if (is_consistent_identity) { |
| + if (not_new_avatar_menu) { |
| + return STATE_OLD_AVATAR_MENU; |
| + } else if (is_consistent_identity) { |
| return STATE_ACCOUNT_CONSISTENCY; |
| } else if (is_new_profile_management) { |
| return STATE_NEW_PROFILE_MANAGEMENT; |
| } else if (not_new_profile_management) { |
| - return STATE_NONE; |
| + return STATE_NEW_AVATAR_MENU; |
| } else if (not_consistent_identity) { |
| - return STATE_NEW_PROFILE_MANAGEMENT; |
| + return STATE_NEW_AVATAR_MENU; |
| } |
| + // Set the default state |
| #if defined(OS_ANDROID) |
| State state = STATE_ACCOUNT_CONSISTENCY; |
| #else |
| - State state = STATE_NONE; |
| + State state = STATE_NEW_AVATAR_MENU; |
| #endif |
| if (!trial_type.empty()) { |
| @@ -83,7 +98,7 @@ State GetProcessState() { |
| } else if (trial_type == "AccountConsistency") { |
| state = STATE_ACCOUNT_CONSISTENCY; |
| } else { |
| - state = STATE_NONE; |
| + state = STATE_NEW_AVATAR_MENU; |
| } |
| } |
| @@ -127,9 +142,7 @@ bool IsGoogleProfileInfo() { |
| } |
| bool IsNewAvatarMenu() { |
| - bool is_new_avatar_menu = |
| - CommandLine::ForCurrentProcess()->HasSwitch(switches::kNewAvatarMenu); |
| - return is_new_avatar_menu || IsNewProfileManagement(); |
| + return GetProcessState() >= STATE_NEW_AVATAR_MENU; |
| } |
| bool IsNewProfileManagement() { |
| @@ -142,7 +155,8 @@ bool IsNewProfileManagementPreviewEnabled() { |
| } |
| void EnableNewAvatarMenuForTesting(base::CommandLine* command_line) { |
| - command_line->AppendSwitch(switches::kNewAvatarMenu); |
| + command_line->AppendSwitch(switches::kEnableNewAvatarMenu); |
| + DCHECK(!command_line->HasSwitch(switches::kDisableNewAvatarMenu)); |
| } |
| void EnableNewProfileManagementForTesting(base::CommandLine* command_line) { |