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

Unified Diff: chrome/browser/chromeos/login/background_view.cc

Issue 7541038: Merge 95406 - Added version info to WebUI (Closed) Base URL: svn://svn.chromium.org/chrome/branches/835/src/
Patch Set: 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
« no previous file with comments | « chrome/browser/chromeos/login/background_view.h ('k') | chrome/browser/chromeos/login/screen_locker.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/login/background_view.cc
===================================================================
--- chrome/browser/chromeos/login/background_view.cc (revision 95585)
+++ chrome/browser/chromeos/login/background_view.cc (working copy)
@@ -85,10 +85,13 @@
#else
is_official_build_(false),
#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) {
views::Painter* painter = CreateBackgroundPainter();
@@ -304,6 +307,16 @@
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:
@@ -342,39 +355,7 @@
AddChildViewAt(boot_times_label_, idx);
}
- if (CrosLibrary::Get()->EnsureLoaded()) {
- 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();
- }
+ version_info_updater_.StartUpdate(is_official_build_);
}
void BackgroundView::InitProgressBar() {
@@ -401,130 +382,4 @@
&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
« no previous file with comments | « chrome/browser/chromeos/login/background_view.h ('k') | chrome/browser/chromeos/login/screen_locker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698