Avi Drissman | 4a8573c | 2022-09-09 19:35:54 | [diff] [blame] | 1 | // Copyright 2014 The Chromium Authors |
[email protected] | 427e48f | 2012-12-05 16:02:24 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. | ||||
4 | |||||
Helmut Januschka | 7290d13 | 2024-03-28 09:15:10 | [diff] [blame] | 5 | #include <string_view> |
6 | |||||
[email protected] | 5799981 | 2013-02-24 05:40:52 | [diff] [blame] | 7 | #include "base/files/file_path.h" |
thestig | 18dfb7a5 | 2014-08-26 10:44:04 | [diff] [blame] | 8 | #include "base/files/file_util.h" |
Avi Drissman | 02e49e58 | 2023-01-07 01:23:18 | [diff] [blame] | 9 | #include "base/functional/bind.h" |
[email protected] | 427e48f | 2012-12-05 16:02:24 | [diff] [blame] | 10 | #include "base/logging.h" |
[email protected] | d883056 | 2013-06-10 22:01:54 | [diff] [blame] | 11 | #include "base/strings/string_util.h" |
Gabriel Charette | 05503913 | 2020-02-26 23:02:06 | [diff] [blame] | 12 | #include "base/task/thread_pool.h" |
Yeunjoo Choi | 7227dba | 2021-08-04 06:35:47 | [diff] [blame] | 13 | #include "chrome/browser/ash/policy/core/browser_policy_connector_ash.h" |
[email protected] | 427e48f | 2012-12-05 16:02:24 | [diff] [blame] | 14 | #include "chrome/browser/browser_process.h" |
Hans Wennborg | 6334445 | 2019-10-15 10:15:21 | [diff] [blame] | 15 | #include "chrome/browser/browser_process_platform_part.h" |
Wenzhao Zang | 2015379 | 2018-09-29 00:37:10 | [diff] [blame] | 16 | #include "chrome/browser/google/google_brand_code_map_chromeos.h" |
[email protected] | 427e48f | 2012-12-05 16:02:24 | [diff] [blame] | 17 | #include "chrome/common/pref_names.h" |
Yeunjoo Choi | a10bd86e | 2022-12-15 02:34:51 | [diff] [blame] | 18 | #include "chromeos/ash/components/system/statistics_provider.h" |
Wenzhao Zang | 2015379 | 2018-09-29 00:37:10 | [diff] [blame] | 19 | #include "components/policy/core/common/cloud/cloud_policy_constants.h" |
brettw | b1fc1b8 | 2016-02-02 00:19:08 | [diff] [blame] | 20 | #include "components/prefs/pref_service.h" |
[email protected] | 427e48f | 2012-12-05 16:02:24 | [diff] [blame] | 21 | #include "content/public/browser/browser_thread.h" |
22 | |||||
[email protected] | dd3e528a | 2014-06-06 11:41:12 | [diff] [blame] | 23 | namespace google_brand { |
[email protected] | 427e48f | 2012-12-05 16:02:24 | [diff] [blame] | 24 | namespace chromeos { |
25 | |||||
26 | namespace { | ||||
27 | |||||
28 | // Path to file that stores the RLZ brand code on ChromeOS. | ||||
[email protected] | a7e1dc0 | 2013-02-14 15:00:47 | [diff] [blame] | 29 | const base::FilePath::CharType kRLZBrandFilePath[] = |
[email protected] | 427e48f | 2012-12-05 16:02:24 | [diff] [blame] | 30 | FILE_PATH_LITERAL("/opt/oem/etc/BRAND_CODE"); |
31 | |||||
Helmut Januschka | 7290d13 | 2024-03-28 09:15:10 | [diff] [blame] | 32 | bool IsBrandValid(std::string_view brand) { |
Wenzhao Zang | 5f5b2b5 | 2018-10-09 19:05:55 | [diff] [blame] | 33 | return !brand.empty(); |
34 | } | ||||
35 | |||||
[email protected] | 427e48f | 2012-12-05 16:02:24 | [diff] [blame] | 36 | // Reads the brand code from file |kRLZBrandFilePath|. |
37 | std::string ReadBrandFromFile() { | ||||
38 | std::string brand; | ||||
[email protected] | 650b2d5 | 2013-02-10 03:41:45 | [diff] [blame] | 39 | base::FilePath brand_file_path(kRLZBrandFilePath); |
Peter Kasting | de196f3 | 2024-12-23 00:06:33 | [diff] [blame] | 40 | if (!base::ReadFileToString(brand_file_path, &brand)) { |
[email protected] | 427e48f | 2012-12-05 16:02:24 | [diff] [blame] | 41 | LOG(WARNING) << "Brand code file missing: " << brand_file_path.value(); |
Peter Kasting | de196f3 | 2024-12-23 00:06:33 | [diff] [blame] | 42 | } |
tfarina | 023b1dcc | 2015-12-06 13:25:41 | [diff] [blame] | 43 | base::TrimWhitespaceASCII(brand, base::TRIM_ALL, &brand); |
[email protected] |