| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/bind.h" | 6 #include "base/bind.h" |
| 7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 // Path to file that stores the RLZ brand code on ChromeOS. | 24 // Path to file that stores the RLZ brand code on ChromeOS. |
| 25 const base::FilePath::CharType kRLZBrandFilePath[] = | 25 const base::FilePath::CharType kRLZBrandFilePath[] = |
| 26 FILE_PATH_LITERAL("/opt/oem/etc/BRAND_CODE"); | 26 FILE_PATH_LITERAL("/opt/oem/etc/BRAND_CODE"); |
| 27 | 27 |
| 28 // Reads the brand code from file |kRLZBrandFilePath|. | 28 // Reads the brand code from file |kRLZBrandFilePath|. |
| 29 std::string ReadBrandFromFile() { | 29 std::string ReadBrandFromFile() { |
| 30 std::string brand; | 30 std::string brand; |
| 31 base::FilePath brand_file_path(kRLZBrandFilePath); | 31 base::FilePath brand_file_path(kRLZBrandFilePath); |
| 32 if (!base::ReadFileToString(brand_file_path, &brand)) | 32 if (!base::ReadFileToString(brand_file_path, &brand)) |
| 33 LOG(WARNING) << "Brand code file missing: " << brand_file_path.value(); | 33 LOG(WARNING) << "Brand code file missing: " << brand_file_path.value(); |
| 34 base::TrimWhitespace(brand, base::TRIM_ALL, &brand); | 34 base::TrimWhitespaceASCII(brand, base::TRIM_ALL, &brand); |
| 35 return brand; | 35 return brand; |
| 36 } | 36 } |
| 37 | 37 |
| 38 // Sets the brand code to |brand|. | 38 // Sets the brand code to |brand|. |
| 39 void SetBrand(const base::Closure& callback, const std::string& brand) { | 39 void SetBrand(const base::Closure& callback, const std::string& brand) { |
| 40 g_browser_process->local_state()->SetString(prefs::kRLZBrand, brand); | 40 g_browser_process->local_state()->SetString(prefs::kRLZBrand, brand); |
| 41 callback.Run(); | 41 callback.Run(); |
| 42 } | 42 } |
| 43 | 43 |
| 44 // True if brand code has been cleared for the current session. | 44 // True if brand code has been cleared for the current session. |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 | 78 |
| 79 base::PostTaskAndReplyWithResult( | 79 base::PostTaskAndReplyWithResult( |
| 80 base::WorkerPool::GetTaskRunner(false /* task_is_slow */).get(), | 80 base::WorkerPool::GetTaskRunner(false /* task_is_slow */).get(), |
| 81 FROM_HERE, | 81 FROM_HERE, |
| 82 base::Bind(&ReadBrandFromFile), | 82 base::Bind(&ReadBrandFromFile), |
| 83 base::Bind(&SetBrand, callback)); | 83 base::Bind(&SetBrand, callback)); |
| 84 } | 84 } |
| 85 | 85 |
| 86 } // namespace chromeos | 86 } // namespace chromeos |
| 87 } // namespace google_brand | 87 } // namespace google_brand |
| OLD | NEW |