Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(256)

Side by Side Diff: components/signin/core/common/profile_management_switches.cc

Issue 431083003: Change new-avatar-menu to an enable-disable flag. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Issue with the rebase Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
11 11
12 namespace { 12 namespace {
13 13
14 const char kNewProfileManagementFieldTrialName[] = "NewProfileManagement"; 14 const char kNewProfileManagementFieldTrialName[] = "NewProfileManagement";
15 15
16 // Different state of new profile management/identity consistency. The code 16 // Different state of new profile management/identity consistency. The code
17 // below assumes the order of the values in this enum. That is, new profile 17 // below assumes the order of the values in this enum. That is, new profile
18 // management is included in consistent identity. 18 // management is included in consistent identity.
19 enum State { 19 enum State {
20 STATE_NONE, 20 STATE_OLD_AVATAR_MENU,
21 STATE_NEW_AVATAR_MENU,
21 STATE_NEW_PROFILE_MANAGEMENT, 22 STATE_NEW_PROFILE_MANAGEMENT,
22 STATE_ACCOUNT_CONSISTENCY 23 STATE_ACCOUNT_CONSISTENCY,
23 }; 24 };
24 25
25 State GetProcessState() { 26 State GetProcessState() {
26 // Get the full name of the field trial so that the underlying mechanism
27 // is properly initialized.
28 std::string trial_type =
29 base::FieldTrialList::FindFullName(kNewProfileManagementFieldTrialName);
30
31 // Find the state of both command line args. 27 // Find the state of both command line args.
28 bool is_new_avatar_menu =
29 CommandLine::ForCurrentProcess()->HasSwitch(
30 switches::kEnableNewAvatarMenu);
32 bool is_new_profile_management = 31 bool is_new_profile_management =
33 CommandLine::ForCurrentProcess()->HasSwitch( 32 CommandLine::ForCurrentProcess()->HasSwitch(
34 switches::kEnableNewProfileManagement); 33 switches::kEnableNewProfileManagement);
35 bool is_consistent_identity = 34 bool is_consistent_identity =
36 CommandLine::ForCurrentProcess()->HasSwitch( 35 CommandLine::ForCurrentProcess()->HasSwitch(
37 switches::kEnableAccountConsistency); 36 switches::kEnableAccountConsistency);
37 bool not_new_avatar_menu =
38 CommandLine::ForCurrentProcess()->HasSwitch(
39 switches::kDisableNewAvatarMenu);
38 bool not_new_profile_management = 40 bool not_new_profile_management =
39 CommandLine::ForCurrentProcess()->HasSwitch( 41 CommandLine::ForCurrentProcess()->HasSwitch(
40 switches::kDisableNewProfileManagement); 42 switches::kDisableNewProfileManagement);
41 bool not_consistent_identity = 43 bool not_consistent_identity =
42 CommandLine::ForCurrentProcess()->HasSwitch( 44 CommandLine::ForCurrentProcess()->HasSwitch(
43 switches::kDisableAccountConsistency); 45 switches::kDisableAccountConsistency);
44 int count_args = (is_new_profile_management ? 1 : 0) + 46 int count_args = (is_new_avatar_menu ? 1 : 0) +
47 (is_new_profile_management ? 1 : 0) +
45 (is_consistent_identity ? 1 : 0) + 48 (is_consistent_identity ? 1 : 0) +
49 (not_new_avatar_menu ? 1 : 0) +
46 (not_new_profile_management ? 1 : 0) + 50 (not_new_profile_management ? 1 : 0) +
47 (not_consistent_identity ? 1 : 0); 51 (not_consistent_identity ? 1 : 0);
48 bool invalid_commandline = count_args > 1; 52 bool invalid_commandline = count_args > 1;
49 53
50 // At most only one of the command line args should be specified, otherwise 54 // At most only one of the command line args should be specified, otherwise
51 // the finch group assignment is undefined. If this is the case, disable 55 // the finch group assignment is undefined. If this is the case, disable
52 // the field trial so that data is not collected in the wrong group. 56 // the field trial so that data is not collected in the wrong group.
57 std::string trial_type;
53 if (invalid_commandline) { 58 if (invalid_commandline) {
54 base::FieldTrial* field_trial = 59 base::FieldTrial* field_trial =
55 base::FieldTrialList::Find(kNewProfileManagementFieldTrialName); 60 base::FieldTrialList::Find(kNewProfileManagementFieldTrialName);
56 if (field_trial) 61 if (field_trial)
57 field_trial->Disable(); 62 field_trial->Disable();
58 63
59 trial_type.clear(); 64 trial_type.clear();
65 } else {
66 // Since the experiment is not being disabled, get the full name of the
67 // field trial which will initialize the underlying mechanism.
68 trial_type =
69 base::FieldTrialList::FindFullName(kNewProfileManagementFieldTrialName);
60 } 70 }
61 71
72 // Forcing the old avatar menu takes precedent over other args.
62 // Enable command line args take precedent over disable command line args. 73 // Enable command line args take precedent over disable command line args.
63 // Consistent identity args take precedent over new profile management args. 74 // Consistent identity args take precedent over new profile management args.
64 if (is_consistent_identity) { 75 if (not_new_avatar_menu) {
76 return STATE_OLD_AVATAR_MENU;
77 } else if (is_consistent_identity) {
65 return STATE_ACCOUNT_CONSISTENCY; 78 return STATE_ACCOUNT_CONSISTENCY;
66 } else if (is_new_profile_management) { 79 } else if (is_new_profile_management) {
67 return STATE_NEW_PROFILE_MANAGEMENT; 80 return STATE_NEW_PROFILE_MANAGEMENT;
81 } else if (is_new_avatar_menu) {
82 return STATE_NEW_AVATAR_MENU;
68 } else if (not_new_profile_management) { 83 } else if (not_new_profile_management) {
69 return STATE_NONE; 84 return STATE_NEW_AVATAR_MENU;
70 } else if (not_consistent_identity) { 85 } else if (not_consistent_identity) {
71 return STATE_NEW_PROFILE_MANAGEMENT; 86 return STATE_NEW_AVATAR_MENU;
72 } 87 }
73 88
89 // Set the default state
74 #if defined(OS_ANDROID) 90 #if defined(OS_ANDROID)
75 State state = STATE_ACCOUNT_CONSISTENCY; 91 State state = STATE_ACCOUNT_CONSISTENCY;
76 #else 92 #else
77 State state = STATE_NONE; 93 State state = STATE_OLD_AVATAR_MENU;
78 #endif 94 #endif
79 95
80 if (!trial_type.empty()) { 96 if (!trial_type.empty()) {
81 if (trial_type == "Enabled") { 97 if (trial_type == "Enabled") {
82 state = STATE_NEW_PROFILE_MANAGEMENT; 98 state = STATE_NEW_PROFILE_MANAGEMENT;
83 } else if (trial_type == "AccountConsistency") { 99 } else if (trial_type == "AccountConsistency") {
84 state = STATE_ACCOUNT_CONSISTENCY; 100 state = STATE_ACCOUNT_CONSISTENCY;
85 } else { 101 } else {
86 state = STATE_NONE; 102 state = STATE_OLD_AVATAR_MENU;
87 } 103 }
88 } 104 }
89 105
90 return state; 106 return state;
91 } 107 }
92 108
93 bool CheckFlag(std::string command_switch, State min_state) { 109 bool CheckFlag(std::string command_switch, State min_state) {
94 // Individiual flag settings take precedence. 110 // Individiual flag settings take precedence.
95 if (CommandLine::ForCurrentProcess()->HasSwitch(command_switch)) 111 if (CommandLine::ForCurrentProcess()->HasSwitch(command_switch))
96 return true; 112 return true;
(...skipping 19 matching lines...) Expand all
116 STATE_NEW_PROFILE_MANAGEMENT); 132 STATE_NEW_PROFILE_MANAGEMENT);
117 } 133 }
118 134
119 bool IsFastUserSwitching() { 135 bool IsFastUserSwitching() {
120 return CommandLine::ForCurrentProcess()->HasSwitch( 136 return CommandLine::ForCurrentProcess()->HasSwitch(
121 switches::kFastUserSwitching); 137 switches::kFastUserSwitching);
122 } 138 }
123 139
124 bool IsGoogleProfileInfo() { 140 bool IsGoogleProfileInfo() {
125 return IsNewAvatarMenu() || 141 return IsNewAvatarMenu() ||
126 CheckFlag(switches::kGoogleProfileInfo, STATE_NONE); 142 CheckFlag(switches::kGoogleProfileInfo, STATE_OLD_AVATAR_MENU);
127 } 143 }
128 144
129 bool IsNewAvatarMenu() { 145 bool IsNewAvatarMenu() {
130 bool is_new_avatar_menu = 146 return GetProcessState() >= STATE_NEW_AVATAR_MENU;
131 CommandLine::ForCurrentProcess()->HasSwitch(switches::kNewAvatarMenu);
132 return is_new_avatar_menu || IsNewProfileManagement();
133 } 147 }
134 148
135 bool IsNewProfileManagement() { 149 bool IsNewProfileManagement() {
136 return GetProcessState() >= STATE_NEW_PROFILE_MANAGEMENT; 150 return GetProcessState() >= STATE_NEW_PROFILE_MANAGEMENT;
137 } 151 }
138 152
139 bool IsNewProfileManagementPreviewEnabled() { 153 bool IsNewProfileManagementPreviewEnabled() {
140 // No promotion to Enable Account Consistency. 154 // No promotion to Enable Account Consistency.
141 return false; 155 return false;
142 } 156 }
143 157
144 void EnableNewAvatarMenuForTesting(base::CommandLine* command_line) { 158 void EnableNewAvatarMenuForTesting(base::CommandLine* command_line) {
145 command_line->AppendSwitch(switches::kNewAvatarMenu); 159 command_line->AppendSwitch(switches::kEnableNewAvatarMenu);
160 DCHECK(!command_line->HasSwitch(switches::kDisableNewAvatarMenu));
146 } 161 }
147 162
148 void EnableNewProfileManagementForTesting(base::CommandLine* command_line) { 163 void EnableNewProfileManagementForTesting(base::CommandLine* command_line) {
149 command_line->AppendSwitch(switches::kEnableNewProfileManagement); 164 command_line->AppendSwitch(switches::kEnableNewProfileManagement);
150 DCHECK(!command_line->HasSwitch(switches::kDisableNewProfileManagement)); 165 DCHECK(!command_line->HasSwitch(switches::kDisableNewProfileManagement));
151 } 166 }
152 167
153 void EnableAccountConsistencyForTesting(base::CommandLine* command_line) { 168 void EnableAccountConsistencyForTesting(base::CommandLine* command_line) {
154 command_line->AppendSwitch(switches::kEnableAccountConsistency); 169 command_line->AppendSwitch(switches::kEnableAccountConsistency);
155 DCHECK(!command_line->HasSwitch(switches::kDisableAccountConsistency)); 170 DCHECK(!command_line->HasSwitch(switches::kDisableAccountConsistency));
156 } 171 }
157 172
158 } // namespace switches 173 } // namespace switches
OLDNEW
« no previous file with comments | « components/signin/core/browser/about_signin_internals.cc ('k') | components/signin/core/common/signin_switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698