Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(174)

Side by Side Diff: chrome/browser/ui/webui/settings/about_handler.cc

Issue 2094703005: MD Settings: Fix broken regulatory label in About on Samus (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/ui/webui/settings/about_handler.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "chrome/browser/ui/webui/settings/about_handler.h" 5 #include "chrome/browser/ui/webui/settings/about_handler.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <string> 9 #include <string>
10 10
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 185
186 // Try the fallback region code if no directory was found. 186 // Try the fallback region code if no directory was found.
187 if (region_path.empty() && region != kDefaultRegionCode) 187 if (region_path.empty() && region != kDefaultRegionCode)
188 region_path = GetRegulatoryLabelDirForRegion(kDefaultRegionCode); 188 region_path = GetRegulatoryLabelDirForRegion(kDefaultRegionCode);
189 189
190 return region_path; 190 return region_path;
191 } 191 }
192 192
193 // Reads the file containing the regulatory label text, if found, relative to 193 // Reads the file containing the regulatory label text, if found, relative to
194 // the asset directory. Must be called from the blocking pool. 194 // the asset directory. Must be called from the blocking pool.
195 std::string ReadRegulatoryLabelText(const base::FilePath& path) { 195 std::string ReadRegulatoryLabelText(const base::FilePath& label_dir) {
196 DCHECK(BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread()); 196 DCHECK(BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread());
197 base::FilePath text_path(chrome::kChromeOSAssetPath); 197 base::FilePath text_path(chrome::kChromeOSAssetPath);
198 text_path = text_path.Append(path); 198 text_path = text_path.Append(label_dir);
199 text_path = text_path.AppendASCII(kRegulatoryLabelTextFilename); 199 text_path = text_path.AppendASCII(kRegulatoryLabelTextFilename);
200 200
201 std::string contents; 201 std::string contents;
202 if (base::ReadFileToString(text_path, &contents)) 202 if (base::ReadFileToString(text_path, &contents))
203 return contents; 203 return contents;
204 return std::string(); 204 return std::string();
205 } 205 }
206 206
207 std::unique_ptr<base::DictionaryValue> GetVersionInfo() { 207 std::unique_ptr<base::DictionaryValue> GetVersionInfo() {
208 std::unique_ptr<base::DictionaryValue> version_info( 208 std::unique_ptr<base::DictionaryValue> version_info(
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
613 } 613 }
614 614
615 CallJavascriptFunction("cr.webUIListenerCallback", 615 CallJavascriptFunction("cr.webUIListenerCallback",
616 base::StringValue("promotion-state-changed"), 616 base::StringValue("promotion-state-changed"),
617 base::StringValue(state_str)); 617 base::StringValue(state_str));
618 } 618 }
619 #endif // defined(OS_MACOSX) 619 #endif // defined(OS_MACOSX)
620 620
621 #if defined(OS_CHROMEOS) 621 #if defined(OS_CHROMEOS)
622 void AboutHandler::OnRegulatoryLabelDirFound(std::string callback_id, 622 void AboutHandler::OnRegulatoryLabelDirFound(std::string callback_id,
623 const base::FilePath& path) { 623 const base::FilePath& label_dir) {
624 if (path.empty()) { 624 if (label_dir.empty()) {
dpapad 2016/06/24 16:29:19 label_dir.empty() makes it looks as if this is che
michaelpg 2016/06/24 16:37:27 Done.
625 ResolveJavascriptCallback(base::StringValue(callback_id), 625 ResolveJavascriptCallback(base::StringValue(callback_id),
626 *base::Value::CreateNullValue()); 626 *base::Value::CreateNullValue());
627 return; 627 return;
628 } 628 }
629 629
630 base::PostTaskAndReplyWithResult( 630 base::PostTaskAndReplyWithResult(
631 content::BrowserThread::GetBlockingPool(), FROM_HERE, 631 content::BrowserThread::GetBlockingPool(), FROM_HERE,
632 base::Bind(&ReadRegulatoryLabelText, path), 632 base::Bind(&ReadRegulatoryLabelText, label_dir),
633 base::Bind(&AboutHandler::OnRegulatoryLabelTextRead, 633 base::Bind(&AboutHandler::OnRegulatoryLabelTextRead,
634 weak_factory_.GetWeakPtr(), callback_id, path)); 634 weak_factory_.GetWeakPtr(), callback_id, label_dir));
635 } 635 }
636 636
637 void AboutHandler::OnRegulatoryLabelTextRead(std::string callback_id, 637 void AboutHandler::OnRegulatoryLabelTextRead(std::string callback_id,
638 const base::FilePath& path, 638 const base::FilePath& label_dir,
639 const std::string& text) { 639 const std::string& text) {
640 std::unique_ptr<base::DictionaryValue> regulatory_info( 640 std::unique_ptr<base::DictionaryValue> regulatory_info(
641 new base::DictionaryValue); 641 new base::DictionaryValue);
642 // Remove unnecessary whitespace. 642 // Remove unnecessary whitespace.
643 regulatory_info->SetString("text", base::CollapseWhitespaceASCII(text, true)); 643 regulatory_info->SetString("text", base::CollapseWhitespaceASCII(text, true));
644 std::string url = std::string("chrome://") + chrome::kChromeOSAssetHost + 644
645 "/" + path.MaybeAsASCII(); 645 std::string image_path =
646 label_dir.AppendASCII(kRegulatoryLabelImageFilename).MaybeAsASCII();
dpapad 2016/06/24 16:29:19 Ah, thanks for fixing, I understand the bug now.
647 std::string url =
648 std::string("chrome://") + chrome::kChromeOSAssetHost + "/" + image_path;
646 regulatory_info->SetString("url", url); 649 regulatory_info->SetString("url", url);
647 650
648 ResolveJavascriptCallback(base::StringValue(callback_id), *regulatory_info); 651 ResolveJavascriptCallback(base::StringValue(callback_id), *regulatory_info);
649 } 652 }
650 653
651 #endif // defined(OS_CHROMEOS) 654 #endif // defined(OS_CHROMEOS)
652 655
653 } // namespace settings 656 } // namespace settings
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/settings/about_handler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698