OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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_BUBBLE_BUBBLE_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_BUBBLE_BUBBLE_H_ |
6 #define CHROME_BROWSER_UI_VIEWS_BUBBLE_BUBBLE_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_BUBBLE_BUBBLE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/observer_list.h" | |
9 #include "views/bubble/bubble_border.h" | 10 #include "views/bubble/bubble_border.h" |
10 #include "ui/base/animation/animation_delegate.h" | 11 #include "ui/base/animation/animation_delegate.h" |
11 #include "views/accelerator.h" | 12 #include "views/accelerator.h" |
12 #include "views/view.h" | 13 #include "views/view.h" |
13 | 14 |
14 #if defined(USE_AURA) | 15 #if defined(USE_AURA) |
15 #include "views/widget/native_widget_aura.h" | 16 #include "views/widget/native_widget_aura.h" |
16 #elif defined(OS_WIN) | 17 #elif defined(OS_WIN) |
17 #include "views/widget/native_widget_win.h" | 18 #include "views/widget/native_widget_win.h" |
18 #elif defined(TOUCH_UI) | 19 #elif defined(TOUCH_UI) |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
79 #elif defined(OS_WIN) | 80 #elif defined(OS_WIN) |
80 : public views::NativeWidgetWin, | 81 : public views::NativeWidgetWin, |
81 #elif defined(TOUCH_UI) | 82 #elif defined(TOUCH_UI) |
82 : public views::NativeWidgetViews, | 83 : public views::NativeWidgetViews, |
83 #elif defined(TOOLKIT_USES_GTK) | 84 #elif defined(TOOLKIT_USES_GTK) |
84 : public views::NativeWidgetGtk, | 85 : public views::NativeWidgetGtk, |
85 #endif | 86 #endif |
86 public views::AcceleratorTarget, | 87 public views::AcceleratorTarget, |
87 public ui::AnimationDelegate { | 88 public ui::AnimationDelegate { |
88 public: | 89 public: |
90 class Observer { | |
91 public: | |
92 // See BubbleDelegate::BubbleClosing for when this is called. | |
93 virtual void OnBubbleClosing(Bubble* bubble, bool closed_by_escape) = 0; | |
Peter Kasting
2011/10/05 01:22:51
Nit: You don't seem to use either of these args, s
sail
2011/10/05 01:32:10
Done.
| |
94 }; | |
95 | |
89 // Shows the Bubble. | 96 // Shows the Bubble. |
90 // |parent| is set as the parent window. | 97 // |parent| is set as the parent window. |
91 // |contents| are the contents shown in the bubble. | 98 // |contents| are the contents shown in the bubble. |
92 // |position_relative_to| is a rect in screen coordinates at which the Bubble | 99 // |position_relative_to| is a rect in screen coordinates at which the Bubble |
93 // will point. | 100 // will point. |
94 // Show() takes ownership of |contents| and deletes the created Bubble when | 101 // Show() takes ownership of |contents| and deletes the created Bubble when |
95 // another window is activated. You can explicitly close the bubble by | 102 // another window is activated. You can explicitly close the bubble by |
96 // invoking Close(). | 103 // invoking Close(). |
97 // |arrow_location| specifies preferred bubble alignment. | 104 // |arrow_location| specifies preferred bubble alignment. |
98 // You may provide an optional |delegate| to: | 105 // You may provide an optional |delegate| to: |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
137 virtual void Close(); | 144 virtual void Close(); |
138 | 145 |
139 // Overridden from ui::AnimationDelegate: | 146 // Overridden from ui::AnimationDelegate: |
140 virtual void AnimationEnded(const ui::Animation* animation); | 147 virtual void AnimationEnded(const ui::Animation* animation); |
141 virtual void AnimationProgressed(const ui::Animation* animation); | 148 virtual void AnimationProgressed(const ui::Animation* animation); |
142 | 149 |
143 #ifdef UNIT_TEST | 150 #ifdef UNIT_TEST |
144 views::View* contents() const { return contents_; } | 151 views::View* contents() const { return contents_; } |
145 #endif | 152 #endif |
146 | 153 |
154 void AddObserver(Observer* obs) { | |
155 observer_list_.AddObserver(obs); | |
156 } | |
157 | |
158 void RemoveObserver(Observer* obs) { | |
159 observer_list_.RemoveObserver(obs); | |
160 } | |
161 | |
147 static const SkColor kBackgroundColor; | 162 static const SkColor kBackgroundColor; |
148 | 163 |
149 protected: | 164 protected: |
150 Bubble(); | 165 Bubble(); |
151 #if defined(OS_CHROMEOS) | 166 #if defined(OS_CHROMEOS) |
152 Bubble(views::Widget::InitParams::Type type, | 167 Bubble(views::Widget::InitParams::Type type, |
153 bool show_while_screen_is_locked); | 168 bool show_while_screen_is_locked); |
154 #endif | 169 #endif |
155 virtual ~Bubble(); | 170 virtual ~Bubble(); |
156 | 171 |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
236 bool show_while_screen_is_locked_; | 251 bool show_while_screen_is_locked_; |
237 #endif | 252 #endif |
238 | 253 |
239 gfx::Rect position_relative_to_; | 254 gfx::Rect position_relative_to_; |
240 views::BubbleBorder::ArrowLocation arrow_location_; | 255 views::BubbleBorder::ArrowLocation arrow_location_; |
241 | 256 |
242 views::View* contents_; | 257 views::View* contents_; |
243 | 258 |
244 bool accelerator_registered_; | 259 bool accelerator_registered_; |
245 | 260 |
261 ObserverList<Observer> observer_list_; | |
262 | |
246 DISALLOW_COPY_AND_ASSIGN(Bubble); | 263 DISALLOW_COPY_AND_ASSIGN(Bubble); |
247 }; | 264 }; |
248 | 265 |
249 #endif // CHROME_BROWSER_UI_VIEWS_BUBBLE_BUBBLE_H_ | 266 #endif // CHROME_BROWSER_UI_VIEWS_BUBBLE_BUBBLE_H_ |
OLD | NEW |