diff options
-rw-r--r-- | chrome/browser/chrome_browser_main.cc | 9 | ||||
-rw-r--r-- | chrome/browser/first_run/first_run.cc | 16 | ||||
-rw-r--r-- | chrome/browser/first_run/first_run_aura.cc | 7 | ||||
-rw-r--r-- | chrome/browser/first_run/first_run_gtk.cc | 6 | ||||
-rw-r--r-- | chrome/browser/first_run/first_run_mac.mm | 9 | ||||
-rw-r--r-- | chrome/browser/first_run/first_run_win.cc | 9 | ||||
-rw-r--r-- | chrome/browser/google/google_update_settings_unittest.cc | 25 | ||||
-rw-r--r-- | chrome/browser/google/google_util.cc | 84 | ||||
-rw-r--r-- | chrome/browser/google/google_util.h | 17 | ||||
-rw-r--r-- | chrome/browser/rlz/rlz.cc | 77 | ||||
-rw-r--r-- | chrome/browser/rlz/rlz.h | 14 | ||||
-rw-r--r-- | chrome/browser/rlz/rlz_unittest.cc | 21 | ||||
-rw-r--r-- | chrome/installer/util/google_update_settings.cc | 29 | ||||
-rw-r--r-- | chrome/installer/util/google_update_settings.h | 15 |
14 files changed, 190 insertions, 148 deletions
diff --git a/chrome/browser/chrome_browser_main.cc b/chrome/browser/chrome_browser_main.cc index 92e6d4c..ac565f3 100644 --- a/chrome/browser/chrome_browser_main.cc +++ b/chrome/browser/chrome_browser_main.cc @@ -41,6 +41,7 @@ #include "chrome/browser/first_run/first_run_browser_process.h" #include "chrome/browser/first_run/upgrade_util.h" #include "chrome/browser/google/google_url_tracker.h" +#include "chrome/browser/google/google_util.h" #include "chrome/browser/instant/instant_field_trial.h" #include "chrome/browser/jankometer.h" #include "chrome/browser/language_usage_metrics.h" @@ -1072,14 +1073,8 @@ void ChromeBrowserMainParts::PredictorFieldTrial() { } void ChromeBrowserMainParts::DefaultAppsFieldTrial() { -#if defined(OS_WIN) - string16 brand; - GoogleUpdateSettings::GetBrand(&brand); -#elif defined(OS_MACOSX) - std::string brand = keystone_glue::BrandCode(); -#else std::string brand; -#endif + google_util::GetBrand(&brand); // Create a 100% field trial based on the brand code. if (LowerCaseEqualsASCII(brand, "ecdb")) { diff --git a/chrome/browser/first_run/first_run.cc b/chrome/browser/first_run/first_run.cc index 3cc08bda..230aa69 100644 --- a/chrome/browser/first_run/first_run.cc +++ b/chrome/browser/first_run/first_run.cc @@ -13,6 +13,7 @@ #include "chrome/browser/browser_process.h" #include "chrome/browser/first_run/first_run_dialog.h" #include "chrome/browser/first_run/first_run_import_observer.h" +#include "chrome/browser/google/google_util.h" #include "chrome/browser/importer/external_process_importer_host.h" #include "chrome/browser/importer/importer_host.h" #include "chrome/browser/importer/importer_list.h" @@ -662,6 +663,21 @@ void FirstRun::AutoImport( FirstRun::CreateSentinel(); } +#if defined(OS_LINUX) +// static +bool FirstRun::IsOrganicFirstRun() { + // We treat all installs as organic. + return true; +} +#else +// static +bool FirstRun::IsOrganicFirstRun() { + std::string brand; + google_util::GetBrand(&brand); + return google_util::IsOrganicFirstRun(brand); +} +#endif // OS_LINUX + #if defined(OS_POSIX) namespace { diff --git a/chrome/browser/first_run/first_run_aura.cc b/chrome/browser/first_run/first_run_aura.cc index f6ace0d..4709710 100644 --- a/chrome/browser/first_run/first_run_aura.cc +++ b/chrome/browser/first_run/first_run_aura.cc @@ -83,13 +83,6 @@ void FirstRun::PlatformSetup() { } // static -bool FirstRun::IsOrganicFirstRun() { - // TODO(beng): - NOTIMPLEMENTED(); - return true; -} - -// static FilePath FirstRun::MasterPrefsPath() { // TODO(beng): NOTIMPLEMENTED(); diff --git a/chrome/browser/first_run/first_run_gtk.cc b/chrome/browser/first_run/first_run_gtk.cc index d970d21..f866d0b 100644 --- a/chrome/browser/first_run/first_run_gtk.cc +++ b/chrome/browser/first_run/first_run_gtk.cc @@ -48,12 +48,6 @@ bool FirstRun::ImportBookmarks(const FilePath& import_bookmarks_path) { } // static -bool FirstRun::IsOrganicFirstRun() { - // We treat all installs as organic. - return true; -} - -// static void FirstRun::PlatformSetup() { // Things that Windows does here (creating a desktop icon, for example) are // handled at install time on Linux. diff --git a/chrome/browser/first_run/first_run_mac.mm b/chrome/browser/first_run/first_run_mac.mm index 7ddea47..2d9fe08 100644 --- a/chrome/browser/first_run/first_run_mac.mm +++ b/chrome/browser/first_run/first_run_mac.mm @@ -6,7 +6,6 @@ #include "base/file_path.h" #include "base/string_util.h" -#include "chrome/browser/mac/keystone_glue.h" #include "chrome/browser/mac/master_prefs.h" bool FirstRun::ImportBookmarks(const FilePath& import_bookmarks_path) { @@ -15,14 +14,6 @@ bool FirstRun::ImportBookmarks(const FilePath& import_bookmarks_path) { } // static -bool FirstRun::IsOrganicFirstRun() { - std::string brand = keystone_glue::BrandCode(); - return brand.empty() || - StartsWithASCII(brand, "GG", true) || - StartsWithASCII(brand, "EU", true); -} - -// static void FirstRun::PlatformSetup() { // Things that Windows does here (creating a desktop icon, for example) are // not needed. diff --git a/chrome/browser/first_run/first_run_win.cc b/chrome/browser/first_run/first_run_win.cc index 867d02c..3b05e48 100644 --- a/chrome/browser/first_run/first_run_win.cc +++ b/chrome/browser/first_run/first_run_win.cc @@ -32,8 +32,6 @@ #include "chrome/common/chrome_switches.h" #include "chrome/common/worker_thread_ticker.h" #include "chrome/installer/util/browser_distribution.h" -#include "chrome/installer/util/google_update_constants.h" -#include "chrome/installer/util/google_update_settings.h" #include "chrome/installer/util/install_util.h" #include "chrome/installer/util/master_preferences.h" #include "chrome/installer/util/shell_util.h" @@ -302,13 +300,6 @@ void FirstRun::PlatformSetup() { } // static -bool FirstRun::IsOrganicFirstRun() { - std::wstring brand; - GoogleUpdateSettings::GetBrand(&brand); - return GoogleUpdateSettings::IsOrganicFirstRun(brand); -} - -// static FilePath FirstRun::MasterPrefsPath() { // The standard location of the master prefs is next to the chrome binary. FilePath master_prefs; diff --git a/chrome/browser/google/google_update_settings_unittest.cc b/chrome/browser/google/google_update_settings_unittest.cc index 0f6564e..060ae77 100644 --- a/chrome/browser/google/google_update_settings_unittest.cc +++ b/chrome/browser/google/google_update_settings_unittest.cc @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "chrome/browser/google/google_util.h" #include "chrome/installer/util/google_update_settings.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/platform_test.h" @@ -32,21 +33,17 @@ TEST_F(GoogleUpdateTest, LastRunTime) { EXPECT_EQ(0, GoogleUpdateSettings::GetLastRunTime()); } +#endif // defined(OS_WIN) + 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)); + const char* false_brand1 = "CHFO"; + EXPECT_FALSE(google_util::IsOrganicFirstRun(false_brand1)); + const char* false_brand2 = "CHMA"; + EXPECT_FALSE(google_util::IsOrganicFirstRun(false_brand2)); + const char* good_brand1 = "EUBA"; + EXPECT_TRUE(google_util::IsOrganicFirstRun(good_brand1)); + const char* good_brand2 = "GGRA"; + EXPECT_TRUE(google_util::IsOrganicFirstRun(good_brand2)); } - -#endif // defined(OS_WIN) diff --git a/chrome/browser/google/google_util.cc b/chrome/browser/google/google_util.cc index eb2f5cc..7eb1b35 100644 --- a/chrome/browser/google/google_util.cc +++ b/chrome/browser/google/google_util.cc @@ -6,12 +6,21 @@ #include <string> +#include "base/command_line.h" +#include "base/string16.h" #include "base/string_util.h" +#include "base/utf_string_conversions.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/google/google_url_tracker.h" +#include "chrome/common/chrome_switches.h" +#include "chrome/installer/util/google_update_settings.h" #include "googleurl/src/gurl.h" #include "net/base/registry_controlled_domain.h" +#if defined(OS_MACOSX) +#include "chrome/browser/mac/keystone_glue.h" +#endif + namespace { // A helper method for adding a query param to |url|. @@ -62,4 +71,79 @@ GURL AppendGoogleTLDParam(const GURL& url) { return AppendParam(url, "sd", google_domain.substr(first_dot + 1)); } +#if defined(OS_WIN) + +bool GetBrand(std::string* brand) { + string16 brand16; + bool ret = GoogleUpdateSettings::GetBrand(&brand16); + if (ret) + brand->assign(WideToASCII(brand16)); + return ret; +} + +bool GetReactivationBrand(std::string* brand) { + string16 brand16; + bool ret = GoogleUpdateSettings::GetReactivationBrand(&brand16); + if (ret) + brand->assign(WideToASCII(brand16)); + return ret; +} + +#elif defined(OS_MACOSX) + +bool GetBrand(std::string* brand) { + brand->assign(keystone_glue::BrandCode()); + return true; +} + +bool GetReactivationBrand(std::string* brand) { + brand->clear(); + return true; +} + +#else + +bool GetBrand(std::string* brand) { + brand->clear(); + return true; +} + +bool GetReactivationBrand(std::string* brand) { + brand->clear(); + return true; +} + +#endif + +bool IsOrganic(const std::string& brand) { + const CommandLine& command_line = *CommandLine::ForCurrentProcess(); + if (command_line.HasSwitch(switches::kOrganicInstall)) + return true; + + static const char* kBrands[] = { + "CHFO", "CHFT", "CHHS", "CHHM", "CHMA", "CHMB", "CHME", "CHMF", + "CHMG", "CHMH", "CHMI", "CHMQ", "CHMV", "CHNB", "CHNC", "CHNG", + "CHNH", "CHNI", "CHOA", "CHOB", "CHOC", "CHON", "CHOO", "CHOP", + "CHOQ", "CHOR", "CHOS", "CHOT", "CHOU", "CHOX", "CHOY", "CHOZ", + "CHPD", "CHPE", "CHPF", "CHPG", "EUBB", "EUBC", "GGLA", "GGLS" + }; + const char** end = &kBrands[arraysize(kBrands)]; + const char** found = std::find(&kBrands[0], end, brand); + if (found != end) + return true; + return (StartsWithASCII(brand, "EUB", true) || + StartsWithASCII(brand, "EUC", true) || + StartsWithASCII(brand, "GGR", true)); +} + +bool IsOrganicFirstRun(const std::string& 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 (StartsWithASCII(brand, "GG", true) || + StartsWithASCII(brand, "EU", true)); +} + } // namespace google_util diff --git a/chrome/browser/google/google_util.h b/chrome/browser/google/google_util.h index bbc7a15..daa4048 100644 --- a/chrome/browser/google/google_util.h +++ b/chrome/browser/google/google_util.h @@ -27,6 +27,23 @@ std::string StringAppendGoogleLocaleParam(const std::string& url); // check to see if the param already exists. GURL AppendGoogleTLDParam(const GURL& url); +// Returns in |brand| the brand code or distribution tag that has been +// assigned to a partner. Returns false if the information is not available. +bool GetBrand(std::string* brand); + +// Returns in |brand| the reactivation brand code or distribution tag +// that has been assigned to a partner for reactivating a dormant chrome +// install. Returns false if the information is not available. +bool GetReactivationBrand(std::string* brand); + +// True if a build is strictly organic, according to its brand code. +bool IsOrganic(const std::string& brand); + +// True if a build should run as organic during first run. This uses +// a slightly different set of brand codes from the standard IsOrganic +// method. +bool IsOrganicFirstRun(const std::string& brand); + } // namespace google_util #endif // CHROME_BROWSER_GOOGLE_GOOGLE_UTIL_H__ diff --git a/chrome/browser/rlz/rlz.cc b/chrome/browser/rlz/rlz.cc index 52c9db4..9c59f64 100644 --- a/chrome/browser/rlz/rlz.cc +++ b/chrome/browser/rlz/rlz.cc @@ -23,6 +23,7 @@ #include "base/threading/thread_restrictions.h" #include "base/utf_string_conversions.h" #include "chrome/browser/browser_process.h" +#include "chrome/browser/google/google_util.h" #include "chrome/browser/search_engines/template_url.h" #include "chrome/browser/search_engines/template_url_service.h" #include "chrome/browser/search_engines/template_url_service_factory.h" @@ -36,11 +37,6 @@ namespace { -// Organic brands all start with GG, such as GGCM. -static bool is_organic(const std::wstring& brand) { - return (brand.size() < 2) ? false : (brand.substr(0, 2) == L"GG"); -} - void RecordProductEvents(bool first_run, bool google_default_search, bool google_default_homepage, bool already_ran, bool omnibox_used, bool homepage_used) { @@ -99,14 +95,12 @@ void RecordProductEvents(bool first_run, bool google_default_search, } } -bool SendFinancialPing(const std::wstring& brand, - const std::wstring& lang, - const std::wstring& referral, - bool exclude_id) { +bool SendFinancialPing(const std::string& brand, + const string16& lang, + const string16& referral) { rlz_lib::AccessPoint points[] = {rlz_lib::CHROME_OMNIBOX, rlz_lib::CHROME_HOME_PAGE, rlz_lib::NO_ACCESS_POINT}; - std::string brand_ascii(WideToASCII(brand)); std::string lang_ascii(WideToASCII(lang)); std::string referral_ascii(WideToASCII(referral)); @@ -114,19 +108,19 @@ bool SendFinancialPing(const std::wstring& brand, // We ignore the return value of SendFinancialPing() since we'll try again // later anyway. Callers of this function are only interested in whether // the ping for the main brand succeeded or not. - std::wstring reactivation_brand; - if (GoogleUpdateSettings::GetReactivationBrand(&reactivation_brand)) { - std::string reactivation_brand_ascii(WideToASCII(reactivation_brand)); - rlz_lib::SupplementaryBranding branding(reactivation_brand.c_str()); + std::string reactivation_brand; + if (google_util::GetReactivationBrand(&reactivation_brand)) { + string16 reactivation_brand16 = UTF8ToUTF16(reactivation_brand); + rlz_lib::SupplementaryBranding branding(reactivation_brand16.c_str()); rlz_lib::SendFinancialPing(rlz_lib::CHROME, points, "chrome", - reactivation_brand_ascii.c_str(), + reactivation_brand.c_str(), referral_ascii.c_str(), lang_ascii.c_str(), - exclude_id, NULL, true); + false, NULL, true); } return rlz_lib::SendFinancialPing(rlz_lib::CHROME, points, "chrome", - brand_ascii.c_str(), referral_ascii.c_str(), - lang_ascii.c_str(), exclude_id, NULL, true); + brand.c_str(), referral_ascii.c_str(), + lang_ascii.c_str(), false, NULL, true); } } // namespace @@ -212,9 +206,9 @@ void RLZTracker::ScheduleDelayedInit(int delay) { void RLZTracker::DelayedInit() { // For organic brandcodes do not use rlz at all. Empty brandcode usually // means a chromium install. This is ok. - std::wstring brand; - if (!GoogleUpdateSettings::GetBrand(&brand) || brand.empty() || - GoogleUpdateSettings::IsOrganic(brand)) + std::string brand; + if (!google_util::GetBrand(&brand) || brand.empty() || + google_util::IsOrganic(brand)) return; RecordProductEvents(first_run_, google_default_search_, @@ -223,9 +217,10 @@ void RLZTracker::DelayedInit() { // If chrome has been reactivated, record the events for this brand // as well. - std::wstring reactivation_brand; - if (GoogleUpdateSettings::GetReactivationBrand(&reactivation_brand)) { - rlz_lib::SupplementaryBranding branding(reactivation_brand.c_str()); + std::string reactivation_brand; + if (google_util::GetReactivationBrand(&reactivation_brand)) { + string16 reactivation_brand16 = UTF8ToUTF16(reactivation_brand); + rlz_lib::SupplementaryBranding branding(reactivation_brand16.c_str()); RecordProductEvents(first_run_, google_default_search_, google_default_homepage_, already_ran_, omnibox_used_, homepage_used_); @@ -250,15 +245,15 @@ void RLZTracker::PingNowImpl() { // This is the entry point of a background thread, so I/O is allowed. base::ThreadRestrictions::ScopedAllowIO allow_io; - std::wstring lang; + string16 lang; GoogleUpdateSettings::GetLanguage(&lang); if (lang.empty()) lang = L"en"; - std::wstring brand; - GoogleUpdateSettings::GetBrand(&brand); - std::wstring referral; + std::string brand; + google_util::GetBrand(&brand); + string16 referral; GoogleUpdateSettings::GetReferral(&referral); - if (SendFinancialPing(brand, lang, referral, is_organic(brand))) { + if (SendFinancialPing(brand, lang, referral)) { GoogleUpdateSettings::ClearReferral(); { @@ -272,11 +267,10 @@ void RLZTracker::PingNowImpl() { } } -bool RLZTracker::SendFinancialPing(const std::wstring& brand, - const std::wstring& lang, - const std::wstring& referral, - bool exclude_id) { - return ::SendFinancialPing(brand, lang, referral, exclude_id); +bool RLZTracker::SendFinancialPing(const std::string& brand, + const string16& lang, + const string16& referral) { + return ::SendFinancialPing(brand, lang, referral); } void RLZTracker::Observe(int type, @@ -336,9 +330,10 @@ bool RLZTracker::RecordProductEvent(rlz_lib::Product product, bool ret = rlz_lib::RecordProductEvent(product, point, event_id); // If chrome has been reactivated, record the event for this brand as well. - std::wstring reactivation_brand; - if (GoogleUpdateSettings::GetReactivationBrand(&reactivation_brand)) { - rlz_lib::SupplementaryBranding branding(reactivation_brand.c_str()); + std::string reactivation_brand; + if (google_util::GetReactivationBrand(&reactivation_brand)) { + string16 reactivation_brand16 = UTF8ToUTF16(reactivation_brand); + rlz_lib::SupplementaryBranding branding(reactivation_brand16.c_str()); ret &= rlz_lib::RecordProductEvent(product, point, event_id); } @@ -348,14 +343,14 @@ bool RLZTracker::RecordProductEvent(rlz_lib::Product product, // GetAccessPointRlz() caches RLZ strings for all access points. If we had // a successful ping, then we update the cached value. bool RLZTracker::GetAccessPointRlz(rlz_lib::AccessPoint point, - std::wstring* rlz) { + string16* rlz) { return GetInstance()->GetAccessPointRlzImpl(point, rlz); } // GetAccessPointRlz() caches RLZ strings for all access points. If we had // a successful ping, then we update the cached value. bool RLZTracker::GetAccessPointRlzImpl(rlz_lib::AccessPoint point, - std::wstring* rlz) { + string16* rlz) { // If the RLZ string for the specified access point is already cached, // simply return its value. { @@ -376,7 +371,7 @@ bool RLZTracker::GetAccessPointRlzImpl(rlz_lib::AccessPoint point, if (!rlz_lib::GetAccessPointRlz(point, str_rlz, rlz_lib::kMaxRlzLength, NULL)) return false; - std::wstring rlz_local(ASCIIToWide(std::string(str_rlz))); + string16 rlz_local(ASCIIToWide(std::string(str_rlz))); if (rlz) *rlz = rlz_local; @@ -389,7 +384,7 @@ bool RLZTracker::ScheduleGetAccessPointRlz(rlz_lib::AccessPoint point) { if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) return false; - std::wstring* not_used = NULL; + string16* not_used = NULL; BrowserThread::PostTask( BrowserThread::FILE, FROM_HERE, NewRunnableFunction(&RLZTracker::GetAccessPointRlz, point, not_used)); diff --git a/chrome/browser/rlz/rlz.h b/chrome/browser/rlz/rlz.h index c335cbd..e30f8cc 100644 --- a/chrome/browser/rlz/rlz.h +++ b/chrome/browser/rlz/rlz.h @@ -16,6 +16,7 @@ #include "base/basictypes.h" #include "base/memory/ref_counted.h" #include "base/memory/singleton.h" +#include "base/string16.h" #include "base/task.h" #include "content/common/notification_observer.h" #include "content/common/notification_registrar.h" @@ -52,7 +53,7 @@ class RLZTracker : public NotificationObserver { // Get the RLZ value of the access point. // Returns false if the rlz string could not be obtained. In some cases // an empty string can be returned which is not an error. - static bool GetAccessPointRlz(rlz_lib::AccessPoint point, std::wstring* rlz); + static bool GetAccessPointRlz(rlz_lib::AccessPoint point, string16* rlz); // Invoked during shutdown to clean up any state created by RLZTracker. static void CleanupRlz(); @@ -94,7 +95,7 @@ class RLZTracker : public NotificationObserver { bool google_default_homepage); // Implementation called from RecordProductEvent() static method. - bool GetAccessPointRlzImpl(rlz_lib::AccessPoint point, std::wstring* rlz); + bool GetAccessPointRlzImpl(rlz_lib::AccessPoint point, string16* rlz); // Schedules the delayed initialization. This method is virtual to allow // tests to override how the scheduling is done. @@ -116,10 +117,9 @@ class RLZTracker : public NotificationObserver { // Sends the financial ping to the RLZ servers. This method is virtual to // allow tests to override. - virtual bool SendFinancialPing(const std::wstring& brand, - const std::wstring& lang, - const std::wstring& referral, - bool exclude_id); + virtual bool SendFinancialPing(const std::string& brand, + const string16& lang, + const string16& referral); // Tracker used for testing purposes only. If this value is non-NULL, it // will be returned from GetInstance() instead of the regular singleton. @@ -139,7 +139,7 @@ class RLZTracker : public NotificationObserver { // The cache must be protected by a lock since it may be accessed from // the UI thread for reading and the IO thread for reading and/or writing. base::Lock cache_lock_; - std::map<rlz_lib::AccessPoint, std::wstring> rlz_cache_; + std::map<rlz_lib::AccessPoint, string16> rlz_cache_; // Keeps track of whether the omnibox or host page have been used. bool omnibox_used_; diff --git a/chrome/browser/rlz/rlz_unittest.cc b/chrome/browser/rlz/rlz_unittest.cc index 2040f19..1c0416a 100644 --- a/chrome/browser/rlz/rlz_unittest.cc +++ b/chrome/browser/rlz/rlz_unittest.cc @@ -115,10 +115,9 @@ class TestRLZTracker : public RLZTracker { return !assume_not_ui_thread_; } - virtual bool SendFinancialPing(const std::wstring& brand, - const std::wstring& lang, - const std::wstring& referral, - bool exclude_id) OVERRIDE { + virtual bool SendFinancialPing(const std::string& brand, + const string16& lang, + const string16& referral) OVERRIDE { // Don't ping the server during tests. pingnow_called_ = true; @@ -159,7 +158,7 @@ void RlzLibTest::SetUp() { // so that the rlz_lib calls work. This needs to be done before we do the // override. - std::wstring temp_hklm_path = base::StringPrintf( + string16 temp_hklm_path = base::StringPrintf( L"%ls\\%ls", RegistryOverrideManager::kTempTestKeyPath, kRlzTempHklm); @@ -169,7 +168,7 @@ void RlzLibTest::SetUp() { temp_hklm_path.c_str(), KEY_READ)); - std::wstring temp_hkcu_path = base::StringPrintf( + string16 temp_hkcu_path = base::StringPrintf( L"%ls\\%ls", RegistryOverrideManager::kTempTestKeyPath, kRlzTempHkcu); @@ -189,7 +188,7 @@ void RlzLibTest::SetUp() { // Make sure a non-organic brand code is set in the registry or the RLZTracker // is pretty much a no-op. BrowserDistribution* dist = BrowserDistribution::GetDistribution(); - std::wstring reg_path = dist->GetStateKey(); + string16 reg_path = dist->GetStateKey(); RegKey key(HKEY_CURRENT_USER, reg_path.c_str(), KEY_SET_VALUE); ASSERT_EQ(ERROR_SUCCESS, key.WriteValue(google_update::kRegRLZBrandField, L"TEST")); @@ -467,7 +466,7 @@ TEST_F(RlzLibTest, GetAccessPointRlzOnIoThread) { // Set dummy RLZ string. rlz_lib::SetAccessPointRlz(rlz_lib::CHROME_OMNIBOX, kOmniboxRlzString); - std::wstring rlz; + string16 rlz; tracker_.set_assume_not_ui_thread(true); EXPECT_TRUE(RLZTracker::GetAccessPointRlz(rlz_lib::CHROME_OMNIBOX, &rlz)); @@ -478,7 +477,7 @@ TEST_F(RlzLibTest, GetAccessPointRlzNotOnIoThread) { // Set dummy RLZ string. rlz_lib::SetAccessPointRlz(rlz_lib::CHROME_OMNIBOX, kOmniboxRlzString); - std::wstring rlz; + string16 rlz; tracker_.set_assume_not_ui_thread(false); EXPECT_FALSE(RLZTracker::GetAccessPointRlz(rlz_lib::CHROME_OMNIBOX, &rlz)); @@ -488,7 +487,7 @@ TEST_F(RlzLibTest, GetAccessPointRlzIsCached) { // Set dummy RLZ string. rlz_lib::SetAccessPointRlz(rlz_lib::CHROME_OMNIBOX, kOmniboxRlzString); - std::wstring rlz; + string16 rlz; tracker_.set_assume_not_ui_thread(false); EXPECT_FALSE(RLZTracker::GetAccessPointRlz(rlz_lib::CHROME_OMNIBOX, &rlz)); @@ -507,7 +506,7 @@ TEST_F(RlzLibTest, PingUpdatesRlzCache) { rlz_lib::SetAccessPointRlz(rlz_lib::CHROME_OMNIBOX, kOmniboxRlzString); rlz_lib::SetAccessPointRlz(rlz_lib::CHROME_HOME_PAGE, kHomepageRlzString); - std::wstring rlz; + string16 rlz; // Prime the cache. tracker_.set_assume_not_ui_thread(true); diff --git a/chrome/installer/util/google_update_settings.cc b/chrome/installer/util/google_update_settings.cc index 5a6f4a2..b79e61a 100644 --- a/chrome/installer/util/google_update_settings.cc +++ b/chrome/installer/util/google_update_settings.cc @@ -486,35 +486,6 @@ bool GoogleUpdateSettings::WriteGoogleUpdateSystemClientKey( return status == ERROR_SUCCESS; } -bool GoogleUpdateSettings::IsOrganic(const std::wstring& brand) { - const CommandLine& command_line = *CommandLine::ForCurrentProcess(); - if (command_line.HasSwitch(switches::kOrganicInstall)) - return true; - - static const wchar_t* kBrands[] = { - L"CHFO", L"CHFT", L"CHHS", L"CHHM", L"CHMA", L"CHMB", L"CHME", L"CHMF", - L"CHMG", L"CHMH", L"CHMI", L"CHMQ", L"CHMV", L"CHNB", L"CHNC", L"CHNG", - L"CHNH", L"CHNI", L"CHOA", L"CHOB", L"CHOC", L"CHON", L"CHOO", L"CHOP", - L"CHOQ", L"CHOR", L"CHOS", L"CHOT", L"CHOU", L"CHOX", L"CHOY", L"CHOZ", - L"CHPD", L"CHPE", L"CHPF", L"CHPG", L"EUBB", L"EUBC", L"GGLA", L"GGLS" - }; - const wchar_t** end = &kBrands[arraysize(kBrands)]; - const wchar_t** found = std::find(&kBrands[0], end, brand); - if (found != end) - return 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 (StartsWith(brand, L"GG", true) || StartsWith(brand, L"EU", true)); -} - GoogleUpdateSettings::UpdatePolicy GoogleUpdateSettings::GetAppUpdatePolicy( const std::wstring& app_guid, bool* is_overridden) { diff --git a/chrome/installer/util/google_update_settings.h b/chrome/installer/util/google_update_settings.h index 243f451..ed84dfb 100644 --- a/chrome/installer/util/google_update_settings.h +++ b/chrome/installer/util/google_update_settings.h @@ -78,11 +78,18 @@ class GoogleUpdateSettings { // Returns in |brand| the RLZ brand code or distribution tag that has been // assigned to a partner. Returns false if the information is not available. + // + // NOTE: This function is Windows only. If the code you are writing is not + // specifically for Windows, prefer calling google_util::GetBrand(). static bool GetBrand(std::wstring* brand); // Returns in |brand| the RLZ reactivation brand code or distribution tag // that has been assigned to a partner for reactivating a dormant chrome // install. Returns false if the information is not available. + // + // NOTE: This function is Windows only. If the code you are writing is not + // specifically for Windows, prefer calling + // google_util::GetReactivationBrand(). static bool GetReactivationBrand(std::wstring* brand); // Returns in |client| the google_update client field, which is currently @@ -167,14 +174,6 @@ class GoogleUpdateSettings { const std::wstring& key, const std::wstring& value); - // 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); - // Returns the effective update policy for |app_guid| as dictated by // Group Policy settings. |is_overridden|, if non-NULL, is populated with // true if an app-specific policy override is in force, or false otherwise. |