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

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

Issue 1868363002: Replace scoped_ptr with std::unique_ptr in //ui (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@scopedptrcc
Patch Set: scopedptrui: rebase-make_scoped_ptr Created 4 years, 8 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/notification_list.h ('k') | ui/message_center/notification_list_unittest.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 (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 <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 bool was_popup = notification->shown_as_popup(); 80 bool was_popup = notification->shown_as_popup();
81 bool was_read = notification->IsRead(); 81 bool was_read = notification->IsRead();
82 if (notification->priority() < SYSTEM_PRIORITY) 82 if (notification->priority() < SYSTEM_PRIORITY)
83 notification->set_shown_as_popup(true); 83 notification->set_shown_as_popup(true);
84 notification->set_is_read(true); 84 notification->set_is_read(true);
85 if (updated_ids && !(was_popup && was_read)) 85 if (updated_ids && !(was_popup && was_read))
86 updated_ids->insert(notification->id()); 86 updated_ids->insert(notification->id());
87 } 87 }
88 } 88 }
89 89
90 void NotificationList::AddNotification(scoped_ptr<Notification> notification) { 90 void NotificationList::AddNotification(
91 std::unique_ptr<Notification> notification) {
91 PushNotification(std::move(notification)); 92 PushNotification(std::move(notification));
92 } 93 }
93 94
94 void NotificationList::UpdateNotificationMessage( 95 void NotificationList::UpdateNotificationMessage(
95 const std::string& old_id, 96 const std::string& old_id,
96 scoped_ptr<Notification> new_notification) { 97 std::unique_ptr<Notification> new_notification) {
97 Notifications::iterator iter = GetNotification(old_id); 98 Notifications::iterator iter = GetNotification(old_id);
98 if (iter == notifications_.end()) 99 if (iter == notifications_.end())
99 return; 100 return;
100 101
101 new_notification->CopyState(*iter); 102 new_notification->CopyState(*iter);
102 103
103 // Handles priority promotion. If the notification is already dismissed but 104 // Handles priority promotion. If the notification is already dismissed but
104 // the updated notification has higher priority, it should re-appear as a 105 // the updated notification has higher priority, it should re-appear as a
105 // toast. Notifications coming from websites through the Web Notification API 106 // toast. Notifications coming from websites through the Web Notification API
106 // will always re-appear on update. 107 // will always re-appear on update.
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 return iter; 323 return iter;
323 } 324 }
324 return notifications_.end(); 325 return notifications_.end();
325 } 326 }
326 327
327 void NotificationList::EraseNotification(Notifications::iterator iter) { 328 void NotificationList::EraseNotification(Notifications::iterator iter) {
328 delete *iter; 329 delete *iter;
329 notifications_.erase(iter); 330 notifications_.erase(iter);
330 } 331 }
331 332
332 void NotificationList::PushNotification(scoped_ptr<Notification> notification) { 333 void NotificationList::PushNotification(
334 std::unique_ptr<Notification> notification) {
333 // Ensure that notification.id is unique by erasing any existing 335 // Ensure that notification.id is unique by erasing any existing
334 // notification with the same id (shouldn't normally happen). 336 // notification with the same id (shouldn't normally happen).
335 Notifications::iterator iter = GetNotification(notification->id()); 337 Notifications::iterator iter = GetNotification(notification->id());
336 bool state_inherited = false; 338 bool state_inherited = false;
337 if (iter != notifications_.end()) { 339 if (iter != notifications_.end()) {
338 notification->CopyState(*iter); 340 notification->CopyState(*iter);
339 state_inherited = true; 341 state_inherited = true;
340 EraseNotification(iter); 342 EraseNotification(iter);
341 } 343 }
342 // Add the notification to the the list and mark it unread and unshown. 344 // Add the notification to the the list and mark it unread and unshown.
343 if (!state_inherited) { 345 if (!state_inherited) {
344 // TODO(mukai): needs to distinguish if a notification is dismissed by 346 // TODO(mukai): needs to distinguish if a notification is dismissed by
345 // the quiet mode or user operation. 347 // the quiet mode or user operation.
346 notification->set_is_read(false); 348 notification->set_is_read(false);
347 notification->set_shown_as_popup(message_center_visible_ 349 notification->set_shown_as_popup(message_center_visible_
348 || quiet_mode_ 350 || quiet_mode_
349 || notification->shown_as_popup()); 351 || notification->shown_as_popup());
350 } 352 }
351 // Take ownership. The notification can only be removed from the list 353 // Take ownership. The notification can only be removed from the list
352 // in EraseNotification(), which will delete it. 354 // in EraseNotification(), which will delete it.
353 notifications_.insert(notification.release()); 355 notifications_.insert(notification.release());
354 } 356 }
355 357
356 } // namespace message_center 358 } // namespace message_center
OLDNEW
« no previous file with comments | « ui/message_center/notification_list.h ('k') | ui/message_center/notification_list_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698