blob: a4b3ad2b533efab18520c018b2f2a83bfe77c12d [file] [log] [blame]
Avi Drissman4a8573c2022-09-09 19:35:541// Copyright 2014 The Chromium Authors
[email protected]427e48f2012-12-05 16:02:242// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
Helmut Januschka7290d132024-03-28 09:15:105#include <string_view>
6
[email protected]57999812013-02-24 05:40:527#include "base/files/file_path.h"
thestig18dfb7a52014-08-26 10:44:048#include "base/files/file_util.h"
Avi Drissman02e49e582023-01-07 01:23:189#include "base/functional/bind.h"
[email protected]427e48f2012-12-05 16:02:2410#include "base/logging.h"
[email protected]d8830562013-06-10 22:01:5411#include "base/strings/string_util.h"
Gabriel Charette055039132020-02-26 23:02:0612#include "base/task/thread_pool.h"
Yeunjoo Choi7227dba2021-08-04 06:35:4713#include "chrome/browser/ash/policy/core/browser_policy_connector_ash.h"
[email protected]427e48f2012-12-05 16:02:2414#include "chrome/browser/browser_process.h"
Hans Wennborg63344452019-10-15 10:15:2115#include "chrome/browser/browser_process_platform_part.h"
Wenzhao Zang20153792018-09-29 00:37:1016#include "chrome/browser/google/google_brand_code_map_chromeos.h"
[email protected]427e48f2012-12-05 16:02:2417#include "chrome/common/pref_names.h"
Yeunjoo Choia10bd86e2022-12-15 02:34:5118#include "chromeos/ash/components/system/statistics_provider.h"
Wenzhao Zang20153792018-09-29 00:37:1019#include "components/policy/core/common/cloud/cloud_policy_constants.h"
brettwb1fc1b82016-02-02 00:19:0820#include "components/prefs/pref_service.h"
[email protected]427e48f2012-12-05 16:02:2421#include "content/public/browser/browser_thread.h"
22
[email protected]dd3e528a2014-06-06 11:41:1223namespace google_brand {
[email protected]427e48f2012-12-05 16:02:2424namespace chromeos {
25
26namespace {
27
28// Path to file that stores the RLZ brand code on ChromeOS.
[email protected]a7e1dc02013-02-14 15:00:4729const base::FilePath::CharType kRLZBrandFilePath[] =
[email protected]427e48f2012-12-05 16:02:2430 FILE_PATH_LITERAL("/opt/oem/etc/BRAND_CODE");
31
Helmut Januschka7290d132024-03-28 09:15:1032bool IsBrandValid(std::string_view brand) {
Wenzhao Zang5f5b2b52018-10-09 19:05:5533 return !brand.empty();
34}
35
[email protected]427e48f2012-12-05 16:02:2436// Reads the brand code from file |kRLZBrandFilePath|.
37std::string ReadBrandFromFile() {
38 std::string brand;
[email protected]650b2d52013-02-10 03:41:4539 base::FilePath brand_file_path(kRLZBrandFilePath);
Peter Kastingde196f32024-12-23 00:06:3340 if (!base::ReadFileToString(brand_file_path, &brand)) {
[email protected]427e48f2012-12-05 16:02:2441 LOG(WARNING) << "Brand code file missing: " << brand_file_path.value();
Peter Kastingde196f32024-12-23 00:06:3342 }
tfarina023b1dcc2015-12-06 13:25:4143 base::TrimWhitespaceASCII(brand, base::TRIM_ALL, &brand);
[email protected]