Commit a58af96e authored by Philip Chen's avatar Philip Chen Committed by Commit Bot

Redefine --regulatory-label-dir flag

It turns out there is no easy way to overwrite the default directory of
regulatory labels (i.e. /usr/share/chromeos-assets/regulatory_labels)
without causing other problems (see the discussion in CL:1482597).

So let's limit the scope of this flag and only use it to pass per-model
'regulatory-label' property from cros_config.

Bug: 933173
Change-Id: I052a171bac74e02eb70e5c81c7027f6d15b7ad0b
Reviewed-on: https://chromium-review.googlesource.com/c/1484494
Commit-Queue: Philip Chen <philipchen@chromium.org>
Auto-Submit: Philip Chen <philipchen@chromium.org>
Reviewed-by: default avatarMichael Giuffrida <michaelpg@chromium.org>
Reviewed-by: default avatarDan Erat <derat@chromium.org>
Cr-Commit-Position: refs/heads/master@{#634978}
parent b634c490
...@@ -80,8 +80,8 @@ namespace { ...@@ -80,8 +80,8 @@ namespace {
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
// The default directory containing the regulatory labels for // The directory containing the regulatory labels for supported
// supported regions, relative to chromeos-assets directory // models/regions, relative to chromeos-assets directory
const char kRegulatoryLabelsDirectory[] = "regulatory_labels"; const char kRegulatoryLabelsDirectory[] = "regulatory_labels";
// File names of the image file and the file containing alt text for the label. // File names of the image file and the file containing alt text for the label.
...@@ -165,30 +165,31 @@ bool CanChangeChannel(Profile* profile) { ...@@ -165,30 +165,31 @@ bool CanChangeChannel(Profile* profile) {
return service && service->IsOwner(); return service && service->IsOwner();
} }
// Returns the absolute path to the directory of regulatory labels // Returns the relative path under the chromeos-assets dir
// for a given region, if found. // to the directory of regulatory labels for a given region, if found
// (e.g. "/usr/share/chromeos-assets/regulatory_labels/us".) // (e.g. "regulatory_labels/us"). Must be called from the blocking pool.
// Must be called from the blocking pool.
base::FilePath GetRegulatoryLabelDirForRegion(const std::string& region) { base::FilePath GetRegulatoryLabelDirForRegion(const std::string& region) {
// Allow the regulatory label path to be overriden by a flag. base::FilePath region_path(kRegulatoryLabelsDirectory);
base::FilePath base_dir = const std::string model_subdir =
base::CommandLine::ForCurrentProcess()->GetSwitchValuePath( base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
chromeos::switches::kRegulatoryLabelDir); chromeos::switches::kRegulatoryLabelDir);
if (base_dir.empty()) { if (!model_subdir.empty()) {
base_dir = base::FilePath(chrome::kChromeOSAssetPath) region_path = region_path.AppendASCII(model_subdir);
.Append(kRegulatoryLabelsDirectory);
} }
const base::FilePath region_dir = base_dir.AppendASCII(region); region_path = region_path.AppendASCII(region);
const base::FilePath image_path =
region_dir.AppendASCII(kRegulatoryLabelImageFilename);
// Check if the label image file exists in the path. // Check if the label image file exists in the full path, e.g.,
return base::PathExists(image_path) ? region_dir : base::FilePath(); // "/usr/share/chromeos-assets/regulatory_labels/us/label.png".
const base::FilePath image_path =
base::FilePath(chrome::kChromeOSAssetPath)
.Append(region_path)
.AppendASCII(kRegulatoryLabelImageFilename);
return base::PathExists(image_path) ? region_path : base::FilePath();
} }
// Finds the absolute path to the directory of regulatory labels, // Finds the relative path under the chromeos-assets dir to the region
// using the VPD region code. Also tries "us" as a fallback region. // subdirectory of regulatory labels, using the VPD region code. Also
// Must be called from the blocking pool. // tries "us" as a fallback region. Must be called from the blocking pool.
base::FilePath FindRegulatoryLabelDir() { base::FilePath FindRegulatoryLabelDir() {
std::string region; std::string region;
base::FilePath region_path; base::FilePath region_path;
...@@ -206,12 +207,14 @@ base::FilePath FindRegulatoryLabelDir() { ...@@ -206,12 +207,14 @@ base::FilePath FindRegulatoryLabelDir() {
return region_path; return region_path;
} }
// Reads the file containing the regulatory label text, if found in // Reads the file containing the regulatory label text, if found
// the given path to the directory of regulatory labels. Must be called // in the given relative path under the chromeos-assets dir.
// from the blocking pool. // Must be called from the blocking pool.
std::string ReadRegulatoryLabelText(const base::FilePath& label_dir_path) { std::string ReadRegulatoryLabelText(const base::FilePath& label_dir_path) {
base::FilePath text_path = const base::FilePath text_path =
label_dir_path.AppendASCII(kRegulatoryLabelTextFilename); base::FilePath(chrome::kChromeOSAssetPath)
.Append(label_dir_path)
.AppendASCII(kRegulatoryLabelTextFilename);
std::string contents; std::string contents;
if (base::ReadFileToString(text_path, &contents)) if (base::ReadFileToString(text_path, &contents))
......
...@@ -506,9 +506,10 @@ const char kShowAndroidFilesInFilesApp[] = "show-android-files-in-files-app"; ...@@ -506,9 +506,10 @@ const char kShowAndroidFilesInFilesApp[] = "show-android-files-in-files-app";
// If true, files in Android internal storage will be hidden in Files app. // If true, files in Android internal storage will be hidden in Files app.
const char kHideAndroidFilesInFilesApp[] = "hide-android-files-in-files-app"; const char kHideAndroidFilesInFilesApp[] = "hide-android-files-in-files-app";
// This directory contains per-region subdirectories with regulatory label // The name of the per-model directory which contains per-region
// files. If this is not set, we fall back to the default directory // subdirectories with regulatory label files for this model.
// '/usr/share/chromeos-assets/regulatory_labels' // The per-model directories (if there are any) are located under
// "/usr/share/chromeos-assets/regulatory_labels/".
const char kRegulatoryLabelDir[] = "regulatory-label-dir"; const char kRegulatoryLabelDir[] = "regulatory-label-dir";
// If true, the developer tool overlay will be shown for the login/lock screen. // If true, the developer tool overlay will be shown for the login/lock screen.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment