Commit 10edbd98 authored by avayvod@chromium.org's avatar avayvod@chromium.org

Added version info to WebUI

R=xiyuan@chromium.org
BUG=chromium-os:18608
TEST=Verify that on WebUI OOBE and Login pages there's version info label.

Review URL: http://codereview.chromium.org/7564028

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@95406 0039d316-1c4b-4281-b951-d872f2087c98
parent 612ba4af
...@@ -85,10 +85,13 @@ BackgroundView::BackgroundView() ...@@ -85,10 +85,13 @@ BackgroundView::BackgroundView()
#else #else
is_official_build_(false), is_official_build_(false),
#endif #endif
background_area_(NULL) { background_area_(NULL),
version_info_updater_(this) {
} }
BackgroundView::~BackgroundView() {} BackgroundView::~BackgroundView() {
version_info_updater_.set_delegate(NULL);
}
void BackgroundView::Init(const GURL& background_url) { void BackgroundView::Init(const GURL& background_url) {
views::Painter* painter = CreateBackgroundPainter(); views::Painter* painter = CreateBackgroundPainter();
...@@ -304,6 +307,16 @@ void BackgroundView::OnLocaleChanged() { ...@@ -304,6 +307,16 @@ void BackgroundView::OnLocaleChanged() {
SchedulePaint(); SchedulePaint();
} }
void BackgroundView::OnOSVersionLabelTextUpdated(
const std::string& os_version_label_text) {
os_version_label_->SetText(ASCIIToWide(os_version_label_text));
}
void BackgroundView::OnBootTimesLabelTextUpdated(
const std::string& boot_times_label_text) {
boot_times_label_->SetText(ASCIIToWide(boot_times_label_text));
}
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// BackgroundView private: // BackgroundView private:
...@@ -342,39 +355,7 @@ void BackgroundView::InitInfoLabels() { ...@@ -342,39 +355,7 @@ void BackgroundView::InitInfoLabels() {
AddChildViewAt(boot_times_label_, idx); AddChildViewAt(boot_times_label_, idx);
} }
if (CrosLibrary::Get()->EnsureLoaded()) { version_info_updater_.StartUpdate(is_official_build_);
version_loader_.EnablePlatformVersions(true);
version_loader_.GetVersion(
&version_consumer_,
NewCallback(this, &BackgroundView::OnVersion),
is_official_build_ ?
VersionLoader::VERSION_SHORT_WITH_DATE :
VersionLoader::VERSION_FULL);
if (!is_official_build_) {
boot_times_loader_.GetBootTimes(
&boot_times_consumer_,
NewCallback(this, &BackgroundView::OnBootTimes));
}
} else {
UpdateVersionLabel();
}
policy::CloudPolicySubsystem* cloud_policy =
g_browser_process->browser_policy_connector()->
device_cloud_policy_subsystem();
if (cloud_policy) {
// Two-step reset because we want to construct new ObserverRegistrar after
// destruction of old ObserverRegistrar to avoid DCHECK violation because
// of adding existing observer.
cloud_policy_registrar_.reset();
cloud_policy_registrar_.reset(
new policy::CloudPolicySubsystem::ObserverRegistrar(
cloud_policy, this));
// Ensure that we have up-to-date enterprise info in case enterprise policy
// is already fetched and has finished initialization.
UpdateEnterpriseInfo();
}
} }
void BackgroundView::InitProgressBar() { void BackgroundView::InitProgressBar() {
...@@ -401,130 +382,4 @@ void BackgroundView::UpdateWindowType() { ...@@ -401,130 +382,4 @@ void BackgroundView::UpdateWindowType() {
&params); &params);
} }
void BackgroundView::UpdateVersionLabel() {
if (!CrosLibrary::Get()->EnsureLoaded()) {
os_version_label_->SetText(
ASCIIToWide(CrosLibrary::Get()->load_error_string()));
return;
}
if (version_text_.empty())
return;
chrome::VersionInfo version_info;
std::string label_text = l10n_util::GetStringUTF8(IDS_PRODUCT_NAME);
label_text += ' ';
label_text += version_info.Version();
label_text += " (";
// TODO(rkc): Fix this for RTL.
// http://code.google.com/p/chromium-os/issues/detail?id=17621
label_text += l10n_util::GetStringUTF8(IDS_PLATFORM_LABEL);
label_text += ' ';
label_text += version_text_;
label_text += ')';
if (!enterprise_domain_text_.empty()) {
label_text += ' ';
if (enterprise_status_text_.empty()) {
label_text += l10n_util::GetStringFUTF8(
IDS_LOGIN_MANAGED_BY_LABEL_FORMAT,
UTF8ToUTF16(enterprise_domain_text_));
} else {
label_text += l10n_util::GetStringFUTF8(
IDS_LOGIN_MANAGED_BY_WITH_STATUS_LABEL_FORMAT,
UTF8ToUTF16(enterprise_domain_text_),
UTF8ToUTF16(enterprise_status_text_));
}
}
// Workaround over incorrect width calculation in old fonts.
// TODO(glotov): remove the following line when new fonts are used.
label_text += ' ';
os_version_label_->SetText(UTF8ToWide(label_text));
}
void BackgroundView::UpdateEnterpriseInfo() {
policy::BrowserPolicyConnector* policy_connector =
g_browser_process->browser_policy_connector();
std::string status_text;
policy::CloudPolicySubsystem* cloud_policy_subsystem =
policy_connector->device_cloud_policy_subsystem();
if (cloud_policy_subsystem) {
switch (cloud_policy_subsystem->state()) {
case policy::CloudPolicySubsystem::UNENROLLED:
status_text = l10n_util::GetStringUTF8(
IDS_LOGIN_MANAGED_BY_STATUS_PENDING);
break;
case policy::CloudPolicySubsystem::UNMANAGED:
case policy::CloudPolicySubsystem::BAD_GAIA_TOKEN:
case policy::CloudPolicySubsystem::LOCAL_ERROR:
status_text = l10n_util::GetStringUTF8(
IDS_LOGIN_MANAGED_BY_STATUS_LOST_CONNECTION);
break;
case policy::CloudPolicySubsystem::NETWORK_ERROR:
status_text = l10n_util::GetStringUTF8(
IDS_LOGIN_MANAGED_BY_STATUS_NETWORK_ERROR);
break;
case policy::CloudPolicySubsystem::TOKEN_FETCHED:
case policy::CloudPolicySubsystem::SUCCESS:
break;
}
}
SetEnterpriseInfo(policy_connector->GetEnterpriseDomain(), status_text);
}
void BackgroundView::SetEnterpriseInfo(const std::string& domain_name,
const std::string& status_text) {
if (domain_name != enterprise_domain_text_ ||
status_text != enterprise_status_text_) {
enterprise_domain_text_ = domain_name;
enterprise_status_text_ = status_text;
UpdateVersionLabel();
}
}
void BackgroundView::OnVersion(
VersionLoader::Handle handle, std::string version) {
version_text_.swap(version);
UpdateVersionLabel();
}
void BackgroundView::OnBootTimes(
BootTimesLoader::Handle handle, BootTimesLoader::BootTimes boot_times) {
const char* kBootTimesNoChromeExec =
"Non-firmware boot took %.2f seconds (kernel %.2fs, system %.2fs)";
const char* kBootTimesChromeExec =
"Non-firmware boot took %.2f seconds "
"(kernel %.2fs, system %.2fs, chrome %.2fs)";
std::string boot_times_text;
if (boot_times.chrome > 0) {
boot_times_text =
base::StringPrintf(
kBootTimesChromeExec,
boot_times.total,
boot_times.pre_startup,
boot_times.system,
boot_times.chrome);
} else {
boot_times_text =
base::StringPrintf(
kBootTimesNoChromeExec,
boot_times.total,
boot_times.pre_startup,
boot_times.system);
}
// Use UTF8ToWide once this string is localized.
boot_times_label_->SetText(ASCIIToWide(boot_times_text));
}
void BackgroundView::OnPolicyStateChanged(
policy::CloudPolicySubsystem::PolicySubsystemState state,
policy::CloudPolicySubsystem::ErrorDetails error_details) {
UpdateEnterpriseInfo();
}
} // namespace chromeos } // namespace chromeos
...@@ -6,12 +6,9 @@ ...@@ -6,12 +6,9 @@
#define CHROME_BROWSER_CHROMEOS_LOGIN_BACKGROUND_VIEW_H_ #define CHROME_BROWSER_CHROMEOS_LOGIN_BACKGROUND_VIEW_H_
#pragma once #pragma once
#include "chrome/browser/chromeos/boot_times_loader.h"
#include "chrome/browser/chromeos/cros/cros_library.h"
#include "chrome/browser/chromeos/login/login_html_dialog.h" #include "chrome/browser/chromeos/login/login_html_dialog.h"
#include "chrome/browser/chromeos/status/status_area_host.h" #include "chrome/browser/chromeos/status/status_area_host.h"
#include "chrome/browser/chromeos/version_loader.h" #include "chrome/browser/chromeos/login/version_info_updater.h"
#include "chrome/browser/policy/cloud_policy_subsystem.h"
#include "views/view.h" #include "views/view.h"
namespace views { namespace views {
...@@ -35,8 +32,8 @@ class StatusAreaView; ...@@ -35,8 +32,8 @@ class StatusAreaView;
// StatusAreaView. // StatusAreaView.
class BackgroundView : public views::View, class BackgroundView : public views::View,
public StatusAreaHost, public StatusAreaHost,
public chromeos::LoginHtmlDialog::Delegate, public LoginHtmlDialog::Delegate,
public policy::CloudPolicySubsystem::Observer { public VersionInfoUpdater::Delegate {
public: public:
enum LoginStep { enum LoginStep {
SELECT_NETWORK, SELECT_NETWORK,
...@@ -52,7 +49,7 @@ class BackgroundView : public views::View, ...@@ -52,7 +49,7 @@ class BackgroundView : public views::View,
BackgroundView(); BackgroundView();
virtual ~BackgroundView(); virtual ~BackgroundView();
// Initializes the background view. It backgroun_url is given (non empty), // Initializes the background view. It background_url is given (non empty),
// it creates a DOMView background area that renders a webpage. // it creates a DOMView background area that renders a webpage.
void Init(const GURL& background_url); void Init(const GURL& background_url);
...@@ -122,6 +119,12 @@ class BackgroundView : public views::View, ...@@ -122,6 +119,12 @@ class BackgroundView : public views::View,
// Overridden from LoginHtmlDialog::Delegate: // Overridden from LoginHtmlDialog::Delegate:
virtual void OnDialogClosed() OVERRIDE {} virtual void OnDialogClosed() OVERRIDE {}
// Overridden from VersionInfoUpdater::Delegate:
virtual void OnOSVersionLabelTextUpdated(
const std::string& os_version_label_text) OVERRIDE;
virtual void OnBootTimesLabelTextUpdated(
const std::string& boot_times_label_text) OVERRIDE;
private: private:
// Creates and adds the status_area. // Creates and adds the status_area.
void InitStatusArea(); void InitStatusArea();
...@@ -134,27 +137,6 @@ class BackgroundView : public views::View, ...@@ -134,27 +137,6 @@ class BackgroundView : public views::View,
// after we've painted. // after we've painted.
void UpdateWindowType(); void UpdateWindowType();
// Update the version label.
void UpdateVersionLabel();
// Check and update enterprise domain.
void UpdateEnterpriseInfo();
// Set enterprise domain name.
void SetEnterpriseInfo(const std::string& domain_name,
const std::string& status_text);
// Callback from chromeos::VersionLoader giving the version.
void OnVersion(VersionLoader::Handle handle, std::string version);
// Callback from chromeos::InfoLoader giving the boot times.
void OnBootTimes(
BootTimesLoader::Handle handle, BootTimesLoader::BootTimes boot_times);
// policy::CloudPolicySubsystem::Observer methods:
virtual void OnPolicyStateChanged(
policy::CloudPolicySubsystem::PolicySubsystemState state,
policy::CloudPolicySubsystem::ErrorDetails error_details);
// All of these variables could be NULL. // All of these variables could be NULL.
StatusAreaView* status_area_; StatusAreaView* status_area_;
views::Label* os_version_label_; views::Label* os_version_label_;
...@@ -162,33 +144,17 @@ class BackgroundView : public views::View, ...@@ -162,33 +144,17 @@ class BackgroundView : public views::View,
OobeProgressBar* progress_bar_; OobeProgressBar* progress_bar_;
ShutdownButton* shutdown_button_; ShutdownButton* shutdown_button_;
// Handles asynchronously loading the version.
VersionLoader version_loader_;
// Used to request the version.
CancelableRequestConsumer version_consumer_;
// Handles asynchronously loading the boot times.
BootTimesLoader boot_times_loader_;
// Used to request the boot times.
CancelableRequestConsumer boot_times_consumer_;
// True if running official BUILD. // True if running official BUILD.
bool is_official_build_; bool is_official_build_;
// DOMView for rendering a webpage as a background. // DOMView for rendering a webpage as a background.
DOMView* background_area_; DOMView* background_area_;
// Information pieces for version label.
std::string version_text_;
std::string enterprise_domain_text_;
std::string enterprise_status_text_;
// Proxy settings dialog that can be invoked from network menu. // Proxy settings dialog that can be invoked from network menu.
scoped_ptr<LoginHtmlDialog> proxy_settings_dialog_; scoped_ptr<LoginHtmlDialog> proxy_settings_dialog_;
// CloudPolicySubsysterm observer registrar // Updates version info.
scoped_ptr<policy::CloudPolicySubsystem::ObserverRegistrar> VersionInfoUpdater version_info_updater_;
cloud_policy_registrar_;
DISALLOW_COPY_AND_ASSIGN(BackgroundView); DISALLOW_COPY_AND_ASSIGN(BackgroundView);
}; };
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include "base/string_util.h" #include "base/string_util.h"
#include "base/timer.h" #include "base/timer.h"
#include "base/utf_string_conversions.h" #include "base/utf_string_conversions.h"
#include "chrome/browser/chromeos/cros/cros_library.h"
#include "chrome/browser/chromeos/cros/login_library.h" #include "chrome/browser/chromeos/cros/login_library.h"
#include "chrome/browser/chromeos/cros/screen_lock_library.h" #include "chrome/browser/chromeos/cros/screen_lock_library.h"
#include "chrome/browser/chromeos/input_method/input_method_manager.h" #include "chrome/browser/chromeos/input_method/input_method_manager.h"
......
// 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/chromeos/login/version_info_updater.h"
#include <string>
#include <vector>
#include "base/string16.h"
#include "base/string_util.h"
#include "base/stringprintf.h"
#include "base/utf_string_conversions.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/cros/cros_library.h"
#include "chrome/browser/chromeos/wm_ipc.h"
#include "chrome/browser/policy/browser_policy_connector.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/common/chrome_version_info.h"
#include "googleurl/src/gurl.h"
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
#include "grit/theme_resources.h"
#include "third_party/cros/chromeos_wm_ipc_enums.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
namespace chromeos {
///////////////////////////////////////////////////////////////////////////////
// VersionInfoUpdater public:
VersionInfoUpdater::VersionInfoUpdater(Delegate* delegate)
: delegate_(delegate) {
}
VersionInfoUpdater::~VersionInfoUpdater() {
}
void VersionInfoUpdater::StartUpdate(bool is_official_build) {
if (CrosLibrary::Get()->EnsureLoaded()) {
version_loader_.EnablePlatformVersions(true);
version_loader_.GetVersion(
&version_consumer_,
NewCallback(this, &VersionInfoUpdater::OnVersion),
is_official_build ?
VersionLoader::VERSION_SHORT_WITH_DATE :
VersionLoader::VERSION_FULL);
if (!is_official_build) {
boot_times_loader_.GetBootTimes(
&boot_times_consumer_,
NewCallback(this, &VersionInfoUpdater::OnBootTimes));
}
} else {
UpdateVersionLabel();
}
policy::CloudPolicySubsystem* cloud_policy =
g_browser_process->browser_policy_connector()->
device_cloud_policy_subsystem();
if (cloud_policy) {
// Two-step reset because we want to construct new ObserverRegistrar after
// destruction of old ObserverRegistrar to avoid DCHECK violation because
// of adding existing observer.
cloud_policy_registrar_.reset();
cloud_policy_registrar_.reset(
new policy::CloudPolicySubsystem::ObserverRegistrar(
cloud_policy, this));
// Ensure that we have up-to-date enterprise info in case enterprise policy
// is already fetched and has finished initialization.
UpdateEnterpriseInfo();
}
}
void VersionInfoUpdater::UpdateVersionLabel() {
if (!CrosLibrary::Get()->EnsureLoaded()) {
if (delegate_) {
delegate_->OnOSVersionLabelTextUpdated(
CrosLibrary::Get()->load_error_string());
}
return;
}
if (version_text_.empty())
return;
chrome::VersionInfo version_info;
std::string label_text = l10n_util::GetStringUTF8(IDS_PRODUCT_NAME);
label_text += ' ';
label_text += version_info.Version();
label_text += " (";
// TODO(rkc): Fix this for RTL.
// http://code.google.com/p/chromium-os/issues/detail?id=17621
label_text += l10n_util::GetStringUTF8(IDS_PLATFORM_LABEL);
label_text += ' ';
label_text += version_text_;
label_text += ')';
if (!enterprise_domain_text_.empty()) {
label_text += ' ';
if (enterprise_status_text_.empty()) {
label_text += l10n_util::GetStringFUTF8(
IDS_LOGIN_MANAGED_BY_LABEL_FORMAT,
UTF8ToUTF16(enterprise_domain_text_));
} else {
label_text += l10n_util::GetStringFUTF8(
IDS_LOGIN_MANAGED_BY_WITH_STATUS_LABEL_FORMAT,
UTF8ToUTF16(enterprise_domain_text_),
UTF8ToUTF16(enterprise_status_text_));
}
}
// Workaround over incorrect width calculation in old fonts.
// TODO(glotov): remove the following line when new fonts are used.
label_text += ' ';
if (delegate_)
delegate_->OnOSVersionLabelTextUpdated(label_text);
}
void VersionInfoUpdater::UpdateEnterpriseInfo() {
policy::BrowserPolicyConnector* policy_connector =
g_browser_process->browser_policy_connector();
std::string status_text;
policy::CloudPolicySubsystem* cloud_policy_subsystem =
policy_connector->device_cloud_policy_subsystem();
if (cloud_policy_subsystem) {
switch (cloud_policy_subsystem->state()) {
case policy::CloudPolicySubsystem::UNENROLLED:
status_text = l10n_util::GetStringUTF8(
IDS_LOGIN_MANAGED_BY_STATUS_PENDING);
break;
case policy::CloudPolicySubsystem::UNMANAGED:
case policy::CloudPolicySubsystem::BAD_GAIA_TOKEN:
case policy::CloudPolicySubsystem::LOCAL_ERROR:
status_text = l10n_util::GetStringUTF8(
IDS_LOGIN_MANAGED_BY_STATUS_LOST_CONNECTION);
break;
case policy::CloudPolicySubsystem::NETWORK_ERROR:
status_text = l10n_util::GetStringUTF8(
IDS_LOGIN_MANAGED_BY_STATUS_NETWORK_ERROR);
break;
case policy::CloudPolicySubsystem::TOKEN_FETCHED:
case policy::CloudPolicySubsystem::SUCCESS:
break;
}
}
SetEnterpriseInfo(policy_connector->GetEnterpriseDomain(), status_text);
}
void VersionInfoUpdater::SetEnterpriseInfo(const std::string& domain_name,
const std::string& status_text) {
if (domain_name != enterprise_domain_text_ ||
status_text != enterprise_status_text_) {
enterprise_domain_text_ = domain_name;
enterprise_status_text_ = status_text;
UpdateVersionLabel();
}
}
void VersionInfoUpdater::OnVersion(
VersionLoader::Handle handle, std::string version) {
version_text_.swap(version);
UpdateVersionLabel();
}
void VersionInfoUpdater::OnBootTimes(
BootTimesLoader::Handle handle, BootTimesLoader::BootTimes boot_times) {
const char* kBootTimesNoChromeExec =
"Non-firmware boot took %.2f seconds (kernel %.2fs, system %.2fs)";
const char* kBootTimesChromeExec =
"Non-firmware boot took %.2f seconds "
"(kernel %.2fs, system %.2fs, chrome %.2fs)";
std::string boot_times_text;
if (boot_times.chrome > 0) {
boot_times_text =
base::StringPrintf(
kBootTimesChromeExec,
boot_times.total,
boot_times.pre_startup,
boot_times.system,
boot_times.chrome);
} else {
boot_times_text =
base::StringPrintf(
kBootTimesNoChromeExec,
boot_times.total,
boot_times.pre_startup,
boot_times.system);
}
// Use UTF8ToWide once this string is localized.
if (delegate_)
delegate_->OnBootTimesLabelTextUpdated(boot_times_text);
}
void VersionInfoUpdater::OnPolicyStateChanged(
policy::CloudPolicySubsystem::PolicySubsystemState state,
policy::CloudPolicySubsystem::ErrorDetails error_details) {
UpdateEnterpriseInfo();
}
} // namespace chromeos
// 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.
#ifndef CHROME_BROWSER_CHROMEOS_LOGIN_VERSION_INFO_UPDATER_H_
#define CHROME_BROWSER_CHROMEOS_LOGIN_VERSION_INFO_UPDATER_H_
#pragma once
#include <string>
#include "chrome/browser/chromeos/boot_times_loader.h"
#include "chrome/browser/chromeos/version_loader.h"
#include "chrome/browser/policy/cloud_policy_subsystem.h"
namespace chromeos {
// Fetches all info we want to show on OOBE/Login screens about system
// version, boot times and cloud policy.
class VersionInfoUpdater : policy::CloudPolicySubsystem::Observer {
public:
class Delegate {
public:
virtual ~Delegate() {}
// Called when OS version label should be updated.
virtual void OnOSVersionLabelTextUpdated(
const std::string& os_version_label_text) = 0;
// Called when boot times label should be updated.
virtual void OnBootTimesLabelTextUpdated(
const std::string& boot_times_label_text) = 0;
};
explicit VersionInfoUpdater(Delegate* delegate);
virtual ~VersionInfoUpdater();
// Sets delegate.
void set_delegate(Delegate* delegate) { delegate_ = delegate; }
// Starts fetching version info. The delegate will be notified when update
// is received.
void StartUpdate(bool is_official_build);
private:
// policy::CloudPolicySubsystem::Observer methods:
virtual void OnPolicyStateChanged(
policy::CloudPolicySubsystem::PolicySubsystemState state,
policy::CloudPolicySubsystem::ErrorDetails error_details) OVERRIDE;
// Update the version label.
void UpdateVersionLabel();
// Check and update enterprise domain.
void UpdateEnterpriseInfo();
// Set enterprise domain name.
void SetEnterpriseInfo(const std::string& domain_name,
const std::string& status_text);
// Callback from chromeos::VersionLoader giving the version.
void OnVersion(VersionLoader::Handle handle, std::string version);
// Callback from chromeos::InfoLoader giving the boot times.
void OnBootTimes(
BootTimesLoader::Handle handle, BootTimesLoader::BootTimes boot_times);
// Handles asynchronously loading the version.
VersionLoader version_loader_;
// Used to request the version.
CancelableRequestConsumer version_consumer_;
// Handles asynchronously loading the boot times.
BootTimesLoader boot_times_loader_;
// Used to request the boot times.
CancelableRequestConsumer boot_times_consumer_;
// Information pieces for version label.
std::string version_text_;
std::string enterprise_domain_text_;
std::string enterprise_status_text_;
// Full text for the OS version label.
std::string os_version_label_text_;
// CloudPolicySubsysterm observer registrar
scoped_ptr<policy::CloudPolicySubsystem::ObserverRegistrar>
cloud_policy_registrar_;
Delegate* delegate_;
DISALLOW_COPY_AND_ASSIGN(VersionInfoUpdater);
};
} // namespace chromeos
#endif // CHROME_BROWSER_CHROMEOS_LOGIN_VERSION_INFO_UPDATER_H_
...@@ -524,3 +524,14 @@ body.login-display #progress { ...@@ -524,3 +524,14 @@ body.login-display #progress {
html[dir=rtl] .error-message { html[dir=rtl] .error-message {
background-position: right top; background-position: right top;
} }
#version-labels {
-webkit-transition: all .5s linear;
bottom: 10px;
color: #999;
font-size: 11px;
left: 10px;
opacity: 1.0;
position: absolute;
text-shadow: 0 1px 1px #fff;
}
...@@ -63,6 +63,10 @@ ...@@ -63,6 +63,10 @@
</div> </div>
</div> </div>
</div> </div>
<div id="version-labels">
<div id="version"></div>
<div id="boot-times"></div>
</div>
<div id="security-info"> <div id="security-info">
<a id="security-link" href="#" i18n-content="eulaSystemSecuritySetting"></a> <a id="security-link" href="#" i18n-content="eulaSystemSecuritySetting"></a>
</div> </div>
......
...@@ -510,6 +510,15 @@ cr.define('cr.ui', function() { ...@@ -510,6 +510,15 @@ cr.define('cr.ui', function() {
} }
}; };
/**
* Sets text content for a div with |labelId|.
* @param {string} labelId Id of the label div.
* @param {string} labelText Text for the label.
*/
Oobe.setLabelText = function(labelId, labelText) {
$(labelId).textContent = labelText;
};
// Export // Export
return { return {
Oobe: Oobe Oobe: Oobe
......
// 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
// 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.
#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_CORE_OOBE_HANDLER_H_
#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_CORE_OOBE_HANDLER_H_
#pragma once
#include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h"
#include "chrome/browser/chromeos/login/version_info_updater.h"
namespace base {
class ListValue;
}
namespace chromeos {
class OobeUI;
// The core handler for Javascript messages related to the "oobe" view.
class CoreOobeHandler : public BaseScreenHandler,
public VersionInfoUpdater::Delegate {
public:
explicit CoreOobeHandler(OobeUI* oobe_ui);
virtual ~CoreOobeHandler();
// BaseScreenHandler implementation:
virtual void GetLocalizedStrings(
base::DictionaryValue* localized_strings) OVERRIDE;
virtual void Initialize() OVERRIDE;
// WebUIMessageHandler implementation.
virtual void RegisterMessages() OVERRIDE;
// VersionInfoUpdater::Delegate implementation:
virtual void OnOSVersionLabelTextUpdated(
const std::string& os_version_label_text) OVERRIDE;
virtual void OnBootTimesLabelTextUpdated(
const std::string& boot_times_label_text) OVERRIDE;
// Show or hide OOBE UI.
void ShowOobeUI(bool show);
bool show_oobe_ui() const {
return show_oobe_ui_;
}
private:
// Handlers for JS WebUI messages.
void OnInitialized(const base::ListValue* args);
void OnToggleAccessibility(const base::ListValue* args);
// Calls javascript to sync OOBE UI visibility with show_oobe_ui_.
void UpdateOobeUIVisibility();
// Updates label with specified id with specified text.
void UpdateLabel(const std::string& id, const std::string& text);
// Owner of this handler.
OobeUI* oobe_ui_;
// True if we should show OOBE instead of login.
bool show_oobe_ui_;
// Updates when version info is changed.
VersionInfoUpdater version_info_updater_;
DISALLOW_COPY_AND_ASSIGN(CoreOobeHandler);
};
} // namespace chromeos
#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_CORE_OOBE_HANDLER_H_
...@@ -10,12 +10,12 @@ ...@@ -10,12 +10,12 @@
#include "base/memory/ref_counted_memory.h" #include "base/memory/ref_counted_memory.h"
#include "base/values.h" #include "base/values.h"
#include "chrome/browser/browser_about_handler.h" #include "chrome/browser/browser_about_handler.h"
#include "chrome/browser/chromeos/accessibility_util.h"
#include "chrome/browser/chromeos/login/enterprise_enrollment_screen_actor.h" #include "chrome/browser/chromeos/login/enterprise_enrollment_screen_actor.h"
#include "chrome/browser/chromeos/login/wizard_controller.h" #include "chrome/browser/chromeos/login/wizard_controller.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/webui/chrome_url_data_manager.h" #include "chrome/browser/ui/webui/chrome_url_data_manager.h"
#include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h" #include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h"
#include "chrome/browser/ui/webui/chromeos/login/core_oobe_handler.h"
#include "chrome/browser/ui/webui/chromeos/login/enterprise_enrollment_screen_handler.h" #include "chrome/browser/ui/webui/chromeos/login/enterprise_enrollment_screen_handler.h"
#include "chrome/browser/ui/webui/chromeos/login/eula_screen_handler.h" #include "chrome/browser/ui/webui/chromeos/login/eula_screen_handler.h"
#include "chrome/browser/ui/webui/chromeos/login/network_screen_handler.h" #include "chrome/browser/ui/webui/chromeos/login/network_screen_handler.h"
...@@ -28,17 +28,10 @@ ...@@ -28,17 +28,10 @@
#include "chrome/common/url_constants.h" #include "chrome/common/url_constants.h"
#include "content/browser/tab_contents/tab_contents.h" #include "content/browser/tab_contents/tab_contents.h"
#include "grit/browser_resources.h" #include "grit/browser_resources.h"
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h" #include "ui/base/resource/resource_bundle.h"
namespace { namespace {
// JS API callbacks names.
const char kJsApiScreenStateInitialize[] = "screenStateInitialize";
const char kJsApiToggleAccessibility[] = "toggleAccessibility";
// Path for the enterprise enrollment gaia page hosting. // Path for the enterprise enrollment gaia page hosting.
const char kEnterpriseEnrollmentGaiaLoginPath[] = "gaialogin"; const char kEnterpriseEnrollmentGaiaLoginPath[] = "gaialogin";
...@@ -66,45 +59,6 @@ class OobeUIHTMLSource : public ChromeURLDataManager::DataSource { ...@@ -66,45 +59,6 @@ class OobeUIHTMLSource : public ChromeURLDataManager::DataSource {
DISALLOW_COPY_AND_ASSIGN(OobeUIHTMLSource); DISALLOW_COPY_AND_ASSIGN(OobeUIHTMLSource);
}; };
// CoreOobeHandler -------------------------------------------------------------
// The core handler for Javascript messages related to the "oobe" view.
class CoreOobeHandler : public BaseScreenHandler {
public:
explicit CoreOobeHandler(OobeUI* oobe_ui);
virtual ~CoreOobeHandler();
// BaseScreenHandler implementation:
virtual void GetLocalizedStrings(base::DictionaryValue* localized_strings);
virtual void Initialize();
// WebUIMessageHandler implementation.
virtual void RegisterMessages();
// Show or hide OOBE UI.
void ShowOobeUI(bool show);
bool show_oobe_ui() const {
return show_oobe_ui_;
}
private:
// Handlers for JS WebUI messages.
void OnInitialized(const ListValue* args);
void OnToggleAccessibility(const ListValue* args);
// Calls javascript to sync OOBE UI visibility with show_oobe_ui_.
void UpdateOobeUIVisibility();
// Owner of this handler.
OobeUI* oobe_ui_;
// True if we should show OOBE instead of login.
bool show_oobe_ui_;
DISALLOW_COPY_AND_ASSIGN(CoreOobeHandler);
};
// OobeUIHTMLSource ------------------------------------------------------- // OobeUIHTMLSource -------------------------------------------------------
OobeUIHTMLSource::OobeUIHTMLSource(DictionaryValue* localized_strings) OobeUIHTMLSource::OobeUIHTMLSource(DictionaryValue* localized_strings)
...@@ -132,58 +86,6 @@ void OobeUIHTMLSource::StartDataRequest(const std::string& path, ...@@ -132,58 +86,6 @@ void OobeUIHTMLSource::StartDataRequest(const std::string& path,
SendResponse(request_id, base::RefCountedString::TakeString(&response)); SendResponse(request_id, base::RefCountedString::TakeString(&response));
} }
// CoreOobeHandler ------------------------------------------------------------
// 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) {
}
CoreOobeHandler::~CoreOobeHandler() {
}
void CoreOobeHandler::GetLocalizedStrings(
base::DictionaryValue* localized_strings) {
localized_strings->SetString(
"productName", l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME));
}
void CoreOobeHandler::Initialize() {
UpdateOobeUIVisibility();
}
void CoreOobeHandler::RegisterMessages() {
web_ui_->RegisterMessageCallback(kJsApiToggleAccessibility,
NewCallback(this, &CoreOobeHandler::OnToggleAccessibility));
web_ui_->RegisterMessageCallback(kJsApiScreenStateInitialize,
NewCallback(this, &CoreOobeHandler::OnInitialized));
}
void CoreOobeHandler::OnInitialized(const ListValue* args) {
oobe_ui_->InitializeHandlers();
}
void CoreOobeHandler::OnToggleAccessibility(const 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);
}
// OobeUI ---------------------------------------------------------------------- // OobeUI ----------------------------------------------------------------------
OobeUI::OobeUI(TabContents* contents) OobeUI::OobeUI(TabContents* contents)
......
...@@ -609,6 +609,8 @@ ...@@ -609,6 +609,8 @@
'browser/chromeos/login/user_view.h', 'browser/chromeos/login/user_view.h',
'browser/chromeos/login/username_view.cc', 'browser/chromeos/login/username_view.cc',
'browser/chromeos/login/username_view.h', 'browser/chromeos/login/username_view.h',
'browser/chromeos/login/version_info_updater.cc',
'browser/chromeos/login/version_info_updater.h',
'browser/chromeos/login/view_screen.h', 'browser/chromeos/login/view_screen.h',
'browser/chromeos/login/views_enterprise_enrollment_screen_actor.cc', 'browser/chromeos/login/views_enterprise_enrollment_screen_actor.cc',
'browser/chromeos/login/views_enterprise_enrollment_screen_actor.h', 'browser/chromeos/login/views_enterprise_enrollment_screen_actor.h',
...@@ -3430,6 +3432,8 @@ ...@@ -3430,6 +3432,8 @@
'browser/ui/webui/chromeos/keyboard_overlay_ui.h', 'browser/ui/webui/chromeos/keyboard_overlay_ui.h',
'browser/ui/webui/chromeos/login/base_screen_handler.cc', 'browser/ui/webui/chromeos/login/base_screen_handler.cc',
'browser/ui/webui/chromeos/login/base_screen_handler.h', 'browser/ui/webui/chromeos/login/base_screen_handler.h',
'browser/ui/webui/chromeos/login/core_oobe_handler.cc',
'browser/ui/webui/chromeos/login/core_oobe_handler.h',
'browser/ui/webui/chromeos/login/enterprise_enrollment_screen_handler.cc', 'browser/ui/webui/chromeos/login/enterprise_enrollment_screen_handler.cc',
'browser/ui/webui/chromeos/login/enterprise_enrollment_screen_handler.h', 'browser/ui/webui/chromeos/login/enterprise_enrollment_screen_handler.h',
'browser/ui/webui/chromeos/login/eula_screen_handler.cc', 'browser/ui/webui/chromeos/login/eula_screen_handler.cc',
......
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