| OLD | NEW |
| 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 "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/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
| 11 #include "chrome/browser/notifications/balloon.h" | 11 #include "chrome/browser/notifications/balloon.h" |
| 12 #include "chrome/browser/notifications/balloon_host.h" | 12 #include "chrome/browser/notifications/balloon_host.h" |
| 13 #include "chrome/browser/notifications/notification.h" | 13 #include "chrome/browser/notifications/notification.h" |
| 14 #include "chrome/browser/ui/browser.h" | 14 #include "chrome/browser/ui/browser.h" |
| 15 #include "chrome/browser/ui/panels/docked_panel_collection.h" | 15 #include "chrome/browser/ui/panels/docked_panel_collection.h" |
| 16 #include "chrome/browser/ui/panels/panel.h" | 16 #include "chrome/browser/ui/panels/panel.h" |
| 17 #include "chrome/browser/ui/panels/panel_manager.h" | 17 #include "chrome/browser/ui/panels/panel_manager.h" |
| 18 #include "content/public/browser/notification_registrar.h" | 18 #include "content/public/browser/notification_registrar.h" |
| 19 #include "content/public/browser/notification_service.h" | 19 #include "content/public/browser/notification_service.h" |
| 20 #include "ui/gfx/rect.h" | 20 #include "ui/gfx/rect.h" |
| 21 #include "ui/gfx/screen.h" | 21 #include "ui/gfx/screen.h" |
| 22 #include "ui/gfx/size.h" | 22 #include "ui/gfx/size.h" |
| 23 | 23 |
| 24 namespace { | |
| 25 | |
| 26 // Portion of the screen allotted for notifications. When notification balloons | 24 // Portion of the screen allotted for notifications. When notification balloons |
| 27 // extend over this, no new notifications are shown until some are closed. | 25 // extend over this, no new notifications are shown until some are closed. |
| 28 const double kPercentBalloonFillFactor = 0.7; | 26 const double kPercentBalloonFillFactor = 0.7; |
| 29 | 27 |
| 30 // Allow at least this number of balloons on the screen. | 28 // Allow at least this number of balloons on the screen. |
| 31 const int kMinAllowedBalloonCount = 2; | 29 const int kMinAllowedBalloonCount = 2; |
| 32 | 30 |
| 33 // Delay from the mouse leaving the balloon collection before | |
| 34 // there is a relayout, in milliseconds. | |
| 35 const int kRepositionDelayMs = 300; | |
| 36 | |
| 37 // The spacing between the balloon and the panel. | 31 // The spacing between the balloon and the panel. |
| 38 const int kVerticalSpacingBetweenBalloonAndPanel = 5; | 32 const int kVerticalSpacingBetweenBalloonAndPanel = 5; |
| 39 | 33 |
| 40 } // namespace | 34 #if USE_OFFSETS |
| 35 // Delay from the mouse leaving the balloon collection before |
| 36 // there is a relayout, in milliseconds. |
| 37 const int kRepositionDelayMs = 300; |
| 38 #endif // USE_OFFSETS |
| 39 |
| 41 | 40 |
| 42 BalloonCollectionImpl::BalloonCollectionImpl() | 41 BalloonCollectionImpl::BalloonCollectionImpl() |
| 43 #if USE_OFFSETS | 42 #if USE_OFFSETS |
| 44 : reposition_factory_(this), | 43 : reposition_factory_(this), |
| 45 added_as_message_loop_observer_(false) | 44 added_as_message_loop_observer_(false) |
| 46 #endif | 45 #endif |
| 47 { | 46 { |
| 48 registrar_.Add(this, chrome::NOTIFICATION_PANEL_COLLECTION_UPDATED, | 47 registrar_.Add(this, chrome::NOTIFICATION_PANEL_COLLECTION_UPDATED, |
| 49 content::NotificationService::AllSources()); | 48 content::NotificationService::AllSources()); |
| 50 registrar_.Add(this, chrome::NOTIFICATION_PANEL_CHANGED_EXPANSION_STATE, | 49 registrar_.Add(this, chrome::NOTIFICATION_PANEL_CHANGED_EXPANSION_STATE, |
| (...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().work_area(); | 478 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().work_area(); |
| 480 #endif | 479 #endif |
| 481 if (work_area_ != new_work_area) { | 480 if (work_area_ != new_work_area) { |
| 482 work_area_.SetRect(new_work_area.x(), new_work_area.y(), | 481 work_area_.SetRect(new_work_area.x(), new_work_area.y(), |
| 483 new_work_area.width(), new_work_area.height()); | 482 new_work_area.width(), new_work_area.height()); |
| 484 changed = true; | 483 changed = true; |
| 485 } | 484 } |
| 486 | 485 |
| 487 return changed; | 486 return changed; |
| 488 } | 487 } |
| OLD | NEW |