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

Side by Side Diff: chrome/browser/notifications/balloon.h

Issue 231723006: Remove balloon notification code. The last user was the Linux GTK port but that's deleted now. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: sync after elliot's r263101 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 // Handles the visible notification (or balloons).
6
7 #ifndef CHROME_BROWSER_NOTIFICATIONS_BALLOON_H_
8 #define CHROME_BROWSER_NOTIFICATIONS_BALLOON_H_
9
10 #include "base/basictypes.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "ui/gfx/point.h"
13 #include "ui/gfx/rect.h"
14 #include "ui/gfx/size.h"
15
16 class Balloon;
17 class BalloonCollection;
18 class BalloonHost;
19 class Notification;
20 class Profile;
21
22 // Interface for a view that displays a balloon.
23 class BalloonView {
24 public:
25 virtual ~BalloonView() {}
26
27 // Show the view on the screen.
28 virtual void Show(Balloon* balloon) = 0;
29
30 // Notify that the content of notification has chagned.
31 virtual void Update() = 0;
32
33 // Reposition the view to match the position of its balloon.
34 virtual void RepositionToBalloon() = 0;
35
36 // Close the view.
37 virtual void Close(bool by_user) = 0;
38
39 // The total size of the view.
40 virtual gfx::Size GetSize() const = 0;
41
42 // The host for the view's contents. May be NULL if an implementation does
43 // not have a host associated with it (i.e. does not do html rendering).
44 virtual BalloonHost* GetHost() const = 0;
45
46 // Returns the horizontal margin the content is inset by.
47 static int GetHorizontalMargin();
48 };
49
50 // Represents a Notification on the screen.
51 class Balloon {
52 public:
53 Balloon(const Notification& notification,
54 Profile* profile,
55 BalloonCollection* collection);
56 virtual ~Balloon();
57
58 const Notification& notification() const { return *notification_.get(); }
59 Profile* profile() const { return profile_; }
60
61 gfx::Point GetPosition() const {
62 return position_ + offset_;
63 }
64 void SetPosition(const gfx::Point& upper_left, bool reposition);
65
66 const gfx::Vector2d& offset() const { return offset_; }
67 void set_offset(const gfx::Vector2d& offset) { offset_ = offset; }
68 void add_offset(const gfx::Vector2d& offset) { offset_.Add(offset); }
69
70 const gfx::Size& content_size() const { return content_size_; }
71 void set_content_size(const gfx::Size& size) { content_size_ = size; }
72
73 const BalloonCollection* collection() const { return collection_; }
74
75 const gfx::Size& min_scrollbar_size() const { return min_scrollbar_size_; }
76 void set_min_scrollbar_size(const gfx::Size& size) {
77 min_scrollbar_size_ = size;
78 }
79
80 // Request a new content size for this balloon. This will get passed
81 // to the balloon collection for checking against available space and
82 // min/max restrictions.
83 void ResizeDueToAutoResize(const gfx::Size& size);
84
85 // Provides a view for this balloon. Ownership transfers to this object.
86 void set_view(BalloonView* balloon_view);
87
88 // Returns the balloon view associated with the balloon.
89 BalloonView* balloon_view() const { return balloon_view_.get(); }
90
91 // Returns the viewing size for the balloon (content + frame).
92 gfx::Size GetViewSize() const { return balloon_view_->GetSize(); }
93
94 // Shows the balloon.
95 virtual void Show();
96
97 // Notify that the content of notification has changed.
98 virtual void Update(const Notification& notification);
99
100 // Called when the balloon is clicked by the user.
101 virtual void OnClick();
102
103 // Called when the user clicks a button in the balloon.
104 virtual void OnButtonClick(int button_index);
105
106 // Called when the balloon is closed, either by user (through the UI)
107 // or by a script.
108 virtual void OnClose(bool by_user);
109
110 // Called by script to cause the balloon to close.
111 virtual void CloseByScript();
112
113 // Returns the ID of the extension that created this balloon's notification.
114 std::string GetExtensionId();
115
116 private:
117 // Non-owned pointer to the profile.
118 Profile* profile_;
119
120 // The notification being shown in this balloon.
121 scoped_ptr<Notification> notification_;
122
123 // The collection that this balloon belongs to. Non-owned pointer.
124 BalloonCollection* collection_;
125
126 // The actual UI element for the balloon.
127 scoped_ptr<BalloonView> balloon_view_;
128
129 // Position and size of the balloon on the screen.
130 gfx::Point position_;
131 gfx::Size content_size_;
132
133 // Temporary offset for balloons that need to be positioned in a non-standard
134 // position for keeping the close buttons under the mouse cursor.
135 gfx::Vector2d offset_;
136
137 // Smallest size for this balloon where scrollbars will be shown.
138 gfx::Size min_scrollbar_size_;
139
140 DISALLOW_COPY_AND_ASSIGN(Balloon);
141 };
142
143 #endif // CHROME_BROWSER_NOTIFICATIONS_BALLOON_H_
OLDNEW
« no previous file with comments | « chrome/browser/local_discovery/privet_notifications.cc ('k') | chrome/browser/notifications/balloon.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698