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

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

Issue 2081873002: Incorporate comments in Dbus code and add Eol icon (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/eol_notification.h" 5 #include "chrome/browser/chromeos/eol_notification.h"
6 6
7 #include "chrome/browser/browser_process.h" 7 #include "chrome/browser/browser_process.h"
8 #include "chrome/browser/notifications/notification.h" 8 #include "chrome/browser/notifications/notification.h"
9 #include "chrome/browser/notifications/notification_ui_manager.h" 9 #include "chrome/browser/notifications/notification_ui_manager.h"
10 #include "chrome/browser/ui/browser_navigator.h" 10 #include "chrome/browser/ui/browser_navigator.h"
11 #include "chrome/browser/ui/browser_navigator_params.h" 11 #include "chrome/browser/ui/browser_navigator_params.h"
12 #include "chrome/common/pref_names.h" 12 #include "chrome/common/pref_names.h"
13 #include "chrome/common/url_constants.h" 13 #include "chrome/common/url_constants.h"
14 #include "chrome/grit/generated_resources.h" 14 #include "chrome/grit/generated_resources.h"
15 #include "chromeos/dbus/dbus_thread_manager.h" 15 #include "chromeos/dbus/dbus_thread_manager.h"
16 #include "chromeos/dbus/update_engine_client.h" 16 #include "chromeos/dbus/update_engine_client.h"
17 #include "components/prefs/pref_service.h" 17 #include "components/prefs/pref_service.h"
18 #include "grit/ash_resources.h" 18 #include "grit/ash_resources.h"
19 #include "third_party/cros_system_api/dbus/update_engine/dbus-constants.h"
20 #include "ui/base/l10n/l10n_util.h" 19 #include "ui/base/l10n/l10n_util.h"
21 #include "ui/base/resource/resource_bundle.h" 20 #include "ui/base/resource/resource_bundle.h"
22 21
23 using message_center::MessageCenter; 22 using message_center::MessageCenter;
24 23
25 namespace chromeos { 24 namespace chromeos {
26 namespace { 25 namespace {
27 26
28 const char kEolNotificationId[] = "eol"; 27 const char kEolNotificationId[] = "eol";
29 const char kDelegateId[] = "eol_delegate"; 28 const char kDelegateId[] = "eol_delegate";
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 86
88 void EolNotification::CheckEolStatus() { 87 void EolNotification::CheckEolStatus() {
89 UpdateEngineClient* update_engine_client = 88 UpdateEngineClient* update_engine_client =
90 DBusThreadManager::Get()->GetUpdateEngineClient(); 89 DBusThreadManager::Get()->GetUpdateEngineClient();
91 90
92 // Request the Eol Status. 91 // Request the Eol Status.
93 update_engine_client->GetEolStatus( 92 update_engine_client->GetEolStatus(
94 base::Bind(&EolNotification::OnEolStatus, weak_factory_.GetWeakPtr())); 93 base::Bind(&EolNotification::OnEolStatus, weak_factory_.GetWeakPtr()));
95 } 94 }
96 95
97 void EolNotification::OnEolStatus(int status) { 96 void EolNotification::OnEolStatus(update_engine::EndOfLifeStatus status) {
98 status_ = status; 97 status_ = status;
99 98
100 const int pre_eol_status = 99 const int pre_eol_status =
101 profile_->GetPrefs()->GetInteger(prefs::kEolStatus); 100 profile_->GetPrefs()->GetInteger(prefs::kEolStatus);
102 profile_->GetPrefs()->SetInteger(prefs::kEolStatus, status_); 101 profile_->GetPrefs()->SetInteger(prefs::kEolStatus, status_);
103 102
104 if (status_ == update_engine::EndOfLifeStatus::kSupported) 103 if (status_ == update_engine::EndOfLifeStatus::kSupported)
105 return; 104 return;
106 105
107 if (pre_eol_status != status_) { 106 if (pre_eol_status != status_) {
(...skipping 17 matching lines...) Expand all
125 124
126 void EolNotification::Update() { 125 void EolNotification::Update() {
127 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); 126 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
128 message_center::RichNotificationData data; 127 message_center::RichNotificationData data;
129 data.buttons.push_back(message_center::ButtonInfo( 128 data.buttons.push_back(message_center::ButtonInfo(
130 l10n_util::GetStringUTF16(IDS_EOL_MORE_INFO_BUTTON))); 129 l10n_util::GetStringUTF16(IDS_EOL_MORE_INFO_BUTTON)));
131 130
132 Notification notification( 131 Notification notification(
133 message_center::NOTIFICATION_TYPE_SIMPLE, 132 message_center::NOTIFICATION_TYPE_SIMPLE,
134 base::string16(), // title 133 base::string16(), // title
135 // TODO(xiaoyinh): Update the Eol icon once it's ready. 134 GetEolMessage(), bundle.GetImageNamed(IDR_AURA_NOTIFICATION_EOL),
136 GetEolMessage(), bundle.GetImageNamed(IDR_AURA_NOTIFICATION_DISPLAY),
137 message_center::NotifierId(message_center::NotifierId::SYSTEM_COMPONENT, 135 message_center::NotifierId(message_center::NotifierId::SYSTEM_COMPONENT,
138 kEolNotificationId), 136 kEolNotificationId),
139 base::string16(), // display_source 137 base::string16(), // display_source
140 GURL(), kEolNotificationId, data, new EolNotificationDelegate(profile_)); 138 GURL(), kEolNotificationId, data, new EolNotificationDelegate(profile_));
141 g_browser_process->notification_ui_manager()->Add(notification, profile_); 139 g_browser_process->notification_ui_manager()->Add(notification, profile_);
142 } 140 }
143 141
144 base::string16 EolNotification::GetEolMessage() { 142 base::string16 EolNotification::GetEolMessage() {
145 if (status_ == update_engine::EndOfLifeStatus::kSecurityOnly) { 143 if (status_ == update_engine::EndOfLifeStatus::kSecurityOnly) {
146 return l10n_util::GetStringUTF16(IDS_EOL_NOTIFICATION_SECURITY_ONLY); 144 return l10n_util::GetStringUTF16(IDS_EOL_NOTIFICATION_SECURITY_ONLY);
147 } else { 145 } else {
148 return l10n_util::GetStringUTF16(IDS_EOL_NOTIFICATION_EOL); 146 return l10n_util::GetStringUTF16(IDS_EOL_NOTIFICATION_EOL);
149 } 147 }
150 } 148 }
151 149
152 } // namespace chromeos 150 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698