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

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

Issue 2712213002: Remove notification and message for security-only state (Closed)
Patch Set: rebase Created 3 years, 9 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/app/chromeos_strings.grdp ('k') | chrome/browser/ui/webui/help/help_handler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 base::Bind(&EolNotification::OnEolStatus, weak_factory_.GetWeakPtr())); 109 base::Bind(&EolNotification::OnEolStatus, weak_factory_.GetWeakPtr()));
110 } 110 }
111 111
112 void EolNotification::OnEolStatus(update_engine::EndOfLifeStatus status) { 112 void EolNotification::OnEolStatus(update_engine::EndOfLifeStatus status) {
113 status_ = status; 113 status_ = status;
114 114
115 const int pre_eol_status = 115 const int pre_eol_status =
116 profile_->GetPrefs()->GetInteger(prefs::kEolStatus); 116 profile_->GetPrefs()->GetInteger(prefs::kEolStatus);
117 profile_->GetPrefs()->SetInteger(prefs::kEolStatus, status_); 117 profile_->GetPrefs()->SetInteger(prefs::kEolStatus, status_);
118 118
119 if (status_ == update_engine::EndOfLifeStatus::kSupported) 119 // Security only state is no longer supported.
120 if (status_ == update_engine::EndOfLifeStatus::kSupported ||
121 status_ == update_engine::EndOfLifeStatus::kSecurityOnly) {
120 return; 122 return;
123 }
121 124
122 if (pre_eol_status != status_) { 125 if (pre_eol_status != status_) {
123 // If Eol status has changed, we should reset 126 // If Eol status has changed, we should reset
124 // kEolNotificationDismissed and show notification. 127 // kEolNotificationDismissed and show notification.
125 profile_->GetPrefs()->SetBoolean(prefs::kEolNotificationDismissed, false); 128 profile_->GetPrefs()->SetBoolean(prefs::kEolNotificationDismissed, false);
126 } 129 }
127 130
128 bool user_dismissed_eol_notification = 131 bool user_dismissed_eol_notification =
129 profile_->GetPrefs()->GetBoolean(prefs::kEolNotificationDismissed); 132 profile_->GetPrefs()->GetBoolean(prefs::kEolNotificationDismissed);
130 if (user_dismissed_eol_notification) 133 if (user_dismissed_eol_notification)
131 return; 134 return;
132 135
133 // When device is in Security-Only state, only show notification the first
134 // time.
135 if (status_ == update_engine::EndOfLifeStatus::kSecurityOnly)
136 profile_->GetPrefs()->SetBoolean(prefs::kEolNotificationDismissed, true);
137
138 Update(); 136 Update();
139 } 137 }
140 138
141 void EolNotification::Update() { 139 void EolNotification::Update() {
142 message_center::ButtonInfo learn_more( 140 message_center::ButtonInfo learn_more(
143 l10n_util::GetStringUTF16(IDS_EOL_MORE_INFO_BUTTON)); 141 l10n_util::GetStringUTF16(IDS_EOL_MORE_INFO_BUTTON));
144 learn_more.icon = gfx::Image( 142 learn_more.icon = gfx::Image(
145 CreateVectorIcon(gfx::VectorIconId::INFO_OUTLINE, kButtonIconColor)); 143 CreateVectorIcon(gfx::VectorIconId::INFO_OUTLINE, kButtonIconColor));
146 message_center::ButtonInfo dismiss( 144 message_center::ButtonInfo dismiss(
147 l10n_util::GetStringUTF16(IDS_EOL_DISMISS_BUTTON)); 145 l10n_util::GetStringUTF16(IDS_EOL_DISMISS_BUTTON));
148 dismiss.icon = gfx::Image( 146 dismiss.icon = gfx::Image(
149 CreateVectorIcon(gfx::VectorIconId::NOTIFICATIONS_OFF, kButtonIconColor)); 147 CreateVectorIcon(gfx::VectorIconId::NOTIFICATIONS_OFF, kButtonIconColor));
150 148
151 message_center::RichNotificationData data; 149 message_center::RichNotificationData data;
152 data.buttons.push_back(learn_more); 150 data.buttons.push_back(learn_more);
153 data.buttons.push_back(dismiss); 151 data.buttons.push_back(dismiss);
154 152
155 Notification notification( 153 Notification notification(
156 message_center::NOTIFICATION_TYPE_SIMPLE, 154 message_center::NOTIFICATION_TYPE_SIMPLE,
157 l10n_util::GetStringUTF16(IDS_EOL_NOTIFICATION_TITLE), GetEolMessage(), 155 l10n_util::GetStringUTF16(IDS_EOL_NOTIFICATION_TITLE),
156 l10n_util::GetStringUTF16(IDS_EOL_NOTIFICATION_EOL),
158 gfx::Image( 157 gfx::Image(
159 CreateVectorIcon(gfx::VectorIconId::EOL, kNotificationIconColor)), 158 CreateVectorIcon(gfx::VectorIconId::EOL, kNotificationIconColor)),
160 message_center::NotifierId(message_center::NotifierId::SYSTEM_COMPONENT, 159 message_center::NotifierId(message_center::NotifierId::SYSTEM_COMPONENT,
161 kEolNotificationId), 160 kEolNotificationId),
162 base::string16(), // display_source 161 base::string16(), // display_source
163 GURL(), kEolNotificationId, data, new EolNotificationDelegate(profile_)); 162 GURL(), kEolNotificationId, data, new EolNotificationDelegate(profile_));
164 g_browser_process->notification_ui_manager()->Add(notification, profile_); 163 g_browser_process->notification_ui_manager()->Add(notification, profile_);
165 } 164 }
166 165
167 base::string16 EolNotification::GetEolMessage() {
168 if (status_ == update_engine::EndOfLifeStatus::kSecurityOnly) {
169 return l10n_util::GetStringUTF16(IDS_EOL_NOTIFICATION_SECURITY_ONLY);
170 } else {
171 return l10n_util::GetStringUTF16(IDS_EOL_NOTIFICATION_EOL);
172 }
173 }
174
175 } // namespace chromeos 166 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/app/chromeos_strings.grdp ('k') | chrome/browser/ui/webui/help/help_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698