OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 // Handles the visible notification (or balloons). |
| 6 |
| 7 #ifndef CHROME_BROWSER_NOTIFICATIONS_BALLOON_H_ |
| 8 #define CHROME_BROWSER_NOTIFICATIONS_BALLOON_H_ |
| 9 |
| 10 #include <vector> |
| 11 |
| 12 #include "base/basictypes.h" |
| 13 #include "base/gfx/point.h" |
| 14 #include "base/gfx/rect.h" |
| 15 #include "base/gfx/size.h" |
| 16 #include "base/scoped_ptr.h" |
| 17 #include "chrome/browser/notifications/notification.h" |
| 18 |
| 19 class Balloon; |
| 20 class Profile; |
| 21 class SiteInstance; |
| 22 |
| 23 // Interface for a view that displays a balloon. |
| 24 class BalloonView { |
| 25 public: |
| 26 virtual ~BalloonView() { } |
| 27 |
| 28 // Show the view on the screen. |
| 29 virtual void Show(Balloon* balloon) = 0; |
| 30 |
| 31 // Reposition the view to match the position of its balloon. |
| 32 virtual void RepositionToBalloon() = 0; |
| 33 |
| 34 // Close the view. |
| 35 virtual void Close() = 0; |
| 36 }; |
| 37 |
| 38 // Represents a Notification on the screen. |
| 39 class Balloon { |
| 40 public: |
| 41 class BalloonCloseListener { |
| 42 public: |
| 43 virtual ~BalloonCloseListener() {} |
| 44 |
| 45 // Called when a balloon is closed. |
| 46 virtual void OnBalloonClosed(Balloon* source) = 0; |
| 47 }; |
| 48 |
| 49 // |listener| may be null in unit tests w/o actual UI. |
| 50 Balloon(const Notification& notification, |
| 51 Profile* profile, |
| 52 BalloonCloseListener* listener); |
| 53 virtual ~Balloon(); |
| 54 |
| 55 const Notification& notification() const { return notification_; } |
| 56 Profile* profile() const { return profile_; } |
| 57 |
| 58 const gfx::Point& position() const { return position_; } |
| 59 void SetPosition(const gfx::Point& upper_left, bool reposition); |
| 60 |
| 61 const gfx::Size& size() const { return size_; } |
| 62 void set_size(const gfx::Size& size) { size_ = size; } |
| 63 |
| 64 // Provides a view for this balloon. Ownership transfers |
| 65 // to this object. |
| 66 void set_view(BalloonView* balloon_view); |
| 67 |
| 68 virtual void Show(); |
| 69 virtual void Close(bool by_user); |
| 70 |
| 71 private: |
| 72 // Non-owned pointer to the profile. |
| 73 Profile* profile_; |
| 74 |
| 75 // The notification being shown in this balloon. |
| 76 Notification notification_; |
| 77 |
| 78 // A listener to be called when the balloon closes. |
| 79 BalloonCloseListener* close_listener_; |
| 80 |
| 81 // The actual UI element for the balloon. |
| 82 scoped_ptr<BalloonView> balloon_view_; |
| 83 |
| 84 // Position and size of the balloon on the screen. |
| 85 gfx::Point position_; |
| 86 gfx::Size size_; |
| 87 |
| 88 DISALLOW_COPY_AND_ASSIGN(Balloon); |
| 89 }; |
| 90 |
| 91 #endif // CHROME_BROWSER_NOTIFICATIONS_BALLOON_H_ |
OLD | NEW |