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_VIEWS_NOTIFICATIONS_BALLOON_VIEW_H_ | 7 #ifndef CHROME_BROWSER_UI_VIEWS_NOTIFICATIONS_BALLOON_VIEW_H_ |
8 #define CHROME_BROWSER_UI_VIEWS_NOTIFICATIONS_BALLOON_VIEW_H_ | 8 #define CHROME_BROWSER_UI_VIEWS_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/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/views/notifications/balloon_view_host.h" | 15 #include "chrome/browser/ui/views/notifications/balloon_view_host.h" |
16 #include "content/public/browser/notification_registrar.h" | 16 #include "content/public/browser/notification_registrar.h" |
17 #include "ui/base/animation/animation_delegate.h" | 17 #include "ui/base/animation/animation_delegate.h" |
18 #include "ui/gfx/path.h" | 18 #include "ui/gfx/path.h" |
19 #include "ui/gfx/point.h" | 19 #include "ui/gfx/point.h" |
20 #include "ui/gfx/rect.h" | 20 #include "ui/gfx/rect.h" |
21 #include "ui/gfx/size.h" | 21 #include "ui/gfx/size.h" |
22 #include "ui/views/controls/button/menu_button.h" | 22 #include "ui/views/controls/button/menu_button.h" |
23 #include "ui/views/controls/button/menu_button_delegate.h" | 23 #include "ui/views/controls/button/menu_button_listener.h" |
24 #include "ui/views/controls/label.h" | 24 #include "ui/views/controls/label.h" |
25 #include "ui/views/view.h" | 25 #include "ui/views/view.h" |
26 #include "ui/views/widget/widget_delegate.h" | 26 #include "ui/views/widget/widget_delegate.h" |
27 | 27 |
28 class BalloonCollection; | 28 class BalloonCollection; |
29 class NotificationOptionsMenuModel; | 29 class NotificationOptionsMenuModel; |
30 | 30 |
31 namespace ui { | 31 namespace ui { |
32 class SlideAnimation; | 32 class SlideAnimation; |
33 } | 33 } |
34 | 34 |
35 namespace views { | 35 namespace views { |
36 class ButtonListener; | 36 class ButtonListener; |
37 class ImageButton; | 37 class ImageButton; |
38 class MenuRunner; | 38 class MenuRunner; |
39 } | 39 } |
40 | 40 |
41 // A balloon view is the UI component for a desktop notification toasts. | 41 // A balloon view is the UI component for a desktop notification toasts. |
42 // It draws a border, and within the border an HTML renderer. | 42 // It draws a border, and within the border an HTML renderer. |
43 class BalloonViewImpl : public BalloonView, | 43 class BalloonViewImpl : public BalloonView, |
44 public views::MenuButtonDelegate, | 44 public views::MenuButtonListener, |
45 public views::WidgetDelegateView, | 45 public views::WidgetDelegateView, |
46 public views::ButtonListener, | 46 public views::ButtonListener, |
47 public content::NotificationObserver, | 47 public content::NotificationObserver, |
48 public ui::AnimationDelegate { | 48 public ui::AnimationDelegate { |
49 public: | 49 public: |
50 explicit BalloonViewImpl(BalloonCollection* collection); | 50 explicit BalloonViewImpl(BalloonCollection* collection); |
51 virtual ~BalloonViewImpl(); | 51 virtual ~BalloonViewImpl(); |
52 | 52 |
53 // BalloonView interface. | 53 // BalloonView interface. |
54 virtual void Show(Balloon* balloon) OVERRIDE; | 54 virtual void Show(Balloon* balloon) OVERRIDE; |
55 virtual void Update() OVERRIDE; | 55 virtual void Update() OVERRIDE; |
56 virtual void RepositionToBalloon() OVERRIDE; | 56 virtual void RepositionToBalloon() OVERRIDE; |
57 virtual void Close(bool by_user) OVERRIDE; | 57 virtual void Close(bool by_user) OVERRIDE; |
58 virtual gfx::Size GetSize() const OVERRIDE; | 58 virtual gfx::Size GetSize() const OVERRIDE; |
59 virtual BalloonHost* GetHost() const OVERRIDE; | 59 virtual BalloonHost* GetHost() const OVERRIDE; |
60 | 60 |
61 void set_enable_web_ui(bool enable) { enable_web_ui_ = enable; } | 61 void set_enable_web_ui(bool enable) { enable_web_ui_ = enable; } |
62 | 62 |
63 private: | 63 private: |
64 // views::View interface. | 64 // views::View interface. |
65 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; | 65 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; |
66 virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE; | 66 virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE; |
67 virtual gfx::Size GetPreferredSize() OVERRIDE; | 67 virtual gfx::Size GetPreferredSize() OVERRIDE; |
68 | 68 |
69 // views::MenuButtonDelegate interface. | 69 // views::MenuButtonListener interface. |
70 virtual void RunMenu(views::View* source, const gfx::Point& pt) OVERRIDE; | 70 virtual void OnMenuButtonClicked(views::View* source, |
| 71 const gfx::Point& point) OVERRIDE; |
71 | 72 |
72 // views::WidgetDelegate interface. | 73 // views::WidgetDelegate interface. |
73 virtual void OnDisplayChanged() OVERRIDE; | 74 virtual void OnDisplayChanged() OVERRIDE; |
74 virtual void OnWorkAreaChanged() OVERRIDE; | 75 virtual void OnWorkAreaChanged() OVERRIDE; |
75 | 76 |
76 // views::ButtonListener interface. | 77 // views::ButtonListener interface. |
77 virtual void ButtonPressed( | 78 virtual void ButtonPressed( |
78 views::Button* sender, const views::Event&) OVERRIDE; | 79 views::Button* sender, const views::Event&) OVERRIDE; |
79 | 80 |
80 // content::NotificationObserver interface. | 81 // content::NotificationObserver interface. |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 | 160 |
160 content::NotificationRegistrar notification_registrar_; | 161 content::NotificationRegistrar notification_registrar_; |
161 | 162 |
162 // Set to true if this is browser generate web UI. | 163 // Set to true if this is browser generate web UI. |
163 bool enable_web_ui_; | 164 bool enable_web_ui_; |
164 | 165 |
165 DISALLOW_COPY_AND_ASSIGN(BalloonViewImpl); | 166 DISALLOW_COPY_AND_ASSIGN(BalloonViewImpl); |
166 }; | 167 }; |
167 | 168 |
168 #endif // CHROME_BROWSER_UI_VIEWS_NOTIFICATIONS_BALLOON_VIEW_H_ | 169 #endif // CHROME_BROWSER_UI_VIEWS_NOTIFICATIONS_BALLOON_VIEW_H_ |
OLD | NEW |