| 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 // Draws the view for the balloons. | 5 // Draws the view for the balloons. |
| 6 | 6 |
| 7 #ifndef CHROME_BROWSER_UI_GTK_NOTIFICATIONS_BALLOON_VIEW_GTK_H_ | 7 #ifndef CHROME_BROWSER_UI_GTK_NOTIFICATIONS_BALLOON_VIEW_GTK_H_ |
| 8 #define CHROME_BROWSER_UI_GTK_NOTIFICATIONS_BALLOON_VIEW_GTK_H_ | 8 #define CHROME_BROWSER_UI_GTK_NOTIFICATIONS_BALLOON_VIEW_GTK_H_ |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 14 #include "chrome/browser/notifications/balloon.h" | 14 #include "chrome/browser/notifications/balloon.h" |
| 15 #include "chrome/browser/ui/gtk/menu_gtk.h" | 15 #include "chrome/browser/ui/gtk/menu_gtk.h" |
| 16 #include "chrome/browser/ui/gtk/notifications/balloon_view_host_gtk.h" | 16 #include "chrome/browser/ui/gtk/notifications/balloon_view_host_gtk.h" |
| 17 #include "content/public/browser/notification_observer.h" | 17 #include "content/public/browser/notification_observer.h" |
| 18 #include "content/public/browser/notification_registrar.h" | 18 #include "content/public/browser/notification_registrar.h" |
| 19 #include "ui/base/animation/animation_delegate.h" | |
| 20 #include "ui/base/gtk/gtk_signal.h" | 19 #include "ui/base/gtk/gtk_signal.h" |
| 20 #include "ui/gfx/animation/animation_delegate.h" |
| 21 #include "ui/gfx/point.h" | 21 #include "ui/gfx/point.h" |
| 22 #include "ui/gfx/rect.h" | 22 #include "ui/gfx/rect.h" |
| 23 #include "ui/gfx/size.h" | 23 #include "ui/gfx/size.h" |
| 24 | 24 |
| 25 class BalloonCollection; | 25 class BalloonCollection; |
| 26 class CustomDrawButton; | 26 class CustomDrawButton; |
| 27 class GtkThemeService; | 27 class GtkThemeService; |
| 28 class MenuGtk; | 28 class MenuGtk; |
| 29 class NotificationOptionsMenuModel; | 29 class NotificationOptionsMenuModel; |
| 30 | 30 |
| 31 namespace ui { | 31 namespace gfx { |
| 32 class SlideAnimation; | 32 class SlideAnimation; |
| 33 } | 33 } |
| 34 | 34 |
| 35 // A balloon view is the UI component for desktop notification toasts. | 35 // A balloon view is the UI component for desktop notification toasts. |
| 36 // It draws a border, and within the border an HTML renderer. | 36 // It draws a border, and within the border an HTML renderer. |
| 37 class BalloonViewImpl : public BalloonView, | 37 class BalloonViewImpl : public BalloonView, |
| 38 public MenuGtk::Delegate, | 38 public MenuGtk::Delegate, |
| 39 public content::NotificationObserver, | 39 public content::NotificationObserver, |
| 40 public ui::AnimationDelegate { | 40 public gfx::AnimationDelegate { |
| 41 public: | 41 public: |
| 42 explicit BalloonViewImpl(BalloonCollection* collection); | 42 explicit BalloonViewImpl(BalloonCollection* collection); |
| 43 virtual ~BalloonViewImpl(); | 43 virtual ~BalloonViewImpl(); |
| 44 | 44 |
| 45 // BalloonView interface. | 45 // BalloonView interface. |
| 46 virtual void Show(Balloon* balloon) OVERRIDE; | 46 virtual void Show(Balloon* balloon) OVERRIDE; |
| 47 virtual void Update() OVERRIDE; | 47 virtual void Update() OVERRIDE; |
| 48 virtual void RepositionToBalloon() OVERRIDE; | 48 virtual void RepositionToBalloon() OVERRIDE; |
| 49 virtual void Close(bool by_user) OVERRIDE; | 49 virtual void Close(bool by_user) OVERRIDE; |
| 50 virtual gfx::Size GetSize() const OVERRIDE; | 50 virtual gfx::Size GetSize() const OVERRIDE; |
| 51 virtual BalloonHost* GetHost() const OVERRIDE; | 51 virtual BalloonHost* GetHost() const OVERRIDE; |
| 52 | 52 |
| 53 // MenuGtk::Delegate interface. | 53 // MenuGtk::Delegate interface. |
| 54 virtual void StoppedShowing() OVERRIDE; | 54 virtual void StoppedShowing() OVERRIDE; |
| 55 | 55 |
| 56 private: | 56 private: |
| 57 // content::NotificationObserver interface. | 57 // content::NotificationObserver interface. |
| 58 virtual void Observe(int type, | 58 virtual void Observe(int type, |
| 59 const content::NotificationSource& source, | 59 const content::NotificationSource& source, |
| 60 const content::NotificationDetails& details) OVERRIDE; | 60 const content::NotificationDetails& details) OVERRIDE; |
| 61 | 61 |
| 62 // ui::AnimationDelegate interface. | 62 // gfx::AnimationDelegate interface. |
| 63 virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE; | 63 virtual void AnimationProgressed(const gfx::Animation* animation) OVERRIDE; |
| 64 | 64 |
| 65 // Do the delayed close work. The balloon and all view components will be | 65 // Do the delayed close work. The balloon and all view components will be |
| 66 // destroyed at this time, so it shouldn't be called while still processing | 66 // destroyed at this time, so it shouldn't be called while still processing |
| 67 // an event that relies on them. | 67 // an event that relies on them. |
| 68 void DelayedClose(bool by_user); | 68 void DelayedClose(bool by_user); |
| 69 | 69 |
| 70 // The height of the balloon's shelf. | 70 // The height of the balloon's shelf. |
| 71 // The shelf is where is close button is located. | 71 // The shelf is where is close button is located. |
| 72 int GetShelfHeight() const; | 72 int GetShelfHeight() const; |
| 73 | 73 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 // The renderer of the HTML contents. | 112 // The renderer of the HTML contents. |
| 113 scoped_ptr<BalloonViewHost> html_contents_; | 113 scoped_ptr<BalloonViewHost> html_contents_; |
| 114 | 114 |
| 115 // The following factory is used to call methods at a later time. | 115 // The following factory is used to call methods at a later time. |
| 116 base::WeakPtrFactory<BalloonViewImpl> weak_factory_; | 116 base::WeakPtrFactory<BalloonViewImpl> weak_factory_; |
| 117 | 117 |
| 118 // Close button. | 118 // Close button. |
| 119 scoped_ptr<CustomDrawButton> close_button_; | 119 scoped_ptr<CustomDrawButton> close_button_; |
| 120 | 120 |
| 121 // An animation to move the balloon on the screen as its position changes. | 121 // An animation to move the balloon on the screen as its position changes. |
| 122 scoped_ptr<ui::SlideAnimation> animation_; | 122 scoped_ptr<gfx::SlideAnimation> animation_; |
| 123 gfx::Rect anim_frame_start_; | 123 gfx::Rect anim_frame_start_; |
| 124 gfx::Rect anim_frame_end_; | 124 gfx::Rect anim_frame_end_; |
| 125 | 125 |
| 126 // The options menu. | 126 // The options menu. |
| 127 scoped_ptr<MenuGtk> options_menu_; | 127 scoped_ptr<MenuGtk> options_menu_; |
| 128 scoped_ptr<NotificationOptionsMenuModel> options_menu_model_; | 128 scoped_ptr<NotificationOptionsMenuModel> options_menu_model_; |
| 129 // The button to open the options menu. | 129 // The button to open the options menu. |
| 130 scoped_ptr<CustomDrawButton> options_menu_button_; | 130 scoped_ptr<CustomDrawButton> options_menu_button_; |
| 131 | 131 |
| 132 content::NotificationRegistrar notification_registrar_; | 132 content::NotificationRegistrar notification_registrar_; |
| 133 | 133 |
| 134 // Is the menu currently showing? | 134 // Is the menu currently showing? |
| 135 bool menu_showing_; | 135 bool menu_showing_; |
| 136 | 136 |
| 137 // Is there a pending system-initiated close? | 137 // Is there a pending system-initiated close? |
| 138 bool pending_close_; | 138 bool pending_close_; |
| 139 | 139 |
| 140 DISALLOW_COPY_AND_ASSIGN(BalloonViewImpl); | 140 DISALLOW_COPY_AND_ASSIGN(BalloonViewImpl); |
| 141 }; | 141 }; |
| 142 | 142 |
| 143 #endif // CHROME_BROWSER_UI_GTK_NOTIFICATIONS_BALLOON_VIEW_GTK_H_ | 143 #endif // CHROME_BROWSER_UI_GTK_NOTIFICATIONS_BALLOON_VIEW_GTK_H_ |
| OLD | NEW |