diff options
author | bcwhite@chromium.org <bcwhite@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-18 23:16:12 +0000 |
---|---|---|
committer | bcwhite@chromium.org <bcwhite@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-18 23:16:12 +0000 |
commit | 4de7526e6caf6695839823fc2524fcfdb6d44af7 (patch) | |
tree | fa258774e347c496bd94b02f383ea492893c96e2 | |
parent | fddfb023161a0ca56d6c5762490da09af5cb2a57 (diff) | |
download | chromium_src-4de7526e6caf6695839823fc2524fcfdb6d44af7.zip chromium_src-4de7526e6caf6695839823fc2524fcfdb6d44af7.tar.gz chromium_src-4de7526e6caf6695839823fc2524fcfdb6d44af7.tar.bz2 |
Run all flag-checks for new-profile-managment et al through common functions for future Finch integration.
In order to do tests and a safe, controlled roll-out of Chrome's new profile management, we're going to enable it using a Finch experiment. The current tests of the existing command-line flags all need to be routed through common functions in order to override these settings if a Finch experiment is set.
Affected flags are:
--new-profile-management
--enable-inline-signin
--google-profile-info
Note that there existed a function to test for NewProfileManagement but it was not in a good place for general testing and definitely not for other flags so it has been extracted as well.
BUG=324046
Review URL: https://codereview.chromium.org/108803007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@241698 0039d316-1c4b-4281-b951-d872f2087c98
33 files changed, 129 insertions, 95 deletions
diff --git a/PRESUBMIT.py b/PRESUBMIT.py index f7b8d8a..573a2c7 100644 --- a/PRESUBMIT.py +++ b/PRESUBMIT.py @@ -868,6 +868,8 @@ def _CheckSpamLogging(input_api, output_api): (r"^base[\\\/]logging\.h$", r"^chrome[\\\/]app[\\\/]chrome_main_delegate\.cc$", r"^chrome[\\\/]browser[\\\/]chrome_browser_main\.cc$", + r"^chrome[\\\/]browser[\\\/]ui[\\\/]startup[\\\/]" + r"startup_browser_creator\.cc$", r"^chrome[\\\/]installer[\\\/]setup[\\\/].*", r"^chrome[\\\/]renderer[\\\/]extensions[\\\/]" r"logging_native_handler\.cc$", diff --git a/chrome/browser/android/signin/signin_manager_android.cc b/chrome/browser/android/signin/signin_manager_android.cc index 132f15f..d5ead38 100644 --- a/chrome/browser/android/signin/signin_manager_android.cc +++ b/chrome/browser/android/signin/signin_manager_android.cc @@ -17,7 +17,6 @@ #include "chrome/browser/browsing_data/browsing_data_helper.h" #include "chrome/browser/browsing_data/browsing_data_remover.h" #include "chrome/browser/profiles/profile_manager.h" -#include "chrome/browser/profiles/profiles_state.h" #include "chrome/browser/signin/android_profile_oauth2_token_service.h" #include "chrome/browser/signin/google_auto_login_helper.h" #include "chrome/browser/signin/profile_oauth2_token_service.h" @@ -25,6 +24,7 @@ #include "chrome/browser/signin/signin_manager.h" #include "chrome/browser/signin/signin_manager_factory.h" #include "chrome/common/pref_names.h" +#include "chrome/common/profile_management_switches.h" #include "jni/SigninManager_jni.h" #if defined(ENABLE_CONFIGURATION_POLICY) @@ -209,7 +209,7 @@ void SigninManagerAndroid::OnBrowsingDataRemoverDone() { } void SigninManagerAndroid::LogInSignedInUser(JNIEnv* env, jobject obj) { - if (profiles::IsNewProfileManagementEnabled()) { + if (switches::IsNewProfileManagement()) { // New Mirror code path that just fires the events and let the // Account Reconcilor handles everything. AndroidProfileOAuth2TokenService* token_service = diff --git a/chrome/browser/browser_process_impl.cc b/chrome/browser/browser_process_impl.cc index a79c5c2..f10bfae7 100644 --- a/chrome/browser/browser_process_impl.cc +++ b/chrome/browser/browser_process_impl.cc @@ -60,7 +60,6 @@ #include "chrome/browser/printing/print_job_manager.h" #include "chrome/browser/printing/print_preview_dialog_controller.h" #include "chrome/browser/profiles/profile_manager.h" -#include "chrome/browser/profiles/profiles_state.h" #include "chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.h" #include "chrome/browser/safe_browsing/safe_browsing_service.h" #include "chrome/browser/shell_integration.h" @@ -77,6 +76,7 @@ #include "chrome/common/extensions/chrome_extensions_client.h" #include "chrome/common/extensions/extension_l10n_util.h" #include "chrome/common/pref_names.h" +#include "chrome/common/profile_management_switches.h" #include "chrome/common/switch_utils.h" #include "chrome/common/url_constants.h" #include "chrome/installer/util/google_update_constants.h" @@ -252,7 +252,7 @@ void BrowserProcessImpl::StartTearDown() { "BrowserProcessImpl::StartTearDown:ProfileManager"); // The desktop User Manager needs to be closed before the guest profile // can be destroyed. - if (profiles::IsNewProfileManagementEnabled()) + if (switches::IsNewProfileManagement()) chrome::HideUserManager(); profile_manager_.reset(); } diff --git a/chrome/browser/chrome_browser_main.cc b/chrome/browser/chrome_browser_main.cc index 0b2548d..f11c24e 100644 --- a/chrome/browser/chrome_browser_main.cc +++ b/chrome/browser/chrome_browser_main.cc @@ -111,6 +111,7 @@ #include "chrome/common/logging_chrome.h" #include "chrome/common/net/net_resource_provider.h" #include "chrome/common/pref_names.h" +#include "chrome/common/profile_management_switches.h" #include "chrome/common/profiling.h" #include "chrome/installer/util/google_update_settings.h" #include "components/nacl/browser/nacl_browser.h" @@ -354,7 +355,7 @@ Profile* CreateProfile(const content::MainFunctionParams& parameters, // signed out, then we should show the user manager instead. By switching // the active profile to the guest profile we ensure that no // browser windows will be opened for the guest profile. - if (profiles::IsNewProfileManagementEnabled() && !profile->IsGuestSession()) { + if (switches::IsNewProfileManagement() && !profile->IsGuestSession()) { ProfileInfoCache& cache = g_browser_process->profile_manager()->GetProfileInfoCache(); size_t profile_index = cache.GetIndexOfProfileWithPath(profile_path); diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc index c395507..d059d5f 100644 --- a/chrome/browser/chrome_content_browser_client.cc +++ b/chrome/browser/chrome_content_browser_client.cc @@ -96,6 +96,7 @@ #include "chrome/common/logging_chrome.h" #include "chrome/common/pepper_permission_util.h" #include "chrome/common/pref_names.h" +#include "chrome/common/profile_management_switches.h" #include "chrome/common/render_messages.h" #include "chrome/common/url_constants.h" #include "chrome/installer/util/google_update_settings.h" @@ -923,10 +924,8 @@ void ChromeContentBrowserClient::RenderProcessHostCreated( #if defined(OS_ANDROID) host->AddFilter(new EncryptedMediaMessageFilterAndroid()); #endif - if (CommandLine::ForCurrentProcess()->HasSwitch( - switches::kNewProfileManagement)) { + if (switches::IsNewProfileManagement()) host->AddFilter(new PrincipalsMessageFilter(id)); - } host->Send(new ChromeViewMsg_SetIsIncognitoProcess( profile->IsOffTheRecord())); diff --git a/chrome/browser/extensions/api/principals_private/principals_private_api.cc b/chrome/browser/extensions/api/principals_private/principals_private_api.cc index f08bd6d..b4fa4a2 100644 --- a/chrome/browser/extensions/api/principals_private/principals_private_api.cc +++ b/chrome/browser/extensions/api/principals_private/principals_private_api.cc @@ -7,14 +7,14 @@ #include "chrome/browser/browser_process.h" #include "chrome/browser/profiles/avatar_menu.h" #include "chrome/browser/profiles/profile_window.h" -#include "chrome/browser/profiles/profiles_state.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_window.h" +#include "chrome/common/profile_management_switches.h" namespace extensions { bool PrincipalsPrivateExtensionFunction::RunImpl() { - if (!profiles::IsNewProfileManagementEnabled()) { + if (!switches::IsNewProfileManagement()) { SetError( "Need to enable new-profile-management to use principalsPrivate API."); return false; diff --git a/chrome/browser/extensions/signin/gaia_auth_extension_loader.cc b/chrome/browser/extensions/signin/gaia_auth_extension_loader.cc index e5e6a6d..6bd63bf 100644 --- a/chrome/browser/extensions/signin/gaia_auth_extension_loader.cc +++ b/chrome/browser/extensions/signin/gaia_auth_extension_loader.cc @@ -11,6 +11,7 @@ #include "chrome/browser/profiles/profile.h" #include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_switches.h" +#include "chrome/common/profile_management_switches.h" #include "content/public/browser/browser_thread.h" #include "grit/browser_resources.h" @@ -51,7 +52,7 @@ void LoadGaiaAuthExtension(Profile* profile) { else if (command_line->HasSwitch(chromeos::switches::kEnableSamlSignin)) manifest_resource_id = IDR_GAIA_AUTH_SAML_MANIFEST; #else - if (command_line->HasSwitch(switches::kEnableInlineSignin)) + if (switches::IsEnableInlineSignin()) manifest_resource_id = IDR_GAIA_AUTH_INLINE_MANIFEST; #endif diff --git a/chrome/browser/profiles/avatar_menu.cc b/chrome/browser/profiles/avatar_menu.cc index c34c65f..0608641 100644 --- a/chrome/browser/profiles/avatar_menu.cc +++ b/chrome/browser/profiles/avatar_menu.cc @@ -24,6 +24,7 @@ #include "chrome/browser/ui/host_desktop.h" #include "chrome/browser/ui/startup/startup_browser_creator.h" #include "chrome/common/chrome_switches.h" +#include "chrome/common/profile_management_switches.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/notification_service.h" #include "grit/generated_resources.h" @@ -101,7 +102,7 @@ bool AvatarMenu::ShouldShowAvatarMenu() { ChromeShellDelegate::instance() && ChromeShellDelegate::instance()->IsMultiProfilesEnabled(); #else - return profiles::IsNewProfileManagementEnabled() || + return switches::IsNewProfileManagement() || (g_browser_process->profile_manager() && g_browser_process->profile_manager()->GetNumberOfProfiles() > 1); #endif @@ -119,7 +120,7 @@ void AvatarMenu::SwitchToProfile(size_t index, bool always_create) { index == GetActiveProfileIndex()); const Item& item = GetItemAt(index); - if (profiles::IsNewProfileManagementEnabled()) { + if (switches::IsNewProfileManagement()) { // Don't open a browser window for signed-out profiles. if (item.signin_required) { chrome::ShowUserManager(item.profile_path); diff --git a/chrome/browser/profiles/gaia_info_update_service.cc b/chrome/browser/profiles/gaia_info_update_service.cc index 90bb802..9733fe4 100644 --- a/chrome/browser/profiles/gaia_info_update_service.cc +++ b/chrome/browser/profiles/gaia_info_update_service.cc @@ -4,7 +4,6 @@ #include "chrome/browser/profiles/gaia_info_update_service.h" -#include "base/command_line.h" #include "base/prefs/pref_service.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/chrome_notification_types.h" @@ -12,8 +11,8 @@ #include "chrome/browser/profiles/profile_info_cache.h" #include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/sync/profile_sync_service.h" -#include "chrome/common/chrome_switches.h" #include "chrome/common/pref_names.h" +#include "chrome/common/profile_management_switches.h" #include "content/public/browser/notification_details.h" #include "third_party/skia/include/core/SkBitmap.h" #include "ui/gfx/image/image.h" @@ -68,10 +67,8 @@ bool GAIAInfoUpdateService::ShouldUseGAIAProfileInfo(Profile* profile) { return false; // To enable this feature for testing pass "--google-profile-info". - if (CommandLine::ForCurrentProcess()->HasSwitch( - switches::kGoogleProfileInfo)) { + if (switches::IsGoogleProfileInfo()) return true; - } // This feature is disable by default. return false; diff --git a/chrome/browser/profiles/profile_list_desktop.cc b/chrome/browser/profiles/profile_list_desktop.cc index 2892aba..4910889 100644 --- a/chrome/browser/profiles/profile_list_desktop.cc +++ b/chrome/browser/profiles/profile_list_desktop.cc @@ -4,11 +4,10 @@ #include "chrome/browser/profiles/profile_list_desktop.h" -#include "base/command_line.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_info_cache.h" #include "chrome/browser/profiles/profile_info_util.h" -#include "chrome/common/chrome_switches.h" +#include "chrome/common/profile_management_switches.h" #include "grit/generated_resources.h" #include "ui/base/l10n/l10n_util.h" @@ -44,8 +43,7 @@ void ProfileListDesktop::RebuildMenu() { profile_info_->GetGAIAPictureOfProfileAtIndex(i); gfx::Image icon = profile_info_->GetAvatarIconOfProfileAtIndex(i); - if (!CommandLine::ForCurrentProcess()->HasSwitch( - switches::kNewProfileManagement)) { + if (!switches::IsNewProfileManagement()) { // old avatar menu uses resized-small images icon = profiles::GetAvatarIconForMenu(icon, is_gaia_picture); } diff --git a/chrome/browser/profiles/profile_manager.cc b/chrome/browser/profiles/profile_manager.cc index 4082919..d89b3a4 100644 --- a/chrome/browser/profiles/profile_manager.cc +++ b/chrome/browser/profiles/profile_manager.cc @@ -43,6 +43,7 @@ #include "chrome/common/chrome_switches.h" #include "chrome/common/logging_chrome.h" #include "chrome/common/pref_names.h" +#include "chrome/common/profile_management_switches.h" #include "chrome/common/url_constants.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/notification_service.h" @@ -847,7 +848,7 @@ void ProfileManager::DoFinalInitForServices(Profile* profile, StartupTaskRunnerServiceFactory::GetForProfile(profile)-> StartDeferredTaskRunners(); - if (profiles::IsNewProfileManagementEnabled()) + if (switches::IsNewProfileManagement()) AccountReconcilorFactory::GetForProfile(profile); } diff --git a/chrome/browser/profiles/profiles_state.cc b/chrome/browser/profiles/profiles_state.cc index f3121a1..07f7d1b 100644 --- a/chrome/browser/profiles/profiles_state.cc +++ b/chrome/browser/profiles/profiles_state.cc @@ -4,7 +4,6 @@ #include "chrome/browser/profiles/profiles_state.h" -#include "base/command_line.h" #include "base/files/file_path.h" #include "base/prefs/pref_registry_simple.h" #include "base/prefs/pref_service.h" @@ -15,7 +14,6 @@ #include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/ui/browser.h" #include "chrome/common/chrome_constants.h" -#include "chrome/common/chrome_switches.h" #include "chrome/common/pref_names.h" #include "grit/generated_resources.h" #include "ui/base/l10n/l10n_util.h" @@ -37,11 +35,6 @@ bool IsMultipleProfilesEnabled() { return true; } -bool IsNewProfileManagementEnabled() { - return CommandLine::ForCurrentProcess()->HasSwitch( - switches::kNewProfileManagement); -} - base::FilePath GetDefaultProfileDir(const base::FilePath& user_data_dir) { base::FilePath default_profile_dir(user_data_dir); default_profile_dir = diff --git a/chrome/browser/profiles/profiles_state.h b/chrome/browser/profiles/profiles_state.h index 8e29f70..782fb3a 100644 --- a/chrome/browser/profiles/profiles_state.h +++ b/chrome/browser/profiles/profiles_state.h @@ -17,9 +17,6 @@ namespace profiles { // Checks if multiple profiles is enabled. bool IsMultipleProfilesEnabled(); -// Checks if new profile management is enabled. -bool IsNewProfileManagementEnabled(); - // Returns the path to the default profile directory, based on the given // user data directory. base::FilePath GetDefaultProfileDir(const base::FilePath& user_data_dir); diff --git a/chrome/browser/signin/signin_header_helper.cc b/chrome/browser/signin/signin_header_helper.cc index 1b4102a..95270fb 100644 --- a/chrome/browser/signin/signin_header_helper.cc +++ b/chrome/browser/signin/signin_header_helper.cc @@ -7,11 +7,10 @@ #include "base/command_line.h" #include "chrome/browser/extensions/extension_renderer_state.h" #include "chrome/browser/profiles/profile_io_data.h" -#include "chrome/browser/profiles/profiles_state.h" #include "chrome/browser/tab_contents/tab_util.h" #include "chrome/browser/ui/browser_finder.h" #include "chrome/browser/ui/browser_window.h" -#include "chrome/common/chrome_switches.h" +#include "chrome/common/profile_management_switches.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/web_contents.h" #include "google_apis/gaia/gaia_auth_util.h" @@ -74,10 +73,8 @@ void AppendMirrorRequestHeaderIfPossible( // available. const GURL& url = redirect_url.is_empty() ? request->url() : redirect_url; GURL origin(url.GetOrigin()); - bool enable_inline = CommandLine::ForCurrentProcess()->HasSwitch( - switches::kEnableInlineSignin); - bool is_gaia_signin = enable_inline && - profiles::IsNewProfileManagementEnabled() && + bool is_gaia_signin = !switches::IsEnableInlineSignin() && + switches::IsNewProfileManagement() && gaia::IsGaiaSignonRealm(origin); if (!is_gaia_signin && !IsDriveOrigin(origin)) return; @@ -108,7 +105,7 @@ void ProcessMirrorResponseHeaderIfExists( if (gaia::IsGaiaSignonRealm(request->url().GetOrigin()) && request->response_headers()->HasHeader(kChromeManageAccountsHeader)) { - DCHECK(profiles::IsNewProfileManagementEnabled() && + DCHECK(switches::IsNewProfileManagement() && !io_data->is_incognito()); content::BrowserThread::PostTask( content::BrowserThread::UI, FROM_HERE, diff --git a/chrome/browser/signin/signin_manager.cc b/chrome/browser/signin/signin_manager.cc index 93669d6..72e446c3 100644 --- a/chrome/browser/signin/signin_manager.cc +++ b/chrome/browser/signin/signin_manager.cc @@ -7,7 +7,6 @@ #include <string> #include <vector> -#include "base/command_line.h" #include "base/memory/ref_counted.h" #include "base/prefs/pref_service.h" #include "base/strings/string_split.h" @@ -29,8 +28,8 @@ #include "chrome/browser/signin/signin_manager_factory.h" #include "chrome/browser/ui/global_error/global_error_service.h" #include "chrome/browser/ui/global_error/global_error_service_factory.h" -#include "chrome/common/chrome_switches.h" #include "chrome/common/pref_names.h" +#include "chrome/common/profile_management_switches.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/notification_service.h" #include "content/public/browser/render_process_host.h" @@ -585,10 +584,8 @@ void SigninManager::OnSignedIn(const std::string& username) { #if !defined(OS_ANDROID) // Don't store password hash except for users of new profile features. - if (CommandLine::ForCurrentProcess()->HasSwitch( - switches::kNewProfileManagement)) { + if (switches::IsNewProfileManagement()) chrome::SetLocalAuthCredentials(profile_, password_); - } #endif password_.clear(); // Don't need it anymore. diff --git a/chrome/browser/signin/signin_promo.cc b/chrome/browser/signin/signin_promo.cc index 3aa44d1..f442996 100644 --- a/chrome/browser/signin/signin_promo.cc +++ b/chrome/browser/signin/signin_promo.cc @@ -4,7 +4,6 @@ #include "chrome/browser/signin/signin_promo.h" -#include "base/command_line.h" #include "base/prefs/pref_service.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_util.h" @@ -22,9 +21,9 @@ #include "chrome/browser/sync/profile_sync_service_factory.h" #include "chrome/browser/ui/webui/options/core_options_handler.h" #include "chrome/browser/ui/webui/theme_source.h" -#include "chrome/common/chrome_switches.h" #include "chrome/common/net/url_util.h" #include "chrome/common/pref_names.h" +#include "chrome/common/profile_management_switches.h" #include "chrome/common/url_constants.h" #include "components/user_prefs/pref_registry_syncable.h" #include "content/public/browser/url_data_source.h" @@ -181,9 +180,7 @@ GURL GetPromoURL(Source source, bool auto_close) { GURL GetPromoURL(Source source, bool auto_close, bool is_constrained) { DCHECK_NE(SOURCE_UNKNOWN, source); - bool enable_inline = CommandLine::ForCurrentProcess()->HasSwitch( - switches::kEnableInlineSignin); - if (enable_inline) { + if (switches::IsEnableInlineSignin()) { std::string url(chrome::kChromeUIChromeSigninURL); base::StringAppendF(&url, "?%s=%d", kSignInPromoQueryKeySource, source); if (auto_close) diff --git a/chrome/browser/ui/browser_command_controller_unittest.cc b/chrome/browser/ui/browser_command_controller_unittest.cc index 65c7a8c..16450fd 100644 --- a/chrome/browser/ui/browser_command_controller_unittest.cc +++ b/chrome/browser/ui/browser_command_controller_unittest.cc @@ -15,6 +15,7 @@ #include "chrome/browser/ui/browser_window_state.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/pref_names.h" +#include "chrome/common/profile_management_switches.h" #include "chrome/test/base/browser_with_test_window_test.h" #include "chrome/test/base/test_browser_window.h" #include "chrome/test/base/testing_browser_process.h" @@ -146,7 +147,7 @@ TEST_F(BrowserCommandControllerTest, OldAvatarMenuDisabledWhenOnlyOneProfile) { if (!profiles::IsMultipleProfilesEnabled()) return; - EXPECT_FALSE(profiles::IsNewProfileManagementEnabled()); + EXPECT_FALSE(switches::IsNewProfileManagement()); TestingProfileManager testing_profile_manager( TestingBrowserProcess::GetGlobal()); @@ -179,7 +180,7 @@ TEST_F(BrowserCommandControllerTest, NewAvatarMenuEnabledWhenOnlyOneProfile) { // The command line is reset at the end of every test by the test suite. CommandLine::ForCurrentProcess()->AppendSwitch( switches::kNewProfileManagement); - EXPECT_TRUE(profiles::IsNewProfileManagementEnabled()); + EXPECT_TRUE(switches::IsNewProfileManagement()); TestingProfileManager testing_profile_manager( TestingBrowserProcess::GetGlobal()); @@ -203,7 +204,7 @@ TEST_F(BrowserCommandControllerTest, NewAvatarMenuEnabledInGuestMode) { // The command line is reset at the end of every test by the test suite. CommandLine::ForCurrentProcess()->AppendSwitch( switches::kNewProfileManagement); - EXPECT_TRUE(profiles::IsNewProfileManagementEnabled()); + EXPECT_TRUE(switches::IsNewProfileManagement()); TestingProfileManager testing_profile_manager( TestingBrowserProcess::GetGlobal()); @@ -262,14 +263,14 @@ TEST_F(BrowserCommandControllerTest, AvatarMenuAlwaysDisabledInIncognitoMode) { const CommandUpdater* command_updater = command_controller.command_updater(); // The old style avatar menu should be disabled. - EXPECT_FALSE(profiles::IsNewProfileManagementEnabled()); + EXPECT_FALSE(switches::IsNewProfileManagement()); EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_AVATAR_MENU)); // The new style avatar menu should also be disabled. // The command line is reset at the end of every test by the test suite. CommandLine::ForCurrentProcess()->AppendSwitch( switches::kNewProfileManagement); - EXPECT_TRUE(profiles::IsNewProfileManagementEnabled()); + EXPECT_TRUE(switches::IsNewProfileManagement()); EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_SHOW_AVATAR_MENU)); } diff --git a/chrome/browser/ui/cocoa/browser/avatar_button_controller.mm b/chrome/browser/ui/cocoa/browser/avatar_button_controller.mm index 7fba944..9a0f49a 100644 --- a/chrome/browser/ui/cocoa/browser/avatar_button_controller.mm +++ b/chrome/browser/ui/cocoa/browser/avatar_button_controller.mm @@ -23,6 +23,7 @@ #import "chrome/browser/ui/cocoa/base_bubble_controller.h" #import "chrome/browser/ui/cocoa/browser/profile_chooser_controller.h" #import "chrome/browser/ui/cocoa/browser_window_controller.h" +#include "chrome/common/profile_management_switches.h" #include "content/public/browser/notification_service.h" #include "grit/generated_resources.h" #include "grit/theme_resources.h" @@ -224,7 +225,7 @@ class Observer : public content::NotificationObserver { point = [[anchor window] convertBaseToScreen:point]; // |menuController_| will automatically release itself on close. - if (profiles::IsNewProfileManagementEnabled()) { + if (switches::IsNewProfileManagement()) { menuController_ = [[ProfileChooserController alloc] initWithBrowser:browser_ anchoredAt:point]; diff --git a/chrome/browser/ui/startup/startup_browser_creator.cc b/chrome/browser/ui/startup/startup_browser_creator.cc index ea25e73..58799e9 100644 --- a/chrome/browser/ui/startup/startup_browser_creator.cc +++ b/chrome/browser/ui/startup/startup_browser_creator.cc @@ -59,6 +59,7 @@ #include "chrome/common/chrome_version_info.h" #include "chrome/common/net/url_fixer_upper.h" #include "chrome/common/pref_names.h" +#include "chrome/common/profile_management_switches.h" #include "chrome/common/url_constants.h" #include "chrome/installer/util/browser_distribution.h" #include "content/public/browser/browser_thread.h" @@ -675,7 +676,7 @@ bool StartupBrowserCreator::ProcessCmdLineImpl( // create a browser window for the corresponding original profile. if (last_opened_profiles.empty()) { // If the last used profile was a guest, show the user manager instead. - if (profiles::IsNewProfileManagementEnabled() && + if (switches::IsNewProfileManagement() && last_used_profile->IsGuestSession()) { chrome::ShowUserManager(base::FilePath()); return true; @@ -709,7 +710,7 @@ bool StartupBrowserCreator::ProcessCmdLineImpl( continue; // Don't re-open a browser window for the guest profile. - if (profiles::IsNewProfileManagementEnabled() && + if (switches::IsNewProfileManagement() && (*it)->IsGuestSession()) continue; @@ -725,7 +726,7 @@ bool StartupBrowserCreator::ProcessCmdLineImpl( // If the last used profile was the guest one, we didn't open it so // we don't need to activate it either. - if (!profiles::IsNewProfileManagementEnabled() && + if (!switches::IsNewProfileManagement() && !last_used_profile->IsGuestSession()) profile_launch_observer.Get().set_profile_to_activate(last_used_profile); } diff --git a/chrome/browser/ui/views/avatar_menu_bubble_view.cc b/chrome/browser/ui/views/avatar_menu_bubble_view.cc index 35dba8d..a8b1d3e 100644 --- a/chrome/browser/ui/views/avatar_menu_bubble_view.cc +++ b/chrome/browser/ui/views/avatar_menu_bubble_view.cc @@ -6,7 +6,6 @@ #include <algorithm> -#include "base/command_line.h" #include "base/strings/string16.h" #include "base/strings/utf_string_conversions.h" #include "chrome/app/chrome_command_ids.h" @@ -23,7 +22,7 @@ #include "chrome/browser/ui/browser_list.h" #include "chrome/browser/ui/browser_window.h" #include "chrome/browser/ui/chrome_pages.h" -#include "chrome/common/chrome_switches.h" +#include "chrome/common/profile_management_switches.h" #include "chrome/common/url_constants.h" #include "content/public/browser/page_navigator.h" #include "content/public/browser/web_contents.h" @@ -726,8 +725,7 @@ void AvatarMenuBubbleView::InitMenuContents( item_views_.push_back(item_view); } - if (CommandLine::ForCurrentProcess()->HasSwitch( - switches::kNewProfileManagement)) { + if (switches::IsNewProfileManagement()) { separator_ = new views::Separator(views::Separator::HORIZONTAL); AddChildView(separator_); buttons_view_ = new ActionButtonView(this, browser_->profile()); diff --git a/chrome/browser/ui/views/avatar_menu_button.cc b/chrome/browser/ui/views/avatar_menu_button.cc index 1bf83be..e9942f5 100644 --- a/chrome/browser/ui/views/avatar_menu_button.cc +++ b/chrome/browser/ui/views/avatar_menu_button.cc @@ -11,12 +11,12 @@ #include "chrome/browser/profiles/avatar_menu.h" #include "chrome/browser/profiles/profile_info_util.h" #include "chrome/browser/profiles/profile_metrics.h" -#include "chrome/browser/profiles/profiles_state.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/views/avatar_menu_bubble_view.h" #include "chrome/browser/ui/views/frame/browser_view.h" #include "chrome/browser/ui/views/profile_chooser_view.h" #include "chrome/common/pref_names.h" +#include "chrome/common/profile_management_switches.h" #include "content/public/browser/notification_service.h" #include "ui/gfx/canvas.h" #include "ui/views/widget/widget.h" @@ -105,7 +105,7 @@ void AvatarMenuButton::ShowAvatarBubble() { gfx::Rect bounds(origin, size()); views::BubbleBorder::Arrow arrow = button_on_right_ ? views::BubbleBorder::TOP_RIGHT : views::BubbleBorder::TOP_LEFT; - if (profiles::IsNewProfileManagementEnabled()) { + if (switches::IsNewProfileManagement()) { ProfileChooserView::ShowBubble( this, arrow, views::BubbleBorder::ALIGN_ARROW_TO_MID_ANCHOR, bounds, browser_); 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 bbc3345..24a7753 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 @@ -4,7 +4,6 @@ #include "chrome/browser/ui/views/frame/browser_non_client_frame_view.h" -#include "base/command_line.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/profiles/avatar_menu.h" #include "chrome/browser/profiles/profile.h" @@ -17,7 +16,7 @@ #include "chrome/browser/ui/views/frame/browser_view.h" #include "chrome/browser/ui/views/frame/taskbar_decorator.h" #include "chrome/browser/ui/views/new_avatar_button.h" -#include "chrome/common/chrome_switches.h" +#include "chrome/common/profile_management_switches.h" #include "grit/generated_resources.h" #include "grit/theme_resources.h" #include "third_party/skia/include/core/SkColor.h" @@ -47,7 +46,7 @@ void BrowserNonClientFrameView::VisibilityChanged(views::View* starting_from, // DrawTaskBarDecoration() has no effect. Therefore we need to call it again // once the window is visible. if (!browser_view_->IsRegularOrGuestSession() || - !profiles::IsNewProfileManagementEnabled()) + !switches::IsNewProfileManagement()) UpdateAvatarInfo(); } @@ -142,7 +141,7 @@ void BrowserNonClientFrameView::UpdateAvatarInfo() { void BrowserNonClientFrameView::UpdateNewStyleAvatarInfo( views::ButtonListener* listener, const NewAvatarButton::AvatarButtonStyle style) { - DCHECK(profiles::IsNewProfileManagementEnabled()); + DCHECK(switches::IsNewProfileManagement()); // This should never be called in incognito mode. DCHECK(browser_view_->IsRegularOrGuestSession()); diff --git a/chrome/browser/ui/views/frame/browser_view.cc b/chrome/browser/ui/views/frame/browser_view.cc index e856e99..05ce96f 100644 --- a/chrome/browser/ui/views/frame/browser_view.cc +++ b/chrome/browser/ui/views/frame/browser_view.cc @@ -91,6 +91,7 @@ #include "chrome/browser/ui/window_sizer/window_sizer.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/pref_names.h" +#include "chrome/common/profile_management_switches.h" #include "chrome/common/url_constants.h" #include "content/public/browser/download_manager.h" #include "content/public/browser/native_web_keyboard_event.h" @@ -2539,7 +2540,7 @@ void BrowserView::ShowAvatarBubble(WebContents* web_contents, } void BrowserView::ShowAvatarBubbleFromAvatarButton() { - if (profiles::IsNewProfileManagementEnabled()) { + if (switches::IsNewProfileManagement()) { NewAvatarButton* button = frame_->GetNewAvatarMenuButton(); if (button) { gfx::Point origin; 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 aa0dc2a..472dcad 100644 --- a/chrome/browser/ui/views/frame/glass_browser_frame_view.cc +++ b/chrome/browser/ui/views/frame/glass_browser_frame_view.cc @@ -4,14 +4,12 @@ #include "chrome/browser/ui/views/frame/glass_browser_frame_view.h" -#include "base/command_line.h" #include "base/prefs/pref_service.h" #include "base/strings/utf_string_conversions.h" #include "chrome/app/chrome_command_ids.h" #include "chrome/app/chrome_dll_resource.h" #include "chrome/browser/chrome_notification_types.h" #include "chrome/browser/profiles/profile.h" -#include "chrome/browser/profiles/profiles_state.h" #include "chrome/browser/themes/theme_properties.h" #include "chrome/browser/ui/views/avatar_menu_button.h" #include "chrome/browser/ui/views/frame/browser_view.h" @@ -19,8 +17,8 @@ #include "chrome/browser/ui/views/tabs/tab.h" #include "chrome/browser/ui/views/tabs/tab_strip.h" #include "chrome/browser/ui/views/toolbar/toolbar_view.h" -#include "chrome/common/chrome_switches.h" #include "chrome/common/pref_names.h" +#include "chrome/common/profile_management_switches.h" #include "content/public/browser/notification_service.h" #include "grit/generated_resources.h" #include "grit/theme_resources.h" @@ -90,7 +88,7 @@ GlassBrowserFrameView::GlassBrowserFrameView(BrowserFrame* frame, InitThrobberIcons(); if (browser_view->IsRegularOrGuestSession() && - profiles::IsNewProfileManagementEnabled()) + switches::IsNewProfileManagement()) UpdateNewStyleAvatarInfo(this, NewAvatarButton::NATIVE_BUTTON); else UpdateAvatarInfo(); @@ -115,7 +113,7 @@ gfx::Rect GlassBrowserFrameView::GetBoundsForTabStrip( // The new avatar button is optionally displayed to the left of the // minimize button. if (new_avatar_button()) { - DCHECK(profiles::IsNewProfileManagementEnabled()); + DCHECK(switches::IsNewProfileManagement()); minimize_button_offset -= new_avatar_button()->width(); } @@ -131,7 +129,7 @@ gfx::Rect GlassBrowserFrameView::GetBoundsForTabStrip( if (!browser_view()->ShouldShowAvatar() && frame()->IsMaximized()) tabstrip_x += avatar_bounds_.x(); else if (browser_view()->IsRegularOrGuestSession() && - profiles::IsNewProfileManagementEnabled()) + switches::IsNewProfileManagement()) tabstrip_x = width() - minimize_button_offset; minimize_button_offset = width(); @@ -266,7 +264,7 @@ void GlassBrowserFrameView::OnPaint(gfx::Canvas* canvas) { void GlassBrowserFrameView::Layout() { if (browser_view()->IsRegularOrGuestSession() && - profiles::IsNewProfileManagementEnabled()) + switches::IsNewProfileManagement()) LayoutNewStyleAvatar(); else LayoutAvatar(); @@ -440,7 +438,7 @@ void GlassBrowserFrameView::PaintRestoredClientEdge(gfx::Canvas* canvas) { } void GlassBrowserFrameView::LayoutNewStyleAvatar() { - DCHECK(profiles::IsNewProfileManagementEnabled()); + DCHECK(switches::IsNewProfileManagement()); if (!new_avatar_button()) return; @@ -564,7 +562,7 @@ void GlassBrowserFrameView::Observe( switch (type) { case chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED: if (browser_view()->IsRegularOrGuestSession() && - profiles::IsNewProfileManagementEnabled()) + switches::IsNewProfileManagement()) UpdateNewStyleAvatarInfo(this, NewAvatarButton::NATIVE_BUTTON); else UpdateAvatarInfo(); diff --git a/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc b/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc index 3813fac..21f5d84 100644 --- a/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc +++ b/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc @@ -7,7 +7,6 @@ #include <algorithm> #include <string> -#include "base/command_line.h" #include "base/compiler_specific.h" #include "base/prefs/pref_service.h" #include "base/strings/utf_string_conversions.h" @@ -24,8 +23,8 @@ #include "chrome/browser/ui/views/tab_icon_view.h" #include "chrome/browser/ui/views/tabs/tab_strip.h" #include "chrome/browser/ui/views/toolbar/toolbar_view.h" -#include "chrome/common/chrome_switches.h" #include "chrome/common/pref_names.h" +#include "chrome/common/profile_management_switches.h" #include "content/public/browser/notification_service.h" #include "content/public/browser/web_contents.h" #include "grit/chromium_strings.h" @@ -142,7 +141,7 @@ OpaqueBrowserFrameView::OpaqueBrowserFrameView(BrowserFrame* frame, AddChildView(window_title_); if (browser_view->IsRegularOrGuestSession() && - profiles::IsNewProfileManagementEnabled()) + switches::IsNewProfileManagement()) UpdateNewStyleAvatarInfo(this, NewAvatarButton::THEMED_BUTTON); else UpdateAvatarInfo(); @@ -396,7 +395,7 @@ void OpaqueBrowserFrameView::Observe( switch (type) { case chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED: if (browser_view() ->IsRegularOrGuestSession() && - profiles::IsNewProfileManagementEnabled()) + switches::IsNewProfileManagement()) UpdateNewStyleAvatarInfo(this, NewAvatarButton::THEMED_BUTTON); else UpdateAvatarInfo(); 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 146de72..95d90b6 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 @@ -6,6 +6,7 @@ #include "chrome/browser/profiles/profiles_state.h" #include "chrome/browser/ui/views/avatar_menu_button.h" +#include "chrome/common/profile_management_switches.h" #include "ui/gfx/font.h" #include "ui/views/controls/button/image_button.h" #include "ui/views/controls/label.h" @@ -371,7 +372,7 @@ void OpaqueBrowserFrameViewLayout::LayoutTitleBar(views::View* host) { } void OpaqueBrowserFrameViewLayout::LayoutNewStyleAvatar(views::View* host) { - DCHECK(profiles::IsNewProfileManagementEnabled()); + DCHECK(switches::IsNewProfileManagement()); if (!new_avatar_button_) return; @@ -654,7 +655,7 @@ void OpaqueBrowserFrameViewLayout::Layout(views::View* host) { leading_button_start_++; if (delegate_->IsRegularOrGuestSession() && - profiles::IsNewProfileManagementEnabled()) + switches::IsNewProfileManagement()) LayoutNewStyleAvatar(host); else LayoutAvatar(host); diff --git a/chrome/browser/ui/views/profile_chooser_view.cc b/chrome/browser/ui/views/profile_chooser_view.cc index 328b94a..6c308a1 100644 --- a/chrome/browser/ui/views/profile_chooser_view.cc +++ b/chrome/browser/ui/views/profile_chooser_view.cc @@ -4,7 +4,6 @@ #include "chrome/browser/ui/views/profile_chooser_view.h" -#include "base/command_line.h" #include "base/strings/utf_string_conversions.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/profiles/profile_info_util.h" @@ -20,7 +19,7 @@ #include "chrome/browser/ui/browser_dialogs.h" #include "chrome/browser/ui/singleton_tabs.h" #include "chrome/browser/ui/views/user_manager_view.h" -#include "chrome/common/chrome_switches.h" +#include "chrome/common/profile_management_switches.h" #include "chrome/common/url_constants.h" #include "grit/chromium_strings.h" #include "grit/generated_resources.h" @@ -570,8 +569,7 @@ void ProfileChooserView::LinkClicked(views::Link* sender, int event_flags) { profiles::LockProfile(browser_->profile()); } else { DCHECK(sender == signin_current_profile_link_); - if (CommandLine::ForCurrentProcess()->HasSwitch( - switches::kEnableInlineSignin)) { + if (switches::IsEnableInlineSignin()) { ShowView(GAIA_SIGNIN_VIEW, avatar_menu_.get()); } else { GURL page = signin::GetPromoURL(signin::SOURCE_MENU, false); 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 1d9f7ba..9ce190d 100644 --- a/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc +++ b/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc @@ -56,6 +56,7 @@ #include "chrome/common/chrome_switches.h" #include "chrome/common/extensions/extension_constants.h" #include "chrome/common/pref_names.h" +#include "chrome/common/profile_management_switches.h" #include "chrome/common/url_constants.h" #include "components/dom_distiller/core/dom_distiller_constants.h" #include "components/dom_distiller/core/dom_distiller_service.h" @@ -447,9 +448,9 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui, #if !defined(OS_CHROMEOS) && !defined(OS_ANDROID) && !defined(OS_IOS) if (url.host() == chrome::kChromeUIUserManagerHost && - CommandLine::ForCurrentProcess()->HasSwitch( - switches::kNewProfileManagement)) + switches::IsNewProfileManagement()) { return &NewWebUI<UserManagerUI>; + } #endif if (url.host() == chrome::kChromeUIChromeURLsHost || diff --git a/chrome/browser/ui/webui/inline_login_ui.cc b/chrome/browser/ui/webui/inline_login_ui.cc index 5a8d095..c7c25fd 100644 --- a/chrome/browser/ui/webui/inline_login_ui.cc +++ b/chrome/browser/ui/webui/inline_login_ui.cc @@ -27,7 +27,7 @@ #include "chrome/browser/ui/sync/one_click_signin_helper.h" #include "chrome/browser/ui/sync/one_click_signin_sync_starter.h" #include "chrome/browser/ui/tabs/tab_strip_model.h" -#include "chrome/common/chrome_switches.h" +#include "chrome/common/profile_management_switches.h" #include "chrome/common/url_constants.h" #include "content/public/browser/storage_partition.h" #include "content/public/browser/web_contents.h" @@ -137,8 +137,7 @@ class InlineLoginUIHandler : public GaiaAuthConsumer, GaiaUrls* gaiaUrls = GaiaUrls::GetInstance(); params.SetString("gaiaUrl", gaiaUrls->gaia_url().spec()); - bool enable_inline = CommandLine::ForCurrentProcess()->HasSwitch( - switches::kEnableInlineSignin); + bool enable_inline = switches::IsEnableInlineSignin(); params.SetInteger("authMode", enable_inline ? kInlineAuthMode : kDefaultAuthMode); diff --git a/chrome/chrome_common.gypi b/chrome/chrome_common.gypi index cb80a7a..c281167 100644 --- a/chrome/chrome_common.gypi +++ b/chrome/chrome_common.gypi @@ -258,6 +258,8 @@ 'common/favicon/favicon_types.h', 'common/favicon/favicon_url_parser.cc', 'common/favicon/favicon_url_parser.h', + 'common/profile_management_switches.cc', + 'common/profile_management_switches.h', 'common/icon_with_badge_image_source.cc', 'common/icon_with_badge_image_source.h', 'common/importer/firefox_importer_utils.cc', diff --git a/chrome/common/profile_management_switches.cc b/chrome/common/profile_management_switches.cc new file mode 100644 index 0000000..70dda70 --- /dev/null +++ b/chrome/common/profile_management_switches.cc @@ -0,0 +1,27 @@ +// 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. + +#include "chrome/common/profile_management_switches.h" + +#include "base/command_line.h" +#include "chrome/common/chrome_switches.h" + +namespace switches { + +bool IsEnableInlineSignin() { + return CommandLine::ForCurrentProcess()->HasSwitch( + switches::kEnableInlineSignin); +} + +bool IsGoogleProfileInfo() { + return CommandLine::ForCurrentProcess()->HasSwitch( + switches::kGoogleProfileInfo); +} + +bool IsNewProfileManagement() { + return CommandLine::ForCurrentProcess()->HasSwitch( + switches::kNewProfileManagement); +} + +} // namespace switches diff --git a/chrome/common/profile_management_switches.h b/chrome/common/profile_management_switches.h new file mode 100644 index 0000000..f035419 --- /dev/null +++ b/chrome/common/profile_management_switches.h @@ -0,0 +1,26 @@ +// 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. + +// These are functions to access various profile-management flags but with +// possible overrides from Experiements. This is done inside chrome/common +// because it is accessed by files through the chrome/ directory tree. + +#ifndef CHROME_COMMON_PROFILE_MANAGEMENT_SWITCHES_H_ +#define CHROME_COMMON_PROFILE_MANAGEMENT_SWITCHES_H_ + +namespace switches { + +// Enables the inline sign in flow on Chrome desktop. +bool IsEnableInlineSignin(); + +// Enables using GAIA information to populate profile name and icon. +bool IsGoogleProfileInfo(); + +// Use new profile management system, including profile sign-out and new +// choosers. +bool IsNewProfileManagement(); + +} // namespace switches + +#endif // CHROME_COMMON_PROFILE_MANAGEMENT_SWITCHES_H_ diff --git a/chrome/renderer/chrome_content_renderer_client.cc b/chrome/renderer/chrome_content_renderer_client.cc index e385327..9568c40 100644 --- a/chrome/renderer/chrome_content_renderer_client.cc +++ b/chrome/renderer/chrome_content_renderer_client.cc @@ -23,6 +23,7 @@ #include "chrome/common/extensions/extension_process_policy.h" #include "chrome/common/localized_error.h" #include "chrome/common/pepper_permission_util.h" +#include "chrome/common/profile_management_switches.h" #include "chrome/common/render_messages.h" #include "chrome/common/url_constants.h" #include "chrome/renderer/benchmarking_extension.h" @@ -286,7 +287,7 @@ void ChromeContentRendererClient::RenderThreadStarted() { // TODO(guohui): needs to forward the new-profile-management switch to // renderer processes. - if (command_line->HasSwitch(switches::kNewProfileManagement)) + if (switches::IsNewProfileManagement()) thread->RegisterExtension(extensions_v8::PrincipalsExtension::Get()); // chrome:, chrome-search:, and chrome-devtools: pages should not be |