| OLD | NEW |
| 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/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 // list. In that case the widget for the notification has to be closed here. | 311 // list. In that case the widget for the notification has to be closed here. |
| 312 if (!updated) | 312 if (!updated) |
| 313 (*toast_iter)->CloseWithAnimation(true); | 313 (*toast_iter)->CloseWithAnimation(true); |
| 314 | 314 |
| 315 if (user_is_closing_toasts_by_clicking_) | 315 if (user_is_closing_toasts_by_clicking_) |
| 316 RepositionWidgetsWithTarget(); | 316 RepositionWidgetsWithTarget(); |
| 317 else | 317 else |
| 318 DoUpdateIfPossible(); | 318 DoUpdateIfPossible(); |
| 319 } | 319 } |
| 320 | 320 |
| 321 void MessagePopupCollection::SetWorkAreaForTest(const gfx::Rect& work_area) { | |
| 322 work_area_ = work_area; | |
| 323 } | |
| 324 | |
| 325 ToastContentsView* MessagePopupCollection::FindToast( | 321 ToastContentsView* MessagePopupCollection::FindToast( |
| 326 const std::string& notification_id) { | 322 const std::string& notification_id) { |
| 327 for (Toasts::iterator iter = toasts_.begin(); iter != toasts_.end(); ++iter) { | 323 for (Toasts::iterator iter = toasts_.begin(); iter != toasts_.end(); ++iter) { |
| 328 if ((*iter)->id() == notification_id) | 324 if ((*iter)->id() == notification_id) |
| 329 return *iter; | 325 return *iter; |
| 330 } | 326 } |
| 331 return NULL; | 327 return NULL; |
| 332 } | 328 } |
| 333 | 329 |
| 334 void MessagePopupCollection::IncrementDeferCounter() { | 330 void MessagePopupCollection::IncrementDeferCounter() { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 362 if (defer_counter_ > 0) | 358 if (defer_counter_ > 0) |
| 363 return; | 359 return; |
| 364 | 360 |
| 365 // Test support. Quit the test run loop when no more updates are deferred, | 361 // Test support. Quit the test run loop when no more updates are deferred, |
| 366 // meaining th echeck for updates did not cause anything to change so no new | 362 // meaining th echeck for updates did not cause anything to change so no new |
| 367 // transition animations were started. | 363 // transition animations were started. |
| 368 if (run_loop_for_test_.get()) | 364 if (run_loop_for_test_.get()) |
| 369 run_loop_for_test_->Quit(); | 365 run_loop_for_test_->Quit(); |
| 370 } | 366 } |
| 371 | 367 |
| 368 void MessagePopupCollection::SetWorkArea(const gfx::Rect& work_area) { |
| 369 if (work_area_ == work_area) |
| 370 return; |
| 371 |
| 372 work_area_ = work_area; |
| 373 RepositionWidgets(); |
| 374 } |
| 375 |
| 372 void MessagePopupCollection::OnDisplayBoundsChanged( | 376 void MessagePopupCollection::OnDisplayBoundsChanged( |
| 373 const gfx::Display& display) { | 377 const gfx::Display& display) { |
| 374 if (display.id() != display_id_) | 378 if (display.id() != display_id_) |
| 375 return; | 379 return; |
| 376 if (work_area_ == display.work_area()) | |
| 377 return; | |
| 378 | 380 |
| 379 work_area_ = display.work_area(); | 381 SetWorkArea(display.work_area()); |
| 380 RepositionWidgets(); | |
| 381 } | 382 } |
| 382 | 383 |
| 383 void MessagePopupCollection::OnDisplayAdded(const gfx::Display& new_display) { | 384 void MessagePopupCollection::OnDisplayAdded(const gfx::Display& new_display) { |
| 384 } | 385 } |
| 385 | 386 |
| 386 void MessagePopupCollection::OnDisplayRemoved(const gfx::Display& old_display) { | 387 void MessagePopupCollection::OnDisplayRemoved(const gfx::Display& old_display) { |
| 387 } | 388 } |
| 388 | 389 |
| 389 views::Widget* MessagePopupCollection::GetWidgetForTest(const std::string& id) { | 390 views::Widget* MessagePopupCollection::GetWidgetForTest(const std::string& id) { |
| 390 for (Toasts::iterator iter = toasts_.begin(); iter != toasts_.end(); ++iter) { | 391 for (Toasts::iterator iter = toasts_.begin(); iter != toasts_.end(); ++iter) { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 408 views::Widget* widget = (*iter)->GetWidget(); | 409 views::Widget* widget = (*iter)->GetWidget(); |
| 409 if (widget) | 410 if (widget) |
| 410 return widget->GetWindowBoundsInScreen(); | 411 return widget->GetWindowBoundsInScreen(); |
| 411 break; | 412 break; |
| 412 } | 413 } |
| 413 } | 414 } |
| 414 return gfx::Rect(); | 415 return gfx::Rect(); |
| 415 } | 416 } |
| 416 | 417 |
| 417 } // namespace message_center | 418 } // namespace message_center |
| OLD | NEW |