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

Side by Side Diff: chrome/browser/chromeos/update_observer.cc

Issue 3157018: Only showing notification when a restart is needed. Partial fix to 5168. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: . Created 10 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 unified diff | Download patch
« no previous file with comments | « chrome/browser/chromeos/update_observer.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/chromeos/update_observer.h" 5 #include "chrome/browser/chromeos/update_observer.h"
6 6
7 #include "app/l10n_util.h" 7 #include "app/l10n_util.h"
8 #include "base/string_number_conversions.h" 8 #include "base/string_number_conversions.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/common/time_format.h" 10 #include "chrome/common/time_format.h"
11 #include "grit/generated_resources.h" 11 #include "grit/generated_resources.h"
12 #include "grit/theme_resources.h" 12 #include "grit/theme_resources.h"
13 13
14 namespace chromeos { 14 namespace chromeos {
15 15
16 UpdateObserver::UpdateObserver(Profile* profile) 16 UpdateObserver::UpdateObserver(Profile* profile)
17 : notification_(profile, "update.chromeos", IDR_NOTIFICATION_UPDATE, 17 : notification_(profile, "update.chromeos", IDR_NOTIFICATION_UPDATE,
18 l10n_util::GetStringUTF16(IDS_UPDATE_TITLE)), 18 l10n_util::GetStringUTF16(IDS_UPDATE_TITLE)) {}
19 progress_(-1) {}
20 19
21 UpdateObserver::~UpdateObserver() { 20 UpdateObserver::~UpdateObserver() {
22 notification_.Hide(); 21 notification_.Hide();
23 } 22 }
24 23
25 void UpdateObserver::UpdateStatusChanged(UpdateLibrary* library) { 24 void UpdateObserver::UpdateStatusChanged(UpdateLibrary* library) {
26 switch (library->status().status) { 25 #if 0
27 case UPDATE_STATUS_IDLE: 26 // TODO seanparent@chromium.org : This update should only be shown when an
28 case UPDATE_STATUS_CHECKING_FOR_UPDATE: 27 // update is critical and should include a restart button using the
29 // Do nothing in these cases, we don't want to notify the user of the 28 // update_engine restart API. Currently removed entirely per Kan's request.
30 // check unless there is an update. We don't hide here because 29
31 // we want the final state to be sticky. 30 if (library->status().status == UPDATE_STATUS_UPDATED_NEED_REBOOT) {
32 break; 31 notification_.Show(l10n_util::GetStringUTF16(IDS_UPDATE_COMPLETED), true);
33 case UPDATE_STATUS_UPDATE_AVAILABLE:
34 notification_.Show(l10n_util::GetStringUTF16(IDS_UPDATE_AVAILABLE),
35 false);
36 break;
37 case UPDATE_STATUS_DOWNLOADING:
38 {
39 int progress = static_cast<int>(library->status().download_progress *
40 100.0);
41 if (progress != progress_) {
42 progress_ = progress;
43 notification_.Show(l10n_util::GetStringFUTF16(IDS_UPDATE_DOWNLOADING,
44 base::IntToString16(progress_)), false);
45 }
46 }
47 break;
48 case UPDATE_STATUS_VERIFYING:
49 notification_.Show(l10n_util::GetStringUTF16(IDS_UPDATE_VERIFYING),
50 false);
51 break;
52 case UPDATE_STATUS_FINALIZING:
53 notification_.Show(l10n_util::GetStringUTF16(IDS_UPDATE_FINALIZING),
54 false);
55 break;
56 case UPDATE_STATUS_UPDATED_NEED_REBOOT:
57 notification_.Show(l10n_util::GetStringUTF16(IDS_UPDATE_COMPLETED), true);
58 break;
59 case UPDATE_STATUS_REPORTING_ERROR_EVENT:
60 // If the update engine encounters an error and we have already
61 // notified the user of the update progress, show an error
62 // notification. Don't show anything otherwise -- for example,
63 // in cases where the update engine encounters an error while
64 // checking for an update.
65 if (notification_.visible()) {
66 notification_.Show(l10n_util::GetStringUTF16(IDS_UPDATE_ERROR), true);
67 }
68 break;
69 default:
70 notification_.Show(l10n_util::GetStringUTF16(IDS_UPDATE_ERROR), true);
71 break;
72 } 32 }
33 #endif
73 } 34 }
74 35
75 } // namespace chromeos 36 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/update_observer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698