| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.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 10 matching lines...) Expand all Loading... |
| 21 namespace { | 21 namespace { |
| 22 | 22 |
| 23 // Path to file that stores the RLZ brand code on ChromeOS. | 23 // Path to file that stores the RLZ brand code on ChromeOS. |
| 24 const base::FilePath::CharType kRLZBrandFilePath[] = | 24 const base::FilePath::CharType kRLZBrandFilePath[] = |
| 25 FILE_PATH_LITERAL("/opt/oem/etc/BRAND_CODE"); | 25 FILE_PATH_LITERAL("/opt/oem/etc/BRAND_CODE"); |
| 26 | 26 |
| 27 // Reads the brand code from file |kRLZBrandFilePath|. | 27 // Reads the brand code from file |kRLZBrandFilePath|. |
| 28 std::string ReadBrandFromFile() { | 28 std::string ReadBrandFromFile() { |
| 29 std::string brand; | 29 std::string brand; |
| 30 base::FilePath brand_file_path(kRLZBrandFilePath); | 30 base::FilePath brand_file_path(kRLZBrandFilePath); |
| 31 if (!file_util::ReadFileToString(brand_file_path, &brand)) | 31 if (!base::ReadFileToString(brand_file_path, &brand)) |
| 32 LOG(WARNING) << "Brand code file missing: " << brand_file_path.value(); | 32 LOG(WARNING) << "Brand code file missing: " << brand_file_path.value(); |
| 33 TrimWhitespace(brand, TRIM_ALL, &brand); | 33 TrimWhitespace(brand, TRIM_ALL, &brand); |
| 34 return brand; | 34 return brand; |
| 35 } | 35 } |
| 36 | 36 |
| 37 // Sets the brand code to |brand|. | 37 // Sets the brand code to |brand|. |
| 38 void SetBrand(const base::Closure& callback, const std::string& brand) { | 38 void SetBrand(const base::Closure& callback, const std::string& brand) { |
| 39 g_browser_process->local_state()->SetString(prefs::kRLZBrand, brand); | 39 g_browser_process->local_state()->SetString(prefs::kRLZBrand, brand); |
| 40 callback.Run(); | 40 callback.Run(); |
| 41 } | 41 } |
| (...skipping 23 matching lines...) Expand all Loading... |
| 65 void SetBrandFromFile(const base::Closure& callback) { | 65 void SetBrandFromFile(const base::Closure& callback) { |
| 66 base::PostTaskAndReplyWithResult( | 66 base::PostTaskAndReplyWithResult( |
| 67 base::WorkerPool::GetTaskRunner(false /* task_is_slow */).get(), | 67 base::WorkerPool::GetTaskRunner(false /* task_is_slow */).get(), |
| 68 FROM_HERE, | 68 FROM_HERE, |
| 69 base::Bind(&ReadBrandFromFile), | 69 base::Bind(&ReadBrandFromFile), |
| 70 base::Bind(&SetBrand, callback)); | 70 base::Bind(&SetBrand, callback)); |
| 71 } | 71 } |
| 72 | 72 |
| 73 } // namespace chromeos | 73 } // namespace chromeos |
| 74 } // namespace google_util | 74 } // namespace google_util |
| OLD | NEW |