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 "chrome/browser/notifications/balloon.h" | 10 #include "chrome/browser/notifications/balloon.h" |
11 #include "content/public/browser/notification_observer.h" | 11 #include "content/public/browser/notification_observer.h" |
12 #include "content/public/browser/notification_registrar.h" | 12 #include "content/public/browser/notification_registrar.h" |
13 #include "ui/base/animation/animation_delegate.h" | 13 #include "ui/gfx/animation/animation_delegate.h" |
14 #include "ui/gfx/rect.h" | 14 #include "ui/gfx/rect.h" |
15 #include "ui/views/controls/button/button.h" | 15 #include "ui/views/controls/button/button.h" |
16 #include "ui/views/controls/button/menu_button_listener.h" | 16 #include "ui/views/controls/button/menu_button_listener.h" |
17 #include "ui/views/widget/widget_delegate.h" | 17 #include "ui/views/widget/widget_delegate.h" |
18 | 18 |
19 class BalloonCollection; | 19 class BalloonCollection; |
20 class BalloonViewHost; | 20 class BalloonViewHost; |
21 class NotificationOptionsMenuModel; | 21 class NotificationOptionsMenuModel; |
22 | 22 |
23 namespace gfx { | 23 namespace gfx { |
24 class Path; | 24 class Path; |
25 } | |
26 | |
27 namespace ui { | |
28 class SlideAnimation; | 25 class SlideAnimation; |
29 } | 26 } |
30 | 27 |
31 namespace views { | 28 namespace views { |
32 class ImageButton; | 29 class ImageButton; |
33 class Label; | 30 class Label; |
34 class MenuButton; | 31 class MenuButton; |
35 class MenuRunner; | 32 class MenuRunner; |
36 } | 33 } |
37 | 34 |
38 // A balloon view is the UI component for a desktop notification toast. | 35 // A balloon view is the UI component for a desktop notification toast. |
39 // It draws a border, and within the border an HTML renderer. | 36 // It draws a border, and within the border an HTML renderer. |
40 class BalloonViewImpl : public BalloonView, | 37 class BalloonViewImpl : public BalloonView, |
41 public views::MenuButtonListener, | 38 public views::MenuButtonListener, |
42 public views::WidgetDelegateView, | 39 public views::WidgetDelegateView, |
43 public views::ButtonListener, | 40 public views::ButtonListener, |
44 public content::NotificationObserver, | 41 public content::NotificationObserver, |
45 public ui::AnimationDelegate { | 42 public gfx::AnimationDelegate { |
46 public: | 43 public: |
47 explicit BalloonViewImpl(BalloonCollection* collection); | 44 explicit BalloonViewImpl(BalloonCollection* collection); |
48 virtual ~BalloonViewImpl(); | 45 virtual ~BalloonViewImpl(); |
49 | 46 |
50 // BalloonView interface. | 47 // BalloonView interface. |
51 virtual void Show(Balloon* balloon) OVERRIDE; | 48 virtual void Show(Balloon* balloon) OVERRIDE; |
52 virtual void Update() OVERRIDE; | 49 virtual void Update() OVERRIDE; |
53 virtual void RepositionToBalloon() OVERRIDE; | 50 virtual void RepositionToBalloon() OVERRIDE; |
54 virtual void Close(bool by_user) OVERRIDE; | 51 virtual void Close(bool by_user) OVERRIDE; |
55 virtual gfx::Size GetSize() const OVERRIDE; | 52 virtual gfx::Size GetSize() const OVERRIDE; |
(...skipping 18 matching lines...) Expand all Loading... |
74 | 71 |
75 // views::ButtonListener interface. | 72 // views::ButtonListener interface. |
76 virtual void ButtonPressed(views::Button* sender, | 73 virtual void ButtonPressed(views::Button* sender, |
77 const ui::Event&) OVERRIDE; | 74 const ui::Event&) OVERRIDE; |
78 | 75 |
79 // content::NotificationObserver interface. | 76 // content::NotificationObserver interface. |
80 virtual void Observe(int type, | 77 virtual void Observe(int type, |
81 const content::NotificationSource& source, | 78 const content::NotificationSource& source, |
82 const content::NotificationDetails& details) OVERRIDE; | 79 const content::NotificationDetails& details) OVERRIDE; |
83 | 80 |
84 // ui::AnimationDelegate interface. | 81 // gfx::AnimationDelegate interface. |
85 virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE; | 82 virtual void AnimationProgressed(const gfx::Animation* animation) OVERRIDE; |
86 | 83 |
87 // Initializes the options menu. | 84 // Initializes the options menu. |
88 void CreateOptionsMenu(); | 85 void CreateOptionsMenu(); |
89 | 86 |
90 // Masks the contents to fit within the frame. | 87 // Masks the contents to fit within the frame. |
91 void GetContentsMask(const gfx::Rect& contents_rect, gfx::Path* path) const; | 88 void GetContentsMask(const gfx::Rect& contents_rect, gfx::Path* path) const; |
92 | 89 |
93 // Masks the frame for the rounded corners of the shadow-bubble. | 90 // Masks the frame for the rounded corners of the shadow-bubble. |
94 void GetFrameMask(const gfx::Rect&, gfx::Path* path) const; | 91 void GetFrameMask(const gfx::Rect&, gfx::Path* path) const; |
95 | 92 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 // Pointer to sub-view is owned by the View sub-class. | 137 // Pointer to sub-view is owned by the View sub-class. |
141 views::ImageButton* close_button_; | 138 views::ImageButton* close_button_; |
142 | 139 |
143 // Pointer to sub-view is owned by View class. | 140 // Pointer to sub-view is owned by View class. |
144 views::Label* source_label_; | 141 views::Label* source_label_; |
145 | 142 |
146 // 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. |
147 scoped_ptr<ui::SlideAnimation> animation_; | 144 scoped_ptr<gfx::SlideAnimation> animation_; |
148 gfx::Rect anim_frame_start_; | 145 gfx::Rect anim_frame_start_; |
149 gfx::Rect anim_frame_end_; | 146 gfx::Rect anim_frame_end_; |
150 | 147 |
151 // The options menu. | 148 // The options menu. |
152 scoped_ptr<NotificationOptionsMenuModel> options_menu_model_; | 149 scoped_ptr<NotificationOptionsMenuModel> options_menu_model_; |
153 scoped_ptr<views::MenuRunner> menu_runner_; | 150 scoped_ptr<views::MenuRunner> menu_runner_; |
154 views::MenuButton* options_menu_button_; | 151 views::MenuButton* options_menu_button_; |
155 | 152 |
156 content::NotificationRegistrar notification_registrar_; | 153 content::NotificationRegistrar notification_registrar_; |
157 | 154 |
158 // Set to true if this is browser generate web UI. | 155 // Set to true if this is browser generate web UI. |
159 bool enable_web_ui_; | 156 bool enable_web_ui_; |
160 | 157 |
161 // Most recent value passed to Close(). | 158 // Most recent value passed to Close(). |
162 bool closed_by_user_; | 159 bool closed_by_user_; |
163 | 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 |