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

Side by Side Diff: ui/message_center/message_center_impl.cc

Issue 15582004: Move NotificationDelegate into message_center. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix Win browsertests. Created 7 years, 7 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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "ui/message_center/message_center_impl.h" 5 #include "ui/message_center/message_center_impl.h"
6 6
7 #include "base/observer_list.h" 7 #include "base/observer_list.h"
8 #include "ui/message_center/message_center_observer.h" 8 #include "ui/message_center/message_center_observer.h"
9 #include "ui/message_center/notification.h" 9 #include "ui/message_center/notification.h"
10 #include "ui/message_center/notification_list.h" 10 #include "ui/message_center/notification_list.h"
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 //------------------------------------------------------------------------------ 75 //------------------------------------------------------------------------------
76 // Client code interface. 76 // Client code interface.
77 77
78 void MessageCenterImpl::AddNotification( 78 void MessageCenterImpl::AddNotification(
79 NotificationType type, 79 NotificationType type,
80 const std::string& id, 80 const std::string& id,
81 const string16& title, 81 const string16& title,
82 const string16& message, 82 const string16& message,
83 const string16& display_source, 83 const string16& display_source,
84 const std::string& extension_id, 84 const std::string& extension_id,
85 const base::DictionaryValue* optional_fields) { 85 const base::DictionaryValue* optional_fields,
86 NotificationDelegate* delegate) {
86 // Sometimes the notification can be added with the same id and the 87 // Sometimes the notification can be added with the same id and the
87 // |notification_list| will replace the notification instead of adding new. 88 // |notification_list| will replace the notification instead of adding new.
88 // This is essentially an update rather than addition. 89 // This is essentially an update rather than addition.
89 bool already_exists = notification_list_->HasNotification(id); 90 bool already_exists = notification_list_->HasNotification(id);
90 notification_list_->AddNotification(type, id, title, message, display_source, 91 notification_list_->AddNotification(type,
91 extension_id, optional_fields); 92 id,
93 title,
94 message,
95 display_source,
96 extension_id,
97 optional_fields,
98 delegate);
92 if (already_exists) { 99 if (already_exists) {
93 FOR_EACH_OBSERVER(MessageCenterObserver, observer_list_, 100 FOR_EACH_OBSERVER(MessageCenterObserver, observer_list_,
94 OnNotificationUpdated(id)); 101 OnNotificationUpdated(id));
95 } else { 102 } else {
96 FOR_EACH_OBSERVER(MessageCenterObserver, observer_list_, 103 FOR_EACH_OBSERVER(MessageCenterObserver, observer_list_,
97 OnNotificationAdded(id)); 104 OnNotificationAdded(id));
98 } 105 }
99 } 106 }
100 107
101 void MessageCenterImpl::UpdateNotification( 108 void MessageCenterImpl::UpdateNotification(
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 notification_list_->MarkNotificationAsExpanded(id); 229 notification_list_->MarkNotificationAsExpanded(id);
223 FOR_EACH_OBSERVER(MessageCenterObserver, observer_list_, 230 FOR_EACH_OBSERVER(MessageCenterObserver, observer_list_,
224 OnNotificationUpdated(id)); 231 OnNotificationUpdated(id));
225 } 232 }
226 233
227 void MessageCenterImpl::ClickOnNotification(const std::string& id) { 234 void MessageCenterImpl::ClickOnNotification(const std::string& id) {
228 if (!HasNotification(id)) 235 if (!HasNotification(id))
229 return; 236 return;
230 if (HasPopupNotifications()) 237 if (HasPopupNotifications())
231 MarkSinglePopupAsShown(id, true); 238 MarkSinglePopupAsShown(id, true);
232 FOR_EACH_OBSERVER(MessageCenterObserver, observer_list_, 239 NotificationDelegate* delegate =
233 OnNotificationClicked(id)); 240 notification_list_->GetNotificationDelegate(id);
241 if (delegate)
242 delegate->Click();
243 FOR_EACH_OBSERVER(
244 MessageCenterObserver, observer_list_, OnNotificationClicked(id));
234 } 245 }
235 246
236 void MessageCenterImpl::ClickOnNotificationButton(const std::string& id, 247 void MessageCenterImpl::ClickOnNotificationButton(const std::string& id,
237 int button_index) { 248 int button_index) {
238 if (!HasNotification(id)) 249 if (!HasNotification(id))
239 return; 250 return;
240 if (HasPopupNotifications()) 251 if (HasPopupNotifications())
241 MarkSinglePopupAsShown(id, true); 252 MarkSinglePopupAsShown(id, true);
242 FOR_EACH_OBSERVER(MessageCenterObserver, observer_list_, 253 NotificationDelegate* delegate =
254 notification_list_->GetNotificationDelegate(id);
255 if (delegate)
256 delegate->ButtonClick(button_index);
257 FOR_EACH_OBSERVER(MessageCenterObserver,
Dmitry Titov 2013/05/24 01:11:57 you use different styles of wrapping long list of
258 observer_list_,
243 OnNotificationButtonClicked(id, button_index)); 259 OnNotificationButtonClicked(id, button_index));
244 } 260 }
245 261
246 void MessageCenterImpl::MarkSinglePopupAsShown(const std::string& id, 262 void MessageCenterImpl::MarkSinglePopupAsShown(const std::string& id,
247 bool mark_notification_as_read) { 263 bool mark_notification_as_read) {
248 if (!HasNotification(id)) 264 if (!HasNotification(id))
249 return; 265 return;
250 notification_list_->MarkSinglePopupAsShown(id, mark_notification_as_read); 266 notification_list_->MarkSinglePopupAsShown(id, mark_notification_as_read);
251 FOR_EACH_OBSERVER(MessageCenterObserver, observer_list_, 267 FOR_EACH_OBSERVER(MessageCenterObserver, observer_list_,
252 OnNotificationUpdated(id)); 268 OnNotificationUpdated(id));
253 } 269 }
254 270
255 void MessageCenterImpl::DisplayedNotification(const std::string& id) { 271 void MessageCenterImpl::DisplayedNotification(const std::string& id) {
256 if (!HasNotification(id)) 272 if (!HasNotification(id))
257 return; 273 return;
258 274
259 if (HasPopupNotifications()) 275 if (HasPopupNotifications())
260 notification_list_->MarkSinglePopupAsDisplayed(id); 276 notification_list_->MarkSinglePopupAsDisplayed(id);
261 FOR_EACH_OBSERVER(MessageCenterObserver, observer_list_, 277 NotificationDelegate* delegate =
262 OnNotificationDisplayed(id)); 278 notification_list_->GetNotificationDelegate(id);
279 if (delegate)
280 delegate->Display();
281 FOR_EACH_OBSERVER(
282 MessageCenterObserver, observer_list_, OnNotificationDisplayed(id));
263 } 283 }
264 284
265 void MessageCenterImpl::SetQuietMode(bool in_quiet_mode) { 285 void MessageCenterImpl::SetQuietMode(bool in_quiet_mode) {
266 notification_list_->SetQuietMode(in_quiet_mode); 286 notification_list_->SetQuietMode(in_quiet_mode);
267 } 287 }
268 288
269 void MessageCenterImpl::EnterQuietModeWithExpire( 289 void MessageCenterImpl::EnterQuietModeWithExpire(
270 const base::TimeDelta& expires_in) { 290 const base::TimeDelta& expires_in) {
271 notification_list_->EnterQuietModeWithExpire(expires_in); 291 notification_list_->EnterQuietModeWithExpire(expires_in);
272 } 292 }
273 293
274 } // namespace message_center 294 } // namespace message_center
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698