summaryrefslogtreecommitdiffstats
path: root/chrome/browser/google/google_util.cc
diff options
context:
space:
mode:
authorrogerta@chromium.org <rogerta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-07 14:17:58 +0000
committerrogerta@chromium.org <rogerta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-07 14:17:58 +0000
commit7a336d6ec8064a899458123d34b9a6739e49a0d9 (patch)
tree327c4a92d7ca092e6938ecd0bdee8d42429769c3 /chrome/browser/google/google_util.cc
parentd4e744e5fd8bd1aa831510cb23044d8017f14e17 (diff)
downloadchromium_src-7a336d6ec8064a899458123d34b9a6739e49a0d9.zip
chromium_src-7a336d6ec8064a899458123d34b9a6739e49a0d9.tar.gz
chromium_src-7a336d6ec8064a899458123d34b9a6739e49a0d9.tar.bz2
Move brand code related function to a common place for all platforms. These
are Google specific APIs. BUG=None TEST=Make sure RLZ still uses correct brand code. Review URL: http://codereview.chromium.org/8136006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@104479 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/google/google_util.cc')
-rw-r--r--chrome/browser/google/google_util.cc84
1 files changed, 84 insertions, 0 deletions
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