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

Side by Side Diff: ui/message_center/views/message_popup_collection.cc

Issue 14017014: Sends updated event for click on notifications. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add tests Created 7 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 | Annotate | Revision Log
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/views/message_popup_collection.h" 5 #include "ui/message_center/views/message_popup_collection.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 if (by_user && widgets_went_empty) 380 if (by_user && widgets_went_empty)
381 RepositionWidgetsWithTarget(removed_bounds); 381 RepositionWidgetsWithTarget(removed_bounds);
382 } 382 }
383 383
384 void MessagePopupCollection::OnNotificationUpdated( 384 void MessagePopupCollection::OnNotificationUpdated(
385 const std::string& notification_id) { 385 const std::string& notification_id) {
386 ToastContainer::iterator toast_iter = toasts_.find(notification_id); 386 ToastContainer::iterator toast_iter = toasts_.find(notification_id);
387 if (toast_iter == toasts_.end()) 387 if (toast_iter == toasts_.end())
388 return; 388 return;
389 389
390 NotificationList::Notifications notifications = 390 NotificationList::PopupNotifications notifications =
391 message_center_->GetNotifications(); 391 message_center_->GetPopupNotifications();
392 bool updated = false; 392 bool updated = false;
393 for (NotificationList::Notifications::iterator iter = 393 for (NotificationList::PopupNotifications::iterator iter =
394 notifications.begin(); iter != notifications.end(); ++iter) { 394 notifications.begin(); iter != notifications.end(); ++iter) {
395 if ((*iter)->id() != notification_id) 395 if ((*iter)->id() != notification_id)
396 continue; 396 continue;
397 397
398 MessageView* view = NotificationView::Create( 398 MessageView* view = NotificationView::Create(
399 *(*iter), message_center_, true); 399 *(*iter), message_center_, true);
400 toast_iter->second->SetContents(view); 400 toast_iter->second->SetContents(view);
401 toast_iter->second->ResetTimeout((*iter)->priority()); 401 toast_iter->second->ResetTimeout((*iter)->priority());
402 toast_iter->second->RestartTimer(); 402 toast_iter->second->RestartTimer();
403 updated = true; 403 updated = true;
404 } 404 }
405 405
406 if (updated) { 406 // Updated() can be called when a notification is excluded from the popup
dewittj 2013/04/18 17:40:51 nit: OnNotificationUpdated() - it made me wonder i
Jun Mukai 2013/04/18 20:22:12 Done.
407 RepositionWidgets(); 407 // notification list but still remains in the full notification list.
408 // Reposition could create extra space which allows additional widgets. 408 // In that case the widget for the notification has to be closed here.
409 UpdateWidgets(); 409 if (!updated) {
410 views::Widget* widget = toast_iter->second->GetWidget();
411 widget->RemoveObserver(this);
412 widgets_.erase(std::find(widgets_.begin(), widgets_.end(), widget));
413 widget->Close();
414 toasts_.erase(toast_iter);
410 } 415 }
416
417 RepositionWidgets();
418 // Reposition could create extra space which allows additional widgets.
419 UpdateWidgets();
411 } 420 }
412 421
413 void MessagePopupCollection::SetWorkAreaForTest(const gfx::Rect& work_area) { 422 void MessagePopupCollection::SetWorkAreaForTest(const gfx::Rect& work_area) {
414 work_area_ = work_area; 423 work_area_ = work_area;
415 } 424 }
416 425
426 views::Widget* MessagePopupCollection::GetWidgetForId(const std::string& id) {
427 ToastContainer::const_iterator iter = toasts_.find(id);
428 return (iter == toasts_.end()) ? NULL : iter->second->GetWidget();
429 }
430
417 } // namespace message_center 431 } // namespace message_center
OLDNEW
« no previous file with comments | « ui/message_center/views/message_popup_collection.h ('k') | ui/message_center/views/message_popup_collection_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698