Remove references to IsNewAvatarMenu since the flag was removed.
This CL removes all references of the new-avatar-menu flag since it's
no longer used. The new avatar menu is always shown on desktop and never
on Mobile and ChromeOS.
BUG=517582
Review URL: https://codereview.chromium.org/1307093004
Cr-Commit-Position: refs/heads/master@{#352041}
diff --git a/chrome/browser/browser_process_impl.cc b/chrome/browser/browser_process_impl.cc
index 7001e103..fecf890 100644
--- a/chrome/browser/browser_process_impl.cc
+++ b/chrome/browser/browser_process_impl.cc
@@ -283,8 +283,7 @@
"BrowserProcessImpl::StartTearDown:ProfileManager");
// The desktop User Manager needs to be closed before the guest profile
// can be destroyed.
- if (switches::IsNewAvatarMenu())
- UserManager::Hide();
+ UserManager::Hide();
profile_manager_.reset();
}
diff --git a/chrome/browser/chrome_browser_main.cc b/chrome/browser/chrome_browser_main.cc
index 13127ba..ba4ce89 100644
--- a/chrome/browser/chrome_browser_main.cc
+++ b/chrome/browser/chrome_browser_main.cc
@@ -383,12 +383,6 @@
base::FilePath profile_path =
GetStartupProfilePath(user_data_dir, parsed_command_line);
- // Without NewAvatarMenu, replace guest with any existing profile.
- if (!switches::IsNewAvatarMenu() &&
- profile_path == ProfileManager::GetGuestProfilePath()) {
- profile_path = g_browser_process->profile_manager()->GetProfileInfoCache().
- GetPathOfProfileAtIndex(0);
- }
profile = g_browser_process->profile_manager()->GetProfile(
profile_path);
diff --git a/chrome/browser/profiles/avatar_menu.cc b/chrome/browser/profiles/avatar_menu.cc
index 6b7fee6..2b5a5924 100644
--- a/chrome/browser/profiles/avatar_menu.cc
+++ b/chrome/browser/profiles/avatar_menu.cc
@@ -39,14 +39,6 @@
using content::BrowserThread;
-namespace {
-
-// Constants for the show profile switcher experiment
-const char kShowProfileSwitcherFieldTrialName[] = "ShowProfileSwitcher";
-const char kAlwaysShowSwitcherGroupName[] = "AlwaysShow";
-
-} // namespace
-
AvatarMenu::AvatarMenu(ProfileInfoInterface* profile_cache,
AvatarMenuObserver* observer,
Browser* browser)
@@ -97,27 +89,15 @@
// static
bool AvatarMenu::ShouldShowAvatarMenu() {
- if (base::FieldTrialList::FindFullName(kShowProfileSwitcherFieldTrialName) ==
- kAlwaysShowSwitcherGroupName) {
- // We should only be in this group when multi-profiles is enabled.
- DCHECK(profiles::IsMultipleProfilesEnabled());
- return true;
- }
-
// TODO: Eliminate this ifdef. Add a delegate interface for the menu which
// would also help remove the Browser dependency in AvatarMenuActions
// implementations.
- if (profiles::IsMultipleProfilesEnabled()) {
#if defined(OS_CHROMEOS)
- // On ChromeOS the menu will not be shown.
- return false;
-#else
- return switches::IsNewAvatarMenu() ||
- (g_browser_process->profile_manager() &&
- g_browser_process->profile_manager()->GetNumberOfProfiles() > 1);
-#endif
- }
+ // On ChromeOS the menu will not be shown.
return false;
+#else
+ return true;
+#endif
}
bool AvatarMenu::CompareItems(const Item* item1, const Item* item2) {
@@ -132,15 +112,16 @@
index == GetActiveProfileIndex());
const Item& item = GetItemAt(index);
- if (switches::IsNewAvatarMenu()) {
- // Don't open a browser window for signed-out profiles.
- if (item.signin_required) {
- UserManager::Show(item.profile_path,
- profiles::USER_MANAGER_NO_TUTORIAL,
- profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION);
- return;
- }
+#if !defined(OS_CHROMEOS)
+ // ChromeOS doesn't have the User Manager, it can't open it.
+ // Don't open a browser window for signed-out profiles.
+ if (item.signin_required) {
+ UserManager::Show(item.profile_path,
+ profiles::USER_MANAGER_NO_TUTORIAL,
+ profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION);
+ return;
}
+#endif
base::FilePath path =
profile_info_->GetPathOfProfileAtIndex(item.profile_index);
diff --git a/chrome/browser/profiles/profile_info_cache.cc b/chrome/browser/profiles/profile_info_cache.cc
index 652c0f1..f7e8b2b 100644
--- a/chrome/browser/profiles/profile_info_cache.cc
+++ b/chrome/browser/profiles/profile_info_cache.cc
@@ -184,7 +184,7 @@
// If needed, start downloading the high-res avatars and migrate any legacy
// profile names.
- if (switches::IsNewAvatarMenu() && !disable_avatar_download_for_testing_)
+ if (!disable_avatar_download_for_testing_)
MigrateLegacyProfileNamesAndDownloadAvatars();
}
@@ -225,7 +225,7 @@
sorted_keys_.insert(FindPositionForProfile(key, name), key);
- if (switches::IsNewAvatarMenu() && !disable_avatar_download_for_testing_)
+ if (!disable_avatar_download_for_testing_)
DownloadHighResAvatarIfNeeded(icon_index, profile_path);
FOR_EACH_OBSERVER(ProfileInfoCacheObserver,
@@ -331,12 +331,13 @@
return *image;
}
- // Use the high resolution version of the avatar if it exists.
- if (switches::IsNewAvatarMenu()) {
- const gfx::Image* image = GetHighResAvatarOfProfileAtIndex(index);
- if (image)
- return *image;
- }
+#if !defined(OS_CHROMEOS) && !defined(OS_ANDROID) && !defined(OS_IOS)
+ // Use the high resolution version of the avatar if it exists. Mobile and
+ // ChromeOS don't need the high resolution version so no need to fetch it.
+ const gfx::Image* image = GetHighResAvatarOfProfileAtIndex(index);
+ if (image)
+ return *image;
+#endif
int resource_id = profiles::GetDefaultAvatarIconResourceIDAtIndex(
GetAvatarIconIndexOfProfileAtIndex(index));
@@ -585,7 +586,7 @@
base::FilePath profile_path = GetPathOfProfileAtIndex(index);
- if (switches::IsNewAvatarMenu() && !disable_avatar_download_for_testing_)
+ if (!disable_avatar_download_for_testing_)
DownloadHighResAvatarIfNeeded(icon_index, profile_path);
FOR_EACH_OBSERVER(ProfileInfoCacheObserver,
@@ -864,10 +865,11 @@
size_t icon_index) const {
base::string16 name;
for (int name_index = 1; ; ++name_index) {
- if (switches::IsNewAvatarMenu()) {
- name = l10n_util::GetStringFUTF16Int(IDS_NEW_NUMBERED_PROFILE_NAME,
- name_index);
- } else if (icon_index < profiles::GetGenericAvatarIconCount()) {
+#if !defined(OS_CHROMEOS) && !defined(OS_ANDROID) && !defined(OS_IOS)
+ name = l10n_util::GetStringFUTF16Int(IDS_NEW_NUMBERED_PROFILE_NAME,
+ name_index);
+#else
+ if (icon_index < profiles::GetGenericAvatarIconCount()) {
name = l10n_util::GetStringFUTF16Int(IDS_NUMBERED_PROFILE_NAME,
name_index);
} else {
@@ -876,6 +878,7 @@
if (name_index > 1)
name.append(base::UTF8ToUTF16(base::IntToString(name_index)));
}
+#endif
// Loop through previously named profiles to ensure we're not duplicating.
bool name_found = false;
@@ -1027,10 +1030,10 @@
bool allow_generic_icon,
bool must_be_unique,
size_t* out_icon_index) const {
- // Always allow all icons for new profiles if using the
- // --new-avatar-menu flag.
- if (switches::IsNewAvatarMenu())
- allow_generic_icon = true;
+#if !defined(OS_CHROMEOS) && !defined(OS_ANDROID) && !defined(OS_IOS)
+ // Always allow the generic icon when displaying the new avatar menu.
+ allow_generic_icon = true;
+#endif
size_t start = allow_generic_icon ? 0 : profiles::GetGenericAvatarIconCount();
size_t end = profiles::GetDefaultAvatarIconCount();
size_t count = end - start;
@@ -1200,8 +1203,6 @@
}
void ProfileInfoCache::MigrateLegacyProfileNamesAndDownloadAvatars() {
- DCHECK(switches::IsNewAvatarMenu());
-
// Only do this on desktop platforms.
#if !defined(OS_ANDROID) && !defined(OS_IOS) && !defined(OS_CHROMEOS)
// Migrate any legacy profile names ("First user", "Default Profile") to
diff --git a/chrome/browser/profiles/profile_info_cache_unittest.cc b/chrome/browser/profiles/profile_info_cache_unittest.cc
index 5aa7fde..cd1f8689 100644
--- a/chrome/browser/profiles/profile_info_cache_unittest.cc
+++ b/chrome/browser/profiles/profile_info_cache_unittest.cc
@@ -551,9 +551,6 @@
// High res avatar downloading is only supported on desktop.
#if !defined(OS_ANDROID) && !defined(OS_IOS) && !defined(OS_CHROMEOS)
TEST_F(ProfileInfoCacheTest, DownloadHighResAvatarTest) {
- switches::EnableNewAvatarMenuForTesting(
- base::CommandLine::ForCurrentProcess());
-
// The TestingProfileManager's ProfileInfoCache doesn't download avatars.
ProfileInfoCache profile_info_cache(g_browser_process->local_state(),
testing_profile_manager_.profile_manager()->user_data_dir());
@@ -617,9 +614,6 @@
}
TEST_F(ProfileInfoCacheTest, NothingToDownloadHighResAvatarTest) {
- switches::EnableNewAvatarMenuForTesting(
- base::CommandLine::ForCurrentProcess());
-
// The TestingProfileManager's ProfileInfoCache doesn't download avatars.
ProfileInfoCache profile_info_cache(
g_browser_process->local_state(),
@@ -642,8 +636,6 @@
}
TEST_F(ProfileInfoCacheTest, MigrateLegacyProfileNamesWithNewAvatarMenu) {
- switches::EnableNewAvatarMenuForTesting(
- base::CommandLine::ForCurrentProcess());
EXPECT_EQ(0U, GetCache()->GetNumberOfProfiles());
base::FilePath path_1 = GetProfilePath("path_1");
@@ -693,11 +685,9 @@
}
#endif
+#if defined(OS_CHROMEOS) || defined(OS_ANDROID) || defined(OS_IOS)
TEST_F(ProfileInfoCacheTest,
DontMigrateLegacyProfileNamesWithoutNewAvatarMenu) {
- switches::DisableNewAvatarMenuForTesting(
- base::CommandLine::ForCurrentProcess());
-
EXPECT_EQ(0U, GetCache()->GetNumberOfProfiles());
base::string16 name_1 = ASCIIToUTF16("Default Profile");
@@ -734,3 +724,4 @@
EXPECT_EQ(name_4, GetCache()->GetNameOfProfileAtIndex(
GetCache()->GetIndexOfProfileWithPath(path_4)));
}
+#endif
diff --git a/chrome/browser/profiles/profile_list_desktop_unittest.cc b/chrome/browser/profiles/profile_list_desktop_unittest.cc
index 553f875..3ca1569 100644
--- a/chrome/browser/profiles/profile_list_desktop_unittest.cc
+++ b/chrome/browser/profiles/profile_list_desktop_unittest.cc
@@ -282,37 +282,6 @@
#endif
}
-TEST_F(ProfileListDesktopTest, DontShowOldAvatarMenuForSingleProfile) {
- switches::DisableNewAvatarMenuForTesting(
- base::CommandLine::ForCurrentProcess());
-
- manager()->CreateTestingProfile("Test 1");
-
- EXPECT_FALSE(AvatarMenu::ShouldShowAvatarMenu());
-
- // If multiprofile mode is enabled, there are no other cases when we wouldn't
- // show the menu.
- if (profiles::IsMultipleProfilesEnabled())
- return;
-
- manager()->CreateTestingProfile("Test 2");
-
- EXPECT_FALSE(AvatarMenu::ShouldShowAvatarMenu());
-}
-
-TEST_F(ProfileListDesktopTest, AlwaysShowNewAvatarMenu) {
- // If multiprofile mode is not enabled then the menu is never shown.
- if (!profiles::IsMultipleProfilesEnabled())
- return;
-
- switches::EnableNewAvatarMenuForTesting(
- base::CommandLine::ForCurrentProcess());
-
- manager()->CreateTestingProfile("Test 1");
-
- EXPECT_TRUE(AvatarMenu::ShouldShowAvatarMenu());
-}
-
TEST_F(ProfileListDesktopTest, ShowAvatarMenu) {
// If multiprofile mode is not enabled then the menu is never shown.
if (!profiles::IsMultipleProfilesEnabled())
diff --git a/chrome/browser/profiles/profile_manager.cc b/chrome/browser/profiles/profile_manager.cc
index 40f9bd7..fe4b02ce 100644
--- a/chrome/browser/profiles/profile_manager.cc
+++ b/chrome/browser/profiles/profile_manager.cc
@@ -688,15 +688,15 @@
base::FilePath new_path;
if (last_non_supervised_profile_path.empty()) {
- // If we are using --new-avatar-menu, then assign the default
- // placeholder avatar and name. Otherwise, use random ones.
- bool is_new_avatar_menu = switches::IsNewAvatarMenu();
+ base::string16 new_avatar_url = base::string16();
+ base::string16 new_profile_name = base::string16();
+
+#if !defined(OS_CHROMEOS) && !defined(OS_ANDROID) && !defined(OS_IOS)
int avatar_index = profiles::GetPlaceholderAvatarIndex();
- base::string16 new_avatar_url = is_new_avatar_menu ?
- base::UTF8ToUTF16(profiles::GetDefaultAvatarIconUrl(avatar_index)) :
- base::string16();
- base::string16 new_profile_name = is_new_avatar_menu ?
- cache.ChooseNameForNewProfile(avatar_index) : base::string16();
+ new_avatar_url =
+ base::UTF8ToUTF16(profiles::GetDefaultAvatarIconUrl(avatar_index));
+ new_profile_name = cache.ChooseNameForNewProfile(avatar_index);
+#endif
new_path = GenerateNextProfileDirectoryPath();
CreateProfileAsync(new_path,
@@ -823,12 +823,13 @@
cache.GetSupervisedUserIdOfProfileAtIndex(profile_cache_index);
} else if (profile->GetPath() ==
profiles::GetDefaultProfileDir(cache.GetUserDataDir())) {
- // The --new-avatar-menu flag no longer uses the "First User" name.
- bool is_new_avatar_menu = switches::IsNewAvatarMenu();
avatar_index = profiles::GetPlaceholderAvatarIndex();
- profile_name = is_new_avatar_menu ?
- base::UTF16ToUTF8(cache.ChooseNameForNewProfile(avatar_index)) :
- l10n_util::GetStringUTF8(IDS_DEFAULT_PROFILE_NAME);
+#if !defined(OS_CHROMEOS) && !defined(OS_ANDROID) && !defined(OS_IOS)
+ profile_name =
+ base::UTF16ToUTF8(cache.ChooseNameForNewProfile(avatar_index));
+#else
+ profile_name = l10n_util::GetStringUTF8(IDS_DEFAULT_PROFILE_NAME);
+#endif
} else {
avatar_index = cache.ChooseAvatarIconIndexForNewProfile();
profile_name =
diff --git a/chrome/browser/profiles/profile_manager_unittest.cc b/chrome/browser/profiles/profile_manager_unittest.cc
index 78e3273..50037f95 100644
--- a/chrome/browser/profiles/profile_manager_unittest.cc
+++ b/chrome/browser/profiles/profile_manager_unittest.cc
@@ -1054,10 +1054,6 @@
if (!profiles::IsMultipleProfilesEnabled())
return;
- // The command line is reset at the end of every test by the test suite.
- switches::EnableNewAvatarMenuForTesting(
- base::CommandLine::ForCurrentProcess());
-
ProfileManager* profile_manager = g_browser_process->profile_manager();
ProfileInfoCache& cache = profile_manager->GetProfileInfoCache();
EXPECT_EQ(0u, cache.GetNumberOfProfiles());
@@ -1093,10 +1089,6 @@
if (!profiles::IsMultipleProfilesEnabled())
return;
- // The command line is reset at the end of every test by the test suite.
- switches::EnableNewAvatarMenuForTesting(
- base::CommandLine::ForCurrentProcess());
-
ProfileManager* profile_manager = g_browser_process->profile_manager();
ProfileInfoCache& cache = profile_manager->GetProfileInfoCache();
EXPECT_EQ(0u, cache.GetNumberOfProfiles());
@@ -1140,10 +1132,6 @@
if (!profiles::IsMultipleProfilesEnabled())
return;
- // The command line is reset at the end of every test by the test suite.
- switches::EnableNewAvatarMenuForTesting(
- base::CommandLine::ForCurrentProcess());
-
ProfileManager* profile_manager = g_browser_process->profile_manager();
ProfileInfoCache& cache = profile_manager->GetProfileInfoCache();
EXPECT_EQ(0u, cache.GetNumberOfProfiles());
@@ -1195,10 +1183,6 @@
if (!profiles::IsMultipleProfilesEnabled())
return;
- // The command line is reset at the end of every test by the test suite.
- switches::EnableNewAvatarMenuForTesting(
- base::CommandLine::ForCurrentProcess());
-
ProfileManager* profile_manager = g_browser_process->profile_manager();
ProfileInfoCache& cache = profile_manager->GetProfileInfoCache();
EXPECT_EQ(0u, cache.GetNumberOfProfiles());
diff --git a/chrome/browser/profiles/profile_window_browsertest.cc b/chrome/browser/profiles/profile_window_browsertest.cc
index 1868752..16fc0fc 100644
--- a/chrome/browser/profiles/profile_window_browsertest.cc
+++ b/chrome/browser/profiles/profile_window_browsertest.cc
@@ -87,12 +87,6 @@
ProfileWindowBrowserTest() {}
~ProfileWindowBrowserTest() override {}
- void SetUpCommandLine(base::CommandLine* command_line) override {
- InProcessBrowserTest::SetUpCommandLine(command_line);
- switches::EnableNewAvatarMenuForTesting(
- base::CommandLine::ForCurrentProcess());
- }
-
Browser* OpenGuestBrowser();
void CloseBrowser(Browser* browser);
diff --git a/chrome/browser/resources/options/manage_profile_overlay.js b/chrome/browser/resources/options/manage_profile_overlay.js
index 5b3e41f..1f80642 100644
--- a/chrome/browser/resources/options/manage_profile_overlay.js
+++ b/chrome/browser/resources/options/manage_profile_overlay.js
@@ -95,25 +95,11 @@
$('create-profile-supervised-sign-in-link').onclick =
function(event) {
- // Without the new avatar menu, the signin process will open an overlay
- // to configure sync, which would replace this overlay. It's smoother to
- // close this one now.
- // With the new avatar menu enabled, a sign-in flow in the avatar menu
- // is triggered instead, which does not open any overlays, so there's no
- // need to close this one.
- if (!loadTimeData.getBoolean('newAvatarMenuEnabled')) {
- // TODO(pamg): Move the sync-setup overlay to a higher layer so this
- // one can stay open under it, after making sure that doesn't break
- // anything else.
- PageManager.closeOverlay();
- }
SyncSetupOverlay.startSignIn();
};
$('create-profile-supervised-sign-in-again-link').onclick =
function(event) {
- if (!loadTimeData.getBoolean('newAvatarMenuEnabled'))
- PageManager.closeOverlay();
SyncSetupOverlay.showSetupUI();
};
diff --git a/chrome/browser/signin/signin_global_error.cc b/chrome/browser/signin/signin_global_error.cc
index b2e8f86..71f8a46 100644
--- a/chrome/browser/signin/signin_global_error.cc
+++ b/chrome/browser/signin/signin_global_error.cc
@@ -35,12 +35,8 @@
SigninErrorController* error_controller,
Profile* profile)
: profile_(profile),
- error_controller_(error_controller),
- is_added_to_global_error_service_(false) {
+ error_controller_(error_controller) {
error_controller_->AddObserver(this);
- is_added_to_global_error_service_ = !switches::IsNewAvatarMenu();
- if (is_added_to_global_error_service_)
- GlobalErrorServiceFactory::GetForProfile(profile_)->AddGlobalError(this);
}
SigninGlobalError::~SigninGlobalError() {
@@ -60,11 +56,6 @@
}
void SigninGlobalError::Shutdown() {
- if (is_added_to_global_error_service_) {
- GlobalErrorServiceFactory::GetForProfile(profile_)->RemoveGlobalError(this);
- is_added_to_global_error_service_ = false;
- }
-
error_controller_->RemoveObserver(this);
error_controller_ = NULL;
}
@@ -106,15 +97,9 @@
UMA_HISTOGRAM_ENUMERATION("Signin.Reauth",
signin_metrics::HISTOGRAM_REAUTH_SHOWN,
signin_metrics::HISTOGRAM_REAUTH_MAX);
- if (switches::IsNewAvatarMenu()) {
- browser->window()->ShowAvatarBubbleFromAvatarButton(
- BrowserWindow::AVATAR_BUBBLE_MODE_REAUTH,
- signin::ManageAccountsParams());
- } else {
- chrome::ShowSingletonTab(
- browser,
- signin::GetReauthURL(profile_, error_controller_->error_account_id()));
- }
+ browser->window()->ShowAvatarBubbleFromAvatarButton(
+ BrowserWindow::AVATAR_BUBBLE_MODE_REAUTH,
+ signin::ManageAccountsParams());
#endif
}
diff --git a/chrome/browser/signin/signin_global_error.h b/chrome/browser/signin/signin_global_error.h
index 86846c8..4d642fc 100644
--- a/chrome/browser/signin/signin_global_error.h
+++ b/chrome/browser/signin/signin_global_error.h
@@ -62,9 +62,6 @@
// The SigninErrorController that provides auth status.
SigninErrorController* error_controller_;
- // True if signin global error was added to the global error service.
- bool is_added_to_global_error_service_;
-
DISALLOW_COPY_AND_ASSIGN(SigninGlobalError);
};
diff --git a/chrome/browser/signin/signin_promo.cc b/chrome/browser/signin/signin_promo.cc
index 0637886..9db75c8 100644
--- a/chrome/browser/signin/signin_promo.cc
+++ b/chrome/browser/signin/signin_promo.cc
@@ -197,12 +197,9 @@
}
GURL GetReauthURLWithEmail(const std::string& email) {
- signin_metrics::Source source = switches::IsNewAvatarMenu() ?
- signin_metrics::SOURCE_REAUTH : signin_metrics::SOURCE_SETTINGS;
-
GURL url = signin::GetPromoURL(
- source, true /* auto_close */,
- switches::IsNewAvatarMenu() /* is_constrained */);
+ signin_metrics::SOURCE_REAUTH, true /* auto_close */,
+ true /* is_constrained */);
url = net::AppendQueryParameter(url, "email", email);
url = net::AppendQueryParameter(url, "validateEmail", "1");
diff --git a/chrome/browser/signin/signin_ui_util.cc b/chrome/browser/signin/signin_ui_util.cc
index f7f8a21..bca615f 100644
--- a/chrome/browser/signin/signin_ui_util.cc
+++ b/chrome/browser/signin/signin_ui_util.cc
@@ -163,7 +163,7 @@
}
void InitializePrefsForProfile(Profile* profile) {
- if (profile->IsNewProfile() && switches::IsNewAvatarMenu()) {
+ if (profile->IsNewProfile()) {
// Suppresses the upgrade tutorial for a new profile.
profile->GetPrefs()->SetInteger(
prefs::kProfileAvatarTutorialShown, kUpgradeWelcomeTutorialShowMax + 1);
diff --git a/chrome/browser/ui/browser_command_controller_browsertest.cc b/chrome/browser/ui/browser_command_controller_browsertest.cc
index feb5af2..5a03f0a 100644
--- a/chrome/browser/ui/browser_command_controller_browsertest.cc
+++ b/chrome/browser/ui/browser_command_controller_browsertest.cc
@@ -78,9 +78,6 @@
// Flakes http://crbug.com/471953
IN_PROC_BROWSER_TEST_F(BrowserCommandControllerBrowserTest,
DISABLED_NewAvatarMenuEnabledInGuestMode) {
- switches::EnableNewAvatarMenuForTesting(
- base::CommandLine::ForCurrentProcess());
-
EXPECT_EQ(1U, BrowserList::GetInstance(chrome::GetActiveDesktop())->size());
// Create a guest browser nicely. Using CreateProfile() and CreateBrowser()
diff --git a/chrome/browser/ui/browser_command_controller_unittest.cc b/chrome/browser/ui/browser_command_controller_unittest.cc
index a80c758..c6c9a90 100644
--- a/chrome/browser/ui/browser_command_controller_unittest.cc
+++ b/chrome/browser/ui/browser_command_controller_unittest.cc
@@ -173,15 +173,10 @@
EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_FULLSCREEN));
}
-TEST_F(BrowserCommandControllerTest, OldAvatarMenuEnabledForOneOrMoreProfiles) {
+TEST_F(BrowserCommandControllerTest, AvatarAcceleratorEnabledOnDesktop) {
if (!profiles::IsMultipleProfilesEnabled())
return;
- // The command line is reset at the end of every test by the test suite.
- switches::DisableNewAvatarMenuForTesting(
- base::CommandLine::ForCurrentProcess());
- ASSERT_FALSE(switches::IsNewAvatarMenu());
-
TestingProfileManager testing_profile_manager(
TestingBrowserProcess::GetGlobal());
ASSERT_TRUE(testing_profile_manager.SetUp());
@@ -211,33 +206,6 @@
testing_profile_manager.DeleteTestingProfile("p2");
}
-TEST_F(BrowserCommandControllerTest, NewAvatarMenuEnabledWhenOnlyOneProfile) {
- if (!profiles::IsMultipleProfilesEnabled())
- return;
-
- // The command line is reset at the end of every test by the test suite.
- switches::EnableNewAvatarMenuForTesting(
- base::CommandLine::ForCurrentProcess());
-
- TestingProfileManager testing_profile_manager(
- TestingBrowserProcess::GetGlobal());
- ASSERT_TRUE(testing_profile_manager.SetUp());
- ProfileManager* profile_manager = testing_profile_manager.profile_manager();
-
- chrome::BrowserCommandController command_controller(browser());
- const CommandUpdater* command_updater = command_controller.command_updater();
-
- testing_profile_manager.CreateTestingProfile("p1");
- ASSERT_EQ(1U, profile_manager->GetNumberOfProfiles());
-#if defined(OS_CHROMEOS)
- // Chrome OS uses system tray menu to handle multi-profiles.
- EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_AVATAR_MENU));
-#else
- EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SHOW_AVATAR_MENU));
-#endif
- testing_profile_manager.DeleteTestingProfile("p1");
-}
-
TEST_F(BrowserCommandControllerTest, AvatarMenuAlwaysDisabledInIncognitoMode) {
if (!profiles::IsMultipleProfilesEnabled())
return;
@@ -255,15 +223,7 @@
chrome::BrowserCommandController command_controller(otr_browser.get());
const CommandUpdater* command_updater = command_controller.command_updater();
- // Both the old style and the new style avatar menu should be disabled.
- EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_AVATAR_MENU));
- if (switches::IsNewAvatarMenu()) {
- switches::DisableNewAvatarMenuForTesting(
- base::CommandLine::ForCurrentProcess());
- } else {
- switches::EnableNewAvatarMenuForTesting(
- base::CommandLine::ForCurrentProcess());
- }
+ // The avatar menu should be disabled.
EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_AVATAR_MENU));
// The command line is reset at the end of every test by the test suite.
}
diff --git a/chrome/browser/ui/chrome_pages.cc b/chrome/browser/ui/chrome_pages.cc
index 4e601389..448d16f 100644
--- a/chrome/browser/ui/chrome_pages.cc
+++ b/chrome/browser/ui/chrome_pages.cc
@@ -370,8 +370,14 @@
// away from Chrome, and accidentally close the avatar bubble. The same will
// happen if we had to switch browser windows to show the sign in page. In
// this case, fallback to the full-tab signin page.
- if (switches::IsNewAvatarMenu() &&
- source != signin_metrics::SOURCE_APP_LAUNCHER && !switched_browser) {
+ bool show_avatar_bubble =
+ source != signin_metrics::SOURCE_APP_LAUNCHER && !switched_browser;
+#if defined(OS_CHROMEOS)
+ // ChromeOS doesn't have the avatar bubble.
+ show_avatar_bubble = false;
+#endif
+
+ if (show_avatar_bubble) {
browser->window()->ShowAvatarBubbleFromAvatarButton(
BrowserWindow::AVATAR_BUBBLE_MODE_SIGNIN,
signin::ManageAccountsParams());
diff --git a/chrome/browser/ui/cocoa/bookmarks/bookmark_sync_promo_controller_unittest.mm b/chrome/browser/ui/cocoa/bookmarks/bookmark_sync_promo_controller_unittest.mm
deleted file mode 100644
index 2a82c2f..0000000
--- a/chrome/browser/ui/cocoa/bookmarks/bookmark_sync_promo_controller_unittest.mm
+++ /dev/null
@@ -1,51 +0,0 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#import "chrome/browser/ui/cocoa/bookmarks/bookmark_sync_promo_controller.h"
-
-#import <Cocoa/Cocoa.h>
-
-#include "base/basictypes.h"
-#include "base/command_line.h"
-#include "base/mac/scoped_nsobject.h"
-#include "chrome/browser/extensions/extension_service.h"
-#include "chrome/browser/extensions/test_extension_system.h"
-#include "chrome/browser/ui/browser.h"
-#include "chrome/browser/ui/tabs/tab_strip_model.h"
-#include "chrome/test/base/browser_with_test_window_test.h"
-#include "components/signin/core/common/profile_management_switches.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace {
-
-class BookmarkSyncPromoControllerTest : public BrowserWithTestWindowTest {
- public:
- void SetUp() override {
- switches::DisableNewAvatarMenuForTesting(
- base::CommandLine::ForCurrentProcess());
- BrowserWithTestWindowTest::SetUp();
- ASSERT_TRUE(profile());
- // Adds TestExtensionSystem, since signin uses the gaia auth extension.
- static_cast<extensions::TestExtensionSystem*>(
- extensions::ExtensionSystem::Get(profile()))
- ->CreateExtensionService(base::CommandLine::ForCurrentProcess(),
- base::FilePath(), false);
- }
-};
-
-TEST_F(BookmarkSyncPromoControllerTest, SignInLink) {
- int starting_tab_count = browser()->tab_strip_model()->count();
-
- base::scoped_nsobject<BookmarkSyncPromoController> syncPromo(
- [[BookmarkSyncPromoController alloc] initWithBrowser:browser()]);
-
- // Simulate clicking the "Sign in" link.
- [syncPromo textView:nil clickedOnLink:nil atIndex:0u];
-
- // A new tab should have been opened.
- int tab_count = browser()->tab_strip_model()->count();
- EXPECT_EQ(starting_tab_count + 1, tab_count);
-}
-
-} // namespace
diff --git a/chrome/browser/ui/cocoa/browser_window_controller.mm b/chrome/browser/ui/cocoa/browser_window_controller.mm
index c4205301..6249bad 100644
--- a/chrome/browser/ui/cocoa/browser_window_controller.mm
+++ b/chrome/browser/ui/cocoa/browser_window_controller.mm
@@ -1389,8 +1389,7 @@
}
- (BOOL)shouldUseNewAvatarButton {
- return switches::IsNewAvatarMenu() &&
- profiles::IsRegularOrGuestSession(browser_.get());
+ return profiles::IsRegularOrGuestSession(browser_.get());
}
- (BOOL)isBookmarkBarVisible {
diff --git a/chrome/browser/ui/cocoa/profiles/avatar_base_controller.mm b/chrome/browser/ui/cocoa/profiles/avatar_base_controller.mm
index e634fdfb..abda2f19 100644
--- a/chrome/browser/ui/cocoa/profiles/avatar_base_controller.mm
+++ b/chrome/browser/ui/cocoa/profiles/avatar_base_controller.mm
@@ -93,11 +93,6 @@
[avatarController_ updateAvatarButtonAndLayoutParent:YES];
}
- void OnProfileAvatarChanged(const base::FilePath& profile_path) override {
- if (!switches::IsNewAvatarMenu() && profile_->GetPath() == profile_path)
- [avatarController_ updateAvatarButtonAndLayoutParent:YES];
- }
-
void OnProfileSupervisedUserIdChanged(
const base::FilePath& profile_path) override {
if (profile_->GetPath() == profile_path)
@@ -152,18 +147,16 @@
withMode:(BrowserWindow::AvatarBubbleMode)mode
withServiceType:(signin::GAIAServiceType)serviceType {
if (menuController_) {
- if (switches::IsNewAvatarMenu()) {
- profiles::BubbleViewMode viewMode;
- profiles::TutorialMode tutorialMode;
- profiles::BubbleViewModeFromAvatarBubbleMode(
- mode, &viewMode, &tutorialMode);
- if (tutorialMode != profiles::TUTORIAL_MODE_NONE) {
- ProfileChooserController* profileChooserController =
- base::mac::ObjCCastStrict<ProfileChooserController>(
- menuController_);
- [profileChooserController setTutorialMode:tutorialMode];
- [profileChooserController initMenuContentsWithView:viewMode];
- }
+ profiles::BubbleViewMode viewMode;
+ profiles::TutorialMode tutorialMode;
+ profiles::BubbleViewModeFromAvatarBubbleMode(
+ mode, &viewMode, &tutorialMode);
+ if (tutorialMode != profiles::TUTORIAL_MODE_NONE) {
+ ProfileChooserController* profileChooserController =
+ base::mac::ObjCCastStrict<ProfileChooserController>(
+ menuController_);
+ [profileChooserController setTutorialMode:tutorialMode];
+ [profileChooserController initMenuContentsWithView:viewMode];
}
return;
}
@@ -179,40 +172,32 @@
// The new avatar bubble does not have an arrow, and it should be anchored
// to the edge of the avatar button.
- int anchorX = switches::IsNewAvatarMenu() ?
- NSMaxX([anchor bounds]) - kMenuXOffsetAdjust :
- NSMidX([anchor bounds]);
+ int anchorX = NSMaxX([anchor bounds]) - kMenuXOffsetAdjust;
NSPoint point = NSMakePoint(anchorX,
NSMaxY([anchor bounds]) + kMenuYOffsetAdjust);
point = [anchor convertPoint:point toView:nil];
point = [[anchor window] convertBaseToScreen:point];
// |menuController_| will automatically release itself on close.
- if (switches::IsNewAvatarMenu()) {
- profiles::BubbleViewMode viewMode;
- profiles::TutorialMode tutorialMode;
- profiles::BubbleViewModeFromAvatarBubbleMode(
- mode, &viewMode, &tutorialMode);
- // Don't start creating the view if it would be an empty fast user switcher.
- // It has to happen here to prevent the view system from creating an empty
- // container.
- if (viewMode == profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER &&
- !profiles::HasProfileSwitchTargets(browser_->profile())) {
- return;
- }
-
- menuController_ =
- [[ProfileChooserController alloc] initWithBrowser:browser_
- anchoredAt:point
- viewMode:viewMode
- tutorialMode:tutorialMode
- serviceType:serviceType];
- } else {
- menuController_ =
- [[AvatarMenuBubbleController alloc] initWithBrowser:browser_
- anchoredAt:point];
+ profiles::BubbleViewMode viewMode;
+ profiles::TutorialMode tutorialMode;
+ profiles::BubbleViewModeFromAvatarBubbleMode(
+ mode, &viewMode, &tutorialMode);
+ // Don't start creating the view if it would be an empty fast user switcher.
+ // It has to happen here to prevent the view system from creating an empty
+ // container.
+ if (viewMode == profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER &&
+ !profiles::HasProfileSwitchTargets(browser_->profile())) {
+ return;
}
+ menuController_ =
+ [[ProfileChooserController alloc] initWithBrowser:browser_
+ anchoredAt:point
+ viewMode:viewMode
+ tutorialMode:tutorialMode
+ serviceType:serviceType];
+
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(bubbleWillClose:)
diff --git a/chrome/browser/ui/cocoa/profiles/avatar_button_controller_unittest.mm b/chrome/browser/ui/cocoa/profiles/avatar_button_controller_unittest.mm
index 3460037..1e3e745 100644
--- a/chrome/browser/ui/cocoa/profiles/avatar_button_controller_unittest.mm
+++ b/chrome/browser/ui/cocoa/profiles/avatar_button_controller_unittest.mm
@@ -57,8 +57,6 @@
class AvatarButtonControllerTest : public CocoaProfileTest {
public:
void SetUp() override {
- switches::EnableNewAvatarMenuForTesting(
- base::CommandLine::ForCurrentProcess());
DCHECK(profiles::IsMultipleProfilesEnabled());
CocoaProfileTest::SetUp();
diff --git a/chrome/browser/ui/cocoa/profiles/avatar_icon_controller_unittest.mm b/chrome/browser/ui/cocoa/profiles/avatar_icon_controller_unittest.mm
index 8c70080..46501ef 100644
--- a/chrome/browser/ui/cocoa/profiles/avatar_icon_controller_unittest.mm
+++ b/chrome/browser/ui/cocoa/profiles/avatar_icon_controller_unittest.mm
@@ -16,8 +16,11 @@
#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_window.h"
#import "chrome/browser/ui/cocoa/base_bubble_controller.h"
+#import "chrome/browser/ui/cocoa/browser_window_cocoa.h"
+#import "chrome/browser/ui/cocoa/browser_window_controller.h"
#include "chrome/browser/ui/cocoa/cocoa_profile_test.h"
#include "chrome/browser/ui/cocoa/info_bubble_window.h"
+#import "chrome/browser/ui/cocoa/profiles/avatar_button_controller.h"
#import "chrome/browser/ui/cocoa/profiles/avatar_menu_bubble_controller.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/test/base/testing_profile.h"
@@ -27,15 +30,11 @@
class AvatarIconControllerTest : public CocoaProfileTest {
public:
+ AvatarIconControllerTest() {}
+
void SetUp() override {
- switches::DisableNewAvatarMenuForTesting(
- base::CommandLine::ForCurrentProcess());
CocoaProfileTest::SetUp();
ASSERT_TRUE(browser());
-
- controller_.reset(
- [[AvatarIconController alloc] initWithBrowser:browser()]);
- [[controller_ view] setHidden:YES];
}
void TearDown() override {
@@ -43,86 +42,30 @@
CocoaProfileTest::TearDown();
}
- NSButton* button() { return [controller_ buttonView]; }
-
- NSView* view() { return [controller_ view]; }
-
- AvatarIconController* controller() { return controller_.get(); }
-
- private:
- base::scoped_nsobject<AvatarIconController> controller_;
+ AvatarBaseController* icon_controller() {
+ BrowserWindowCocoa* window =
+ static_cast<BrowserWindowCocoa*>(browser()->window());
+ return [window->cocoa_controller() avatarButtonController];
+ }
};
-TEST_F(AvatarIconControllerTest, AddRemoveProfiles) {
- EXPECT_TRUE([view() isHidden]);
-
- testing_profile_manager()->CreateTestingProfile("one");
-
- EXPECT_FALSE([view() isHidden]);
-
- testing_profile_manager()->CreateTestingProfile("two");
- EXPECT_FALSE([view() isHidden]);
-
- testing_profile_manager()->DeleteTestingProfile("one");
- EXPECT_FALSE([view() isHidden]);
-
- testing_profile_manager()->DeleteTestingProfile("two");
- EXPECT_TRUE([view() isHidden]);
-}
-
-TEST_F(AvatarIconControllerTest, DoubleOpen) {
- // Create a second profile to enable the avatar menu.
- testing_profile_manager()->CreateTestingProfile("p2");
-
- EXPECT_FALSE([controller() menuController]);
-
- [button() performClick:button()];
-
- BaseBubbleController* menu = [controller() menuController];
- EXPECT_TRUE([menu isKindOfClass:[AvatarMenuBubbleController class]]);
-
- EXPECT_TRUE(menu);
-
- [button() performClick:button()];
- EXPECT_EQ(menu, [controller() menuController]);
-
- // Do not animate out because that is hard to test around.
- static_cast<InfoBubbleWindow*>(menu.window).allowedAnimations =
- info_bubble::kAnimateNone;
- [menu close];
- EXPECT_FALSE([controller() menuController]);
-
- testing_profile_manager()->DeleteTestingProfile("p2");
-}
-
-TEST_F(AvatarIconControllerTest, SupervisedUserLabel) {
- DCHECK(!profile()->IsSupervised());
- EXPECT_FALSE([controller() labelButtonView]);
-
- // Create a second, supervised profile to enable the avatar menu.
- std::string name = "p2";
- TestingProfile* profile = testing_profile_manager()->CreateTestingProfile(
- name, scoped_ptr<syncable_prefs::PrefServiceSyncable>(),
- base::ASCIIToUTF16(name), 0, "asdf", TestingProfile::TestingFactories());
- EXPECT_TRUE(profile->IsSupervised());
-
- // http://crbug.com/39725
- TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse(
- profile, &TemplateURLServiceFactory::BuildInstanceFor);
- AutocompleteClassifierFactory::GetInstance()->SetTestingFactoryAndUse(
- profile, &AutocompleteClassifierFactory::BuildInstanceFor);
- profile->CreateBookmarkModel(true);
- bookmarks::test::WaitForBookmarkModelToLoad(
- BookmarkModelFactory::GetForProfile(profile));
-
+TEST_F(AvatarIconControllerTest, ShowingAvatarIconInIncognito) {
Browser* browser =
- new Browser(Browser::CreateParams(profile, chrome::GetActiveDesktop()));
- // Build a new controller to check if it is initialized correctly for a
- // supervised user profile.
- base::scoped_nsobject<AvatarIconController> controller(
- [[AvatarIconController alloc] initWithBrowser:browser]);
-
- EXPECT_TRUE([controller labelButtonView]);
+ new Browser(Browser::CreateParams(profile()->GetOffTheRecordProfile(),
+ chrome::GetActiveDesktop()));
+ BrowserWindowCocoa* window =
+ static_cast<BrowserWindowCocoa*>(browser->window());
+ AvatarBaseController* icon_controller =
+ [window->cocoa_controller() avatarButtonController];
+ // In incognito, we should be using the AvatarIconController to show the
+ // incognito guy.
+ EXPECT_TRUE([icon_controller isKindOfClass:[AvatarIconController class]]);
browser->window()->Close();
}
+
+TEST_F(AvatarIconControllerTest, ShowingAvatarButtonInRegularSession) {
+ // In a regular session, we should be using the AvatarButtonController to show
+ // the profile name.
+ EXPECT_TRUE([icon_controller() isKindOfClass:[AvatarButtonController class]]);
+}
diff --git a/chrome/browser/ui/cocoa/profiles/avatar_menu_bubble_controller_unittest.mm b/chrome/browser/ui/cocoa/profiles/avatar_menu_bubble_controller_unittest.mm
index 1ededed..b848ab5 100644
--- a/chrome/browser/ui/cocoa/profiles/avatar_menu_bubble_controller_unittest.mm
+++ b/chrome/browser/ui/cocoa/profiles/avatar_menu_bubble_controller_unittest.mm
@@ -29,9 +29,6 @@
}
void SetUp() override {
- switches::DisableNewAvatarMenuForTesting(
- base::CommandLine::ForCurrentProcess());
-
CocoaTest::SetUp();
ASSERT_TRUE(manager_.SetUp());
diff --git a/chrome/browser/ui/cocoa/profiles/profile_chooser_controller_unittest.mm b/chrome/browser/ui/cocoa/profiles/profile_chooser_controller_unittest.mm
index 5d13036..af7d97c 100644
--- a/chrome/browser/ui/cocoa/profiles/profile_chooser_controller_unittest.mm
+++ b/chrome/browser/ui/cocoa/profiles/profile_chooser_controller_unittest.mm
@@ -150,8 +150,6 @@
};
TEST_F(ProfileChooserControllerTest, InitialLayoutWithNewMenu) {
- switches::EnableNewAvatarMenuForTesting(
- base::CommandLine::ForCurrentProcess());
StartProfileChooserController();
NSArray* subviews = [[[controller() window] contentView] subviews];
@@ -217,8 +215,6 @@
}
TEST_F(ProfileChooserControllerTest, RightClickTutorialShownAfterWelcome) {
- switches::EnableNewAvatarMenuForTesting(
- base::CommandLine::ForCurrentProcess());
// The welcome upgrade tutorial takes precedence so show it then dismiss it.
// The right click tutorial should be shown right away.
StartProfileChooserControllerWithTutorialMode(
@@ -229,8 +225,6 @@
}
TEST_F(ProfileChooserControllerTest, RightClickTutorialShownAfterReopen) {
- switches::EnableNewAvatarMenuForTesting(
- base::CommandLine::ForCurrentProcess());
// The welcome upgrade tutorial takes precedence so show it then close the
// menu. Reopening the menu should show the tutorial.
StartProfileChooserController();
@@ -247,8 +241,6 @@
}
TEST_F(ProfileChooserControllerTest, RightClickTutorialNotShownAfterDismiss) {
- switches::EnableNewAvatarMenuForTesting(
- base::CommandLine::ForCurrentProcess());
// The welcome upgrade tutorial takes precedence so show it then close the
// menu. Reopening the menu should show the tutorial.
StartProfileChooserController();
@@ -280,9 +272,6 @@
}
TEST_F(ProfileChooserControllerTest, OtherProfilesSortedAlphabetically) {
- switches::EnableNewAvatarMenuForTesting(
- base::CommandLine::ForCurrentProcess());
-
// Add two extra profiles, to make sure sorting is alphabetical and not
// by order of creation.
testing_profile_manager()->CreateTestingProfile(
@@ -321,8 +310,6 @@
TEST_F(ProfileChooserControllerTest,
LocalProfileActiveCardLinksWithNewMenu) {
- switches::EnableNewAvatarMenuForTesting(
- base::CommandLine::ForCurrentProcess());
StartProfileChooserController();
NSArray* subviews = [[[controller() window] contentView] subviews];
ASSERT_EQ(2U, [subviews count]);
@@ -369,8 +356,6 @@
TEST_F(ProfileChooserControllerTest,
SignedInProfileActiveCardLinksWithNewMenu) {
- switches::EnableNewAvatarMenuForTesting(
- base::CommandLine::ForCurrentProcess());
// Sign in the first profile.
ProfileInfoCache* cache = testing_profile_manager()->profile_info_cache();
cache->SetAuthInfoOfProfileAtIndex(0, kGaiaId, base::ASCIIToUTF16(kEmail));
diff --git a/chrome/browser/ui/startup/startup_browser_creator.cc b/chrome/browser/ui/startup/startup_browser_creator.cc
index f7fac349..f114fb6d 100644
--- a/chrome/browser/ui/startup/startup_browser_creator.cc
+++ b/chrome/browser/ui/startup/startup_browser_creator.cc
@@ -250,6 +250,45 @@
static_cast<int>(output_string.size()));
}
+// Shows the User Manager on startup if the last used profile must sign in or
+// if the last used profile was the guest or system profile.
+// Returns true if the User Manager was shown, false otherwise.
+bool ShowUserManagerOnStartupIfNeeded(
+ Profile* last_used_profile, const base::CommandLine& command_line) {
+#if defined(OS_CHROMEOS)
+ // ChromeOS never shows the User Manager on startup.
+ return false;
+#else
+ const ProfileInfoCache& profile_info =
+ g_browser_process->profile_manager()->GetProfileInfoCache();
+ size_t profile_index = profile_info.GetIndexOfProfileWithPath(
+ last_used_profile->GetPath());
+
+ if (profile_index == std::string::npos ||
+ !profile_info.ProfileIsSigninRequiredAtIndex(profile_index)) {
+ // Signin is not required. However, guest, system or locked profiles cannot
+ // be re-opened on startup. The only exception is if there's already a Guest
+ // window open in a separate process (for example, launching a new browser
+ // after clicking on a downloaded file in Guest mode).
+ if ((!last_used_profile->IsGuestSession() &&
+ !last_used_profile->IsSystemProfile()) ||
+ (chrome::GetTotalBrowserCountForProfile(
+ last_used_profile->GetOffTheRecordProfile()) > 0)) {
+ return false;
+ }
+ }
+
+ // Show the User Manager.
+ profiles::UserManagerProfileSelected action =
+ command_line.HasSwitch(switches::kShowAppList) ?
+ profiles::USER_MANAGER_SELECT_PROFILE_APP_LAUNCHER :
+ profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION;
+ UserManager::Show(
+ base::FilePath(), profiles::USER_MANAGER_NO_TUTORIAL, action);
+ return true;
+#endif
+}
+
} // namespace
StartupBrowserCreator::StartupBrowserCreator()
@@ -671,34 +710,8 @@
// |last_used_profile| is the last used incognito profile. Restoring it will
// create a browser window for the corresponding original profile.
if (last_opened_profiles.empty()) {
- // If the last used profile is locked or was a guest, show the user manager.
- if (switches::IsNewAvatarMenu()) {
- ProfileInfoCache& profile_info =
- g_browser_process->profile_manager()->GetProfileInfoCache();
- size_t profile_index = profile_info.GetIndexOfProfileWithPath(
- last_used_profile->GetPath());
- bool signin_required = profile_index != std::string::npos &&
- profile_info.ProfileIsSigninRequiredAtIndex(profile_index);
-
- // Guest, system or locked profiles cannot be re-opened on startup. The
- // only exception is if there's already a Guest window open in a separate
- // process (for example, launching a new browser after clicking on a
- // downloaded file in Guest mode).
- bool guest_or_system = last_used_profile->IsGuestSession() ||
- last_used_profile->IsSystemProfile();
- bool has_guest_browsers = guest_or_system &&
- chrome::GetTotalBrowserCountForProfile(
- last_used_profile->GetOffTheRecordProfile()) > 0;
- if (signin_required || (guest_or_system && !has_guest_browsers)) {
- profiles::UserManagerProfileSelected action =
- command_line.HasSwitch(switches::kShowAppList) ?
- profiles::USER_MANAGER_SELECT_PROFILE_APP_LAUNCHER :
- profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION;
- UserManager::Show(
- base::FilePath(), profiles::USER_MANAGER_NO_TUTORIAL, action);
- return true;
- }
- }
+ if (ShowUserManagerOnStartupIfNeeded(last_used_profile, command_line))
+ return true;
Profile* profile_to_open = last_used_profile->IsGuestSession() ?
last_used_profile->GetOffTheRecordProfile() : last_used_profile;
@@ -709,15 +722,17 @@
return false;
}
} else {
+#if !defined(OS_CHROMEOS)
// Guest profiles should not be reopened on startup. This can happen if
// the last used profile was a Guest, but other profiles were also open
// when Chrome was closed. In this case, pick a different open profile
// to be the active one, since the Guest profile is never added to the list
// of open profiles.
- if (switches::IsNewAvatarMenu() && last_used_profile->IsGuestSession()) {
+ if (last_used_profile->IsGuestSession()) {
DCHECK(!last_opened_profiles[0]->IsGuestSession());
last_used_profile = last_opened_profiles[0];
}
+#endif
// Launch the last used profile with the full command line, and the other
// opened profiles without the URLs to launch.
diff --git a/chrome/browser/ui/views/frame/browser_non_client_frame_view.cc b/chrome/browser/ui/views/frame/browser_non_client_frame_view.cc
index c4d6a7c..8e7369b 100644
--- a/chrome/browser/ui/views/frame/browser_non_client_frame_view.cc
+++ b/chrome/browser/ui/views/frame/browser_non_client_frame_view.cc
@@ -73,18 +73,26 @@
if (!is_visible)
return;
- // The first time UpdateOldAvatarButton() is called the window is not visible
- // so DrawTaskBarDecoration() has no effect. Therefore we need to call it
- // again once the window is visible.
- if (!browser_view_->IsRegularOrGuestSession() ||
- !switches::IsNewAvatarMenu()) {
+#if defined(OS_CHROMEOS)
+ // On ChromeOS we always need to give the old avatar button a chance to update
+ // in case we're in a teleported window. On desktop, the old avatar button
+ // only shows up when in incognito mode.
+ UpdateOldAvatarButton();
+ OnProfileAvatarChanged(base::FilePath());
+#else
+ if (!browser_view_->IsRegularOrGuestSession()) {
+ // The first time UpdateOldAvatarButton() is called the window is not
+ // visible so DrawTaskBarDecoration() has no effect. Therefore we need to
+ // call it again once the window is visible.
UpdateOldAvatarButton();
}
- // Make sure the task bar icon is correctly updated call
- // |OnProfileAvatarChanged()| in this case, but only for non guest profiles.
- if (!browser_view_->IsGuestSession() || !switches::IsNewAvatarMenu())
+ // Call OnProfileAvatarChanged() in this case to make sure the task bar icon
+ // is correctly updated. Guest profiles don't badge the icon so no need to do
+ // this in guest mode.
+ if (!browser_view_->IsGuestSession())
OnProfileAvatarChanged(base::FilePath());
+#endif
}
void BrowserNonClientFrameView::ChildPreferredSizeChanged(View* child) {
@@ -179,9 +187,11 @@
}
void BrowserNonClientFrameView::UpdateAvatar() {
- if (browser_view()->IsRegularOrGuestSession() && switches::IsNewAvatarMenu())
+#if !defined(OS_CHROMEOS)
+ if (browser_view()->IsRegularOrGuestSession())
UpdateNewAvatarButtonImpl();
else
+#endif
UpdateOldAvatarButton();
}
@@ -246,7 +256,6 @@
void BrowserNonClientFrameView::UpdateNewAvatarButton(
views::ButtonListener* listener,
const NewAvatarButton::AvatarButtonStyle style) {
- DCHECK(switches::IsNewAvatarMenu());
// This should never be called in incognito mode.
DCHECK(browser_view_->IsRegularOrGuestSession());
@@ -282,11 +291,12 @@
void BrowserNonClientFrameView::OnProfileAvatarChanged(
const base::FilePath& profile_path) {
UpdateTaskbarDecoration();
- // Profile avatars are only displayed in the old UI or incognito.
- if ((!browser_view()->IsGuestSession() && browser_view()->IsOffTheRecord()) ||
- !switches::IsNewAvatarMenu()) {
+ // Profile avatars are only displayed in incognito or on ChromeOS teleported
+ // windows.
+#if !defined(OS_CHROMEOS)
+ if (!browser_view()->IsGuestSession() && browser_view()->IsOffTheRecord())
+#endif
UpdateOldAvatarButton();
- }
}
void BrowserNonClientFrameView::UpdateTaskbarDecoration() {
diff --git a/chrome/browser/ui/views/frame/browser_non_client_frame_view_ash.cc b/chrome/browser/ui/views/frame/browser_non_client_frame_view_ash.cc
index fd553577e..e8b68fa 100644
--- a/chrome/browser/ui/views/frame/browser_non_client_frame_view_ash.cc
+++ b/chrome/browser/ui/views/frame/browser_non_client_frame_view_ash.cc
@@ -568,7 +568,7 @@
#if defined(FRAME_AVATAR_BUTTON)
void BrowserNonClientFrameViewAsh::LayoutNewStyleAvatar() {
- DCHECK(switches::IsNewAvatarMenu());
+ DCHECK(new_avatar_button());
gfx::Size button_size = new_avatar_button()->GetPreferredSize();
int button_x = width() -
diff --git a/chrome/browser/ui/views/frame/glass_browser_frame_view.cc b/chrome/browser/ui/views/frame/glass_browser_frame_view.cc
index 8287970..6475ec4 100644
--- a/chrome/browser/ui/views/frame/glass_browser_frame_view.cc
+++ b/chrome/browser/ui/views/frame/glass_browser_frame_view.cc
@@ -114,7 +114,6 @@
// The new avatar button is optionally displayed to the left of the
// minimize button.
if (new_avatar_button()) {
- DCHECK(switches::IsNewAvatarMenu());
minimize_button_offset -=
new_avatar_button()->width() + kNewAvatarButtonOffset;
@@ -137,8 +136,7 @@
if (base::i18n::IsRTL()) {
if (!browser_view()->ShouldShowAvatar() && frame()->IsMaximized()) {
tabstrip_x += avatar_bounds_.x();
- } else if (browser_view()->IsRegularOrGuestSession() &&
- switches::IsNewAvatarMenu()) {
+ } else if (browser_view()->IsRegularOrGuestSession()) {
tabstrip_x = width() - minimize_button_offset;
}
@@ -274,7 +272,7 @@
}
void GlassBrowserFrameView::Layout() {
- if (browser_view()->IsRegularOrGuestSession() && switches::IsNewAvatarMenu())
+ if (browser_view()->IsRegularOrGuestSession())
LayoutNewStyleAvatar();
else
LayoutAvatar();
@@ -487,7 +485,7 @@
}
void GlassBrowserFrameView::LayoutNewStyleAvatar() {
- DCHECK(switches::IsNewAvatarMenu());
+ DCHECK(browser_view()->IsRegularOrGuestSession());
if (!new_avatar_button())
return;
@@ -514,9 +512,6 @@
}
void GlassBrowserFrameView::LayoutAvatar() {
- // Even though the avatar is used for both incognito and profiles we always
- // use the incognito icon to layout the avatar button. The profile icon
- // can be customized so we can't depend on its size to perform layout.
gfx::ImageSkia incognito_icon = browser_view()->GetOTRAvatarIcon();
int avatar_x = NonClientBorderThickness() + kAvatarLeftSpacing;
diff --git a/chrome/browser/ui/views/frame/opaque_browser_frame_view_layout.cc b/chrome/browser/ui/views/frame/opaque_browser_frame_view_layout.cc
index 91f71c9..ea63ba1 100644
--- a/chrome/browser/ui/views/frame/opaque_browser_frame_view_layout.cc
+++ b/chrome/browser/ui/views/frame/opaque_browser_frame_view_layout.cc
@@ -391,7 +391,6 @@
}
void OpaqueBrowserFrameViewLayout::LayoutNewStyleAvatar(views::View* host) {
- DCHECK(switches::IsNewAvatarMenu());
if (!new_avatar_button_)
return;
@@ -689,7 +688,7 @@
// on the trailing side.
leading_button_start_++;
- if (delegate_->IsRegularOrGuestSession() && switches::IsNewAvatarMenu())
+ if (delegate_->IsRegularOrGuestSession())
LayoutNewStyleAvatar(host);
else
LayoutAvatar(host);
diff --git a/chrome/browser/ui/views/frame/opaque_browser_frame_view_layout_unittest.cc b/chrome/browser/ui/views/frame/opaque_browser_frame_view_layout_unittest.cc
index 1d0f219..921cf49 100644
--- a/chrome/browser/ui/views/frame/opaque_browser_frame_view_layout_unittest.cc
+++ b/chrome/browser/ui/views/frame/opaque_browser_frame_view_layout_unittest.cc
@@ -200,33 +200,7 @@
root_view_->AddChildView(window_title_);
}
- void AddAvatarButton() {
- // Disable the New Avatar Menu.
- switches::DisableNewAvatarMenuForTesting(
- base::CommandLine::ForCurrentProcess());
-
- menu_button_ = new AvatarMenuButton(nullptr, false);
- menu_button_->set_id(VIEW_ID_AVATAR_BUTTON);
- delegate_->SetShouldShowAvatar(true);
- root_view_->AddChildView(menu_button_);
- }
-
-#if defined(ENABLE_SUPERVISED_USERS)
- void AddSupervisedUserAvatarLabel() {
- supervised_user_avatar_label_ = new SupervisedUserAvatarLabel(nullptr);
- supervised_user_avatar_label_->set_id(VIEW_ID_SUPERVISED_USER_AVATAR_LABEL);
- root_view_->AddChildView(supervised_user_avatar_label_);
-
- // The avatar label should only be used together with the avatar button.
- AddAvatarButton();
- }
-#endif
-
void AddNewAvatarButton() {
- // Enable the New Avatar Menu.
- switches::EnableNewAvatarMenuForTesting(
- base::CommandLine::ForCurrentProcess());
-
new_avatar_button_ =
new views::MenuButton(nullptr, base::string16(), nullptr, false);
new_avatar_button_->set_id(VIEW_ID_NEW_AVATAR_BUTTON);
@@ -414,55 +388,6 @@
EXPECT_EQ("27,3 370x17", window_title_->bounds().ToString());
}
-TEST_F(OpaqueBrowserFrameViewLayoutTest, WindowWithAvatar) {
- // Tests a normal tabstrip window with an avatar icon.
- AddAvatarButton();
- root_view_->Layout();
-
- ExpectBasicWindowBounds();
-
- // Check the location of the avatar
- EXPECT_EQ("7,11 40x29", menu_button_->bounds().ToString());
- EXPECT_EQ("45,13 352x29",
- layout_manager_->GetBoundsForTabStrip(
- delegate_->GetTabstripPreferredSize(), kWidth).ToString());
- EXPECT_EQ("261x73", layout_manager_->GetMinimumSize(kWidth).ToString());
-}
-
-TEST_F(OpaqueBrowserFrameViewLayoutTest,
- WindowWithAvatarWithoutCaptionButtonsOnLeft) {
- // Tests the layout of a chrome window with an avatar icon and no caption
- // buttons. However, the caption buttons *would* be on the left if they
- // weren't hidden, and therefore, the avatar icon should be on the right.
- // The lack of caption buttons should force the tab strip to be condensed.
- AddAvatarButton();
- std::vector<views::FrameButton> leading_buttons;
- std::vector<views::FrameButton> trailing_buttons;
- leading_buttons.push_back(views::FRAME_BUTTON_CLOSE);
- leading_buttons.push_back(views::FRAME_BUTTON_MINIMIZE);
- leading_buttons.push_back(views::FRAME_BUTTON_MAXIMIZE);
- layout_manager_->SetButtonOrdering(leading_buttons, trailing_buttons);
- delegate_->SetShouldShowCaptionButtons(false);
- root_view_->Layout();
-
- EXPECT_EQ("0,0 0x0", maximize_button_->bounds().ToString());
- EXPECT_EQ("0,0 0x0", minimize_button_->bounds().ToString());
- EXPECT_EQ("0,0 0x0", restore_button_->bounds().ToString());
- EXPECT_EQ("0,0 0x0", close_button_->bounds().ToString());
-
- // Check the location of the avatar
- EXPECT_EQ("458,0 40x24", menu_button_->bounds().ToString());
- EXPECT_EQ("-5,-3 458x29",
- layout_manager_->GetBoundsForTabStrip(
- delegate_->GetTabstripPreferredSize(), kWidth).ToString());
- EXPECT_EQ("251x61", layout_manager_->GetMinimumSize(kWidth).ToString());
-
- // A normal window with no window icon still produces icon bounds for
- // Windows, which has a hidden icon that a user can double click on to close
- // the window.
- EXPECT_EQ("2,0 17x17", layout_manager_->IconBounds().ToString());
-}
-
TEST_F(OpaqueBrowserFrameViewLayoutTest, WindowWithNewAvatar) {
// Tests a normal tabstrip window with the new style avatar icon.
AddNewAvatarButton();
@@ -479,75 +404,3 @@
delegate_->GetTabstripPreferredSize(), kWidth).ToString());
EXPECT_EQ("261x73", layout_manager_->GetMinimumSize(kWidth).ToString());
}
-
-#if defined(ENABLE_SUPERVISED_USERS)
-TEST_F(OpaqueBrowserFrameViewLayoutTest, WindowWithAvatarWithButtonsOnLeft) {
- // Tests the layout of a chrome window with an avatar icon and caption buttons
- // on the left. The avatar icon should therefore be on the right.
- // AddAvatarLabel() also adds the avatar button.
- AddSupervisedUserAvatarLabel();
- std::vector<views::FrameButton> leading_buttons;
- std::vector<views::FrameButton> trailing_buttons;
- leading_buttons.push_back(views::FRAME_BUTTON_CLOSE);
- leading_buttons.push_back(views::FRAME_BUTTON_MINIMIZE);
- leading_buttons.push_back(views::FRAME_BUTTON_MAXIMIZE);
- layout_manager_->SetButtonOrdering(leading_buttons, trailing_buttons);
- root_view_->Layout();
-
- EXPECT_EQ("73,1 25x18", maximize_button_->bounds().ToString());
- EXPECT_EQ("47,1 26x18", minimize_button_->bounds().ToString());
- EXPECT_EQ("0,0 0x0", restore_button_->bounds().ToString());
- EXPECT_EQ("4,1 43x18", close_button_->bounds().ToString());
-
- // Check the location of the avatar
- EXPECT_EQ("454,11 40x29", menu_button_->bounds().ToString());
-
- // Check the tab strip bounds.
- gfx::Rect tab_strip_bounds = layout_manager_->GetBoundsForTabStrip(
- delegate_->GetTabstripPreferredSize(), kWidth);
- EXPECT_GT(tab_strip_bounds.x(), maximize_button_->bounds().x());
- EXPECT_GT(maximize_button_->bounds().right(), tab_strip_bounds.x());
- EXPECT_EQ(13, tab_strip_bounds.y());
- EXPECT_EQ(29, tab_strip_bounds.height());
- EXPECT_GT(supervised_user_avatar_label_->bounds().x(),
- tab_strip_bounds.right());
- EXPECT_EQ("261x73", layout_manager_->GetMinimumSize(kWidth).ToString());
-
- // Check the relative location of the avatar label to the avatar. The right
- // end of the avatar label should be slightly to the right of the right end of
- // the avatar icon.
- EXPECT_GT(supervised_user_avatar_label_->bounds().right(),
- menu_button_->bounds().right());
- EXPECT_GT(menu_button_->bounds().x(),
- supervised_user_avatar_label_->bounds().x());
- EXPECT_GT(menu_button_->bounds().bottom(),
- supervised_user_avatar_label_->bounds().bottom());
- EXPECT_GT(supervised_user_avatar_label_->bounds().y(),
- menu_button_->bounds().y());
-
- // This means that the menu will pop out facing the left (if it were to face
- // the right, it would go outside the window frame and be clipped).
- EXPECT_TRUE(menu_button_->button_on_right());
-
- // If the buttons are on the left, there should be no hidden icon for the user
- // to double click.
- EXPECT_EQ("0,0 0x0", layout_manager_->IconBounds().ToString());
-}
-
-TEST_F(OpaqueBrowserFrameViewLayoutTest, WindowWithAvatarLabelAndButtonOnLeft) {
- AddSupervisedUserAvatarLabel();
- root_view_->Layout();
-
- ExpectBasicWindowBounds();
-
- // Check the location of the avatar label relative to the avatar button if
- // both are displayed on the left side.
- // The label height and width depends on the font size and the text displayed.
- // This may possibly change, so we don't test it here.
- EXPECT_EQ(menu_button_->bounds().x() - 2,
- supervised_user_avatar_label_->bounds().x());
- EXPECT_EQ(menu_button_->bounds().bottom() - 3 -
- supervised_user_avatar_label_->bounds().height(),
- supervised_user_avatar_label_->bounds().y());
-}
-#endif
diff --git a/chrome/browser/ui/views/profiles/avatar_menu_button.cc b/chrome/browser/ui/views/profiles/avatar_menu_button.cc
index 1c0aa182..30da45d 100644
--- a/chrome/browser/ui/views/profiles/avatar_menu_button.cc
+++ b/chrome/browser/ui/views/profiles/avatar_menu_button.cc
@@ -121,24 +121,20 @@
if (index == std::string::npos)
return false;
- if (switches::IsNewAvatarMenu()) {
- *avatar = cache.GetAvatarIconOfProfileAtIndex(index);
- // TODO(noms): Once the code for the old avatar menu button is removed,
- // this function will only be called for badging the taskbar icon. The
- // function can be renamed to something like GetAvatarImageForBadging()
- // and only needs to return the avatar from
- // AvatarMenu::GetImageForMenuButton().
-#if !defined(OS_CHROMEOS)
- bool is_badge_rectangle = false;
- AvatarMenu::GetImageForMenuButton(profile->GetPath(),
- taskbar_badge_avatar,
- &is_badge_rectangle);
+#if defined(OS_CHROMEOS)
+ AvatarMenu::GetImageForMenuButton(profile->GetPath(), avatar, is_rectangle);
+#else
+ *avatar = cache.GetAvatarIconOfProfileAtIndex(index);
+ // TODO(noms): Once the code for the old avatar menu button is removed,
+ // this function will only be called for badging the taskbar icon. The
+ // function can be renamed to something like GetAvatarImageForBadging()
+ // and only needs to return the avatar from
+ // AvatarMenu::GetImageForMenuButton().
+ bool is_badge_rectangle = false;
+ AvatarMenu::GetImageForMenuButton(profile->GetPath(),
+ taskbar_badge_avatar,
+ &is_badge_rectangle);
#endif
- } else {
- AvatarMenu::GetImageForMenuButton(profile->GetPath(),
- avatar,
- is_rectangle);
- }
}
return true;
}
diff --git a/chrome/browser/ui/views/profiles/avatar_menu_button_browsertest.cc b/chrome/browser/ui/views/profiles/avatar_menu_button_browsertest.cc
deleted file mode 100644
index 09265e8..0000000
--- a/chrome/browser/ui/views/profiles/avatar_menu_button_browsertest.cc
+++ /dev/null
@@ -1,65 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/ui/views/profiles/avatar_menu_button.h"
-
-#include "base/command_line.h"
-#include "base/path_service.h"
-#include "base/strings/utf_string_conversions.h"
-#include "chrome/browser/profiles/profile_manager.h"
-#include "chrome/browser/profiles/profiles_state.h"
-#include "chrome/browser/ui/browser_list.h"
-#include "chrome/browser/ui/views/frame/browser_view.h"
-#include "chrome/common/chrome_paths.h"
-#include "chrome/common/chrome_switches.h"
-#include "chrome/test/base/in_process_browser_test.h"
-#include "chrome/test/base/test_switches.h"
-#include "chrome/test/base/testing_browser_process.h"
-#include "components/signin/core/common/profile_management_switches.h"
-
-class AvatarMenuButtonTest : public InProcessBrowserTest {
- public:
- AvatarMenuButtonTest();
- ~AvatarMenuButtonTest() override;
-
- protected:
- void SetUpCommandLine(base::CommandLine* command_line) override;
- void CreateTestingProfile();
- AvatarMenuButton* GetAvatarMenuButton();
- void StartAvatarMenu();
-
- private:
- DISALLOW_COPY_AND_ASSIGN(AvatarMenuButtonTest);
-};
-
-AvatarMenuButtonTest::AvatarMenuButtonTest() {
-}
-
-AvatarMenuButtonTest::~AvatarMenuButtonTest() {
-}
-
-void AvatarMenuButtonTest::SetUpCommandLine(base::CommandLine* command_line) {
- switches::DisableNewAvatarMenuForTesting(command_line);
-}
-
-void AvatarMenuButtonTest::CreateTestingProfile() {
- ProfileManager* profile_manager = g_browser_process->profile_manager();
- EXPECT_EQ(1u, profile_manager->GetNumberOfProfiles());
-
- base::FilePath path;
- PathService::Get(chrome::DIR_USER_DATA, &path);
- path = path.AppendASCII("test_profile");
- if (!base::PathExists(path))
- ASSERT_TRUE(base::CreateDirectory(path));
- Profile* profile =
- Profile::CreateProfile(path, NULL, Profile::CREATE_MODE_SYNCHRONOUS);
- profile_manager->RegisterTestingProfile(profile, true, false);
- EXPECT_EQ(2u, profile_manager->GetNumberOfProfiles());
-}
-
-AvatarMenuButton* AvatarMenuButtonTest::GetAvatarMenuButton() {
- BrowserView* browser_view = reinterpret_cast<BrowserView*>(
- browser()->window());
- return browser_view->frame()->GetAvatarMenuButton();
-}
diff --git a/chrome/browser/ui/views/profiles/profile_chooser_view_browsertest.cc b/chrome/browser/ui/views/profiles/profile_chooser_view_browsertest.cc
index 14a3246d..b3a0199 100644
--- a/chrome/browser/ui/views/profiles/profile_chooser_view_browsertest.cc
+++ b/chrome/browser/ui/views/profiles/profile_chooser_view_browsertest.cc
@@ -104,7 +104,6 @@
protected:
void SetUp() override {
ExtensionBrowserTest::SetUp();
- DCHECK(switches::IsNewAvatarMenu());
DCHECK(switches::IsNewProfileManagement());
}
diff --git a/chrome/browser/ui/views/sync/profile_signin_confirmation_dialog_views.cc b/chrome/browser/ui/views/sync/profile_signin_confirmation_dialog_views.cc
index 53d28f6..e01845c 100644
--- a/chrome/browser/ui/views/sync/profile_signin_confirmation_dialog_views.cc
+++ b/chrome/browser/ui/views/sync/profile_signin_confirmation_dialog_views.cc
@@ -60,8 +60,7 @@
// bubble.
// TODO(guohui): removes the workaround once the profile confirmation dialog
// is fixed.
- if (switches::IsNewAvatarMenu() && ProfileChooserView::IsShowing())
- ProfileChooserView::Hide();
+ ProfileChooserView::Hide();
ProfileSigninConfirmationDialogViews* dialog =
new ProfileSigninConfirmationDialogViews(
diff --git a/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc b/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc
index 06a611f..53c542e 100644
--- a/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc
+++ b/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc
@@ -510,10 +510,8 @@
return &NewWebUI<PopularSitesInternalsUI>;
#endif
#if !defined(OS_CHROMEOS) && !defined(OS_ANDROID) && !defined(OS_IOS)
- if (url.host() == chrome::kChromeUIUserManagerHost &&
- switches::IsNewAvatarMenu()) {
+ if (url.host() == chrome::kChromeUIUserManagerHost)
return &NewWebUI<UserManagerUI>;
- }
#endif
/****************************************************************************
diff --git a/chrome/browser/ui/webui/options/browser_options_handler.cc b/chrome/browser/ui/webui/options/browser_options_handler.cc
index aceef52..4cc2664e 100644
--- a/chrome/browser/ui/webui/options/browser_options_handler.cc
+++ b/chrome/browser/ui/webui/options/browser_options_handler.cc
@@ -666,14 +666,15 @@
RegisterTitle(values, "thirdPartyImeConfirmOverlay",
IDS_OPTIONS_SETTINGS_LANGUAGES_THIRD_PARTY_WARNING_TITLE);
+ values->SetBoolean("usingNewProfilesUI", false);
+#else
+ values->SetBoolean("usingNewProfilesUI", true);
#endif
values->SetBoolean("showSetDefault", ShouldShowSetDefaultBrowser());
values->SetBoolean("allowAdvancedSettings", ShouldAllowAdvancedSettings());
- values->SetBoolean("usingNewProfilesUI", switches::IsNewAvatarMenu());
-
#if defined(OS_CHROMEOS)
values->SetBoolean(
"showWakeOnWifi",
diff --git a/chrome/browser/ui/webui/options/manage_profile_handler.cc b/chrome/browser/ui/webui/options/manage_profile_handler.cc
index 056c20c..04754bb 100644
--- a/chrome/browser/ui/webui/options/manage_profile_handler.cc
+++ b/chrome/browser/ui/webui/options/manage_profile_handler.cc
@@ -131,8 +131,6 @@
supervised_user_dashboard_url,
supervised_user_dashboard_display));
- localized_strings->SetBoolean("newAvatarMenuEnabled",
- switches::IsNewAvatarMenu());
localized_strings->SetBoolean("profileShortcutsEnabled",
ProfileShortcutManager::IsFeatureEnabled());
diff --git a/chrome/browser/ui/webui/options/sync_setup_handler.cc b/chrome/browser/ui/webui/options/sync_setup_handler.cc
index 8c637c6..5c9a6179 100644
--- a/chrome/browser/ui/webui/options/sync_setup_handler.cc
+++ b/chrome/browser/ui/webui/options/sync_setup_handler.cc
@@ -368,7 +368,7 @@
SigninErrorController* error_controller =
SigninErrorControllerFactory::GetForProfile(browser->profile());
DCHECK(error_controller->HasError());
- if (switches::IsNewAvatarMenu() && !force_new_tab) {
+ if (!force_new_tab) {
browser->window()->ShowAvatarBubbleFromAvatarButton(
BrowserWindow::AVATAR_BUBBLE_MODE_REAUTH,
signin::ManageAccountsParams());
@@ -378,7 +378,7 @@
}
} else {
signin_metrics::LogSigninSource(signin_metrics::SOURCE_SETTINGS);
- if (switches::IsNewAvatarMenu() && !force_new_tab) {
+ if (!force_new_tab) {
browser->window()->ShowAvatarBubbleFromAvatarButton(
BrowserWindow::AVATAR_BUBBLE_MODE_SIGNIN,
signin::ManageAccountsParams());
diff --git a/chrome/browser/ui/webui/signin/inline_login_handler_impl.cc b/chrome/browser/ui/webui/signin/inline_login_handler_impl.cc
index 5a7b0bb9..83b5eab 100644
--- a/chrome/browser/ui/webui/signin/inline_login_handler_impl.cc
+++ b/chrome/browser/ui/webui/signin/inline_login_handler_impl.cc
@@ -356,9 +356,8 @@
SigninErrorController* error_controller =
SigninErrorControllerFactory::GetForProfile(profile_);
- bool is_new_avatar_menu = switches::IsNewAvatarMenu();
-
- OneClickSigninSyncStarter::StartSyncMode start_mode;
+ OneClickSigninSyncStarter::StartSyncMode start_mode =
+ OneClickSigninSyncStarter::CONFIRM_SYNC_SETTINGS_FIRST;
if (source == signin_metrics::SOURCE_SETTINGS || choose_what_to_sync_) {
bool show_settings_without_configure =
error_controller->HasError() &&
@@ -367,25 +366,12 @@
start_mode = show_settings_without_configure ?
OneClickSigninSyncStarter::SHOW_SETTINGS_WITHOUT_CONFIGURE :
OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST;
- } else {
- start_mode = is_new_avatar_menu ?
- OneClickSigninSyncStarter::CONFIRM_SYNC_SETTINGS_FIRST :
- OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS;
}
- OneClickSigninSyncStarter::ConfirmationRequired confirmation_required;
- if (confirm_untrusted_signin_) {
- confirmation_required =
- OneClickSigninSyncStarter::CONFIRM_UNTRUSTED_SIGNIN;
- } else if (is_new_avatar_menu) {
- confirmation_required = OneClickSigninSyncStarter::CONFIRM_AFTER_SIGNIN;
- } else {
- confirmation_required =
- source == signin_metrics::SOURCE_SETTINGS ||
- choose_what_to_sync_ ?
- OneClickSigninSyncStarter::NO_CONFIRMATION :
- OneClickSigninSyncStarter::CONFIRM_AFTER_SIGNIN;
- }
+ OneClickSigninSyncStarter::ConfirmationRequired confirmation_required =
+ confirm_untrusted_signin_ ?
+ OneClickSigninSyncStarter::CONFIRM_UNTRUSTED_SIGNIN :
+ OneClickSigninSyncStarter::CONFIRM_AFTER_SIGNIN;
bool start_signin = !HandleCrossAccountError(result.refresh_token, source,
confirmation_required, start_mode);
diff --git a/chrome/browser/ui/webui/signin/login_ui_service.cc b/chrome/browser/ui/webui/signin/login_ui_service.cc
index 2a63883..cc1681d 100644
--- a/chrome/browser/ui/webui/signin/login_ui_service.cc
+++ b/chrome/browser/ui/webui/signin/login_ui_service.cc
@@ -74,24 +74,15 @@
void LoginUIService::DisplayLoginResult(Browser* browser,
const base::string16& message) {
- last_login_result_ = message;
- if (switches::IsNewAvatarMenu()) {
- browser->window()->ShowAvatarBubbleFromAvatarButton(
- message.empty() ? BrowserWindow::AVATAR_BUBBLE_MODE_CONFIRM_SIGNIN :
- BrowserWindow::AVATAR_BUBBLE_MODE_SHOW_ERROR,
- signin::ManageAccountsParams());
- } else {
-#if defined(ENABLE_ONE_CLICK_SIGNIN)
- browser->window()->ShowOneClickSigninBubble(
- BrowserWindow::ONE_CLICK_SIGNIN_BUBBLE_TYPE_BUBBLE,
- base::string16(), /* no SAML email */
- message,
- // This callback is never invoked.
- // TODO(rogerta): Separate out the bubble API so we don't have to pass
- // ignored |email| and |callback| params.
- BrowserWindow::StartSyncCallback());
+#if defined(OS_CHROMEOS)
+ // ChromeOS doesn't have the avatar bubble so it never calls this function.
+ NOTREACHED();
#endif
- }
+ last_login_result_ = message;
+ browser->window()->ShowAvatarBubbleFromAvatarButton(
+ message.empty() ? BrowserWindow::AVATAR_BUBBLE_MODE_CONFIRM_SIGNIN :
+ BrowserWindow::AVATAR_BUBBLE_MODE_SHOW_ERROR,
+ signin::ManageAccountsParams());
}
const base::string16& LoginUIService::GetLastLoginResult() {
diff --git a/chrome/browser/ui/webui/signin/user_manager_ui_browsertest.cc b/chrome/browser/ui/webui/signin/user_manager_ui_browsertest.cc
index f7c6482..f46c3e4 100644
--- a/chrome/browser/ui/webui/signin/user_manager_ui_browsertest.cc
+++ b/chrome/browser/ui/webui/signin/user_manager_ui_browsertest.cc
@@ -26,16 +26,6 @@
public testing::WithParamInterface<bool> {
public:
UserManagerUIBrowserTest() {}
-
- protected:
- void SetUp() override {
- InProcessBrowserTest::SetUp();
- DCHECK(switches::IsNewAvatarMenu());
- }
-
- void SetUpCommandLine(base::CommandLine* command_line) override {
- switches::EnableNewAvatarMenuForTesting(command_line);
- }
};
IN_PROC_BROWSER_TEST_F(UserManagerUIBrowserTest, PageLoads) {
diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi
index d063931..1f01fe7 100644
--- a/chrome/chrome_tests.gypi
+++ b/chrome/chrome_tests.gypi
@@ -652,7 +652,6 @@
'browser/ui/views/location_bar/zoom_bubble_view_browsertest.cc',
'browser/ui/views/media_router/media_router_ui_browsertest.cc',
'browser/ui/views/new_task_manager_view_browsertest.cc',
- 'browser/ui/views/profiles/avatar_menu_button_browsertest.cc',
'browser/ui/views/toolbar/browser_actions_container_browsertest.cc',
'browser/ui/views/toolbar/toolbar_view_browsertest.cc',
'browser/ui/views/translate/translate_bubble_view_browsertest.cc',
diff --git a/chrome/chrome_tests_unit.gypi b/chrome/chrome_tests_unit.gypi
index 932a4c80..4fe608d 100644
--- a/chrome/chrome_tests_unit.gypi
+++ b/chrome/chrome_tests_unit.gypi
@@ -326,7 +326,6 @@
'browser/ui/cocoa/bookmarks/bookmark_menu_cocoa_controller_unittest.mm',
'browser/ui/cocoa/bookmarks/bookmark_model_observer_for_cocoa_unittest.mm',
'browser/ui/cocoa/bookmarks/bookmark_name_folder_controller_unittest.mm',
- 'browser/ui/cocoa/bookmarks/bookmark_sync_promo_controller_unittest.mm',
'browser/ui/cocoa/bookmarks/bookmark_tree_browser_cell_unittest.mm',
'browser/ui/cocoa/browser/edit_search_engine_cocoa_controller_unittest.mm',
'browser/ui/cocoa/browser/zoom_bubble_controller_unittest.mm',
diff --git a/components/signin/core/browser/about_signin_internals.cc b/components/signin/core/browser/about_signin_internals.cc
index 514f1bf0..7f3a6a10 100644
--- a/components/signin/core/browser/about_signin_internals.cc
+++ b/components/signin/core/browser/about_signin_internals.cc
@@ -514,8 +514,6 @@
AddSectionEntry(basic_info, "Chrome Version", product_version);
AddSectionEntry(basic_info, "Webview Based Signin?",
switches::IsEnableWebviewBasedSignin() == true ? "On" : "Off");
- AddSectionEntry(basic_info, "New Avatar Menu?",
- switches::IsNewAvatarMenu() == true ? "On" : "Off");
AddSectionEntry(basic_info, "New Profile Management?",
switches::IsNewProfileManagement() == true ? "On" : "Off");
AddSectionEntry(basic_info, "Account Consistency?",
diff --git a/components/signin/core/common/profile_management_switches.cc b/components/signin/core/common/profile_management_switches.cc
index 768ae5c..5231174 100644
--- a/components/signin/core/common/profile_management_switches.cc
+++ b/components/signin/core/common/profile_management_switches.cc
@@ -17,7 +17,6 @@
// below assumes the order of the values in this enum. That is, new profile
// management is included in consistent identity.
enum State {
- STATE_OLD_AVATAR_MENU,
STATE_NEW_AVATAR_MENU,
STATE_NEW_PROFILE_MANAGEMENT,
STATE_ACCOUNT_CONSISTENCY,
@@ -25,26 +24,20 @@
State GetProcessState() {
// Find the state of both command line args.
- bool is_new_avatar_menu = base::CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kEnableNewAvatarMenu);
bool is_new_profile_management =
base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableNewProfileManagement);
bool is_consistent_identity =
base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableAccountConsistency);
- bool not_new_avatar_menu = base::CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kDisableNewAvatarMenu);
bool not_new_profile_management =
base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDisableNewProfileManagement);
bool not_consistent_identity =
base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDisableAccountConsistency);
- int count_args = (is_new_avatar_menu ? 1 : 0) +
- (is_new_profile_management ? 1 : 0) +
+ int count_args = (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;
@@ -67,17 +60,12 @@
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 (not_new_avatar_menu) {
- return STATE_OLD_AVATAR_MENU;
- } else if (is_consistent_identity) {
+ if (is_consistent_identity) {
return STATE_ACCOUNT_CONSISTENCY;
} else if (is_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) {
return STATE_NEW_AVATAR_MENU;
} else if (not_consistent_identity) {
@@ -141,15 +129,6 @@
return CheckFlag(switches::kGoogleProfileInfo, STATE_NEW_AVATAR_MENU);
}
-bool IsNewAvatarMenu() {
- // NewAvatarMenu is only available on desktop.
-#if defined(OS_ANDROID) || defined(OS_IOS) || defined(OS_CHROMEOS)
- return false;
-#else
- return GetProcessState() >= STATE_NEW_AVATAR_MENU;
-#endif
-}
-
bool IsNewProfileManagement() {
return GetProcessState() >= STATE_NEW_PROFILE_MANAGEMENT;
}
@@ -159,16 +138,6 @@
return false;
}
-void EnableNewAvatarMenuForTesting(base::CommandLine* command_line) {
- command_line->AppendSwitch(switches::kEnableNewAvatarMenu);
- DCHECK(!command_line->HasSwitch(switches::kDisableNewAvatarMenu));
-}
-
-void DisableNewAvatarMenuForTesting(base::CommandLine* command_line) {
- command_line->AppendSwitch(switches::kDisableNewAvatarMenu);
- DCHECK(!command_line->HasSwitch(switches::kEnableNewAvatarMenu));
-}
-
void EnableNewProfileManagementForTesting(base::CommandLine* command_line) {
command_line->AppendSwitch(switches::kEnableNewProfileManagement);
DCHECK(!command_line->HasSwitch(switches::kDisableNewProfileManagement));
diff --git a/components/signin/core/common/profile_management_switches.h b/components/signin/core/common/profile_management_switches.h
index c1ad761..9ef7ab6 100644
--- a/components/signin/core/common/profile_management_switches.h
+++ b/components/signin/core/common/profile_management_switches.h
@@ -28,20 +28,13 @@
// Enables using GAIA information to populate profile name and icon.
bool IsGoogleProfileInfo();
-// Whether the new avatar menu is enabled, either because new profile management
-// is enabled or because the new profile management preview UI is enabled.
-bool IsNewAvatarMenu();
-
// Use new profile management system, including profile sign-out and new
// choosers.
bool IsNewProfileManagement();
// Whether the new profile management preview has been enabled.
bool IsNewProfileManagementPreviewEnabled();
-
// Called in tests to force enabling different modes.
-void EnableNewAvatarMenuForTesting(base::CommandLine* command_line);
-void DisableNewAvatarMenuForTesting(base::CommandLine* command_line);
void EnableNewProfileManagementForTesting(base::CommandLine* command_line);
void EnableAccountConsistencyForTesting(base::CommandLine* command_line);
diff --git a/components/signin/core/common/signin_switches.cc b/components/signin/core/common/signin_switches.cc
index 2e1950c..a9e549a 100644
--- a/components/signin/core/common/signin_switches.cc
+++ b/components/signin/core/common/signin_switches.cc
@@ -16,9 +16,6 @@
// Disables new profile management system, including new profile chooser UI.
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.
const char kDisableSigninScopedDeviceId[] = "disable-signin-scoped-device-id";
@@ -29,9 +26,6 @@
// webview-based flow.
const char kEnableIframeBasedSignin[] = "enable-iframe-based-signin";
-// 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";
diff --git a/components/signin/core/common/signin_switches.h b/components/signin/core/common/signin_switches.h
index 68f34ce33..9e0154ff 100644
--- a/components/signin/core/common/signin_switches.h
+++ b/components/signin/core/common/signin_switches.h
@@ -15,12 +15,10 @@
// alongside the definition of their values in the .cc file.
extern const char kClearTokenService[];
extern const char kDisableAccountConsistency[];
-extern const char kDisableNewAvatarMenu[];
extern const char kDisableNewProfileManagement[];
extern const char kDisableSigninScopedDeviceId[];
extern const char kEnableAccountConsistency[];
extern const char kEnableIframeBasedSignin[];
-extern const char kEnableNewAvatarMenu[];
extern const char kEnableNewProfileManagement[];
extern const char kEnableRefreshTokenAnnotationRequest[];
extern const char kExtensionsMultiAccount[];