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

Unified Diff: chrome/browser/ui/webui/chromeos/login/core_oobe_handler.cc

Issue 7564028: Added version info to WebUI (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added boot times label Created 9 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/webui/chromeos/login/core_oobe_handler.cc
diff --git a/chrome/browser/ui/webui/chromeos/login/core_oobe_handler.cc b/chrome/browser/ui/webui/chromeos/login/core_oobe_handler.cc
new file mode 100644
index 0000000000000000000000000000000000000000..ed767e8c59ba20fee1633557ae2462bfc2700e90
--- /dev/null
+++ b/chrome/browser/ui/webui/chromeos/login/core_oobe_handler.cc
@@ -0,0 +1,100 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/webui/chromeos/login/core_oobe_handler.h"
+
+#include "base/values.h"
+#include "base/utf_string_conversions.h"
+#include "chrome/browser/chromeos/accessibility_util.h"
+#include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h"
+#include "grit/chromium_strings.h"
+#include "grit/generated_resources.h"
+#include "ui/base/l10n/l10n_util.h"
+
+namespace {
+
+// JS API callbacks names.
+const char kJsApiScreenStateInitialize[] = "screenStateInitialize";
+const char kJsApiToggleAccessibility[] = "toggleAccessibility";
+
+} // namespace
+
+namespace chromeos {
+
+// Note that show_oobe_ui_ defaults to false because WizardController assumes
+// OOBE UI is not visible by default.
+CoreOobeHandler::CoreOobeHandler(OobeUI* oobe_ui)
+ : oobe_ui_(oobe_ui),
+ show_oobe_ui_(false),
+ version_info_updater_(this) {
+}
+
+CoreOobeHandler::~CoreOobeHandler() {
+}
+
+void CoreOobeHandler::GetLocalizedStrings(
+ base::DictionaryValue* localized_strings) {
+ localized_strings->SetString(
+ "productName", l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME));
+}
+
+void CoreOobeHandler::Initialize() {
+ UpdateOobeUIVisibility();
+#if defined(OFFICIAL_BUILD)
+ version_info_updater_.StartUpdate(true);
+#else
+ version_info_updater_.StartUpdate(false);
+#endif
+}
+
+void CoreOobeHandler::RegisterMessages() {
+ web_ui_->RegisterMessageCallback(kJsApiToggleAccessibility,
+ NewCallback(this, &CoreOobeHandler::OnToggleAccessibility));
+ web_ui_->RegisterMessageCallback(kJsApiScreenStateInitialize,
+ NewCallback(this, &CoreOobeHandler::OnInitialized));
+}
+
+void CoreOobeHandler::OnInitialized(const base::ListValue* args) {
+ oobe_ui_->InitializeHandlers();
+}
+
+void CoreOobeHandler::OnToggleAccessibility(const base::ListValue* args) {
+ accessibility::ToggleAccessibility();
+}
+
+void CoreOobeHandler::ShowOobeUI(bool show) {
+ if (show == show_oobe_ui_)
+ return;
+
+ show_oobe_ui_ = show;
+
+ if (page_is_ready())
+ UpdateOobeUIVisibility();
+}
+
+void CoreOobeHandler::UpdateOobeUIVisibility() {
+ base::FundamentalValue showValue(show_oobe_ui_);
+ web_ui_->CallJavascriptFunction("cr.ui.Oobe.showOobeUI", showValue);
+}
+
+void CoreOobeHandler::OnOSVersionLabelTextUpdated(
+ const std::string& os_version_label_text) {
+ UpdateLabel("version", os_version_label_text);
+}
+
+void CoreOobeHandler::OnBootTimesLabelTextUpdated(
+ const std::string& boot_times_label_text) {
+ UpdateLabel("boot-times", boot_times_label_text);
+}
+
+void CoreOobeHandler::UpdateLabel(const std::string& id,
+ const std::string& text) {
+ base::StringValue id_value(ASCIIToUTF16(id));
+ base::StringValue text_value(ASCIIToUTF16(text));
+ web_ui_->CallJavascriptFunction("cr.ui.Oobe.setLabelText",
+ id_value,
+ text_value);
+}
+
+} // namespace chromeos
« no previous file with comments | « chrome/browser/ui/webui/chromeos/login/core_oobe_handler.h ('k') | chrome/browser/ui/webui/chromeos/login/oobe_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698