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

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

Issue 323133005: Enable consistent identity on android platform by default. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased 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 "components/signin/core/common/signin_switches.h" 9 #include "components/signin/core/common/signin_switches.h"
10 10
11 namespace { 11 namespace {
12 12
13 const char kNewProfileManagementFieldTrialName[] = "NewProfileManagement"; 13 const char kNewProfileManagementFieldTrialName[] = "NewProfileManagement";
14 14
15 // Different state of new profile management/identity consistency. The code 15 // Different state of new profile management/identity consistency. The code
16 // 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
17 // management is included in consistent identity. 17 // management is included in consistent identity.
18 enum State { 18 enum State {
19 STATE_NONE, 19 STATE_NONE,
20 STATE_NEW_PROFILE_MANAGEMENT, 20 STATE_NEW_PROFILE_MANAGEMENT,
21 STATE_ACCOUNT_CONSISTENCY 21 STATE_ACCOUNT_CONSISTENCY
22 }; 22 };
23 23
24 #if defined(OS_ANDROID)
25
24 State GetProcessState() { 26 State GetProcessState() {
guohui 2014/06/11 15:53:01 eh this method is essentially a copy/paste of the
25 // Get the full name of the field trial so that the underlying mechanism 27 // Get the full name of the field trial so that the underlying mechanism
26 // is properly initialize. 28 // is properly initialize.
noms (inactive) 2014/06/11 14:14:12 nit: s/initialize/initialized, here and below. sor
Roger Tawa OOO till Jul 10th 2014/06/13 02:17:19 Done.
29 std::string trial_type =
30 base::FieldTrialList::FindFullName(kNewProfileManagementFieldTrialName);
31
32 // Find the state of both command line args.
33 bool not_new_profile_management =
34 CommandLine::ForCurrentProcess()->HasSwitch(
35 switches::kDisableNewProfileManagement);
36 bool not_consistent_identity =
37 CommandLine::ForCurrentProcess()->HasSwitch(
38 switches::kDisableAccountConsistency);
39
40 State state = STATE_ACCOUNT_CONSISTENCY;
41
42 // If both command line args are set, disable the field trial completely
43 // since the assigned group is undefined. Otherwise use the state of the
44 // command line flag specified. If neither command line arg is specified,
45 // see if the group was set from the server.
46 if (not_new_profile_management && not_consistent_identity) {
47 base::FieldTrial* field_trial =
48 base::FieldTrialList::Find(kNewProfileManagementFieldTrialName);
49 if (field_trial)
50 field_trial->Disable();
51
52 return STATE_NONE;
53 } else if (not_new_profile_management) {
54 return STATE_NONE;
55 } else if (not_consistent_identity) {
56 return STATE_NEW_PROFILE_MANAGEMENT;
57 }
58
59 if (!trial_type.empty()) {
60 if (trial_type == "Enabled") {
61 state = STATE_NEW_PROFILE_MANAGEMENT;
62 } else if (trial_type == "AccountConsistency") {
63 state = STATE_ACCOUNT_CONSISTENCY;
64 }
65 }
66
67 return state;
68 }
69
70 #else
71
72 State GetProcessState() {
73 // Get the full name of the field trial so that the underlying mechanism
74 // is properly initialize.
27 std::string trial_type = 75 std::string trial_type =
28 base::FieldTrialList::FindFullName(kNewProfileManagementFieldTrialName); 76 base::FieldTrialList::FindFullName(kNewProfileManagementFieldTrialName);
29 77
30 // Find the state of both command line args. 78 // Find the state of both command line args.
31 bool is_new_profile_management = 79 bool is_new_profile_management =
32 CommandLine::ForCurrentProcess()->HasSwitch( 80 CommandLine::ForCurrentProcess()->HasSwitch(
33 switches::kNewProfileManagement); 81 switches::kEnableNewProfileManagement);
34 bool is_consistent_identity = 82 bool is_consistent_identity =
35 CommandLine::ForCurrentProcess()->HasSwitch( 83 CommandLine::ForCurrentProcess()->HasSwitch(
36 switches::kEnableAccountConsistency); 84 switches::kEnableAccountConsistency);
37 85
38 State state = STATE_NONE; 86 State state = STATE_NONE;
39 87
40 // If both command line args are set, disable the field trial completely 88 // If both command line args are set, disable the field trial completely
41 // since the assigned group is undefined. Otherwise use the state of the 89 // since the assigned group is undefined. Otherwise use the state of the
42 // command line flag specified. If neither command line arg is specified, 90 // command line flag specified. If neither command line arg is specified,
43 // see if the group was set from the server. 91 // see if the group was set from the server.
44 if (is_new_profile_management && is_consistent_identity) { 92 if (is_new_profile_management && is_consistent_identity) {
45 base::FieldTrial* field_trial = 93 base::FieldTrial* field_trial =
46 base::FieldTrialList::Find(kNewProfileManagementFieldTrialName); 94 base::FieldTrialList::Find(kNewProfileManagementFieldTrialName);
47 if (field_trial) 95 if (field_trial)
48 field_trial->Disable(); 96 field_trial->Disable();
49 97
50 return STATE_ACCOUNT_CONSISTENCY; 98 return STATE_ACCOUNT_CONSISTENCY;
51 } else if (is_new_profile_management) { 99 } else if (is_new_profile_management) {
52 return STATE_NEW_PROFILE_MANAGEMENT; 100 return STATE_NEW_PROFILE_MANAGEMENT;
53 } else if (is_consistent_identity) { 101 } else if (is_consistent_identity) {
54 return STATE_ACCOUNT_CONSISTENCY; 102 return STATE_ACCOUNT_CONSISTENCY;
55 } 103 }
56 104
57 if (state == STATE_NONE && !trial_type.empty()) { 105 if (!trial_type.empty()) {
58 if (trial_type == "Enabled") { 106 if (trial_type == "Enabled") {
59 state = STATE_NEW_PROFILE_MANAGEMENT; 107 state = STATE_NEW_PROFILE_MANAGEMENT;
60 } else if (trial_type == "AccountConsistency") { 108 } else if (trial_type == "AccountConsistency") {
61 state = STATE_ACCOUNT_CONSISTENCY; 109 state = STATE_ACCOUNT_CONSISTENCY;
62 } 110 }
63 } 111 }
64 112
65 return state; 113 return state;
66 } 114 }
67 115
116 #endif
117
68 bool CheckFlag(std::string command_switch, State min_state) { 118 bool CheckFlag(std::string command_switch, State min_state) {
69 // Individiual flag settings take precedence. 119 // Individiual flag settings take precedence.
70 if (CommandLine::ForCurrentProcess()->HasSwitch(command_switch)) 120 if (CommandLine::ForCurrentProcess()->HasSwitch(command_switch))
71 return true; 121 return true;
72 122
73 return GetProcessState() >= min_state; 123 return GetProcessState() >= min_state;
74 } 124 }
75 125
76 } // namespace 126 } // namespace
77 127
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 return GetProcessState() >= STATE_NEW_PROFILE_MANAGEMENT; 164 return GetProcessState() >= STATE_NEW_PROFILE_MANAGEMENT;
115 } 165 }
116 166
117 bool IsNewProfileManagementPreviewEnabled() { 167 bool IsNewProfileManagementPreviewEnabled() {
118 bool is_new_avatar_menu = 168 bool is_new_avatar_menu =
119 CommandLine::ForCurrentProcess()->HasSwitch(switches::kNewAvatarMenu); 169 CommandLine::ForCurrentProcess()->HasSwitch(switches::kNewAvatarMenu);
120 return is_new_avatar_menu && IsNewProfileManagement(); 170 return is_new_avatar_menu && IsNewProfileManagement();
121 } 171 }
122 172
123 } // namespace switches 173 } // namespace switches
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698