diff options
author | blundell@chromium.org <blundell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-06 11:41:12 +0000 |
---|---|---|
committer | blundell@chromium.org <blundell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-06 11:41:12 +0000 |
commit | dd3e528a58d34ddc5fa518ab30ae83058b4b7497 (patch) | |
tree | 20db969a562e2ff2656d7c1ea8dbce87f58c7c38 | |
parent | 438f807d5039436f6cd82402037cb8f4b486474e (diff) | |
download | chromium_src-dd3e528a58d34ddc5fa518ab30ae83058b4b7497.zip chromium_src-dd3e528a58d34ddc5fa518ab30ae83058b4b7497.tar.gz chromium_src-dd3e528a58d34ddc5fa518ab30ae83058b4b7497.tar.bz2 |
Move branding information out of google_util
google_util is intended for componentization, whereas the information of what
the current brand is and whether a given brand is organic is inherently
embedder-specific. This functionality is moved to a new google_brand namespace.
BUG=373224
TBR=jochen
Review URL: https://codereview.chromium.org/316963002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@275413 0039d316-1c4b-4281-b951-d872f2087c98
25 files changed, 275 insertions, 224 deletions
diff --git a/chrome/browser/chrome_browser_field_trials_desktop.cc b/chrome/browser/chrome_browser_field_trials_desktop.cc index 520c842..e79ff1f 100644 --- a/chrome/browser/chrome_browser_field_trials_desktop.cc +++ b/chrome/browser/chrome_browser_field_trials_desktop.cc @@ -12,7 +12,7 @@ #include "base/prefs/pref_service.h" #include "base/strings/string_util.h" #include "chrome/browser/auto_launch_trial.h" -#include "chrome/browser/google/google_util.h" +#include "chrome/browser/google/google_brand.h" #include "chrome/browser/omnibox/omnibox_field_trial.h" #include "chrome/browser/prerender/prerender_field_trial.h" #include "chrome/browser/profiles/profiles_state.h" @@ -38,7 +38,7 @@ namespace { void AutoLaunchChromeFieldTrial() { std::string brand; - google_util::GetBrand(&brand); + google_brand::GetBrand(&brand); // Create a 100% field trial based on the brand code. if (auto_launch_trial::IsInExperimentGroup(brand)) { diff --git a/chrome/browser/chromeos/login/login_utils.cc b/chrome/browser/chromeos/login/login_utils.cc index caef573..71dd7ee 100644 --- a/chrome/browser/chromeos/login/login_utils.cc +++ b/chrome/browser/chromeos/login/login_utils.cc @@ -56,7 +56,7 @@ #include "chrome/browser/chromeos/settings/cros_settings.h" #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/first_run/first_run.h" -#include "chrome/browser/google/google_util_chromeos.h" +#include "chrome/browser/google/google_brand_chromeos.h" #include "chrome/browser/lifetime/application_lifetime.h" #include "chrome/browser/pref_service_flags_storage.h" #include "chrome/browser/profiles/profile.h" @@ -673,7 +673,7 @@ void LoginUtilsImpl::InitRlzDelayed(Profile* user_profile) { #if defined(ENABLE_RLZ) if (!g_browser_process->local_state()->HasPrefPath(prefs::kRLZBrand)) { // Read brand code asynchronously from an OEM data and repost ourselves. - google_util::chromeos::InitBrand( + google_brand::chromeos::InitBrand( base::Bind(&LoginUtilsImpl::InitRlzDelayed, AsWeakPtr(), user_profile)); return; } @@ -690,7 +690,7 @@ void LoginUtilsImpl::InitRlz(Profile* user_profile, bool disabled) { PrefService* local_state = g_browser_process->local_state(); if (disabled) { // Empty brand code means an organic install (no RLZ pings are sent). - google_util::chromeos::ClearBrandForCurrentSession(); + google_brand::chromeos::ClearBrandForCurrentSession(); } if (disabled != local_state->GetBoolean(prefs::kRLZDisabled)) { // When switching to RLZ enabled/disabled state, clear all recorded events. diff --git a/chrome/browser/extensions/updater/extension_updater_unittest.cc b/chrome/browser/extensions/updater/extension_updater_unittest.cc index 0f7cc57..0342d8c 100644 --- a/chrome/browser/extensions/updater/extension_updater_unittest.cc +++ b/chrome/browser/extensions/updater/extension_updater_unittest.cc @@ -35,7 +35,7 @@ #include "chrome/browser/extensions/updater/extension_updater.h" #include "chrome/browser/extensions/updater/manifest_fetch_data.h" #include "chrome/browser/extensions/updater/request_queue_impl.h" -#include "chrome/browser/google/google_util.h" +#include "chrome/browser/google/google_brand.h" #include "chrome/browser/omaha_query_params/omaha_query_params.h" #include "chrome/browser/prefs/pref_service_syncable.h" #include "chrome/common/pref_names.h" @@ -1376,7 +1376,7 @@ class ExtensionUpdaterTest : public testing::Test { } void TestGalleryRequestsWithBrand(bool use_organic_brand_code) { - google_util::BrandForTesting brand_for_testing( + google_brand::BrandForTesting brand_for_testing( use_organic_brand_code ? "GGLS" : "TEST"); // We want to test a variety of combinations of expected ping conditions for diff --git a/chrome/browser/extensions/updater/manifest_fetch_data.cc b/chrome/browser/extensions/updater/manifest_fetch_data.cc index d4da1a4..9ab495f 100644 --- a/chrome/browser/extensions/updater/manifest_fetch_data.cc +++ b/chrome/browser/extensions/updater/manifest_fetch_data.cc @@ -10,7 +10,7 @@ #include "base/metrics/histogram.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_util.h" -#include "chrome/browser/google/google_util.h" +#include "chrome/browser/google/google_brand.h" #include "chrome/browser/metrics/chrome_metrics_service_accessor.h" #include "chrome/browser/omaha_query_params/omaha_query_params.h" #include "net/base/escape.h" @@ -91,8 +91,8 @@ bool ManifestFetchData::AddExtension(const std::string& id, if (base_url_.DomainIs("google.com")) { #if defined(GOOGLE_CHROME_BUILD) std::string brand; - google_util::GetBrand(&brand); - if (!brand.empty() && !google_util::IsOrganic(brand)) + google_brand::GetBrand(&brand); + if (!brand.empty() && !google_brand::IsOrganic(brand)) parts.push_back("brand=" + brand); #endif diff --git a/chrome/browser/first_run/first_run.cc b/chrome/browser/first_run/first_run.cc index 89efce7..8afa281 100644 --- a/chrome/browser/first_run/first_run.cc +++ b/chrome/browser/first_run/first_run.cc @@ -24,7 +24,7 @@ #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/updater/extension_updater.h" #include "chrome/browser/first_run/first_run_internal.h" -#include "chrome/browser/google/google_util.h" +#include "chrome/browser/google/google_brand.h" #include "chrome/browser/importer/external_process_importer_host.h" #include "chrome/browser/importer/importer_list.h" #include "chrome/browser/importer/importer_progress_observer.h" @@ -566,8 +566,8 @@ bool CreateSentinel() { #if !defined(OS_LINUX) && !defined(OS_BSD) bool IsOrganicFirstRun() { std::string brand; - google_util::GetBrand(&brand); - return google_util::IsOrganicFirstRun(brand); + google_brand::GetBrand(&brand); + return google_brand::IsOrganicFirstRun(brand); } #endif diff --git a/chrome/browser/google/google_brand.cc b/chrome/browser/google/google_brand.cc new file mode 100644 index 0000000..a452844 --- /dev/null +++ b/chrome/browser/google/google_brand.cc @@ -0,0 +1,146 @@ +// 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/google/google_brand.h" + +#include <string> + + +#include "base/strings/string_util.h" +#include "base/strings/utf_string_conversions.h" +#include "chrome/installer/util/google_update_settings.h" + +#if defined(OS_MACOSX) +#include "chrome/browser/mac/keystone_glue.h" +#elif defined(OS_CHROMEOS) +#include "chrome/browser/google/google_brand_chromeos.h" +#endif + + +// Helpers -------------------------------------------------------------------- + +namespace { + +const char* g_brand_for_testing = NULL; + +} // namespace + + +namespace google_brand { + +// Global functions ----------------------------------------------------------- + +#if defined(OS_WIN) + +bool GetBrand(std::string* brand) { + if (g_brand_for_testing) { + brand->assign(g_brand_for_testing); + return true; + } + + base::string16 brand16; + bool ret = GoogleUpdateSettings::GetBrand(&brand16); + if (ret) + brand->assign(base::UTF16ToASCII(brand16)); + return ret; +} + +bool GetReactivationBrand(std::string* brand) { + base::string16 brand16; + bool ret = GoogleUpdateSettings::GetReactivationBrand(&brand16); + if (ret) + brand->assign(base::UTF16ToASCII(brand16)); + return ret; +} + +#else + +bool GetBrand(std::string* brand) { + if (g_brand_for_testing) { + brand->assign(g_brand_for_testing); + return true; + } + +#if defined(OS_MACOSX) + brand->assign(keystone_glue::BrandCode()); +#elif defined(OS_CHROMEOS) + brand->assign(google_brand::chromeos::GetBrand()); +#else + brand->clear(); +#endif + return true; +} + +bool GetReactivationBrand(std::string* brand) { + brand->clear(); + return true; +} + +#endif + +bool IsOrganic(const std::string& brand) { +#if defined(OS_MACOSX) + if (brand.empty()) { + // An empty brand string on Mac is used for channels other than stable, + // which are always organic. + return true; + } +#endif + + const char* const kBrands[] = { + "CHCA", "CHCB", "CHCG", "CHCH", "CHCI", "CHCJ", "CHCK", "CHCL", + "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", "ECBA", "ECBB", "ECDA", "ECDB", + "ECSA", "ECSB", "ECVA", "ECVB", "ECWA", "ECWB", "ECWC", "ECWD", + "ECWE", "ECWF", "EUBB", "EUBC", "GGLA", "GGLS" + }; + const char* const* end = &kBrands[arraysize(kBrands)]; + const char* const* 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) { +#if defined(OS_MACOSX) + if (brand.empty()) { + // An empty brand string on Mac is used for channels other than stable, + // which are always organic. + return true; + } +#endif + + return StartsWithASCII(brand, "GG", true) || + StartsWithASCII(brand, "EU", true); +} + +bool IsInternetCafeBrandCode(const std::string& brand) { + const char* const kBrands[] = { + "CHIQ", "CHSG", "HLJY", "NTMO", "OOBA", "OOBB", "OOBC", "OOBD", "OOBE", + "OOBF", "OOBG", "OOBH", "OOBI", "OOBJ", "IDCM", + }; + const char* const* end = &kBrands[arraysize(kBrands)]; + const char* const* found = std::find(&kBrands[0], end, brand); + return found != end; +} + +// BrandForTesting ------------------------------------------------------------ + +BrandForTesting::BrandForTesting(const std::string& brand) : brand_(brand) { + DCHECK(g_brand_for_testing == NULL); + g_brand_for_testing = brand_.c_str(); +} + +BrandForTesting::~BrandForTesting() { + g_brand_for_testing = NULL; +} + + +} // namespace google_brand diff --git a/chrome/browser/google/google_brand.h b/chrome/browser/google/google_brand.h new file mode 100644 index 0000000..a653f41 --- /dev/null +++ b/chrome/browser/google/google_brand.h @@ -0,0 +1,55 @@ +// 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. +// +// This namespace provides various helpers and state relating to Google Chrome +// distributions (such as RLZ), and specifically relating to the brand of the +// current install. Brands are codes that are assigned to partners for tracking +// distribution information. + +#ifndef CHROME_BROWSER_GOOGLE_GOOGLE_BRAND_H__ +#define CHROME_BROWSER_GOOGLE_GOOGLE_BRAND_H__ + +#include <string> + +#include "base/basictypes.h" + +class GURL; + +namespace google_brand { + +// 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); + +// True if |brand| is an internet cafe brand code. +bool IsInternetCafeBrandCode(const std::string& brand); + +// This class is meant to be used only from test code, and sets the brand +// code returned by the function GetBrand() above while the object exists. +class BrandForTesting { + public: + explicit BrandForTesting(const std::string& brand); + ~BrandForTesting(); + + private: + std::string brand_; + DISALLOW_COPY_AND_ASSIGN(BrandForTesting); +}; + +} // namespace google_brand + +#endif // CHROME_BROWSER_GOOGLE_GOOGLE_BRAND_H__ diff --git a/chrome/browser/google/google_util_chromeos.cc b/chrome/browser/google/google_brand_chromeos.cc index 5783846..8494168 100644 --- a/chrome/browser/google/google_util_chromeos.cc +++ b/chrome/browser/google/google_brand_chromeos.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// 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. @@ -16,7 +16,7 @@ #include "chromeos/system/statistics_provider.h" #include "content/public/browser/browser_thread.h" -namespace google_util { +namespace google_brand { namespace chromeos { namespace { @@ -82,4 +82,4 @@ void InitBrand(const base::Closure& callback) { } } // namespace chromeos -} // namespace google_util +} // namespace google_brand diff --git a/chrome/browser/google/google_util_chromeos.h b/chrome/browser/google/google_brand_chromeos.h index 14bf599..51e1afd 100644 --- a/chrome/browser/google/google_util_chromeos.h +++ b/chrome/browser/google/google_brand_chromeos.h @@ -1,15 +1,15 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// 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. -#ifndef CHROME_BROWSER_GOOGLE_GOOGLE_UTIL_CHROMEOS_H_ -#define CHROME_BROWSER_GOOGLE_GOOGLE_UTIL_CHROMEOS_H_ +#ifndef CHROME_BROWSER_GOOGLE_GOOGLE_BRAND_CHROMEOS_H_ +#define CHROME_BROWSER_GOOGLE_GOOGLE_BRAND_CHROMEOS_H_ #include <string> #include "base/callback_forward.h" -namespace google_util { +namespace google_brand { namespace chromeos { // Returns the brand code stored in Local State that has been assigned to a @@ -26,6 +26,6 @@ void ClearBrandForCurrentSession(); void InitBrand(const base::Closure& callback); } // namespace chromeos -} // namespace google_util +} // namespace google_brand -#endif // CHROME_BROWSER_GOOGLE_GOOGLE_UTIL_CHROMEOS_H_ +#endif // CHROME_BROWSER_GOOGLE_GOOGLE_BRAND_CHROMEOS_H_ diff --git a/chrome/browser/google/google_update_settings_unittest.cc b/chrome/browser/google/google_update_settings_unittest.cc index 1bdc68a..f3dcf93 100644 --- a/chrome/browser/google/google_update_settings_unittest.cc +++ b/chrome/browser/google/google_update_settings_unittest.cc @@ -6,7 +6,7 @@ #include "base/compiler_specific.h" #include "base/path_service.h" #include "base/test/scoped_path_override.h" -#include "chrome/browser/google/google_util.h" +#include "chrome/browser/google/google_brand.h" #include "chrome/common/chrome_paths.h" #include "chrome/installer/util/google_update_settings.h" #include "testing/gtest/include/gtest/gtest.h" @@ -51,14 +51,14 @@ TEST_F(GoogleUpdateTest, LastRunTime) { TEST_F(GoogleUpdateTest, IsOrganicFirstRunBrandCodes) { // Test some brand codes to ensure that future changes to this method won't // go unnoticed. - EXPECT_FALSE(google_util::IsOrganicFirstRun("CHFO")); - EXPECT_FALSE(google_util::IsOrganicFirstRun("CHMA")); - EXPECT_TRUE(google_util::IsOrganicFirstRun("EUBA")); - EXPECT_TRUE(google_util::IsOrganicFirstRun("GGRA")); + EXPECT_FALSE(google_brand::IsOrganicFirstRun("CHFO")); + EXPECT_FALSE(google_brand::IsOrganicFirstRun("CHMA")); + EXPECT_TRUE(google_brand::IsOrganicFirstRun("EUBA")); + EXPECT_TRUE(google_brand::IsOrganicFirstRun("GGRA")); #if defined(OS_MACOSX) // An empty brand string on Mac is used for channels other than stable, // which are always organic. - EXPECT_TRUE(google_util::IsOrganicFirstRun("")); + EXPECT_TRUE(google_brand::IsOrganicFirstRun("")); #endif } diff --git a/chrome/browser/google/google_util.cc b/chrome/browser/google/google_util.cc index 3b6f1cb..9b587dd 100644 --- a/chrome/browser/google/google_util.cc +++ b/chrome/browser/google/google_util.cc @@ -14,20 +14,12 @@ #include "base/strings/string_util.h" #include "base/strings/utf_string_conversions.h" #include "chrome/browser/browser_process.h" -#include "chrome/browser/google/google_url_tracker.h" #include "chrome/common/net/url_fixer_upper.h" -#include "chrome/installer/util/google_update_settings.h" #include "components/google/core/browser/google_switches.h" #include "net/base/registry_controlled_domains/registry_controlled_domain.h" #include "net/base/url_util.h" #include "url/gurl.h" -#if defined(OS_MACOSX) -#include "chrome/browser/mac/keystone_glue.h" -#elif defined(OS_CHROMEOS) -#include "chrome/browser/google/google_util_chromeos.h" -#endif - // Only use Link Doctor on official builds. It uses an API key, too, but // seems best to just disable it, for more responsive error pages and to reduce // server load. @@ -42,7 +34,6 @@ namespace { -const char* brand_for_testing = NULL; bool gUseMockLinkDoctorBaseURLForTesting = false; bool IsPathHomePageBase(const std::string& path) { @@ -127,54 +118,6 @@ GURL GetGoogleSearchURL(GURL google_homepage_url) { return google_homepage_url.ReplaceComponents(replacements); } -#if defined(OS_WIN) - -bool GetBrand(std::string* brand) { - if (brand_for_testing) { - brand->assign(brand_for_testing); - return true; - } - - base::string16 brand16; - bool ret = GoogleUpdateSettings::GetBrand(&brand16); - if (ret) - brand->assign(base::UTF16ToASCII(brand16)); - return ret; -} - -bool GetReactivationBrand(std::string* brand) { - base::string16 brand16; - bool ret = GoogleUpdateSettings::GetReactivationBrand(&brand16); - if (ret) - brand->assign(base::UTF16ToASCII(brand16)); - return ret; -} - -#else - -bool GetBrand(std::string* brand) { - if (brand_for_testing) { - brand->assign(brand_for_testing); - return true; - } - -#if defined(OS_MACOSX) - brand->assign(keystone_glue::BrandCode()); -#elif defined(OS_CHROMEOS) - brand->assign(google_util::chromeos::GetBrand()); -#else - brand->clear(); -#endif - return true; -} - -bool GetReactivationBrand(std::string* brand) { - brand->clear(); - return true; -} - -#endif - GURL CommandLineGoogleBaseURL() { // Unit tests may add command-line flags after the first call to this // function, so we don't simply initialize a static |base_url| directly and @@ -254,69 +197,4 @@ bool IsGoogleSearchUrl(const GURL& url) { (!is_home_page_base && HasGoogleSearchQueryParam(url.query())); } -bool IsOrganic(const std::string& brand) { -#if defined(OS_MACOSX) - if (brand.empty()) { - // An empty brand string on Mac is used for channels other than stable, - // which are always organic. - return true; - } -#endif - - const char* const kBrands[] = { - "CHCA", "CHCB", "CHCG", "CHCH", "CHCI", "CHCJ", "CHCK", "CHCL", - "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", "ECBA", "ECBB", "ECDA", "ECDB", - "ECSA", "ECSB", "ECVA", "ECVB", "ECWA", "ECWB", "ECWC", "ECWD", - "ECWE", "ECWF", "EUBB", "EUBC", "GGLA", "GGLS" - }; - const char* const* end = &kBrands[arraysize(kBrands)]; - const char* const* 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) { -#if defined(OS_MACOSX) - if (brand.empty()) { - // An empty brand string on Mac is used for channels other than stable, - // which are always organic. - return true; - } -#endif - - return StartsWithASCII(brand, "GG", true) || - StartsWithASCII(brand, "EU", true); -} - -bool IsInternetCafeBrandCode(const std::string& brand) { - const char* const kBrands[] = { - "CHIQ", "CHSG", "HLJY", "NTMO", "OOBA", "OOBB", "OOBC", "OOBD", "OOBE", - "OOBF", "OOBG", "OOBH", "OOBI", "OOBJ", "IDCM", - }; - const char* const* end = &kBrands[arraysize(kBrands)]; - const char* const* found = std::find(&kBrands[0], end, brand); - return found != end; -} - - -// BrandForTesting ------------------------------------------------------------ - -BrandForTesting::BrandForTesting(const std::string& brand) : brand_(brand) { - DCHECK(brand_for_testing == NULL); - brand_for_testing = brand_.c_str(); -} - -BrandForTesting::~BrandForTesting() { - brand_for_testing = NULL; -} - - } // namespace google_util diff --git a/chrome/browser/google/google_util.h b/chrome/browser/google/google_util.h index d116e05..a8cc238 100644 --- a/chrome/browser/google/google_util.h +++ b/chrome/browser/google/google_util.h @@ -13,8 +13,7 @@ class GURL; -// This namespace provides various helpers around handling Google-related URLs -// and state relating to Google Chrome distributions (such as RLZ). +// This namespace provides various helpers around handling Google-related URLs. namespace google_util { // True iff |str| contains a "q=" query parameter with a non-empty value. @@ -45,15 +44,6 @@ std::string GetGoogleCountryCode(GURL google_homepage_url); // Returns the Google search URL for the given Google homepage URL. GURL GetGoogleSearchURL(GURL google_homepage_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); - // Returns the Google base URL specified on the command line, if it exists. // This performs some fixup and sanity-checking to ensure that the resulting URL // is valid and has no query or ref. @@ -113,29 +103,6 @@ bool IsGoogleHomePageUrl(const GURL& url); // True if |url| represents a valid Google search URL. bool IsGoogleSearchUrl(const GURL& url); -// 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); - -// True if |brand| is an internet cafe brand code. -bool IsInternetCafeBrandCode(const std::string& brand); - -// This class is meant to be used only from test code, and sets the brand -// code returned by the function GetBrand() above while the object exists. -class BrandForTesting { - public: - explicit BrandForTesting(const std::string& brand); - ~BrandForTesting(); - - private: - std::string brand_; - DISALLOW_COPY_AND_ASSIGN(BrandForTesting); -}; - } // namespace google_util #endif // CHROME_BROWSER_GOOGLE_GOOGLE_UTIL_H__ diff --git a/chrome/browser/metrics/chrome_metrics_service_client.cc b/chrome/browser/metrics/chrome_metrics_service_client.cc index 011cb34..c970657 100644 --- a/chrome/browser/metrics/chrome_metrics_service_client.cc +++ b/chrome/browser/metrics/chrome_metrics_service_client.cc @@ -19,7 +19,7 @@ #include "base/time/time.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/chrome_notification_types.h" -#include "chrome/browser/google/google_util.h" +#include "chrome/browser/google/google_brand.h" #include "chrome/browser/memory_details.h" #include "chrome/browser/metrics/extensions_metrics_provider.h" #include "chrome/browser/metrics/metrics_service.h" @@ -159,7 +159,7 @@ std::string ChromeMetricsServiceClient::GetApplicationLocale() { } bool ChromeMetricsServiceClient::GetBrand(std::string* brand_code) { - return google_util::GetBrand(brand_code); + return google_brand::GetBrand(brand_code); } metrics::SystemProfileProto::Channel ChromeMetricsServiceClient::GetChannel() { diff --git a/chrome/browser/profile_resetter/automatic_profile_resetter_delegate.cc b/chrome/browser/profile_resetter/automatic_profile_resetter_delegate.cc index 3e51eec..ca878f9 100644 --- a/chrome/browser/profile_resetter/automatic_profile_resetter_delegate.cc +++ b/chrome/browser/profile_resetter/automatic_profile_resetter_delegate.cc @@ -17,7 +17,7 @@ #include "base/values.h" #include "chrome/app/chrome_command_ids.h" #include "chrome/browser/chrome_notification_types.h" -#include "chrome/browser/google/google_util.h" +#include "chrome/browser/google/google_brand.h" #include "chrome/browser/profile_resetter/brandcode_config_fetcher.h" #include "chrome/browser/profile_resetter/profile_reset_global_error.h" #include "chrome/browser/profile_resetter/profile_resetter.h" @@ -193,7 +193,7 @@ void AutomaticProfileResetterDelegateImpl:: return; std::string brandcode; - google_util::GetBrand(&brandcode); + google_brand::GetBrand(&brandcode); if (brandcode.empty()) { brandcoded_defaults_.reset(new BrandcodedDefaultSettings); brandcoded_defaults_fetched_event_.Signal(); diff --git a/chrome/browser/profile_resetter/automatic_profile_resetter_delegate_unittest.cc b/chrome/browser/profile_resetter/automatic_profile_resetter_delegate_unittest.cc index a72e2fa..2201978 100644 --- a/chrome/browser/profile_resetter/automatic_profile_resetter_delegate_unittest.cc +++ b/chrome/browser/profile_resetter/automatic_profile_resetter_delegate_unittest.cc @@ -21,7 +21,7 @@ #include "chrome/app/chrome_command_ids.h" #include "chrome/browser/chrome_notification_types.h" #include "chrome/browser/extensions/extension_service_unittest.h" -#include "chrome/browser/google/google_util.h" +#include "chrome/browser/google/google_brand.h" #include "chrome/browser/profile_resetter/brandcoded_default_settings.h" #include "chrome/browser/profile_resetter/profile_reset_global_error.h" #include "chrome/browser/search_engines/default_search_manager.h" @@ -441,7 +441,7 @@ TEST_F(AutomaticProfileResetterDelegateTest, TEST_F(AutomaticProfileResetterDelegateTest, FetchAndWaitOnDefaultSettingsVanilla) { - google_util::BrandForTesting scoped_brand_for_testing((std::string())); + google_brand::BrandForTesting scoped_brand_for_testing((std::string())); // Expect ready_callback to be called just after empty brandcoded settings // are loaded, given this is a vanilla build. Fail if it is not called, or @@ -473,7 +473,7 @@ TEST_F(AutomaticProfileResetterDelegateTest, TEST_F(AutomaticProfileResetterDelegateTest, FetchAndWaitOnDefaultSettingsBranded) { - google_util::BrandForTesting scoped_brand_for_testing(kTestBrandcode); + google_brand::BrandForTesting scoped_brand_for_testing(kTestBrandcode); // Expect ready_callback to be called just after the brandcoded settings are // downloaded. Fail if it is not called, or called too early. @@ -506,7 +506,7 @@ TEST_F(AutomaticProfileResetterDelegateTest, TEST_F(AutomaticProfileResetterDelegateTest, FetchAndWaitOnDefaultSettingsBrandedFailure) { - google_util::BrandForTesting scoped_brand_for_testing(kTestBrandcode); + google_brand::BrandForTesting scoped_brand_for_testing(kTestBrandcode); // Expect ready_callback to be called just after the brandcoded settings have // failed to download. Fail if it is not called, or called too early. @@ -532,7 +532,7 @@ TEST_F(AutomaticProfileResetterDelegateTest, } TEST_F(AutomaticProfileResetterDelegateTest, TriggerReset) { - google_util::BrandForTesting scoped_brand_for_testing(kTestBrandcode); + google_brand::BrandForTesting scoped_brand_for_testing(kTestBrandcode); PrefService* prefs = profile()->GetPrefs(); DCHECK(prefs); @@ -551,7 +551,7 @@ TEST_F(AutomaticProfileResetterDelegateTest, TriggerReset) { TEST_F(AutomaticProfileResetterDelegateTest, TriggerResetWithDefaultSettingsAlreadyLoaded) { - google_util::BrandForTesting scoped_brand_for_testing(kTestBrandcode); + google_brand::BrandForTesting scoped_brand_for_testing(kTestBrandcode); PrefService* prefs = profile()->GetPrefs(); DCHECK(prefs); @@ -573,7 +573,7 @@ TEST_F(AutomaticProfileResetterDelegateTest, TEST_F(AutomaticProfileResetterDelegateTest, TriggerResetAndSendFeedback) { - google_util::BrandForTesting scoped_brand_for_testing(kTestBrandcode); + google_brand::BrandForTesting scoped_brand_for_testing(kTestBrandcode); PrefService* prefs = profile()->GetPrefs(); DCHECK(prefs); diff --git a/chrome/browser/rlz/rlz.cc b/chrome/browser/rlz/rlz.cc index 63686b1..748058e 100644 --- a/chrome/browser/rlz/rlz.cc +++ b/chrome/browser/rlz/rlz.cc @@ -19,6 +19,7 @@ #include "base/strings/utf_string_conversions.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/chrome_notification_types.h" +#include "chrome/browser/google/google_brand.h" #include "chrome/browser/google/google_util.h" #include "chrome/browser/omnibox/omnibox_log.h" #include "chrome/browser/prefs/session_startup_pref.h" @@ -65,7 +66,7 @@ const base::TimeDelta kMaxInitDelay = base::TimeDelta::FromSeconds(200); const base::TimeDelta kMinInitDelay = base::TimeDelta::FromSeconds(20); bool IsBrandOrganic(const std::string& brand) { - return brand.empty() || google_util::IsOrganic(brand); + return brand.empty() || google_brand::IsOrganic(brand); } void RecordProductEvents(bool first_run, @@ -291,7 +292,7 @@ bool RLZTracker::Init(bool first_run, delay = std::min(kMaxInitDelay, std::max(min_init_delay_, delay)); - if (google_util::GetBrand(&brand_) && !IsBrandOrganic(brand_)) { + if (google_brand::GetBrand(&brand_) && !IsBrandOrganic(brand_)) { // Register for notifications from the omnibox so that we can record when // the user performs a first search. registrar_.Add(this, chrome::NOTIFICATION_OMNIBOX_OPENED_URL, @@ -304,7 +305,7 @@ bool RLZTracker::Init(bool first_run, content::NotificationService::AllSources()); #endif // !defined(OS_IOS) } - google_util::GetReactivationBrand(&reactivation_brand_); + google_brand::GetReactivationBrand(&reactivation_brand_); net::URLRequestContextGetter* context_getter = g_browser_process->system_request_context(); diff --git a/chrome/browser/rlz/rlz_unittest.cc b/chrome/browser/rlz/rlz_unittest.cc index 5a12d12..279426e 100644 --- a/chrome/browser/rlz/rlz_unittest.cc +++ b/chrome/browser/rlz/rlz_unittest.cc @@ -10,7 +10,7 @@ #include "chrome/browser/autocomplete/autocomplete_controller.h" #include "chrome/browser/autocomplete/autocomplete_input.h" #include "chrome/browser/chrome_notification_types.h" -#include "chrome/browser/google/google_util.h" +#include "chrome/browser/google/google_brand.h" #include "chrome/browser/omnibox/omnibox_log.h" #include "chrome/browser/profiles/profile.h" #include "chrome/installer/util/browser_distribution.h" @@ -182,7 +182,7 @@ class RlzLibTest : public RlzLibTestNoMachineState { TestRLZTracker tracker_; #if defined(OS_POSIX) - scoped_ptr<google_util::BrandForTesting> brand_override_; + scoped_ptr<google_brand::BrandForTesting> brand_override_; #endif }; @@ -199,10 +199,10 @@ void RlzLibTest::SetMainBrand(const char* brand) { #if defined(OS_WIN) SetRegistryBrandValue(google_update::kRegRLZBrandField, brand); #elif defined(OS_POSIX) - brand_override_.reset(new google_util::BrandForTesting(brand)); + brand_override_.reset(new google_brand::BrandForTesting(brand)); #endif std::string check_brand; - google_util::GetBrand(&check_brand); + google_brand::GetBrand(&check_brand); EXPECT_EQ(brand, check_brand); } @@ -211,7 +211,7 @@ void RlzLibTest::SetReactivationBrand(const char* brand) { #if defined(OS_WIN) SetRegistryBrandValue(google_update::kRegRLZReactivationBrandField, brand); std::string check_brand; - google_util::GetReactivationBrand(&check_brand); + google_brand::GetReactivationBrand(&check_brand); EXPECT_EQ(brand, check_brand); #endif } @@ -278,13 +278,13 @@ void RlzLibTest::ExpectEventRecorded(const char* event_name, bool expected) { void RlzLibTest::ExpectRlzPingSent(bool expected) { std::string brand; - google_util::GetBrand(&brand); + google_brand::GetBrand(&brand); EXPECT_EQ(expected, tracker_.was_ping_sent_for_brand(brand.c_str())); } void RlzLibTest::ExpectReactivationRlzPingSent(bool expected) { std::string brand; - google_util::GetReactivationBrand(&brand); + google_brand::GetReactivationBrand(&brand); EXPECT_EQ(expected, tracker_.was_ping_sent_for_brand(brand.c_str())); } diff --git a/chrome/browser/search_engines/search_terms_data.cc b/chrome/browser/search_engines/search_terms_data.cc index f72b0b7..68ec5c0 100644 --- a/chrome/browser/search_engines/search_terms_data.cc +++ b/chrome/browser/search_engines/search_terms_data.cc @@ -9,6 +9,7 @@ #include "base/metrics/field_trial.h" #include "base/prefs/pref_service.h" #include "chrome/browser/browser_process.h" +#include "chrome/browser/google/google_brand.h" #include "chrome/browser/google/google_profile_helper.h" #include "chrome/browser/google/google_url_tracker.h" #include "chrome/browser/google/google_util.h" @@ -122,8 +123,8 @@ base::string16 UIThreadSearchTermsData::GetRlzParameterValue( // For organic brandcodes do not use rlz at all. Empty brandcode usually // means a chromium install. This is ok. std::string brand; - if (google_util::GetBrand(&brand) && !brand.empty() && - !google_util::IsOrganic(brand)) { + if (google_brand::GetBrand(&brand) && !brand.empty() && + !google_brand::IsOrganic(brand)) { // This call will return false the first time(s) it is called until the // value has been cached. This normally would mean that at most one omnibox // search might not send the RLZ data but this is not really a problem. diff --git a/chrome/browser/search_engines/template_url_service_test_util.cc b/chrome/browser/search_engines/template_url_service_test_util.cc index eda8407..3259ff3 100644 --- a/chrome/browser/search_engines/template_url_service_test_util.cc +++ b/chrome/browser/search_engines/template_url_service_test_util.cc @@ -19,7 +19,7 @@ #include "testing/gtest/include/gtest/gtest.h" #if defined(OS_CHROMEOS) -#include "chrome/browser/google/google_util_chromeos.h" +#include "chrome/browser/google/google_brand_chromeos.h" #endif // Trivial subclass of TemplateURLService that records the last invocation of @@ -214,7 +214,7 @@ void TemplateURLServiceTestUtil::SetUp() { TemplateURLServiceTestUtilBase::CreateTemplateUrlService(); #if defined(OS_CHROMEOS) - google_util::chromeos::ClearBrandForCurrentSession(); + google_brand::chromeos::ClearBrandForCurrentSession(); #endif } diff --git a/chrome/browser/search_engines/template_url_unittest.cc b/chrome/browser/search_engines/template_url_unittest.cc index 97ea55b..18db3bb 100644 --- a/chrome/browser/search_engines/template_url_unittest.cc +++ b/chrome/browser/search_engines/template_url_unittest.cc @@ -15,7 +15,7 @@ #include "testing/gtest/include/gtest/gtest.h" #if defined(ENABLE_RLZ) -#include "chrome/browser/google/google_util.h" +#include "chrome/browser/google/google_brand.h" #endif #if defined(OS_ANDROID) @@ -657,8 +657,8 @@ TEST_F(TemplateURLTest, RLZ) { base::string16 rlz_string; #if defined(ENABLE_RLZ) std::string brand; - if (google_util::GetBrand(&brand) && !brand.empty() && - !google_util::IsOrganic(brand)) { + if (google_brand::GetBrand(&brand) && !brand.empty() && + !google_brand::IsOrganic(brand)) { RLZTracker::GetAccessPointRlz(RLZTracker::ChromeOmnibox(), &rlz_string); } #elif defined(OS_ANDROID) @@ -687,8 +687,8 @@ TEST_F(TemplateURLTest, RLZFromAppList) { base::string16 rlz_string; #if defined(ENABLE_RLZ) std::string brand; - if (google_util::GetBrand(&brand) && !brand.empty() && - !google_util::IsOrganic(brand)) { + if (google_brand::GetBrand(&brand) && !brand.empty() && + !google_brand::IsOrganic(brand)) { RLZTracker::GetAccessPointRlz(RLZTracker::ChromeAppList(), &rlz_string); } #endif diff --git a/chrome/browser/signin/signin_promo.cc b/chrome/browser/signin/signin_promo.cc index 6e30394..4f7e86a 100644 --- a/chrome/browser/signin/signin_promo.cc +++ b/chrome/browser/signin/signin_promo.cc @@ -11,6 +11,7 @@ #include "base/strings/utf_string_conversions.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/first_run/first_run.h" +#include "chrome/browser/google/google_brand.h" #include "chrome/browser/google/google_util.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_info_cache.h" @@ -62,12 +63,12 @@ bool g_force_web_based_signin_flow = false; // Checks we want to show the sign in promo for the given brand. bool AllowPromoAtStartupForCurrentBrand() { std::string brand; - google_util::GetBrand(&brand); + google_brand::GetBrand(&brand); if (brand.empty()) return true; - if (google_util::IsInternetCafeBrandCode(brand)) + if (google_brand::IsInternetCafeBrandCode(brand)) return false; // Enable for both organic and distribution. diff --git a/chrome/browser/ui/webui/options/reset_profile_settings_handler.cc b/chrome/browser/ui/webui/options/reset_profile_settings_handler.cc index 79a10cf..130eb137 100644 --- a/chrome/browser/ui/webui/options/reset_profile_settings_handler.cc +++ b/chrome/browser/ui/webui/options/reset_profile_settings_handler.cc @@ -10,7 +10,7 @@ #include "base/prefs/pref_service.h" #include "base/strings/string16.h" #include "base/values.h" -#include "chrome/browser/google/google_util.h" +#include "chrome/browser/google/google_brand.h" #include "chrome/browser/profile_resetter/automatic_profile_resetter.h" #include "chrome/browser/profile_resetter/automatic_profile_resetter_factory.h" #include "chrome/browser/profile_resetter/brandcode_config_fetcher.h" @@ -29,7 +29,7 @@ namespace options { ResetProfileSettingsHandler::ResetProfileSettingsHandler() : automatic_profile_resetter_(NULL), has_shown_confirmation_dialog_(false) { - google_util::GetBrand(&brandcode_); + google_brand::GetBrand(&brandcode_); } ResetProfileSettingsHandler::~ResetProfileSettingsHandler() {} diff --git a/chrome/browser/upgrade_detector_impl.cc b/chrome/browser/upgrade_detector_impl.cc index 3137fb0..65ebf18 100644 --- a/chrome/browser/upgrade_detector_impl.cc +++ b/chrome/browser/upgrade_detector_impl.cc @@ -22,7 +22,7 @@ #include "base/time/time.h" #include "base/version.h" #include "chrome/browser/browser_process.h" -#include "chrome/browser/google/google_util.h" +#include "chrome/browser/google/google_brand.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/chrome_version_info.h" #include "chrome/common/pref_names.h" @@ -360,7 +360,7 @@ bool UpgradeDetectorImpl::DetectOutdatedInstall() { static bool simulate_outdated = SimulatingOutdated(); if (!simulate_outdated) { std::string brand; - if (google_util::GetBrand(&brand) && !google_util::IsOrganic(brand)) + if (google_brand::GetBrand(&brand) && !google_brand::IsOrganic(brand)) return false; #if defined(OS_WIN) diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index da32231..6e1c064 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -715,10 +715,12 @@ 'browser/google/google_url_tracker_navigation_helper.h', 'browser/google/google_url_tracker_navigation_helper_impl.cc', 'browser/google/google_url_tracker_navigation_helper_impl.h', + 'browser/google/google_brand.cc', + 'browser/google/google_brand.h', + 'browser/google/google_brand_chromeos.cc', + 'browser/google/google_brand_chromeos.h', 'browser/google/google_util.cc', 'browser/google/google_util.h', - 'browser/google/google_util_chromeos.cc', - 'browser/google/google_util_chromeos.h', 'browser/gpu/gl_string_manager.cc', 'browser/gpu/gl_string_manager.h', 'browser/gpu/gpu_feature_checker.cc', diff --git a/chrome/installer/util/google_update_settings.h b/chrome/installer/util/google_update_settings.h index c05bf09..a2ff11d 100644 --- a/chrome/installer/util/google_update_settings.h +++ b/chrome/installer/util/google_update_settings.h @@ -127,7 +127,7 @@ class GoogleUpdateSettings { // 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(). + // specifically for Windows, prefer calling google_brand::GetBrand(). static bool GetBrand(std::wstring* brand); // Returns in |brand| the RLZ reactivation brand code or distribution tag @@ -136,7 +136,7 @@ class GoogleUpdateSettings { // // NOTE: This function is Windows only. If the code you are writing is not // specifically for Windows, prefer calling - // google_util::GetReactivationBrand(). + // google_brand::GetReactivationBrand(). static bool GetReactivationBrand(std::wstring* brand); // Returns in |client| the google_update client field, which is currently |