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

Unified Diff: chrome/browser/ui/webui/help/help_handler.cc

Issue 780203002: Fix threading bugs in product label UI. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: File path and ImageSource changes Created 6 years 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/webui/help/help_handler.cc
diff --git a/chrome/browser/ui/webui/help/help_handler.cc b/chrome/browser/ui/webui/help/help_handler.cc
index b88247f3f3061447b0ef0f9e38ef3f2e5bed1c6b..3417b036c7a93722d8e4ae2bc82b10e7e89b5f42 100644
--- a/chrome/browser/ui/webui/help/help_handler.cc
+++ b/chrome/browser/ui/webui/help/help_handler.cc
@@ -47,8 +47,10 @@
#if defined(OS_CHROMEOS)
#include "base/files/file_util_proxy.h"
#include "base/i18n/time_formatting.h"
+#include "base/path_service.h"
#include "base/prefs/pref_service.h"
#include "base/sys_info.h"
+#include "base/task_runner_util.h"
#include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos.h"
#include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos_factory.h"
#include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
@@ -58,6 +60,7 @@
#include "chrome/browser/ui/webui/chromeos/image_source.h"
#include "chrome/browser/ui/webui/help/help_utils_chromeos.h"
#include "chrome/browser/ui/webui/help/version_updater_chromeos.h"
+#include "chromeos/chromeos_paths.h"
#include "chromeos/chromeos_switches.h"
#include "chromeos/dbus/dbus_thread_manager.h"
#include "chromeos/dbus/power_manager_client.h"
@@ -126,6 +129,18 @@ bool CanChangeChannel(Profile* profile) {
return false;
}
+// Reads the file containing the FCC label text, if found.
+std::string ReadFCCLabelText() {
+ base::FilePath shared_assets_dir;
+ std::string contents;
+ if (PathService::Get(chromeos::DIR_SHARED_ASSETS, &shared_assets_dir) &&
+ base::ReadFileToString(shared_assets_dir.AppendASCII(kFCCLabelTextPath),
+ &contents)) {
+ return contents;
+ }
+ return std::string();
+}
+
#endif // defined(OS_CHROMEOS)
} // namespace
@@ -403,9 +418,12 @@ void HelpHandler::OnPageLoaded(const base::ListValue* args) {
version_updater_->GetChannel(false,
base::Bind(&HelpHandler::OnTargetChannel, weak_factory_.GetWeakPtr()));
- BrowserThread::PostTask(
- BrowserThread::FILE, FROM_HERE,
- base::Bind(&HelpHandler::LoadFCCLabelText, weak_factory_.GetWeakPtr()));
+ base::PostTaskAndReplyWithResult(
+ content::BrowserThread::GetBlockingPool(),
+ FROM_HERE,
+ base::Bind(&ReadFCCLabelText),
+ base::Bind(&HelpHandler::OnFCCLabelTextRead,
+ weak_factory_.GetWeakPtr()));
#endif
}
@@ -587,16 +605,13 @@ void HelpHandler::OnTargetChannel(const std::string& channel) {
"help.HelpPage.updateTargetChannel", base::StringValue(channel));
}
-void HelpHandler::LoadFCCLabelText() {
- base::FilePath path(std::string(chrome::kChromeOSAssetPath) +
- kFCCLabelTextPath);
- std::string contents;
- if (base::ReadFileToString(path, &contents)) {
- // Remove unnecessary whitespace.
- base::StringValue label(base::CollapseWhitespaceASCII(contents, true));
- web_ui()->CallJavascriptFunction("help.HelpPage.setProductLabelText",
- label);
- }
+void HelpHandler::OnFCCLabelTextRead(std::string text) {
+ // Remove unnecessary whitespace.
+ text = base::CollapseWhitespaceASCII(text, true);
+ if (text.empty())
+ return;
+ base::StringValue label(text);
+ web_ui()->CallJavascriptFunction("help.HelpPage.setProductLabelText", label);
}
#endif // defined(OS_CHROMEOS)

Powered by Google App Engine
This is Rietveld 408576698