diff options
author | mirandac@chromium.org <mirandac@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-05 21:16:00 +0000 |
---|---|---|
committer | mirandac@chromium.org <mirandac@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-05 21:16:00 +0000 |
commit | 77b6731e1d204a260b64d4c09c827bd2d600154e (patch) | |
tree | f99ed43c9b3b7f3f85ebc3a67c127d0e1de429e4 | |
parent | 38316e10b63cd29621d6071b9eba957f329b1203 (diff) | |
download | chromium_src-77b6731e1d204a260b64d4c09c827bd2d600154e.zip chromium_src-77b6731e1d204a260b64d4c09c827bd2d600154e.tar.gz chromium_src-77b6731e1d204a260b64d4c09c827bd2d600154e.tar.bz2 |
Change determination of when to show the first run search engine selection dialog based on brand codes.
Also, remove crufty old FirstRun::InSearchExperimentLocale.
BUG=none
TEST=new google_update_settings_unittest, and search engine selection shows only for brand codes beginning with EU or GG.
Review URL: http://codereview.chromium.org/6677134
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@80527 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/browser_main.cc | 6 | ||||
-rw-r--r-- | chrome/browser/first_run/first_run.cc | 18 | ||||
-rw-r--r-- | chrome/browser/first_run/first_run.h | 11 | ||||
-rw-r--r-- | chrome/browser/first_run/first_run_gtk.cc | 2 | ||||
-rw-r--r-- | chrome/browser/first_run/first_run_mac.mm | 2 | ||||
-rw-r--r-- | chrome/browser/first_run/first_run_win.cc | 17 | ||||
-rw-r--r-- | chrome/browser/google/google_update_settings_unittest.cc | 19 | ||||
-rw-r--r-- | chrome/installer/util/google_update_settings.cc | 15 | ||||
-rw-r--r-- | chrome/installer/util/google_update_settings.h | 7 |
9 files changed, 54 insertions, 43 deletions
diff --git a/chrome/browser/browser_main.cc b/chrome/browser/browser_main.cc index bff2d12..f1ac8e6 100644 --- a/chrome/browser/browser_main.cc +++ b/chrome/browser/browser_main.cc @@ -779,8 +779,10 @@ MetricsService* InitializeMetrics(const CommandLine& parsed_command_line, // should not continue. Profile* CreateProfile(const MainFunctionParams& parameters, const FilePath& user_data_dir) { - Profile* profile = g_browser_process->profile_manager()->GetDefaultProfile( + Profile* profile = g_browser_process->profile_manager()->GetLastUsedProfile( user_data_dir); +// Profile* profile = g_browser_process->profile_manager()->GetDefaultProfile( +// user_data_dir); if (profile) return profile; @@ -1817,7 +1819,7 @@ int BrowserMain(const MainFunctionParams& parameters) { // shutdown because otherwise we can't be sure the user has finished // selecting a search engine through the dialog reached from the first run // bubble link. - if (FirstRun::InSearchExperimentLocale() && record_search_engine) { + if (record_search_engine) { const TemplateURL* default_search_engine = profile->GetTemplateURLModel()->GetDefaultSearchProvider(); // The default engine can be NULL if the administrator has disabled diff --git a/chrome/browser/first_run/first_run.cc b/chrome/browser/first_run/first_run.cc index b015b95..dbbf3fe 100644 --- a/chrome/browser/first_run/first_run.cc +++ b/chrome/browser/first_run/first_run.cc @@ -264,11 +264,7 @@ bool FirstRun::ProcessMasterPreferences(const FilePath& user_data_dir, &import_bookmarks_path); #if defined(OS_WIN) - std::wstring brand; - GoogleUpdateSettings::GetBrand(&brand); - // This should generally be true, as skip_first_run_ui is a setting used for - // non-organic builds. - if (!GoogleUpdateSettings::IsOrganic(brand)) { + if (!IsOrganicFirstRun()) { // If search engines aren't explicitly imported, don't import. if (!(out_prefs->do_import_items & importer::SEARCH_ENGINES)) { out_prefs->dont_import_items |= importer::SEARCH_ENGINES; @@ -536,17 +532,17 @@ void FirstRun::AutoImport( items = items | importer::HISTORY; // Home page is imported in organic builds only unless turned off or // defined in master_preferences. - if (IsOrganic()) { + if (IsOrganicFirstRun()) { if (!(dont_import_items & importer::HOME_PAGE) && !homepage_defined) items = items | importer::HOME_PAGE; } else { if (import_items & importer::HOME_PAGE) items = items | importer::HOME_PAGE; } - // Search engines are only imported in organic builds unless overridden + // Search engines are only imported in certain builds unless overridden // in master_preferences. Search engines are not imported automatically // if the user already has a user preferences directory. - if (IsOrganic()) { + if (IsOrganicFirstRun()) { if (!(dont_import_items & importer::SEARCH_ENGINES) && !local_state_file_exists) { items = items | importer::SEARCH_ENGINES; @@ -564,9 +560,9 @@ void FirstRun::AutoImport( UserMetrics::RecordAction(UserMetricsAction("FirstRunDef_Accept")); - // Launch the search engine dialog only if build is organic, and user has not - // already set preferences. - if (IsOrganic() && !local_state_file_exists) { + // Launch the search engine dialog only for certain builds, and only if the + // user has not already set preferences. + if (IsOrganicFirstRun() && !local_state_file_exists) { // The home page string may be set in the preferences, but the user should // initially use Chrome with the NTP as home page in organic builds. profile->GetPrefs()->SetBoolean(prefs::kHomePageIsNewTabPage, true); diff --git a/chrome/browser/first_run/first_run.h b/chrome/browser/first_run/first_run.h index 4868f6b..d41c9be 100644 --- a/chrome/browser/first_run/first_run.h +++ b/chrome/browser/first_run/first_run.h @@ -64,9 +64,6 @@ class FirstRun { // Creates the quick launch shortcut to chrome for the current user. Returns // false if it fails. It will overwrite the shortcut if it exists. static bool CreateChromeQuickLaunchShortcut(); - // Returns true if we are being run in a locale in which search experiments - // are allowed. - static bool InSearchExperimentLocale(); #endif // OS_WIN // Import bookmarks and/or browser items (depending on platform support) // in this process. This function is paired with FirstRun::ImportSettings(). @@ -75,7 +72,7 @@ class FirstRun { static int ImportNow(Profile* profile, const CommandLine& cmdline); // Automatically import history and home page (and search engine, if - // nonorganic). + // ShouldShowSearchEngineDialog is true). static void AutoImport( Profile* profile, bool homepage_defined, @@ -89,11 +86,11 @@ class FirstRun { // Does platform specific setup. Called at the start of AutoImport. static void PlatformSetup(); - // Returns whether the current install is "organic". - static bool IsOrganic(); + // Returns whether the first run should be "organic". + static bool IsOrganicFirstRun(); // Shows the search engine choice dialog, and any other platform dialogs. - // Only called in "organic" installs. + // Only called if IsOrganicFirstRun is true. static void ShowFirstRunDialog(Profile* profile, bool randomize_search_engine_experiment); diff --git a/chrome/browser/first_run/first_run_gtk.cc b/chrome/browser/first_run/first_run_gtk.cc index 913444c..b039f43 100644 --- a/chrome/browser/first_run/first_run_gtk.cc +++ b/chrome/browser/first_run/first_run_gtk.cc @@ -89,7 +89,7 @@ void FirstRun::ShowFirstRunDialog(Profile* profile, } // static -bool FirstRun::IsOrganic() { +bool FirstRun::IsOrganicFirstRun() { // We treat all installs as organic. return true; } diff --git a/chrome/browser/first_run/first_run_mac.mm b/chrome/browser/first_run/first_run_mac.mm index fd6e7d6..0150f52 100644 --- a/chrome/browser/first_run/first_run_mac.mm +++ b/chrome/browser/first_run/first_run_mac.mm @@ -103,7 +103,7 @@ bool FirstRun::ImportBookmarks(const FilePath& import_bookmarks_path) { } // static -bool FirstRun::IsOrganic() { +bool FirstRun::IsOrganicFirstRun() { // We treat all installs as organic. return true; } diff --git a/chrome/browser/first_run/first_run_win.cc b/chrome/browser/first_run/first_run_win.cc index e4648b4..f72464e 100644 --- a/chrome/browser/first_run/first_run_win.cc +++ b/chrome/browser/first_run/first_run_win.cc @@ -411,10 +411,10 @@ void FirstRun::PlatformSetup() { } // static -bool FirstRun::IsOrganic() { +bool FirstRun::IsOrganicFirstRun() { std::wstring brand; GoogleUpdateSettings::GetBrand(&brand); - return GoogleUpdateSettings::IsOrganic(brand); + return GoogleUpdateSettings::IsOrganicFirstRun(brand); } // static @@ -542,19 +542,6 @@ int FirstRun::ImportFromBrowser(Profile* profile, return importer_observer.import_result(); } -// static -bool FirstRun::InSearchExperimentLocale() { - static std::set<std::string> allowed_locales; - if (allowed_locales.empty()) { - // List of locales in which search experiment can be run. - allowed_locales.insert("en-GB"); - allowed_locales.insert("en-US"); - } - const std::string app_locale = g_browser_process->GetApplicationLocale(); - std::set<std::string>::iterator locale = allowed_locales.find(app_locale); - return locale != allowed_locales.end(); -} - ////////////////////////////////////////////////////////////////////////// namespace { diff --git a/chrome/browser/google/google_update_settings_unittest.cc b/chrome/browser/google/google_update_settings_unittest.cc index 13a7e33..0f6564e 100644 --- a/chrome/browser/google/google_update_settings_unittest.cc +++ b/chrome/browser/google/google_update_settings_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -32,4 +32,21 @@ TEST_F(GoogleUpdateTest, LastRunTime) { EXPECT_EQ(0, GoogleUpdateSettings::GetLastRunTime()); } +TEST_F(GoogleUpdateTest, ShouldShowSearchEngineDialog) { + // Test some brand codes to ensure that future changes to this method won't + // go unnoticed. + const wchar_t* false_brand1 = L"CHFO"; + EXPECT_FALSE(GoogleUpdateSettings::IsOrganicFirstRun( + false_brand1)); + const wchar_t* false_brand2 = L"CHMA"; + EXPECT_FALSE(GoogleUpdateSettings::IsOrganicFirstRun( + false_brand2)); + const wchar_t* good_brand1 = L"EUBA"; + EXPECT_TRUE(GoogleUpdateSettings::IsOrganicFirstRun( + good_brand1)); + const wchar_t* good_brand2 = L"GGRA"; + EXPECT_TRUE(GoogleUpdateSettings::IsOrganicFirstRun( + good_brand2)); +} + #endif // defined(OS_WIN) diff --git a/chrome/installer/util/google_update_settings.cc b/chrome/installer/util/google_update_settings.cc index 598a3e3..49d80ec 100644 --- a/chrome/installer/util/google_update_settings.cc +++ b/chrome/installer/util/google_update_settings.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -370,8 +370,15 @@ bool GoogleUpdateSettings::IsOrganic(const std::wstring& brand) { const wchar_t** found = std::find(&kBrands[0], end, brand); if (found != end) return true; - if (StartsWith(brand, L"EUB", true) || StartsWith(brand, L"EUC", true) || - StartsWith(brand, L"GGR", true)) + return (StartsWith(brand, L"EUB", true) || StartsWith(brand, L"EUC", true) || + StartsWith(brand, L"GGR", true)); +} + +bool GoogleUpdateSettings::IsOrganicFirstRun(const std::wstring& brand) { + // Used for testing, to force search engine selector to appear. + const CommandLine& command_line = *CommandLine::ForCurrentProcess(); + if (command_line.HasSwitch(switches::kOrganicInstall)) return true; - return false; + + return (StartsWith(brand, L"GG", true) || StartsWith(brand, L"EU", true)); } diff --git a/chrome/installer/util/google_update_settings.h b/chrome/installer/util/google_update_settings.h index da531b2..002a532 100644 --- a/chrome/installer/util/google_update_settings.h +++ b/chrome/installer/util/google_update_settings.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -145,6 +145,11 @@ class GoogleUpdateSettings { // True if a build is strictly organic, according to its brand code. static bool IsOrganic(const std::wstring& brand); + // True if a build should run as organic in the first run process. This uses + // a slightly different set of brand codes from the standard IsOrganic + // method. + static bool IsOrganicFirstRun(const std::wstring& brand); + private: DISALLOW_IMPLICIT_CONSTRUCTORS(GoogleUpdateSettings); }; |