Commit 674b7b92 authored by seanparent@google.com's avatar seanparent@google.com

Only showing notification when a restart is needed. Partial fix to 5168.

BUG=chromium-os:5168
TEST=Manual - use devserver to install update and verify notification
appears to restart after update is installed with no other notifications.

Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=56616

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@56899 0039d316-1c4b-4281-b951-d872f2087c98
parent 41ce748f
...@@ -15,61 +15,22 @@ namespace chromeos { ...@@ -15,61 +15,22 @@ namespace chromeos {
UpdateObserver::UpdateObserver(Profile* profile) UpdateObserver::UpdateObserver(Profile* profile)
: notification_(profile, "update.chromeos", IDR_NOTIFICATION_UPDATE, : notification_(profile, "update.chromeos", IDR_NOTIFICATION_UPDATE,
l10n_util::GetStringUTF16(IDS_UPDATE_TITLE)), l10n_util::GetStringUTF16(IDS_UPDATE_TITLE)) {}
progress_(-1) {}
UpdateObserver::~UpdateObserver() { UpdateObserver::~UpdateObserver() {
notification_.Hide(); notification_.Hide();
} }
void UpdateObserver::UpdateStatusChanged(UpdateLibrary* library) { void UpdateObserver::UpdateStatusChanged(UpdateLibrary* library) {
switch (library->status().status) { #if 0
case UPDATE_STATUS_IDLE: // TODO seanparent@chromium.org : This update should only be shown when an
case UPDATE_STATUS_CHECKING_FOR_UPDATE: // update is critical and should include a restart button using the
// Do nothing in these cases, we don't want to notify the user of the // update_engine restart API. Currently removed entirely per Kan's request.
// check unless there is an update. We don't hide here because
// we want the final state to be sticky. if (library->status().status == UPDATE_STATUS_UPDATED_NEED_REBOOT) {
break; notification_.Show(l10n_util::GetStringUTF16(IDS_UPDATE_COMPLETED), true);
case UPDATE_STATUS_UPDATE_AVAILABLE:
notification_.Show(l10n_util::GetStringUTF16(IDS_UPDATE_AVAILABLE),
false);
break;
case UPDATE_STATUS_DOWNLOADING:
{
int progress = static_cast<int>(library->status().download_progress *
100.0);
if (progress != progress_) {
progress_ = progress;
notification_.Show(l10n_util::GetStringFUTF16(IDS_UPDATE_DOWNLOADING,
base::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;
case UPDATE_STATUS_REPORTING_ERROR_EVENT:
// If the update engine encounters an error and we have already
// notified the user of the update progress, show an error
// notification. Don't show anything otherwise -- for example,
// in cases where the update engine encounters an error while
// checking for an update.
if (notification_.visible()) {
notification_.Show(l10n_util::GetStringUTF16(IDS_UPDATE_ERROR), true);
}
break;
default:
notification_.Show(l10n_util::GetStringUTF16(IDS_UPDATE_ERROR), true);
break;
} }
#endif
} }
} // namespace chromeos } // namespace chromeos
...@@ -27,7 +27,6 @@ class UpdateObserver : public UpdateLibrary::Observer { ...@@ -27,7 +27,6 @@ class UpdateObserver : public UpdateLibrary::Observer {
virtual void UpdateStatusChanged(UpdateLibrary* library); virtual void UpdateStatusChanged(UpdateLibrary* library);
SystemNotification notification_; SystemNotification notification_;
int progress_; // Last displayed remaining time in minutes
DISALLOW_COPY_AND_ASSIGN(UpdateObserver); DISALLOW_COPY_AND_ASSIGN(UpdateObserver);
}; };
......
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