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 #ifndef ASH_SYSTEM_TRAY_TRAY_BUBBLE_WRAPPER_H_ | 5 #ifndef ASH_SYSTEM_TRAY_TRAY_BUBBLE_WRAPPER_H_ |
6 #define ASH_SYSTEM_TRAY_TRAY_BUBBLE_WRAPPER_H_ | 6 #define ASH_SYSTEM_TRAY_TRAY_BUBBLE_WRAPPER_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/memory/weak_ptr.h" |
10 #include "ui/views/widget/widget_observer.h" | 11 #include "ui/views/widget/widget_observer.h" |
11 | 12 |
12 namespace views { | 13 namespace views { |
13 class TrayBubbleView; | 14 class TrayBubbleView; |
14 } | 15 } |
15 | 16 |
16 namespace ash { | 17 namespace ash { |
17 namespace internal { | 18 namespace internal { |
18 | 19 |
19 class TrayBackgroundView; | 20 class TrayBackgroundView; |
20 class TrayEventFilter; | 21 class TrayEventFilter; |
21 | 22 |
22 // Creates and manages the Widget and EventFilter components of a bubble. | 23 // Creates and manages the Widget and EventFilter components of a bubble. |
23 | 24 class TrayBubbleWrapper : public views::WidgetObserver, |
24 class TrayBubbleWrapper : public views::WidgetObserver { | 25 public base::SupportsWeakPtr<TrayBubbleWrapper> { |
25 public: | 26 public: |
26 TrayBubbleWrapper(TrayBackgroundView* tray, | 27 TrayBubbleWrapper(TrayBackgroundView* tray, |
27 views::TrayBubbleView* bubble_view); | 28 views::TrayBubbleView* bubble_view); |
28 virtual ~TrayBubbleWrapper(); | 29 virtual ~TrayBubbleWrapper(); |
29 | 30 |
30 // views::WidgetObserver overrides: | 31 // views::WidgetObserver overrides: |
31 virtual void OnWidgetDestroying(views::Widget* widget) OVERRIDE; | 32 virtual void OnWidgetDestroying(views::Widget* widget) OVERRIDE; |
32 | 33 |
33 const TrayBackgroundView* tray() const { return tray_; } | 34 const TrayBackgroundView* tray() const { return tray_; } |
34 TrayBackgroundView* tray() { return tray_; } | 35 TrayBackgroundView* tray() { return tray_; } |
35 const views::TrayBubbleView* bubble_view() const { return bubble_view_; } | 36 const views::TrayBubbleView* bubble_view() const { return bubble_view_; } |
36 const views::Widget* bubble_widget() const { return bubble_widget_; } | 37 const views::Widget* bubble_widget() const { return bubble_widget_; } |
37 | 38 |
38 private: | 39 private: |
| 40 void HideBubbleWithView(); |
| 41 |
| 42 // unowned. |tray_| owns this and it should outlive. |
39 TrayBackgroundView* tray_; | 43 TrayBackgroundView* tray_; |
40 views::TrayBubbleView* bubble_view_; // unowned | 44 |
| 45 // unowned. |
| 46 views::TrayBubbleView* bubble_view_; |
| 47 |
| 48 // unowned. |
41 views::Widget* bubble_widget_; | 49 views::Widget* bubble_widget_; |
42 | 50 |
43 DISALLOW_COPY_AND_ASSIGN(TrayBubbleWrapper); | 51 DISALLOW_COPY_AND_ASSIGN(TrayBubbleWrapper); |
44 }; | 52 }; |
45 | 53 |
46 } // namespace internal | 54 } // namespace internal |
47 } // namespace ash | 55 } // namespace ash |
48 | 56 |
49 #endif // ASH_SYSTEM_TRAY_TRAY_BUBBLE_WRAPPER_H_ | 57 #endif // ASH_SYSTEM_TRAY_TRAY_BUBBLE_WRAPPER_H_ |
OLD | NEW |