diff options
author | seanparent@google.com <seanparent@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-13 22:55:55 +0000 |
---|---|---|
committer | seanparent@google.com <seanparent@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-13 22:55:55 +0000 |
commit | 3cdf37690c508a8251f0893e0a757b2fa50f7f2a (patch) | |
tree | 025619f3f2aa38efedef0c30dd6f97a73e30452d /chrome/browser/chromeos/update_observer.cc | |
parent | 070c49c0f0578ccda58ccc4d3528f9458b5a2879 (diff) | |
download | chromium_src-3cdf37690c508a8251f0893e0a757b2fa50f7f2a.zip chromium_src-3cdf37690c508a8251f0893e0a757b2fa50f7f2a.tar.gz chromium_src-3cdf37690c508a8251f0893e0a757b2fa50f7f2a.tar.bz2 |
Added system notification for update_engine.
BUG=chromium-os:1178 1610 2033
TEST=UpdateBrowserTest.Notifications
Review URL: http://codereview.chromium.org/2859043
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@52237 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/chromeos/update_observer.cc')
-rw-r--r-- | chrome/browser/chromeos/update_observer.cc | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/chrome/browser/chromeos/update_observer.cc b/chrome/browser/chromeos/update_observer.cc new file mode 100644 index 0000000..ac1af56 --- /dev/null +++ b/chrome/browser/chromeos/update_observer.cc @@ -0,0 +1,66 @@ +// Copyright (c) 2010 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/update_observer.h" + +#include "app/l10n_util.h" +#include "base/string_util.h" +#include "base/utf_string_conversions.h" +#include "chrome/common/time_format.h" +#include "grit/generated_resources.h" +#include "grit/theme_resources.h" + +namespace chromeos { + +UpdateObserver::UpdateObserver(Profile* profile) + : notification_(profile, "update.chromeos", IDR_NOTIFICATION_UPDATE, + l10n_util::GetStringUTF16(IDS_UPDATE_TITLE)), + progress_(-1) {} + +UpdateObserver::~UpdateObserver() { + notification_.Hide(); +} + +void UpdateObserver::Changed(UpdateLibrary* object) { + switch (object->status().status) { + case UPDATE_STATUS_ERROR: + notification_.Show(l10n_util::GetStringUTF16(IDS_UPDATE_ERROR), true); + break; + case UPDATE_STATUS_IDLE: + case UPDATE_STATUS_CHECKING_FOR_UPDATE: + // Do nothing in these cases, we don't want to notify the user of the + // check unless there is an update. We don't hide here because + // we want the final state to be sticky. + break; + case UPDATE_STATUS_UPDATE_AVAILABLE: + notification_.Show(l10n_util::GetStringUTF16(IDS_UPDATE_AVAILABLE), + false); + break; + case UPDATE_STATUS_DOWNLOADING: + { + int progress = static_cast<int>(object->status().download_progress * + 100.0); + if (progress != progress_) { + progress_ = progress; + notification_.Show(l10n_util::GetStringFUTF16(IDS_UPDATE_DOWNLOADING, + IntToString16(progress_)), false); + } + } + break; + case UPDATE_STATUS_VERIFYING: + notification_.Show(l10n_util::GetStringUTF16(IDS_UPDATE_VERIFYING), + false); + break; + case UPDATE_STATUS_FINALIZING: + notification_.Show(l10n_util::GetStringUTF16(IDS_UPDATE_FINALIZING), + false); + break; + case UPDATE_STATUS_UPDATED_NEED_REBOOT: + notification_.Show(l10n_util::GetStringUTF16(IDS_UPDATE_COMPLETED), true); + break; + } +} + +} // namespace chromeos + |