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

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

Issue 21308002: Update Mac notification tray behavior. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments from #1 Created 7 years, 4 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 | Annotate | Revision Log
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/time.h" 10 #include "base/time/time.h"
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 309
310 size_t NotificationList::NotificationCount() const { 310 size_t NotificationList::NotificationCount() const {
311 return notifications_.size(); 311 return notifications_.size();
312 } 312 }
313 313
314 void NotificationList::SetQuietModeInternal(bool quiet_mode) { 314 void NotificationList::SetQuietModeInternal(bool quiet_mode) {
315 quiet_mode_ = quiet_mode; 315 quiet_mode_ = quiet_mode;
316 if (quiet_mode_) { 316 if (quiet_mode_) {
317 for (Notifications::iterator iter = notifications_.begin(); 317 for (Notifications::iterator iter = notifications_.begin();
318 iter != notifications_.end(); ++iter) { 318 iter != notifications_.end(); ++iter) {
319 (*iter)->set_is_read(true);
320 (*iter)->set_shown_as_popup(true); 319 (*iter)->set_shown_as_popup(true);
321 } 320 }
322 unread_count_ = 0;
323 } 321 }
324 } 322 }
325 323
326 NotificationList::Notifications::iterator 324 NotificationList::Notifications::iterator
327 NotificationList::GetNotification(const std::string& id) { 325 NotificationList::GetNotification(const std::string& id) {
328 for (Notifications::iterator iter = notifications_.begin(); 326 for (Notifications::iterator iter = notifications_.begin();
329 iter != notifications_.end(); ++iter) { 327 iter != notifications_.end(); ++iter) {
330 if ((*iter)->id() == id) 328 if ((*iter)->id() == id)
331 return iter; 329 return iter;
332 } 330 }
(...skipping 14 matching lines...) Expand all
347 bool state_inherited = false; 345 bool state_inherited = false;
348 if (iter != notifications_.end()) { 346 if (iter != notifications_.end()) {
349 notification->CopyState(*iter); 347 notification->CopyState(*iter);
350 state_inherited = true; 348 state_inherited = true;
351 EraseNotification(iter); 349 EraseNotification(iter);
352 } 350 }
353 // Add the notification to the the list and mark it unread and unshown. 351 // Add the notification to the the list and mark it unread and unshown.
354 if (!state_inherited) { 352 if (!state_inherited) {
355 // TODO(mukai): needs to distinguish if a notification is dismissed by 353 // TODO(mukai): needs to distinguish if a notification is dismissed by
356 // the quiet mode or user operation. 354 // the quiet mode or user operation.
357 notification->set_is_read(quiet_mode_); 355 notification->set_is_read(false);
358 notification->set_shown_as_popup(message_center_visible_ || quiet_mode_); 356 notification->set_shown_as_popup(message_center_visible_ || quiet_mode_);
359 if (!quiet_mode_ && notification->priority() > MIN_PRIORITY) 357 if (notification->priority() > MIN_PRIORITY)
360 ++unread_count_; 358 ++unread_count_;
361 } 359 }
362 // Take ownership. The notification can only be removed from the list 360 // Take ownership. The notification can only be removed from the list
363 // in EraseNotification(), which will delete it. 361 // in EraseNotification(), which will delete it.
364 notifications_.insert(notification.release()); 362 notifications_.insert(notification.release());
365 } 363 }
366 364
367 } // namespace message_center 365 } // namespace message_center
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698