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

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

Issue 14631005: Enable users of NotificationUIManager to specify binary images. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase for relanding. Created 7 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
« no previous file with comments | « ui/message_center/message_center_impl.h ('k') | ui/message_center/message_center_style.h » ('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 (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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 return notification_list_->GetNotifications(); 73 return notification_list_->GetNotifications();
74 } 74 }
75 75
76 NotificationList::PopupNotifications 76 NotificationList::PopupNotifications
77 MessageCenterImpl::GetPopupNotifications() { 77 MessageCenterImpl::GetPopupNotifications() {
78 return notification_list_->GetPopupNotifications(); 78 return notification_list_->GetPopupNotifications();
79 } 79 }
80 80
81 //------------------------------------------------------------------------------ 81 //------------------------------------------------------------------------------
82 // Client code interface. 82 // Client code interface.
83 void MessageCenterImpl::AddNotification(scoped_ptr<Notification> notification) {
84 DCHECK(notification.get());
83 85
84 void MessageCenterImpl::AddNotification(
85 NotificationType type,
86 const std::string& id,
87 const string16& title,
88 const string16& message,
89 const string16& display_source,
90 const std::string& extension_id,
91 const base::DictionaryValue* optional_fields,
92 NotificationDelegate* delegate) {
93 // Sometimes the notification can be added with the same id and the 86 // Sometimes the notification can be added with the same id and the
94 // |notification_list| will replace the notification instead of adding new. 87 // |notification_list| will replace the notification instead of adding new.
95 // This is essentially an update rather than addition. 88 // This is essentially an update rather than addition.
89 const std::string& id = notification->id();
96 bool already_exists = notification_list_->HasNotification(id); 90 bool already_exists = notification_list_->HasNotification(id);
97 notification_list_->AddNotification(type, 91 notification_list_->AddNotification(notification.Pass());
98 id, 92
99 title,
100 message,
101 display_source,
102 extension_id,
103 optional_fields,
104 delegate);
105 if (already_exists) { 93 if (already_exists) {
106 FOR_EACH_OBSERVER(MessageCenterObserver, observer_list_, 94 FOR_EACH_OBSERVER(
107 OnNotificationUpdated(id)); 95 MessageCenterObserver, observer_list_, OnNotificationUpdated(id));
108 } else { 96 } else {
109 FOR_EACH_OBSERVER(MessageCenterObserver, observer_list_, 97 FOR_EACH_OBSERVER(
110 OnNotificationAdded(id)); 98 MessageCenterObserver, observer_list_, OnNotificationAdded(id));
111 } 99 }
112 } 100 }
113 101
114 void MessageCenterImpl::UpdateNotification( 102 void MessageCenterImpl::UpdateNotification(
115 const std::string& old_id, 103 const std::string& old_id,
116 const std::string& new_id, 104 scoped_ptr<Notification> new_notification) {
117 const string16& title, 105 std::string new_id = new_notification->id();
118 const string16& message, 106 notification_list_->UpdateNotificationMessage(old_id,
119 const base::DictionaryValue* optional_fields, 107 new_notification.Pass());
120 NotificationDelegate* delegate) {
121 notification_list_->UpdateNotificationMessage(
122 old_id, new_id, title, message, optional_fields, delegate);
123 if (old_id == new_id) { 108 if (old_id == new_id) {
124 FOR_EACH_OBSERVER(MessageCenterObserver, observer_list_, 109 FOR_EACH_OBSERVER(MessageCenterObserver, observer_list_,
125 OnNotificationUpdated(new_id)); 110 OnNotificationUpdated(new_id));
126 } else { 111 } else {
127 FOR_EACH_OBSERVER(MessageCenterObserver, observer_list_, 112 FOR_EACH_OBSERVER(MessageCenterObserver, observer_list_,
128 OnNotificationRemoved(old_id, false)); 113 OnNotificationRemoved(old_id, false));
129 FOR_EACH_OBSERVER(MessageCenterObserver, observer_list_, 114 FOR_EACH_OBSERVER(MessageCenterObserver, observer_list_,
130 OnNotificationAdded(new_id)); 115 OnNotificationAdded(new_id));
131 } 116 }
132 } 117 }
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 void MessageCenterImpl::SetQuietMode(bool in_quiet_mode) { 277 void MessageCenterImpl::SetQuietMode(bool in_quiet_mode) {
293 notification_list_->SetQuietMode(in_quiet_mode); 278 notification_list_->SetQuietMode(in_quiet_mode);
294 } 279 }
295 280
296 void MessageCenterImpl::EnterQuietModeWithExpire( 281 void MessageCenterImpl::EnterQuietModeWithExpire(
297 const base::TimeDelta& expires_in) { 282 const base::TimeDelta& expires_in) {
298 notification_list_->EnterQuietModeWithExpire(expires_in); 283 notification_list_->EnterQuietModeWithExpire(expires_in);
299 } 284 }
300 285
301 } // namespace message_center 286 } // namespace message_center
OLDNEW
« no previous file with comments | « ui/message_center/message_center_impl.h ('k') | ui/message_center/message_center_style.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698