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

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

Issue 340723002: Revert 277793 "Enable consistent identity on android platform by..." (Closed) Base URL: svn://svn.chromium.org/chrome/branches/2056/src/
Patch Set: Created 6 years, 6 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"
10 #include "components/signin/core/common/signin_switches.h" 9 #include "components/signin/core/common/signin_switches.h"
11 10
12 namespace { 11 namespace {
13 12
14 const char kNewProfileManagementFieldTrialName[] = "NewProfileManagement"; 13 const char kNewProfileManagementFieldTrialName[] = "NewProfileManagement";
15 14
16 // Different state of new profile management/identity consistency. The code 15 // 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 16 // below assumes the order of the values in this enum. That is, new profile
18 // management is included in consistent identity. 17 // management is included in consistent identity.
19 enum State { 18 enum State {
20 STATE_NONE, 19 STATE_NONE,
21 STATE_NEW_PROFILE_MANAGEMENT, 20 STATE_NEW_PROFILE_MANAGEMENT,
22 STATE_ACCOUNT_CONSISTENCY 21 STATE_ACCOUNT_CONSISTENCY
23 }; 22 };
24 23
25 State GetProcessState() { 24 State GetProcessState() {
26 // Get the full name of the field trial so that the underlying mechanism 25 // Get the full name of the field trial so that the underlying mechanism
27 // is properly initialized. 26 // is properly initialize.
28 std::string trial_type = 27 std::string trial_type =
29 base::FieldTrialList::FindFullName(kNewProfileManagementFieldTrialName); 28 base::FieldTrialList::FindFullName(kNewProfileManagementFieldTrialName);
30 29
31 // Find the state of both command line args. 30 // Find the state of both command line args.
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::kNewProfileManagement);
35 bool is_consistent_identity = 34 bool is_consistent_identity =
36 CommandLine::ForCurrentProcess()->HasSwitch( 35 CommandLine::ForCurrentProcess()->HasSwitch(
37 switches::kEnableAccountConsistency); 36 switches::kEnableAccountConsistency);
38 bool not_new_profile_management =
39 CommandLine::ForCurrentProcess()->HasSwitch(
40 switches::kDisableNewProfileManagement);
41 bool not_consistent_identity =
42 CommandLine::ForCurrentProcess()->HasSwitch(
43 switches::kDisableAccountConsistency);
44 int count_args = (is_new_profile_management ? 1 : 0) +
45 (is_consistent_identity ? 1 : 0) +
46 (not_new_profile_management ? 1 : 0) +
47 (not_consistent_identity ? 1 : 0);
48 bool invalid_commandline = count_args > 1;
49 37
50 // At most only one of the command line args should be specified, otherwise 38 State state = STATE_NONE;
51 // the finch group assignment is undefined. If this is the case, disable 39
52 // the field trial so that data is not collected in the wrong group. 40 // If both command line args are set, disable the field trial completely
53 if (invalid_commandline) { 41 // since the assigned group is undefined. Otherwise use the state of the
42 // command line flag specified. If neither command line arg is specified,
43 // see if the group was set from the server.
44 if (is_new_profile_management && is_consistent_identity) {
54 base::FieldTrial* field_trial = 45 base::FieldTrial* field_trial =
55 base::FieldTrialList::Find(kNewProfileManagementFieldTrialName); 46 base::FieldTrialList::Find(kNewProfileManagementFieldTrialName);
56 if (field_trial) 47 if (field_trial)
57 field_trial->Disable(); 48 field_trial->Disable();
58 49
59 trial_type.clear();
60 }
61
62 // Enable command line args take precedent over disable command line args.
63 // Consistent identity args take precedent over new profile management args.
64 if (is_consistent_identity) {
65 return STATE_ACCOUNT_CONSISTENCY; 50 return STATE_ACCOUNT_CONSISTENCY;
66 } else if (is_new_profile_management) { 51 } else if (is_new_profile_management) {
67 return STATE_NEW_PROFILE_MANAGEMENT; 52 return STATE_NEW_PROFILE_MANAGEMENT;
68 } else if (not_new_profile_management) { 53 } else if (is_consistent_identity) {
69 return STATE_NONE; 54 return STATE_ACCOUNT_CONSISTENCY;
70 } else if (not_consistent_identity) {
71 return STATE_NEW_PROFILE_MANAGEMENT;
72 } 55 }
73 56
74 #if defined(OS_ANDROID) 57 if (state == STATE_NONE && !trial_type.empty()) {
75 State state = STATE_ACCOUNT_CONSISTENCY;
76 #else
77 State state = STATE_NONE;
78 #endif
79
80 if (!trial_type.empty()) {
81 if (trial_type == "Enabled") { 58 if (trial_type == "Enabled") {
82 state = STATE_NEW_PROFILE_MANAGEMENT; 59 state = STATE_NEW_PROFILE_MANAGEMENT;
83 } else if (trial_type == "AccountConsistency") { 60 } else if (trial_type == "AccountConsistency") {
84 state = STATE_ACCOUNT_CONSISTENCY; 61 state = STATE_ACCOUNT_CONSISTENCY;
85 } else {
86 state = STATE_NONE;
87 } 62 }
88 } 63 }
89 64
90 return state; 65 return state;
91 } 66 }
92 67
93 bool CheckFlag(std::string command_switch, State min_state) { 68 bool CheckFlag(std::string command_switch, State min_state) {
94 // Individiual flag settings take precedence. 69 // Individiual flag settings take precedence.
95 if (CommandLine::ForCurrentProcess()->HasSwitch(command_switch)) 70 if (CommandLine::ForCurrentProcess()->HasSwitch(command_switch))
96 return true; 71 return true;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 bool IsNewProfileManagement() { 113 bool IsNewProfileManagement() {
139 return GetProcessState() >= STATE_NEW_PROFILE_MANAGEMENT; 114 return GetProcessState() >= STATE_NEW_PROFILE_MANAGEMENT;
140 } 115 }
141 116
142 bool IsNewProfileManagementPreviewEnabled() { 117 bool IsNewProfileManagementPreviewEnabled() {
143 bool is_new_avatar_menu = 118 bool is_new_avatar_menu =
144 CommandLine::ForCurrentProcess()->HasSwitch(switches::kNewAvatarMenu); 119 CommandLine::ForCurrentProcess()->HasSwitch(switches::kNewAvatarMenu);
145 return is_new_avatar_menu && IsNewProfileManagement(); 120 return is_new_avatar_menu && IsNewProfileManagement();
146 } 121 }
147 122
148 void EnableNewProfileManagementForTesting(base::CommandLine* command_line) {
149 command_line->AppendSwitch(switches::kEnableNewProfileManagement);
150 DCHECK(!command_line->HasSwitch(switches::kDisableNewProfileManagement));
151 }
152
153 void EnableAccountConsistencyForTesting(base::CommandLine* command_line) {
154 command_line->AppendSwitch(switches::kEnableAccountConsistency);
155 DCHECK(!command_line->HasSwitch(switches::kDisableAccountConsistency));
156 }
157
158 } // namespace switches 123 } // namespace switches
OLDNEW
« no previous file with comments | « components/signin/core/common/profile_management_switches.h ('k') | components/signin/core/common/signin_switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698