Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(140)

Side by Side Diff: chrome/browser/ui/gtk/notifications/balloon_view_gtk.h

Issue 231733005: Delete the GTK+ port of Chrome. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remerge to ToT Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 // Draws the view for the balloons.
6
7 #ifndef CHROME_BROWSER_UI_GTK_NOTIFICATIONS_BALLOON_VIEW_GTK_H_
8 #define CHROME_BROWSER_UI_GTK_NOTIFICATIONS_BALLOON_VIEW_GTK_H_
9
10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/weak_ptr.h"
14 #include "chrome/browser/notifications/balloon.h"
15 #include "chrome/browser/ui/gtk/menu_gtk.h"
16 #include "chrome/browser/ui/gtk/notifications/balloon_view_host_gtk.h"
17 #include "content/public/browser/notification_observer.h"
18 #include "content/public/browser/notification_registrar.h"
19 #include "ui/base/gtk/gtk_signal.h"
20 #include "ui/gfx/animation/animation_delegate.h"
21 #include "ui/gfx/point.h"
22 #include "ui/gfx/rect.h"
23 #include "ui/gfx/size.h"
24
25 class BalloonCollection;
26 class CustomDrawButton;
27 class GtkThemeService;
28 class MenuGtk;
29 class NotificationOptionsMenuModel;
30
31 namespace gfx {
32 class SlideAnimation;
33 }
34
35 // A balloon view is the UI component for desktop notification toasts.
36 // It draws a border, and within the border an HTML renderer.
37 class BalloonViewImpl : public BalloonView,
38 public MenuGtk::Delegate,
39 public content::NotificationObserver,
40 public gfx::AnimationDelegate {
41 public:
42 explicit BalloonViewImpl(BalloonCollection* collection);
43 virtual ~BalloonViewImpl();
44
45 // BalloonView interface.
46 virtual void Show(Balloon* balloon) OVERRIDE;
47 virtual void Update() OVERRIDE;
48 virtual void RepositionToBalloon() OVERRIDE;
49 virtual void Close(bool by_user) OVERRIDE;
50 virtual gfx::Size GetSize() const OVERRIDE;
51 virtual BalloonHost* GetHost() const OVERRIDE;
52
53 // MenuGtk::Delegate interface.
54 virtual void StoppedShowing() OVERRIDE;
55
56 private:
57 // content::NotificationObserver interface.
58 virtual void Observe(int type,
59 const content::NotificationSource& source,
60 const content::NotificationDetails& details) OVERRIDE;
61
62 // gfx::AnimationDelegate interface.
63 virtual void AnimationProgressed(const gfx::Animation* animation) OVERRIDE;
64
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
67 // an event that relies on them.
68 void DelayedClose(bool by_user);
69
70 // The height of the balloon's shelf.
71 // The shelf is where is close button is located.
72 int GetShelfHeight() const;
73
74 // The width and height that the frame should be. If the balloon inside
75 // changes size, this will not be the same as the actual frame size until
76 // RepositionToBalloon() has been called and the animation completes.
77 int GetDesiredTotalWidth() const;
78 int GetDesiredTotalHeight() const;
79
80 // Where the balloon contents should be placed with respect to the top left
81 // of the frame.
82 gfx::Point GetContentsOffset() const;
83
84 // Where the balloon contents should be in screen coordinates.
85 gfx::Rect GetContentsRectangle() const;
86
87 CHROMEGTK_CALLBACK_1(BalloonViewImpl, gboolean, OnContentsExpose,
88 GdkEventExpose*);
89 CHROMEGTK_CALLBACK_0(BalloonViewImpl, void, OnCloseButton);
90 CHROMEGTK_CALLBACK_1(BalloonViewImpl, gboolean, OnExpose, GdkEventExpose*);
91 CHROMEGTK_CALLBACK_1(BalloonViewImpl, void, OnOptionsMenuButton,
92 GdkEventButton*);
93 CHROMEGTK_CALLBACK_0(BalloonViewImpl, gboolean, OnDestroy);
94
95 // Non-owned pointer to the balloon which owns this object.
96 Balloon* balloon_;
97
98 GtkThemeService* theme_service_;
99
100 // The window that contains the frame of the notification.
101 GtkWidget* frame_container_;
102
103 // The widget that contains the shelf.
104 GtkWidget* shelf_;
105
106 // The hbox within the shelf that contains the buttons.
107 GtkWidget* hbox_;
108
109 // The window that contains the contents of the notification.
110 GtkWidget* html_container_;
111
112 // The renderer of the HTML contents.
113 scoped_ptr<BalloonViewHost> html_contents_;
114
115 // Close button.
116 scoped_ptr<CustomDrawButton> close_button_;
117
118 // An animation to move the balloon on the screen as its position changes.
119 scoped_ptr<gfx::SlideAnimation> animation_;
120 gfx::Rect anim_frame_start_;
121 gfx::Rect anim_frame_end_;
122
123 // The options menu.
124 scoped_ptr<MenuGtk> options_menu_;
125 scoped_ptr<NotificationOptionsMenuModel> options_menu_model_;
126 // The button to open the options menu.
127 scoped_ptr<CustomDrawButton> options_menu_button_;
128
129 content::NotificationRegistrar notification_registrar_;
130
131 // Is the menu currently showing?
132 bool menu_showing_;
133
134 // Is there a pending system-initiated close?
135 bool pending_close_;
136
137 base::WeakPtrFactory<BalloonViewImpl> weak_factory_;
138
139 DISALLOW_COPY_AND_ASSIGN(BalloonViewImpl);
140 };
141
142 #endif // CHROME_BROWSER_UI_GTK_NOTIFICATIONS_BALLOON_VIEW_GTK_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698