| 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 // Draws the view for the balloons. | 5 // Draws the view for the balloons. |
| 6 | 6 |
| 7 #ifndef CHROME_BROWSER_CHROMEOS_NOTIFICATIONS_BALLOON_VIEW_H_ | 7 #ifndef CHROME_BROWSER_CHROMEOS_NOTIFICATIONS_BALLOON_VIEW_H_ |
| 8 #define CHROME_BROWSER_CHROMEOS_NOTIFICATIONS_BALLOON_VIEW_H_ | 8 #define CHROME_BROWSER_CHROMEOS_NOTIFICATIONS_BALLOON_VIEW_H_ |
| 9 #pragma once | 9 #pragma once |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/compiler_specific.h" |
| 12 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 14 #include "chrome/browser/notifications/balloon.h" | 15 #include "chrome/browser/notifications/balloon.h" |
| 15 #include "content/public/browser/notification_observer.h" | 16 #include "content/public/browser/notification_observer.h" |
| 16 #include "content/public/browser/notification_registrar.h" | 17 #include "content/public/browser/notification_registrar.h" |
| 17 #include "ui/gfx/path.h" | 18 #include "ui/gfx/path.h" |
| 18 #include "ui/gfx/point.h" | 19 #include "ui/gfx/point.h" |
| 19 #include "ui/gfx/rect.h" | 20 #include "ui/gfx/rect.h" |
| 20 #include "ui/gfx/size.h" | 21 #include "ui/gfx/size.h" |
| 21 #include "views/view.h" | 22 #include "views/view.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 34 // A balloon view is the UI component for a notification panel. | 35 // A balloon view is the UI component for a notification panel. |
| 35 class BalloonViewImpl : public BalloonView, | 36 class BalloonViewImpl : public BalloonView, |
| 36 public views::View, | 37 public views::View, |
| 37 public content::NotificationObserver, | 38 public content::NotificationObserver, |
| 38 public base::SupportsWeakPtr<BalloonViewImpl> { | 39 public base::SupportsWeakPtr<BalloonViewImpl> { |
| 39 public: | 40 public: |
| 40 BalloonViewImpl(bool sticky, bool controls, bool web_ui); | 41 BalloonViewImpl(bool sticky, bool controls, bool web_ui); |
| 41 virtual ~BalloonViewImpl(); | 42 virtual ~BalloonViewImpl(); |
| 42 | 43 |
| 43 // views::View interface. | 44 // views::View interface. |
| 44 virtual void Layout(); | 45 virtual void Layout() OVERRIDE; |
| 45 virtual void ViewHierarchyChanged(bool is_add, View* parent, View* child); | 46 virtual void ViewHierarchyChanged(bool is_add, |
| 47 View* parent, |
| 48 View* child) OVERRIDE; |
| 46 | 49 |
| 47 // BalloonView interface. | 50 // BalloonView interface. |
| 48 virtual void Show(Balloon* balloon); | 51 virtual void Show(Balloon* balloon) OVERRIDE; |
| 49 virtual void Update(); | 52 virtual void Update() OVERRIDE; |
| 50 virtual void Close(bool by_user); | 53 virtual void Close(bool by_user) OVERRIDE; |
| 51 virtual void RepositionToBalloon(); | 54 virtual void RepositionToBalloon() OVERRIDE; |
| 52 virtual gfx::Size GetSize() const; | 55 virtual gfx::Size GetSize() const OVERRIDE; |
| 53 virtual BalloonHost* GetHost() const; | 56 virtual BalloonHost* GetHost() const OVERRIDE; |
| 54 | 57 |
| 55 // True if the notification is stale. False if the notification is new. | 58 // True if the notification is stale. False if the notification is new. |
| 56 bool stale() const { return stale_; } | 59 bool stale() const { return stale_; } |
| 57 | 60 |
| 58 // Makes the notification stale. | 61 // Makes the notification stale. |
| 59 void set_stale() { stale_ = true; } | 62 void set_stale() { stale_ = true; } |
| 60 | 63 |
| 61 // True if the notification is sticky. | 64 // True if the notification is sticky. |
| 62 bool sticky() const { return sticky_; } | 65 bool sticky() const { return sticky_; } |
| 63 | 66 |
| 64 // True if the notification is being closed. | 67 // True if the notification is being closed. |
| 65 bool closed() const { return closed_; } | 68 bool closed() const { return closed_; } |
| 66 | 69 |
| 67 // True if the balloon is for the given |notification|. | 70 // True if the balloon is for the given |notification|. |
| 68 bool IsFor(const Notification& notification) const; | 71 bool IsFor(const Notification& notification) const; |
| 69 | 72 |
| 70 // Called when the notification becomes active (mouse is on). | 73 // Called when the notification becomes active (mouse is on). |
| 71 void Activated(); | 74 void Activated(); |
| 72 | 75 |
| 73 // Called when the notification becomes inactive. | 76 // Called when the notification becomes inactive. |
| 74 void Deactivated(); | 77 void Deactivated(); |
| 75 | 78 |
| 76 private: | 79 private: |
| 77 friend class NotificationControlView; | 80 friend class NotificationControlView; |
| 78 | 81 |
| 79 // views::View interface. | 82 // views::View interface. |
| 80 virtual gfx::Size GetPreferredSize(); | 83 virtual gfx::Size GetPreferredSize() OVERRIDE; |
| 81 | 84 |
| 82 // content::NotificationObserver interface. | 85 // content::NotificationObserver interface. |
| 83 virtual void Observe(int type, | 86 virtual void Observe(int type, |
| 84 const content::NotificationSource& source, | 87 const content::NotificationSource& source, |
| 85 const content::NotificationDetails& details); | 88 const content::NotificationDetails& details) OVERRIDE; |
| 86 | 89 |
| 87 // Initializes the options menu. | 90 // Initializes the options menu. |
| 88 void CreateOptionsMenu(); | 91 void CreateOptionsMenu(); |
| 89 | 92 |
| 90 // Do the delayed close work. | 93 // Do the delayed close work. |
| 91 void DelayedClose(bool by_user); | 94 void DelayedClose(bool by_user); |
| 92 | 95 |
| 93 // Denies the permission to show the ballooon from its source. | 96 // Denies the permission to show the ballooon from its source. |
| 94 void DenyPermission(); | 97 void DenyPermission(); |
| 95 | 98 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 115 bool closed_; | 118 bool closed_; |
| 116 // True to enable WebUI in the notification. | 119 // True to enable WebUI in the notification. |
| 117 bool web_ui_; | 120 bool web_ui_; |
| 118 | 121 |
| 119 DISALLOW_COPY_AND_ASSIGN(BalloonViewImpl); | 122 DISALLOW_COPY_AND_ASSIGN(BalloonViewImpl); |
| 120 }; | 123 }; |
| 121 | 124 |
| 122 } // namespace chromeos | 125 } // namespace chromeos |
| 123 | 126 |
| 124 #endif // CHROME_BROWSER_CHROMEOS_NOTIFICATIONS_BALLOON_VIEW_H_ | 127 #endif // CHROME_BROWSER_CHROMEOS_NOTIFICATIONS_BALLOON_VIEW_H_ |
| OLD | NEW |