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

Unified 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: incorporate comments from isherman@ 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/eol_notification.cc
diff --git a/chrome/browser/chromeos/eol_notification.cc b/chrome/browser/chromeos/eol_notification.cc
index 8b5f49eb2e14b5fde57624419b074d185921ecb8..692494d8576e256e333a3498a9e3ab9d85c31485 100644
--- a/chrome/browser/chromeos/eol_notification.cc
+++ b/chrome/browser/chromeos/eol_notification.cc
@@ -15,10 +15,10 @@
#include "chromeos/dbus/dbus_thread_manager.h"
#include "chromeos/dbus/update_engine_client.h"
#include "components/prefs/pref_service.h"
-#include "grit/ash_resources.h"
-#include "third_party/cros_system_api/dbus/update_engine/dbus-constants.h"
#include "ui/base/l10n/l10n_util.h"
-#include "ui/base/resource/resource_bundle.h"
+#include "ui/gfx/color_palette.h"
+#include "ui/gfx/paint_vector_icon.h"
+#include "ui/gfx/vector_icons_public.h"
using message_center::MessageCenter;
@@ -27,22 +27,27 @@ namespace {
const char kEolNotificationId[] = "eol";
const char kDelegateId[] = "eol_delegate";
+const SkColor kButtonIconColor = SkColorSetRGB(150, 150, 152);
+const SkColor kNotificationIconColor = SkColorSetRGB(219, 68, 55);
class EolNotificationDelegate : public NotificationDelegate {
public:
explicit EolNotificationDelegate(Profile* profile);
private:
+ // Buttons that appear in notifications.
+ enum EOL_Button { BUTTON_MORE_INFO = 0, BUTTON_DISMISS };
+
~EolNotificationDelegate() override;
// NotificationDelegate overrides:
- void Close(bool by_user) override;
void ButtonClick(int button_index) override;
std::string id() const override;
Profile* const profile_;
void OpenMoreInfoPage();
+ void CancelNotification();
DISALLOW_COPY_AND_ASSIGN(EolNotificationDelegate);
};
@@ -52,16 +57,20 @@ EolNotificationDelegate::EolNotificationDelegate(Profile* profile)
EolNotificationDelegate::~EolNotificationDelegate() {}
-void EolNotificationDelegate::Close(bool by_user) {
- if (by_user) {
- // set dismiss pref.
- profile_->GetPrefs()->SetBoolean(prefs::kEolNotificationDismissed, true);
- }
-}
-
void EolNotificationDelegate::ButtonClick(int button_index) {
- // show eol link
- OpenMoreInfoPage();
+ switch (button_index) {
+ case BUTTON_MORE_INFO:
+ // show eol link
+ OpenMoreInfoPage();
+ break;
+ case BUTTON_DISMISS:
+ // set dismiss pref.
+ profile_->GetPrefs()->SetBoolean(prefs::kEolNotificationDismissed, true);
+ break;
+ default:
+ NOTREACHED();
+ }
+ CancelNotification();
}
std::string EolNotificationDelegate::id() const {
@@ -76,6 +85,12 @@ void EolNotificationDelegate::OpenMoreInfoPage() {
chrome::Navigate(&params);
}
+void EolNotificationDelegate::CancelNotification() {
+ // Clean up the notification
+ g_browser_process->notification_ui_manager()->CancelById(
+ id(), NotificationUIManager::GetProfileID(profile_));
+}
+
} // namespace
EolNotification::EolNotification(Profile* profile)
@@ -94,7 +109,7 @@ void EolNotification::CheckEolStatus() {
base::Bind(&EolNotification::OnEolStatus, weak_factory_.GetWeakPtr()));
}
-void EolNotification::OnEolStatus(int status) {
+void EolNotification::OnEolStatus(update_engine::EndOfLifeStatus status) {
status_ = status;
const int pre_eol_status =
@@ -124,16 +139,24 @@ void EolNotification::OnEolStatus(int status) {
}
void EolNotification::Update() {
- ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
+ message_center::ButtonInfo learn_more(
+ l10n_util::GetStringUTF16(IDS_EOL_MORE_INFO_BUTTON));
+ learn_more.icon = gfx::Image(
+ CreateVectorIcon(gfx::VectorIconId::INFO_OUTLINE, kButtonIconColor));
+ message_center::ButtonInfo dismiss(
+ l10n_util::GetStringUTF16(IDS_EOL_DISMISS_BUTTON));
+ dismiss.icon = gfx::Image(
+ CreateVectorIcon(gfx::VectorIconId::NOTIFICATIONS_OFF, kButtonIconColor));
+
message_center::RichNotificationData data;
- data.buttons.push_back(message_center::ButtonInfo(
- l10n_util::GetStringUTF16(IDS_EOL_MORE_INFO_BUTTON)));
+ data.buttons.push_back(learn_more);
+ data.buttons.push_back(dismiss);
Notification notification(
message_center::NOTIFICATION_TYPE_SIMPLE,
- base::string16(), // title
- // TODO(xiaoyinh): Update the Eol icon once it's ready.
- GetEolMessage(), bundle.GetImageNamed(IDR_AURA_NOTIFICATION_DISPLAY),
+ l10n_util::GetStringUTF16(IDS_EOL_NOTIFICATION_TITLE), GetEolMessage(),
+ gfx::Image(
+ CreateVectorIcon(gfx::VectorIconId::EOL, kNotificationIconColor)),
message_center::NotifierId(message_center::NotifierId::SYSTEM_COMPONENT,
kEolNotificationId),
base::string16(), // display_source
« no previous file with comments | « chrome/browser/chromeos/eol_notification.h ('k') | chrome/browser/chromeos/login/session/user_session_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698