Commit 9152a547 authored by mlerman@chromium.org's avatar mlerman@chromium.org

Move avatar_menu to disable-enable flag. A future CL will set the default...

Move avatar_menu to disable-enable flag. A future CL will set the default behavior to be new_avatar_menu=enabled.

BUG=391497
TBR=davemoore@chromium.org (changes are very minor and are in unit tests)

Review URL: https://codereview.chromium.org/431083003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@287684 0039d316-1c4b-4281-b951-d872f2087c98
parent 18fe977e
...@@ -1456,7 +1456,8 @@ const Experiment kExperiments[] = { ...@@ -1456,7 +1456,8 @@ const Experiment kExperiments[] = {
IDS_FLAGS_ENABLE_NEW_AVATAR_MENU_NAME, IDS_FLAGS_ENABLE_NEW_AVATAR_MENU_NAME,
IDS_FLAGS_ENABLE_NEW_AVATAR_MENU_DESCRIPTION, IDS_FLAGS_ENABLE_NEW_AVATAR_MENU_DESCRIPTION,
kOsMac | kOsWin | kOsLinux, kOsMac | kOsWin | kOsLinux,
SINGLE_VALUE_TYPE(switches::kNewAvatarMenu) ENABLE_DISABLE_VALUE_TYPE(switches::kEnableNewAvatarMenu,
switches::kDisableNewAvatarMenu)
}, },
{ {
"enable-web-based-signin", "enable-web-based-signin",
......
...@@ -53,6 +53,7 @@ class MessageCenterSettingsControllerTest : public testing::Test { ...@@ -53,6 +53,7 @@ class MessageCenterSettingsControllerTest : public testing::Test {
private: private:
TestingProfileManager testing_profile_manager_; TestingProfileManager testing_profile_manager_;
scoped_ptr<MessageCenterSettingsController> controller_; scoped_ptr<MessageCenterSettingsController> controller_;
content::TestBrowserThreadBundle thread_bundle_;
DISALLOW_COPY_AND_ASSIGN(MessageCenterSettingsControllerTest); DISALLOW_COPY_AND_ASSIGN(MessageCenterSettingsControllerTest);
}; };
......
...@@ -531,7 +531,7 @@ TEST_F(ProfileInfoCacheTest, AddStubProfile) { ...@@ -531,7 +531,7 @@ TEST_F(ProfileInfoCacheTest, AddStubProfile) {
} }
TEST_F(ProfileInfoCacheTest, DownloadHighResAvatarTest) { TEST_F(ProfileInfoCacheTest, DownloadHighResAvatarTest) {
CommandLine::ForCurrentProcess()->AppendSwitch(switches::kNewAvatarMenu); switches::EnableNewAvatarMenuForTesting(CommandLine::ForCurrentProcess());
EXPECT_EQ(0U, GetCache()->GetNumberOfProfiles()); EXPECT_EQ(0U, GetCache()->GetNumberOfProfiles());
base::FilePath path_1 = GetProfilePath("path_1"); base::FilePath path_1 = GetProfilePath("path_1");
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include "chrome/browser/profiles/profiles_state.h" #include "chrome/browser/profiles/profiles_state.h"
#include "chrome/test/base/testing_browser_process.h" #include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile_manager.h" #include "chrome/test/base/testing_profile_manager.h"
#include "content/public/test/test_browser_thread_bundle.h"
#include "grit/generated_resources.h" #include "grit/generated_resources.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
...@@ -86,6 +87,7 @@ class ProfileListDesktopTest : public testing::Test { ...@@ -86,6 +87,7 @@ class ProfileListDesktopTest : public testing::Test {
TestingProfileManager manager_; TestingProfileManager manager_;
scoped_ptr<MockObserver> mock_observer_; scoped_ptr<MockObserver> mock_observer_;
scoped_ptr<AvatarMenu> avatar_menu_; scoped_ptr<AvatarMenu> avatar_menu_;
content::TestBrowserThreadBundle thread_bundle_;
DISALLOW_COPY_AND_ASSIGN(ProfileListDesktopTest); DISALLOW_COPY_AND_ASSIGN(ProfileListDesktopTest);
}; };
......
...@@ -75,10 +75,6 @@ class ProfileChooserControllerTest : public CocoaProfileTest { ...@@ -75,10 +75,6 @@ class ProfileChooserControllerTest : public CocoaProfileTest {
[controller_ showWindow:nil]; [controller_ showWindow:nil];
} }
void EnableNewAvatarMenuOnly() {
CommandLine::ForCurrentProcess()->AppendSwitch(switches::kNewAvatarMenu);
}
void EnableFastUserSwitching() { void EnableFastUserSwitching() {
CommandLine::ForCurrentProcess()->AppendSwitch( CommandLine::ForCurrentProcess()->AppendSwitch(
switches::kFastUserSwitching); switches::kFastUserSwitching);
...@@ -97,7 +93,7 @@ class ProfileChooserControllerTest : public CocoaProfileTest { ...@@ -97,7 +93,7 @@ class ProfileChooserControllerTest : public CocoaProfileTest {
}; };
TEST_F(ProfileChooserControllerTest, InitialLayoutWithNewMenu) { TEST_F(ProfileChooserControllerTest, InitialLayoutWithNewMenu) {
EnableNewAvatarMenuOnly(); switches::EnableNewAvatarMenuForTesting(CommandLine::ForCurrentProcess());
StartProfileChooserController(); StartProfileChooserController();
NSArray* subviews = [[[controller() window] contentView] subviews]; NSArray* subviews = [[[controller() window] contentView] subviews];
...@@ -159,7 +155,7 @@ TEST_F(ProfileChooserControllerTest, InitialLayoutWithNewMenu) { ...@@ -159,7 +155,7 @@ TEST_F(ProfileChooserControllerTest, InitialLayoutWithNewMenu) {
} }
TEST_F(ProfileChooserControllerTest, InitialLayoutWithFastUserSwitcher) { TEST_F(ProfileChooserControllerTest, InitialLayoutWithFastUserSwitcher) {
EnableNewAvatarMenuOnly(); switches::EnableNewAvatarMenuForTesting(CommandLine::ForCurrentProcess());
EnableFastUserSwitching(); EnableFastUserSwitching();
StartProfileChooserController(); StartProfileChooserController();
...@@ -218,7 +214,7 @@ TEST_F(ProfileChooserControllerTest, InitialLayoutWithFastUserSwitcher) { ...@@ -218,7 +214,7 @@ TEST_F(ProfileChooserControllerTest, InitialLayoutWithFastUserSwitcher) {
} }
TEST_F(ProfileChooserControllerTest, OtherProfilesSortedAlphabetically) { TEST_F(ProfileChooserControllerTest, OtherProfilesSortedAlphabetically) {
EnableNewAvatarMenuOnly(); switches::EnableNewAvatarMenuForTesting(CommandLine::ForCurrentProcess());
EnableFastUserSwitching(); EnableFastUserSwitching();
// Add two extra profiles, to make sure sorting is alphabetical and not // Add two extra profiles, to make sure sorting is alphabetical and not
...@@ -259,7 +255,7 @@ TEST_F(ProfileChooserControllerTest, OtherProfilesSortedAlphabetically) { ...@@ -259,7 +255,7 @@ TEST_F(ProfileChooserControllerTest, OtherProfilesSortedAlphabetically) {
TEST_F(ProfileChooserControllerTest, TEST_F(ProfileChooserControllerTest,
LocalProfileActiveCardLinksWithNewMenu) { LocalProfileActiveCardLinksWithNewMenu) {
EnableNewAvatarMenuOnly(); switches::EnableNewAvatarMenuForTesting(CommandLine::ForCurrentProcess());
StartProfileChooserController(); StartProfileChooserController();
NSArray* subviews = [[[controller() window] contentView] subviews]; NSArray* subviews = [[[controller() window] contentView] subviews];
ASSERT_EQ(1U, [subviews count]); ASSERT_EQ(1U, [subviews count]);
...@@ -305,7 +301,7 @@ TEST_F(ProfileChooserControllerTest, ...@@ -305,7 +301,7 @@ TEST_F(ProfileChooserControllerTest,
TEST_F(ProfileChooserControllerTest, TEST_F(ProfileChooserControllerTest,
SignedInProfileActiveCardLinksWithNewMenu) { SignedInProfileActiveCardLinksWithNewMenu) {
EnableNewAvatarMenuOnly(); switches::EnableNewAvatarMenuForTesting(CommandLine::ForCurrentProcess());
// Sign in the first profile. // Sign in the first profile.
ProfileInfoCache* cache = testing_profile_manager()->profile_info_cache(); ProfileInfoCache* cache = testing_profile_manager()->profile_info_cache();
cache->SetUserNameOfProfileAtIndex(0, base::ASCIIToUTF16(kEmail)); cache->SetUserNameOfProfileAtIndex(0, base::ASCIIToUTF16(kEmail));
......
...@@ -53,13 +53,12 @@ ProfileChooserViewBrowserTest::~ProfileChooserViewBrowserTest() { ...@@ -53,13 +53,12 @@ ProfileChooserViewBrowserTest::~ProfileChooserViewBrowserTest() {
void ProfileChooserViewBrowserTest::SetUp() { void ProfileChooserViewBrowserTest::SetUp() {
InProcessBrowserTest::SetUp(); InProcessBrowserTest::SetUp();
DCHECK(CommandLine::ForCurrentProcess()->HasSwitch( DCHECK(switches::IsNewAvatarMenu());
switches::kNewAvatarMenu));
} }
void ProfileChooserViewBrowserTest::SetUpCommandLine( void ProfileChooserViewBrowserTest::SetUpCommandLine(
CommandLine* command_line) { CommandLine* command_line) {
command_line->AppendSwitch(switches::kNewAvatarMenu); switches::EnableNewAvatarMenuForTesting(CommandLine::ForCurrentProcess());
} }
void ProfileChooserViewBrowserTest::OpenProfileChooserView() { void ProfileChooserViewBrowserTest::OpenProfileChooserView() {
......
...@@ -365,14 +365,10 @@ scoped_ptr<base::DictionaryValue> AboutSigninInternals::SigninStatus::ToValue( ...@@ -365,14 +365,10 @@ scoped_ptr<base::DictionaryValue> AboutSigninInternals::SigninStatus::ToValue(
AddSectionEntry(basic_info, "Signin Status", signin_status_string); AddSectionEntry(basic_info, "Signin Status", signin_status_string);
AddSectionEntry(basic_info, "Web Based Signin Enabled?", AddSectionEntry(basic_info, "Web Based Signin Enabled?",
switches::IsEnableWebBasedSignin() == true ? "True" : "False"); switches::IsEnableWebBasedSignin() == true ? "True" : "False");
AddSectionEntry(basic_info, "New Profile Management Enabled?",
switches::IsNewProfileManagement() == true ? "True" : "False");
AddSectionEntry(basic_info, "New Avatar Menu Enabled?", AddSectionEntry(basic_info, "New Avatar Menu Enabled?",
switches::IsNewAvatarMenu() == true ? "True" : "False"); switches::IsNewAvatarMenu() == true ? "True" : "False");
bool new_avatar_menu_flag = AddSectionEntry(basic_info, "New Profile Management Enabled?",
CommandLine::ForCurrentProcess()->HasSwitch(switches::kNewAvatarMenu); switches::IsNewProfileManagement() == true ? "True" : "False");
AddSectionEntry(basic_info, "New Avatar Menu Flag Set?",
new_avatar_menu_flag ? "True" : "False");
AddSectionEntry(basic_info, "Account Consistency Enabled?", AddSectionEntry(basic_info, "Account Consistency Enabled?",
switches::IsEnableAccountConsistency() == true ? "True" : "False"); switches::IsEnableAccountConsistency() == true ? "True" : "False");
......
...@@ -17,32 +17,36 @@ const char kNewProfileManagementFieldTrialName[] = "NewProfileManagement"; ...@@ -17,32 +17,36 @@ const char kNewProfileManagementFieldTrialName[] = "NewProfileManagement";
// below assumes the order of the values in this enum. That is, new profile // below assumes the order of the values in this enum. That is, new profile
// management is included in consistent identity. // management is included in consistent identity.
enum State { enum State {
STATE_NONE, STATE_OLD_AVATAR_MENU,
STATE_NEW_AVATAR_MENU,
STATE_NEW_PROFILE_MANAGEMENT, STATE_NEW_PROFILE_MANAGEMENT,
STATE_ACCOUNT_CONSISTENCY STATE_ACCOUNT_CONSISTENCY,
}; };
State GetProcessState() { 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. // Find the state of both command line args.
bool is_new_avatar_menu =
CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableNewAvatarMenu);
bool is_new_profile_management = bool is_new_profile_management =
CommandLine::ForCurrentProcess()->HasSwitch( CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableNewProfileManagement); switches::kEnableNewProfileManagement);
bool is_consistent_identity = bool is_consistent_identity =
CommandLine::ForCurrentProcess()->HasSwitch( CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableAccountConsistency); switches::kEnableAccountConsistency);
bool not_new_avatar_menu =
CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDisableNewAvatarMenu);
bool not_new_profile_management = bool not_new_profile_management =
CommandLine::ForCurrentProcess()->HasSwitch( CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDisableNewProfileManagement); switches::kDisableNewProfileManagement);
bool not_consistent_identity = bool not_consistent_identity =
CommandLine::ForCurrentProcess()->HasSwitch( CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDisableAccountConsistency); 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) + (is_consistent_identity ? 1 : 0) +
(not_new_avatar_menu ? 1 : 0) +
(not_new_profile_management ? 1 : 0) + (not_new_profile_management ? 1 : 0) +
(not_consistent_identity ? 1 : 0); (not_consistent_identity ? 1 : 0);
bool invalid_commandline = count_args > 1; bool invalid_commandline = count_args > 1;
...@@ -50,6 +54,7 @@ State GetProcessState() { ...@@ -50,6 +54,7 @@ State GetProcessState() {
// At most only one of the command line args should be specified, otherwise // 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 finch group assignment is undefined. If this is the case, disable
// the field trial so that data is not collected in the wrong group. // the field trial so that data is not collected in the wrong group.
std::string trial_type;
if (invalid_commandline) { if (invalid_commandline) {
base::FieldTrial* field_trial = base::FieldTrial* field_trial =
base::FieldTrialList::Find(kNewProfileManagementFieldTrialName); base::FieldTrialList::Find(kNewProfileManagementFieldTrialName);
...@@ -57,24 +62,35 @@ State GetProcessState() { ...@@ -57,24 +62,35 @@ State GetProcessState() {
field_trial->Disable(); field_trial->Disable();
trial_type.clear(); 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. // Enable command line args take precedent over disable command line args.
// Consistent identity args take precedent over new profile management 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; return STATE_ACCOUNT_CONSISTENCY;
} else if (is_new_profile_management) { } else if (is_new_profile_management) {
return STATE_NEW_PROFILE_MANAGEMENT; return STATE_NEW_PROFILE_MANAGEMENT;
} else if (is_new_avatar_menu) {
return STATE_NEW_AVATAR_MENU;
} else if (not_new_profile_management) { } else if (not_new_profile_management) {
return STATE_NONE; return STATE_NEW_AVATAR_MENU;
} else if (not_consistent_identity) { } else if (not_consistent_identity) {
return STATE_NEW_PROFILE_MANAGEMENT; return STATE_NEW_AVATAR_MENU;
} }
// Set the default state
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
State state = STATE_ACCOUNT_CONSISTENCY; State state = STATE_ACCOUNT_CONSISTENCY;
#else #else
State state = STATE_NONE; State state = STATE_OLD_AVATAR_MENU;
#endif #endif
if (!trial_type.empty()) { if (!trial_type.empty()) {
...@@ -83,7 +99,7 @@ State GetProcessState() { ...@@ -83,7 +99,7 @@ State GetProcessState() {
} else if (trial_type == "AccountConsistency") { } else if (trial_type == "AccountConsistency") {
state = STATE_ACCOUNT_CONSISTENCY; state = STATE_ACCOUNT_CONSISTENCY;
} else { } else {
state = STATE_NONE; state = STATE_OLD_AVATAR_MENU;
} }
} }
...@@ -123,13 +139,11 @@ bool IsFastUserSwitching() { ...@@ -123,13 +139,11 @@ bool IsFastUserSwitching() {
bool IsGoogleProfileInfo() { bool IsGoogleProfileInfo() {
return IsNewAvatarMenu() || return IsNewAvatarMenu() ||
CheckFlag(switches::kGoogleProfileInfo, STATE_NONE); CheckFlag(switches::kGoogleProfileInfo, STATE_OLD_AVATAR_MENU);
} }
bool IsNewAvatarMenu() { bool IsNewAvatarMenu() {
bool is_new_avatar_menu = return GetProcessState() >= STATE_NEW_AVATAR_MENU;
CommandLine::ForCurrentProcess()->HasSwitch(switches::kNewAvatarMenu);
return is_new_avatar_menu || IsNewProfileManagement();
} }
bool IsNewProfileManagement() { bool IsNewProfileManagement() {
...@@ -142,7 +156,8 @@ bool IsNewProfileManagementPreviewEnabled() { ...@@ -142,7 +156,8 @@ bool IsNewProfileManagementPreviewEnabled() {
} }
void EnableNewAvatarMenuForTesting(base::CommandLine* command_line) { 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) { void EnableNewProfileManagementForTesting(base::CommandLine* command_line) {
......
...@@ -16,13 +16,19 @@ const char kDisableAccountConsistency[] = "disable-account-consistency"; ...@@ -16,13 +16,19 @@ const char kDisableAccountConsistency[] = "disable-account-consistency";
// Disables new profile management system, including new profile chooser UI. // Disables new profile management system, including new profile chooser UI.
const char kDisableNewProfileManagement[] = "disable-new-profile-management"; const char kDisableNewProfileManagement[] = "disable-new-profile-management";
// Disables the new avatar menu, forcing the top-corner avatar button.
const char kDisableNewAvatarMenu[] = "disable-new-avatar-menu";
// Disable sending signin scoped device id to LSO with refresh token request. // Disable sending signin scoped device id to LSO with refresh token request.
const char kDisableSigninScopedDeviceId[] = "disable-signin-scoped-device-id"; const char kDisableSigninScopedDeviceId[] = "disable-signin-scoped-device-id";
// Enables consistent identity features. // Enables consistent identity features.
const char kEnableAccountConsistency[] = "enable-account-consistency"; const char kEnableAccountConsistency[] = "enable-account-consistency";
// Enables new profile management system, including new profile chooser UI. // Enable the new avatar menu and the User Manager.
const char kEnableNewAvatarMenu[] = "enable-new-avatar-menu";
// Enables new profile management system, including lock mode.
const char kEnableNewProfileManagement[] = "new-profile-management"; const char kEnableNewProfileManagement[] = "new-profile-management";
// Enables the pure web-based flow for sign in on first run/NTP/wrench menu/ // Enables the pure web-based flow for sign in on first run/NTP/wrench menu/
...@@ -39,10 +45,4 @@ const char kFastUserSwitching[] = "fast-user-switching"; ...@@ -39,10 +45,4 @@ const char kFastUserSwitching[] = "fast-user-switching";
// Enables using GAIA information to populate profile name and icon. // Enables using GAIA information to populate profile name and icon.
const char kGoogleProfileInfo[] = "google-profile-info"; const char kGoogleProfileInfo[] = "google-profile-info";
// Use new avatar menu. When combined with new-profile-management, it simply
// shows the new profile management avatar menu. Otherwise it shows a redesigned
// avatar menu with the same functionality as the old one, plus a tutorial card
// at the top prompting the user to try out the new profile management UI.
const char kNewAvatarMenu[] = "new-avatar-menu";
} // namespace switches } // namespace switches
...@@ -15,15 +15,16 @@ namespace switches { ...@@ -15,15 +15,16 @@ namespace switches {
// alongside the definition of their values in the .cc file. // alongside the definition of their values in the .cc file.
extern const char kClearTokenService[]; extern const char kClearTokenService[];
extern const char kDisableAccountConsistency[]; extern const char kDisableAccountConsistency[];
extern const char kDisableNewAvatarMenu[];
extern const char kDisableNewProfileManagement[]; extern const char kDisableNewProfileManagement[];
extern const char kDisableSigninScopedDeviceId[]; extern const char kDisableSigninScopedDeviceId[];
extern const char kEnableAccountConsistency[]; extern const char kEnableAccountConsistency[];
extern const char kEnableNewAvatarMenu[];
extern const char kEnableNewProfileManagement[]; extern const char kEnableNewProfileManagement[];
extern const char kEnableWebBasedSignin[]; extern const char kEnableWebBasedSignin[];
extern const char kExtensionsMultiAccount[]; extern const char kExtensionsMultiAccount[];
extern const char kFastUserSwitching[]; extern const char kFastUserSwitching[];
extern const char kGoogleProfileInfo[]; extern const char kGoogleProfileInfo[];
extern const char kNewAvatarMenu[];
} // namespace switches } // namespace switches
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment