| 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 #ifndef CHROME_BROWSER_UI_VIEWS_NOTIFICATIONS_BALLOON_VIEW_VIEWS_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_NOTIFICATIONS_BALLOON_VIEW_VIEWS_H_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_NOTIFICATIONS_BALLOON_VIEW_VIEWS_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_NOTIFICATIONS_BALLOON_VIEW_VIEWS_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/memory/weak_ptr.h" | |
| 11 #include "chrome/browser/notifications/balloon.h" | 10 #include "chrome/browser/notifications/balloon.h" |
| 12 #include "content/public/browser/notification_observer.h" | 11 #include "content/public/browser/notification_observer.h" |
| 13 #include "content/public/browser/notification_registrar.h" | 12 #include "content/public/browser/notification_registrar.h" |
| 14 #include "ui/base/animation/animation_delegate.h" | 13 #include "ui/base/animation/animation_delegate.h" |
| 15 #include "ui/gfx/rect.h" | 14 #include "ui/gfx/rect.h" |
| 16 #include "ui/views/controls/button/button.h" | 15 #include "ui/views/controls/button/button.h" |
| 17 #include "ui/views/controls/button/menu_button_listener.h" | 16 #include "ui/views/controls/button/menu_button_listener.h" |
| 18 #include "ui/views/widget/widget_delegate.h" | 17 #include "ui/views/widget/widget_delegate.h" |
| 19 | 18 |
| 20 class BalloonCollection; | 19 class BalloonCollection; |
| 21 class BalloonViewHost; | 20 class BalloonViewHost; |
| 22 class NotificationOptionsMenuModel; | 21 class NotificationOptionsMenuModel; |
| 23 | 22 |
| 24 namespace gfx { | 23 namespace gfx { |
| 25 class Path; | 24 class Path; |
| 26 } | 25 } |
| 27 | 26 |
| 28 namespace ui { | 27 namespace ui { |
| 29 class SlideAnimation; | 28 class SlideAnimation; |
| 30 } | 29 } |
| 31 | 30 |
| 32 namespace views { | 31 namespace views { |
| 33 class ImageButton; | 32 class ImageButton; |
| 34 class Label; | 33 class Label; |
| 35 class MenuButton; | 34 class MenuButton; |
| 36 class MenuRunner; | 35 class MenuRunner; |
| 37 } | 36 } |
| 38 | 37 |
| 39 // A balloon view is the UI component for a desktop notification toasts. | 38 // A balloon view is the UI component for a desktop notification toast. |
| 40 // It draws a border, and within the border an HTML renderer. | 39 // It draws a border, and within the border an HTML renderer. |
| 41 class BalloonViewImpl : public BalloonView, | 40 class BalloonViewImpl : public BalloonView, |
| 42 public views::MenuButtonListener, | 41 public views::MenuButtonListener, |
| 43 public views::WidgetDelegateView, | 42 public views::WidgetDelegateView, |
| 44 public views::ButtonListener, | 43 public views::ButtonListener, |
| 45 public content::NotificationObserver, | 44 public content::NotificationObserver, |
| 46 public ui::AnimationDelegate { | 45 public ui::AnimationDelegate { |
| 47 public: | 46 public: |
| 48 explicit BalloonViewImpl(BalloonCollection* collection); | 47 explicit BalloonViewImpl(BalloonCollection* collection); |
| 49 virtual ~BalloonViewImpl(); | 48 virtual ~BalloonViewImpl(); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 64 virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE; | 63 virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE; |
| 65 virtual gfx::Size GetPreferredSize() OVERRIDE; | 64 virtual gfx::Size GetPreferredSize() OVERRIDE; |
| 66 | 65 |
| 67 // views::MenuButtonListener interface. | 66 // views::MenuButtonListener interface. |
| 68 virtual void OnMenuButtonClicked(views::View* source, | 67 virtual void OnMenuButtonClicked(views::View* source, |
| 69 const gfx::Point& point) OVERRIDE; | 68 const gfx::Point& point) OVERRIDE; |
| 70 | 69 |
| 71 // views::WidgetDelegate interface. | 70 // views::WidgetDelegate interface. |
| 72 virtual void OnDisplayChanged() OVERRIDE; | 71 virtual void OnDisplayChanged() OVERRIDE; |
| 73 virtual void OnWorkAreaChanged() OVERRIDE; | 72 virtual void OnWorkAreaChanged() OVERRIDE; |
| 73 virtual void DeleteDelegate() OVERRIDE; |
| 74 | 74 |
| 75 // views::ButtonListener interface. | 75 // views::ButtonListener interface. |
| 76 virtual void ButtonPressed(views::Button* sender, | 76 virtual void ButtonPressed(views::Button* sender, |
| 77 const ui::Event&) OVERRIDE; | 77 const ui::Event&) OVERRIDE; |
| 78 | 78 |
| 79 // content::NotificationObserver interface. | 79 // content::NotificationObserver interface. |
| 80 virtual void Observe(int type, | 80 virtual void Observe(int type, |
| 81 const content::NotificationSource& source, | 81 const content::NotificationSource& source, |
| 82 const content::NotificationDetails& details) OVERRIDE; | 82 const content::NotificationDetails& details) OVERRIDE; |
| 83 | 83 |
| 84 // ui::AnimationDelegate interface. | 84 // ui::AnimationDelegate interface. |
| 85 virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE; | 85 virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE; |
| 86 | 86 |
| 87 // Initializes the options menu. | 87 // Initializes the options menu. |
| 88 void CreateOptionsMenu(); | 88 void CreateOptionsMenu(); |
| 89 | 89 |
| 90 // Masks the contents to fit within the frame. | 90 // Masks the contents to fit within the frame. |
| 91 void GetContentsMask(const gfx::Rect& contents_rect, gfx::Path* path) const; | 91 void GetContentsMask(const gfx::Rect& contents_rect, gfx::Path* path) const; |
| 92 | 92 |
| 93 // Masks the frame for the rounded corners of the shadow-bubble. | 93 // Masks the frame for the rounded corners of the shadow-bubble. |
| 94 void GetFrameMask(const gfx::Rect&, gfx::Path* path) const; | 94 void GetFrameMask(const gfx::Rect&, gfx::Path* path) const; |
| 95 | 95 |
| 96 // Adjust the contents window size to be appropriate for the frame. | 96 // Adjust the contents window size to be appropriate for the frame. |
| 97 void SizeContentsWindow(); | 97 void SizeContentsWindow(); |
| 98 | 98 |
| 99 // Do the delayed close work. | |
| 100 void DelayedClose(bool by_user); | |
| 101 | |
| 102 // The height of the balloon's shelf. | 99 // The height of the balloon's shelf. |
| 103 // The shelf is where is close button is located. | 100 // The shelf is where is close button is located. |
| 104 int GetShelfHeight() const; | 101 int GetShelfHeight() const; |
| 105 | 102 |
| 106 // The height of the part of the frame around the balloon. | 103 // The height of the part of the frame around the balloon. |
| 107 int GetBalloonFrameHeight() const; | 104 int GetBalloonFrameHeight() const; |
| 108 | 105 |
| 109 int GetTotalWidth() const; | 106 int GetTotalWidth() const; |
| 110 int GetTotalHeight() const; | 107 int GetTotalHeight() const; |
| 111 | 108 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 130 // Pointer owned by the View subclass. | 127 // Pointer owned by the View subclass. |
| 131 views::Widget* frame_container_; | 128 views::Widget* frame_container_; |
| 132 | 129 |
| 133 // The window that contains the contents of the notification. | 130 // The window that contains the contents of the notification. |
| 134 // Pointer owned by the View subclass. | 131 // Pointer owned by the View subclass. |
| 135 views::Widget* html_container_; | 132 views::Widget* html_container_; |
| 136 | 133 |
| 137 // The renderer of the HTML contents. | 134 // The renderer of the HTML contents. |
| 138 scoped_ptr<BalloonViewHost> html_contents_; | 135 scoped_ptr<BalloonViewHost> html_contents_; |
| 139 | 136 |
| 140 // The following factory is used to call methods at a later time. | |
| 141 base::WeakPtrFactory<BalloonViewImpl> method_factory_; | |
| 142 | |
| 143 // Pointer to sub-view is owned by the View sub-class. | 137 // Pointer to sub-view is owned by the View sub-class. |
| 144 views::ImageButton* close_button_; | 138 views::ImageButton* close_button_; |
| 145 | 139 |
| 146 // Pointer to sub-view is owned by View class. | 140 // Pointer to sub-view is owned by View class. |
| 147 views::Label* source_label_; | 141 views::Label* source_label_; |
| 148 | 142 |
| 149 // An animation to move the balloon on the screen as its position changes. | 143 // An animation to move the balloon on the screen as its position changes. |
| 150 scoped_ptr<ui::SlideAnimation> animation_; | 144 scoped_ptr<ui::SlideAnimation> animation_; |
| 151 gfx::Rect anim_frame_start_; | 145 gfx::Rect anim_frame_start_; |
| 152 gfx::Rect anim_frame_end_; | 146 gfx::Rect anim_frame_end_; |
| 153 | 147 |
| 154 // The options menu. | 148 // The options menu. |
| 155 scoped_ptr<NotificationOptionsMenuModel> options_menu_model_; | 149 scoped_ptr<NotificationOptionsMenuModel> options_menu_model_; |
| 156 scoped_ptr<views::MenuRunner> menu_runner_; | 150 scoped_ptr<views::MenuRunner> menu_runner_; |
| 157 views::MenuButton* options_menu_button_; | 151 views::MenuButton* options_menu_button_; |
| 158 | 152 |
| 159 content::NotificationRegistrar notification_registrar_; | 153 content::NotificationRegistrar notification_registrar_; |
| 160 | 154 |
| 161 // Set to true if this is browser generate web UI. | 155 // Set to true if this is browser generate web UI. |
| 162 bool enable_web_ui_; | 156 bool enable_web_ui_; |
| 163 | 157 |
| 158 // Most recent value passed to Close(). |
| 159 bool closed_by_user_; |
| 160 |
| 164 DISALLOW_COPY_AND_ASSIGN(BalloonViewImpl); | 161 DISALLOW_COPY_AND_ASSIGN(BalloonViewImpl); |
| 165 }; | 162 }; |
| 166 | 163 |
| 167 #endif // CHROME_BROWSER_UI_VIEWS_NOTIFICATIONS_BALLOON_VIEW_VIEWS_H_ | 164 #endif // CHROME_BROWSER_UI_VIEWS_NOTIFICATIONS_BALLOON_VIEW_VIEWS_H_ |
| OLD | NEW |