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

Side by Side Diff: chrome/browser/ui/views/browser_bubble.h

Issue 8673009: Remove unused BrowserBubble remnants. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove more stale code. Created 9 years 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) 2011 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 #ifndef CHROME_BROWSER_UI_VIEWS_BROWSER_BUBBLE_H_
6 #define CHROME_BROWSER_UI_VIEWS_BROWSER_BUBBLE_H_
7 #pragma once
8
9 #include "ui/views/bubble/bubble_border.h"
10 #include "ui/views/widget/widget.h"
11 #include "views/view.h"
12
13 class Browser;
14 class BrowserBubbleHost;
15
16 // A class for creating a floating window that is "attached" to a particular
17 // Browser. If you don't install a delegate, the bubble will hide
18 // automatically when the browser moves. The bubble is only shown manually.
19 // Users are expected to delete the bubble when finished with it.
20 // Class assumes that RTL related mirroring is done by the view.
21 class BrowserBubble {
22 public:
23 // Delegate to browser bubble events.
24 class Delegate {
25 public:
26 // Called when the Browser Window that this bubble is attached to moves.
27 virtual void BubbleBrowserWindowMoved(BrowserBubble* bubble) {}
28
29 // Called with the Browser Window that this bubble is attached to is
30 // about to close.
31 virtual void BubbleBrowserWindowClosing(BrowserBubble* bubble) {}
32
33 // Called when the bubble became active / got focus.
34 virtual void BubbleGotFocus(BrowserBubble* bubble) {}
35
36 // Called when the bubble became inactive / lost focus.
37 // |lost_focus_to_child| is true when a child window became active.
38 virtual void BubbleLostFocus(BrowserBubble* bubble,
39 bool lost_focus_to_child) {}
40 };
41
42 // Note that the bubble will size itself to the preferred size of |view| plus
43 // insets of bubble border. |view| is the embedded view, |browser| is the
44 // browser that the bubble is being positioned relative to, |relative_to| is
45 // the location that the bubble is showing relative to in screen coordinates,
46 // e.g. if the buuble is showing for a toolbar button, |relative_to| usually
47 // would be the bounds of the toolbar button in screen coordiates,
48 // |arrow_location| is the location where the arrow should on the bubble.
49 BrowserBubble(Browser* browser,
50 views::View* view,
51 const gfx::Rect& relative_to,
52 views::BubbleBorder::ArrowLocation arrow_location);
53 virtual ~BrowserBubble();
54
55 // Call manually if you need to detach the bubble from tracking the browser's
56 // position. Note that you must call this manually before deleting this
57 // object since it can't be safely called from the destructor.
58 void DetachFromBrowser();
59
60 // Normally called automatically during construction, but if DetachFromBrowser
61 // has been called manually, then this call will reattach.
62 void AttachToBrowser();
63 bool attached() const { return attached_; }
64
65 // Get/Set the delegate.
66 Delegate* delegate() const { return delegate_; }
67 void set_delegate(Delegate* del) { delegate_ = del; }
68
69 // Notifications from BrowserBubbleHost.
70 // With no delegate, both of these default to Hiding the bubble.
71 virtual void BrowserWindowMoved();
72 virtual void BrowserWindowClosing();
73
74 // Show or hide the bubble.
75 virtual void Show(bool activate);
76 virtual void Hide();
77
78 // The contained view.
79 views::View* view() const { return view_; }
80
81 // Set the bounds of the bubble relative to the browser window.
82 void SetBounds(int x, int y, int w, int h);
83 void MoveTo(int x, int y);
84 int width() { return bounds_.width(); }
85 int height() { return bounds_.height(); }
86 const gfx::Rect& bounds() const { return bounds_; }
87
88 // Reposition the bubble - as we are using a WS_POPUP for the bubble,
89 // we have to manually position it when the browser window moves.
90 void Reposition();
91
92 // Resize the bubble to fit the view.
93 void ResizeToView();
94
95 // Returns the NativeView containing that popup.
96 gfx::NativeView native_view() const { return popup_->GetNativeView(); }
97
98 protected:
99 // Create the popup widget.
100 virtual void InitPopup(const gfx::Insets& content_margins);
101
102 // Get |relative_to_| rect in screen coordinates.
103 gfx::Rect GetAbsoluteRelativeTo();
104
105 // Set bounds using screen coordinates.
106 void SetAbsoluteBounds(const gfx::Rect& window_bounds);
107
108 // Move the popup to an absolute position.
109 void MovePopup(int x, int y, int w, int h);
110
111 // The widget that this bubble is in.
112 views::Widget* popup_;
113
114 // The frame that this bubble is attached to.
115 views::Widget* frame_;
116
117 private:
118 // The view that is displayed in this bubble.
119 views::View* view_;
120
121 // Anchor rect that this bubble is shown relative to, in frame coordinates.
122 gfx::Rect relative_to_;
123
124 // Arrow location of this bubble.
125 views::BubbleBorder::ArrowLocation arrow_location_;
126
127 // The bounds relative to the frame.
128 gfx::Rect bounds_;
129
130 // The delegate isn't owned by the bubble.
131 Delegate* delegate_;
132
133 // Is the bubble attached to a Browser window.
134 bool attached_;
135
136 // Non-owning pointer to the host of this bubble.
137 BrowserBubbleHost* bubble_host_;
138
139 DISALLOW_COPY_AND_ASSIGN(BrowserBubble);
140 };
141
142 #endif // CHROME_BROWSER_UI_VIEWS_BROWSER_BUBBLE_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/browser_actions_container.h ('k') | chrome/browser/ui/views/browser_bubble.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698