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

Side by Side Diff: ash/system/tray/system_tray_bubble.h

Issue 10378070: ash: Separate out SystemTrayBubble and related classes into a new file. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge Created 8 years, 7 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
« no previous file with comments | « ash/system/tray/system_tray.cc ('k') | ash/system/tray/system_tray_bubble.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #ifndef ASH_SYSTEM_TRAY_SYSTEM_TRAY_BUBBLE_H_
6 #define ASH_SYSTEM_TRAY_SYSTEM_TRAY_BUBBLE_H_
7 #pragma once
8
9 #include "ash/system/user/login_status.h"
10 #include "base/base_export.h"
11 #include "base/message_pump_observer.h"
12 #include "base/timer.h"
13 #include "ui/views/bubble/bubble_delegate.h"
14 #include "ui/views/widget/widget.h"
15
16 #include <vector>
17
18 namespace ash {
19
20 class SystemTray;
21 class SystemTrayItem;
22
23 namespace internal {
24
25 class SystemTrayBubble;
26
27 class SystemTrayBubbleView : public views::BubbleDelegateView {
28 public:
29 SystemTrayBubbleView(views::View* anchor,
30 SystemTrayBubble* host,
31 bool can_activate);
32 virtual ~SystemTrayBubbleView();
33
34 void SetBubbleBorder(views::BubbleBorder* border);
35
36 void UpdateAnchor();
37
38 // Called when the host is destroyed.
39 void reset_host() { host_ = NULL; }
40
41 private:
42 // Overridden from views::BubbleDelegateView.
43 virtual void Init() OVERRIDE;
44 virtual gfx::Rect GetAnchorRect() OVERRIDE;
45 // Overridden from views::View.
46 virtual void ChildPreferredSizeChanged(View* child) OVERRIDE;
47 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE;
48 virtual bool CanActivate() const OVERRIDE;
49 virtual gfx::Size GetPreferredSize() OVERRIDE;
50 virtual void OnMouseEntered(const views::MouseEvent& event) OVERRIDE;
51 virtual void OnMouseExited(const views::MouseEvent& event) OVERRIDE;
52
53 SystemTrayBubble* host_;
54 bool can_activate_;
55
56 DISALLOW_COPY_AND_ASSIGN(SystemTrayBubbleView);
57 };
58
59 class SystemTrayBubble : public base::MessagePumpObserver,
60 public views::Widget::Observer {
61 public:
62 enum BubbleType {
63 BUBBLE_TYPE_DEFAULT,
64 BUBBLE_TYPE_DETAILED,
65 BUBBLE_TYPE_NOTIFICATION
66 };
67
68 enum AnchorType {
69 ANCHOR_TYPE_TRAY,
70 ANCHOR_TYPE_BUBBLE
71 };
72
73 SystemTrayBubble(ash::SystemTray* tray,
74 const std::vector<ash::SystemTrayItem*>& items,
75 BubbleType bubble_type);
76 virtual ~SystemTrayBubble();
77
78 // Creates |bubble_view_| and a child views for each member of |items_|.
79 // Also creates |bubble_widget_| and sets up animations.
80 void InitView(views::View* anchor,
81 AnchorType anchor_type,
82 bool can_activate,
83 ash::user::LoginStatus login_status);
84
85 gfx::Rect GetAnchorRect() const;
86
87 BubbleType bubble_type() const { return bubble_type_; }
88 SystemTrayBubbleView* bubble_view() const { return bubble_view_; }
89
90 void DestroyItemViews();
91 void StartAutoCloseTimer(int seconds);
92 void StopAutoCloseTimer();
93 void RestartAutoCloseTimer();
94 void Close();
95
96 private:
97 // Overridden from base::MessagePumpObserver.
98 virtual base::EventStatus WillProcessEvent(
99 const base::NativeEvent& event) OVERRIDE;
100 virtual void DidProcessEvent(const base::NativeEvent& event) OVERRIDE;
101 // Overridden from views::Widget::Observer.
102 virtual void OnWidgetClosing(views::Widget* widget) OVERRIDE;
103 virtual void OnWidgetVisibilityChanged(views::Widget* widget,
104 bool visible) OVERRIDE;
105
106 ash::SystemTray* tray_;
107 SystemTrayBubbleView* bubble_view_;
108 views::Widget* bubble_widget_;
109 std::vector<ash::SystemTrayItem*> items_;
110 BubbleType bubble_type_;
111 AnchorType anchor_type_;
112
113 int autoclose_delay_;
114 base::OneShotTimer<SystemTrayBubble> autoclose_;
115
116 DISALLOW_COPY_AND_ASSIGN(SystemTrayBubble);
117 };
118
119 } // namespace internal
120 } // namespace ash
121
122 #endif // ASH_SYSTEM_TRAY_SYSTEM_TRAY_BUBBLE_H_
OLDNEW
« no previous file with comments | « ash/system/tray/system_tray.cc ('k') | ash/system/tray/system_tray_bubble.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698