Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/notifications/balloon_collection_impl.h" | 5 #include "chrome/browser/notifications/balloon_collection_impl.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 "chrome/browser/notifications/balloon.h" | 10 #include "chrome/browser/notifications/balloon.h" |
| 11 #include "chrome/browser/notifications/balloon_host.h" | 11 #include "chrome/browser/notifications/balloon_host.h" |
| 12 #include "chrome/browser/notifications/notification.h" | 12 #include "chrome/browser/notifications/notification.h" |
| 13 #include "chrome/browser/ui/browser.h" | 13 #include "chrome/browser/ui/browser.h" |
| 14 #include "chrome/browser/ui/panels/panel.h" | 14 #include "chrome/browser/ui/panels/panel.h" |
| 15 #include "chrome/browser/ui/panels/panel_manager.h" | 15 #include "chrome/browser/ui/panels/panel_manager.h" |
| 16 #include "chrome/browser/ui/panels/panel_strip.h" | |
| 16 #include "chrome/common/chrome_notification_types.h" | 17 #include "chrome/common/chrome_notification_types.h" |
| 17 #include "content/public/browser/notification_registrar.h" | 18 #include "content/public/browser/notification_registrar.h" |
| 18 #include "content/public/browser/notification_service.h" | 19 #include "content/public/browser/notification_service.h" |
| 19 #include "ui/gfx/rect.h" | 20 #include "ui/gfx/rect.h" |
| 20 #include "ui/gfx/screen.h" | 21 #include "ui/gfx/screen.h" |
| 21 #include "ui/gfx/size.h" | 22 #include "ui/gfx/size.h" |
| 22 | 23 |
| 23 namespace { | 24 namespace { |
| 24 | 25 |
| 25 // Portion of the screen allotted for notifications. When notification balloons | 26 // Portion of the screen allotted for notifications. When notification balloons |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 392 // restrict to the min & max sizes | 393 // restrict to the min & max sizes |
| 393 return gfx::Size( | 394 return gfx::Size( |
| 394 std::max(min_balloon_width(), | 395 std::max(min_balloon_width(), |
| 395 std::min(max_balloon_width(), size.width())), | 396 std::min(max_balloon_width(), size.width())), |
| 396 std::max(min_balloon_height(), | 397 std::max(min_balloon_height(), |
| 397 std::min(max_balloon_height(), size.height()))); | 398 std::min(max_balloon_height(), size.height()))); |
| 398 } | 399 } |
| 399 | 400 |
| 400 bool BalloonCollectionImpl::Layout::ComputeOffsetToMoveAbovePanels( | 401 bool BalloonCollectionImpl::Layout::ComputeOffsetToMoveAbovePanels( |
| 401 const gfx::Rect& panel_bounds) { | 402 const gfx::Rect& panel_bounds) { |
| 402 const PanelManager::Panels& panels = PanelManager::GetInstance()->panels(); | 403 const PanelManager::Panels& panels = |
|
jennb
2011/12/08 23:52:00
Use std::<vector> instead?
jianli
2011/12/09 22:39:07
Done.
| |
| 404 PanelManager::GetInstance()->panel_strip()->panels(); | |
|
jennb
2011/12/08 23:52:00
Any way to get all panels and look for any panels
jianli
2011/12/09 22:39:07
I will rework on balloon interaction with overflow
| |
| 403 int offset_to_move_above_panels = 0; | 405 int offset_to_move_above_panels = 0; |
| 404 | 406 |
| 405 // The offset is the maximum height of panels that could overlap with the | 407 // The offset is the maximum height of panels that could overlap with the |
| 406 // balloons. | 408 // balloons. |
| 407 if (NeedToMoveAboveLeftSidePanels()) { | 409 if (NeedToMoveAboveLeftSidePanels()) { |
| 408 // If the affecting panel does not lie in the balloon area, no need to | 410 // If the affecting panel does not lie in the balloon area, no need to |
| 409 // update the offset. | 411 // update the offset. |
| 410 if (!panel_bounds.IsEmpty() && | 412 if (!panel_bounds.IsEmpty() && |
| 411 (panel_bounds.right() <= work_area_.x() || | 413 (panel_bounds.right() <= work_area_.x() || |
| 412 panel_bounds.x() >= work_area_.x() + max_balloon_width())) { | 414 panel_bounds.x() >= work_area_.x() + max_balloon_width())) { |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 468 gfx::Rect new_work_area = gfx::Screen::GetPrimaryMonitorWorkArea(); | 470 gfx::Rect new_work_area = gfx::Screen::GetPrimaryMonitorWorkArea(); |
| 469 #endif | 471 #endif |
| 470 if (!work_area_.Equals(new_work_area)) { | 472 if (!work_area_.Equals(new_work_area)) { |
| 471 work_area_.SetRect(new_work_area.x(), new_work_area.y(), | 473 work_area_.SetRect(new_work_area.x(), new_work_area.y(), |
| 472 new_work_area.width(), new_work_area.height()); | 474 new_work_area.width(), new_work_area.height()); |
| 473 changed = true; | 475 changed = true; |
| 474 } | 476 } |
| 475 | 477 |
| 476 return changed; | 478 return changed; |
| 477 } | 479 } |
| OLD | NEW |