Commit 807efe51 authored by michaelpg's avatar michaelpg Committed by Commit bot
Browse files

MD Settings: Fix broken regulatory label in About on Samus

BUG=546841
R=dpapad@chromium.org
TEST=put something in /usr/share/chromeos-assets/regulatory_labels/us/label.{png,txt}
     or test on a samus
CQ_INCLUDE_TRYBOTS=tryserver.chromium.linux:closure_compilation
NOPRESUBMIT=true # unrelated html errors, will fix later

Review-Url: https://codereview.chromium.org/2094703005
Cr-Commit-Position: refs/heads/master@{#402337}
parent 673b2b68
......@@ -55,6 +55,10 @@
.info-section {
margin-bottom: 12px;
}
#regulatoryInfo img {
width: 330px;
}
</style>
<div data-page="about">
<settings-section page-title="$i18n{aboutPageTitle}"
......
......@@ -192,10 +192,10 @@ base::FilePath FindRegulatoryLabelDir() {
// Reads the file containing the regulatory label text, if found, relative to
// the asset directory. Must be called from the blocking pool.
std::string ReadRegulatoryLabelText(const base::FilePath& path) {
std::string ReadRegulatoryLabelText(const base::FilePath& label_dir_path) {
DCHECK(BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread());
base::FilePath text_path(chrome::kChromeOSAssetPath);
text_path = text_path.Append(path);
text_path = text_path.Append(label_dir_path);
text_path = text_path.AppendASCII(kRegulatoryLabelTextFilename);
std::string contents;
......@@ -619,9 +619,10 @@ void AboutHandler::SetPromotionState(VersionUpdater::PromotionState state) {
#endif // defined(OS_MACOSX)
#if defined(OS_CHROMEOS)
void AboutHandler::OnRegulatoryLabelDirFound(std::string callback_id,
const base::FilePath& path) {
if (path.empty()) {
void AboutHandler::OnRegulatoryLabelDirFound(
std::string callback_id,
const base::FilePath& label_dir_path) {
if (label_dir_path.empty()) {
ResolveJavascriptCallback(base::StringValue(callback_id),
*base::Value::CreateNullValue());
return;
......@@ -629,20 +630,24 @@ void AboutHandler::OnRegulatoryLabelDirFound(std::string callback_id,
base::PostTaskAndReplyWithResult(
content::BrowserThread::GetBlockingPool(), FROM_HERE,
base::Bind(&ReadRegulatoryLabelText, path),
base::Bind(&ReadRegulatoryLabelText, label_dir_path),
base::Bind(&AboutHandler::OnRegulatoryLabelTextRead,
weak_factory_.GetWeakPtr(), callback_id, path));
weak_factory_.GetWeakPtr(), callback_id, label_dir_path));
}
void AboutHandler::OnRegulatoryLabelTextRead(std::string callback_id,
const base::FilePath& path,
const std::string& text) {
void AboutHandler::OnRegulatoryLabelTextRead(
std::string callback_id,
const base::FilePath& label_dir_path,
const std::string& text) {
std::unique_ptr<base::DictionaryValue> regulatory_info(
new base::DictionaryValue);
// Remove unnecessary whitespace.
regulatory_info->SetString("text", base::CollapseWhitespaceASCII(text, true));
std::string url = std::string("chrome://") + chrome::kChromeOSAssetHost +
"/" + path.MaybeAsASCII();
std::string image_path =
label_dir_path.AppendASCII(kRegulatoryLabelImageFilename).MaybeAsASCII();
std::string url =
std::string("chrome://") + chrome::kChromeOSAssetHost + "/" + image_path;
regulatory_info->SetString("url", url);
ResolveJavascriptCallback(base::StringValue(callback_id), *regulatory_info);
......
......@@ -126,11 +126,11 @@ class AboutHandler : public settings::SettingsPageUIHandler,
// Callback for when the directory with the regulatory label image and alt
// text has been found.
void OnRegulatoryLabelDirFound(std::string callback_id,
const base::FilePath& path);
const base::FilePath& label_dir_path);
// Callback for when the regulatory text has been read.
void OnRegulatoryLabelTextRead(std::string callback_id,
const base::FilePath& path,
const base::FilePath& label_dir_path,
const std::string& text);
#endif
......
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