Chromium Code Reviews| Index: chrome/browser/google/google_util.cc |
| diff --git a/chrome/browser/google/google_util.cc b/chrome/browser/google/google_util.cc |
| index 0d47f5675ab91f8479ddee5385c3c2b49f715810..43e28def33c457603ceb67b01e647af4a7bbf155 100644 |
| --- a/chrome/browser/google/google_util.cc |
| +++ b/chrome/browser/google/google_util.cc |
| @@ -23,6 +23,11 @@ |
| #if defined(OS_MACOSX) |
| #include "chrome/browser/mac/keystone_glue.h" |
| +#elif defined(OS_CHROMEOS) |
| +#include "base/file_util.h" |
| +#include "base/lazy_instance.h" |
| +#include "base/string_util.h" |
| +#include "base/threading/thread_restrictions.h" |
| #endif |
| #if defined(GOOGLE_CHROME_BUILD) |
| @@ -55,6 +60,34 @@ bool HasQueryParameter(const std::string& str) { |
| bool gUseMockLinkDoctorBaseURLForTesting = false; |
| +#if defined(OS_CHROMEOS) |
|
Peter Kasting
2012/11/19 20:59:10
Nit: Maybe this whole block should go in its own .
Ivan Korotkov
2012/11/28 14:24:22
Done.
|
| +// Path to file that stores RLZ brand code on ChromeOS. |
| +const char kRLZBrandFilePath[] = |
| + FILE_PATH_LITERAL("/opt/oem/etc/rlz_brand_code"); |
| + |
| +// Simple class for caching brand code, meant to be used as a LazyInstance. |
|
Peter Kasting
2012/11/19 20:59:10
Do we really need thread-safety? I thought the go
|
| +class BrandCode { |
| + public: |
| + BrandCode() { |
|
Peter Kasting
2012/11/19 20:59:10
Nit: Don't inline non-accessor methods, even for c
|
| + // Need to perform I/O for the first time, same as on Win. |
| + // TODO(ivankr): as discussed, this will be moved to OOBE->EULA stage. |
|
Peter Kasting
2012/11/19 20:59:10
Can this be done now? I'm leery of adding ScopedA
Ivan Korotkov
2012/11/28 14:24:22
Done.
|
| + base::ThreadRestrictions::ScopedAllowIO allow_io; |
| + FilePath brand_file_path(kRLZBrandFilePath); |
| + if (!file_util::ReadFileToString(brand_file_path, &brand_)) |
| + LOG(WARNING) << "Brand code file missing: " << brand_file_path.value(); |
| + TrimWhitespace(brand_, TRIM_ALL, &brand_); |
| + } |
| + |
| + // Brand code, may be empty. |
| + const std::string& brand() { return brand_; } |
| + |
| + private: |
| + std::string brand_; |
| +}; |
|
Peter Kasting
2012/11/19 20:59:10
Nit: DISALLOW_COPY_AND_ASSIGN
|
| + |
| +base::LazyInstance<BrandCode> g_cached_brand = LAZY_INSTANCE_INITIALIZER; |
| +#endif |
| + |
| } // anonymous namespace |
| namespace google_util { |
| @@ -140,6 +173,8 @@ bool GetBrand(std::string* brand) { |
| #if defined(OS_MACOSX) |
| brand->assign(keystone_glue::BrandCode()); |
| +#elif defined(OS_CHROMEOS) |
| + brand->assign(g_cached_brand.Get().brand()); |
| #else |
| brand->clear(); |
| #endif |