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

Side by Side Diff: ui/message_center/notification_list.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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/notification_list.h" 5 #include "ui/message_center/notification_list.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "base/time.h" 10 #include "base/time.h"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 Notification* notification = *iter; 64 Notification* notification = *iter;
65 notification->set_shown_as_popup(true); 65 notification->set_shown_as_popup(true);
66 notification->set_is_read(true); 66 notification->set_is_read(true);
67 if (updated_ids && 67 if (updated_ids &&
68 !(notification->shown_as_popup() && notification->is_read())) { 68 !(notification->shown_as_popup() && notification->is_read())) {
69 updated_ids->insert(notification->id()); 69 updated_ids->insert(notification->id());
70 } 70 }
71 } 71 }
72 } 72 }
73 73
74 void NotificationList::AddNotification( 74 void NotificationList::AddNotification(NotificationType type,
75 NotificationType type, 75 const std::string& id,
76 const std::string& id, 76 const string16& title,
77 const string16& title, 77 const string16& message,
78 const string16& message, 78 const string16& display_source,
79 const string16& display_source, 79 const std::string& extension_id,
80 const std::string& extension_id, 80 const DictionaryValue* optional_fields,
81 const DictionaryValue* optional_fields) { 81 NotificationDelegate* delegate) {
82 scoped_ptr<Notification> notification( 82 scoped_ptr<Notification> notification(new Notification(type,
83 new Notification(type, id, title, message, display_source, extension_id, 83 id,
84 optional_fields)); 84 title,
85 message,
86 display_source,
87 extension_id,
88 optional_fields,
89 delegate));
85 PushNotification(notification.Pass()); 90 PushNotification(notification.Pass());
86 } 91 }
87 92
88 void NotificationList::UpdateNotificationMessage( 93 void NotificationList::UpdateNotificationMessage(
89 const std::string& old_id, 94 const std::string& old_id,
90 const std::string& new_id, 95 const std::string& new_id,
91 const string16& title, 96 const string16& title,
92 const string16& message, 97 const string16& message,
93 const base::DictionaryValue* optional_fields) { 98 const base::DictionaryValue* optional_fields) {
94 Notifications::iterator iter = GetNotification(old_id); 99 Notifications::iterator iter = GetNotification(old_id);
95 if (iter == notifications_.end()) 100 if (iter == notifications_.end())
96 return; 101 return;
97 102
98 // Copy and update a notification. It has an effect of setting a new timestamp 103 // Copy and update a notification. It has an effect of setting a new timestamp
99 // if not overridden by optional_fields 104 // if not overridden by optional_fields
100 scoped_ptr<Notification> notification( 105 scoped_ptr<Notification> notification(
101 new Notification((*iter)->type(), 106 new Notification((*iter)->type(),
102 new_id, 107 new_id,
103 title, 108 title,
104 message, 109 message,
105 (*iter)->display_source(), 110 (*iter)->display_source(),
106 (*iter)->extension_id(), 111 (*iter)->extension_id(),
107 optional_fields)); 112 optional_fields,
113 NULL));
108 notification->CopyState(*iter); 114 notification->CopyState(*iter);
109 115
110 // Handles priority promotion. If the notification is already dismissed but 116 // Handles priority promotion. If the notification is already dismissed but
111 // the updated notification has higher priority, it should re-appear as a 117 // the updated notification has higher priority, it should re-appear as a
112 // toast. 118 // toast.
113 if ((*iter)->priority() < notification->priority()) { 119 if ((*iter)->priority() < notification->priority()) {
114 notification->set_is_read(false); 120 notification->set_is_read(false);
115 notification->set_shown_as_popup(false); 121 notification->set_shown_as_popup(false);
116 } 122 }
117 123
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 --unread_count_; 284 --unread_count_;
279 } 285 }
280 } 286 }
281 287
282 void NotificationList::MarkNotificationAsExpanded(const std::string& id) { 288 void NotificationList::MarkNotificationAsExpanded(const std::string& id) {
283 Notifications::iterator iter = GetNotification(id); 289 Notifications::iterator iter = GetNotification(id);
284 if (iter != notifications_.end()) 290 if (iter != notifications_.end())
285 (*iter)->set_is_expanded(true); 291 (*iter)->set_is_expanded(true);
286 } 292 }
287 293
294 NotificationDelegate* NotificationList::GetNotificationDelegate(
295 const std::string& id) {
296 Notifications::iterator iter = GetNotification(id);
297 if (iter == notifications_.end())
298 return NULL;
299 return (*iter)->delegate();
300 }
301
288 void NotificationList::SetQuietMode(bool quiet_mode) { 302 void NotificationList::SetQuietMode(bool quiet_mode) {
289 SetQuietModeInternal(quiet_mode); 303 SetQuietModeInternal(quiet_mode);
290 quiet_mode_timer_.reset(); 304 quiet_mode_timer_.reset();
291 } 305 }
292 306
293 void NotificationList::EnterQuietModeWithExpire( 307 void NotificationList::EnterQuietModeWithExpire(
294 const base::TimeDelta& expires_in) { 308 const base::TimeDelta& expires_in) {
295 if (quiet_mode_timer_.get()) { 309 if (quiet_mode_timer_.get()) {
296 // Note that the capital Reset() is the method to restart the timer, not 310 // Note that the capital Reset() is the method to restart the timer, not
297 // scoped_ptr::reset(). 311 // scoped_ptr::reset().
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 notification->set_shown_as_popup(message_center_visible_ || quiet_mode_); 373 notification->set_shown_as_popup(message_center_visible_ || quiet_mode_);
360 if (!quiet_mode_ && notification->priority() > MIN_PRIORITY) 374 if (!quiet_mode_ && notification->priority() > MIN_PRIORITY)
361 ++unread_count_; 375 ++unread_count_;
362 } 376 }
363 // Take ownership. The notification can only be removed from the list 377 // Take ownership. The notification can only be removed from the list
364 // in EraseNotification(), which will delete it. 378 // in EraseNotification(), which will delete it.
365 notifications_.insert(notification.release()); 379 notifications_.insert(notification.release());
366 } 380 }
367 381
368 } // namespace message_center 382 } // namespace message_center
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698