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_SYSTEM_TRAY_H_ | 5 #ifndef ASH_SYSTEM_TRAY_SYSTEM_TRAY_H_ |
6 #define ASH_SYSTEM_TRAY_SYSTEM_TRAY_H_ | 6 #define ASH_SYSTEM_TRAY_SYSTEM_TRAY_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "ash/launcher/background_animator.h" | 9 #include "ash/launcher/background_animator.h" |
10 #include "ash/ash_export.h" | 10 #include "ash/ash_export.h" |
11 #include "ash/system/tray/tray_views.h" | 11 #include "ash/system/tray/tray_views.h" |
12 #include "ash/system/user/login_status.h" | 12 #include "ash/system/user/login_status.h" |
13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
14 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
16 #include "base/memory/scoped_vector.h" | 16 #include "base/memory/scoped_vector.h" |
17 #include "ui/views/view.h" | 17 #include "ui/views/view.h" |
18 | 18 |
| 19 #include <map> |
19 #include <vector> | 20 #include <vector> |
20 | 21 |
21 namespace ash { | 22 namespace ash { |
22 | 23 |
23 class AccessibilityObserver; | 24 class AccessibilityObserver; |
24 class AudioObserver; | 25 class AudioObserver; |
25 class BluetoothObserver; | 26 class BluetoothObserver; |
26 class BrightnessObserver; | 27 class BrightnessObserver; |
27 class CapsLockObserver; | 28 class CapsLockObserver; |
28 class ClockObserver; | 29 class ClockObserver; |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 friend class internal::SystemTrayLayerAnimationObserver; | 148 friend class internal::SystemTrayLayerAnimationObserver; |
148 friend class internal::SystemTrayBubble; | 149 friend class internal::SystemTrayBubble; |
149 | 150 |
150 // Called when the widget associated with |bubble| closes. |bubble| should | 151 // Called when the widget associated with |bubble| closes. |bubble| should |
151 // always == |bubble_|. This triggers destroying |bubble_| and hiding the | 152 // always == |bubble_|. This triggers destroying |bubble_| and hiding the |
152 // launcher if necessary. | 153 // launcher if necessary. |
153 void RemoveBubble(internal::SystemTrayBubble* bubble); | 154 void RemoveBubble(internal::SystemTrayBubble* bubble); |
154 | 155 |
155 const ScopedVector<SystemTrayItem>& items() const { return items_; } | 156 const ScopedVector<SystemTrayItem>& items() const { return items_; } |
156 | 157 |
| 158 // Calculates the x-offset for the item in the tray. Returns -1 if its tray |
| 159 // item view is not visible. |
| 160 int GetTrayXOffset(SystemTrayItem* item) const; |
| 161 |
| 162 // Shows the default view and its arrow position is shifted by |x_offset|. |
| 163 void ShowDefaultViewWithOffset(BubbleCreationType creation_type, |
| 164 int x_offset); |
| 165 |
157 // Constructs or re-constructs |bubble_| and populates it with |items|. | 166 // Constructs or re-constructs |bubble_| and populates it with |items|. |
158 void ShowItems(const std::vector<SystemTrayItem*>& items, | 167 void ShowItems(const std::vector<SystemTrayItem*>& items, |
159 bool details, | 168 bool details, |
160 bool activate, | 169 bool activate, |
161 BubbleCreationType creation_type); | 170 BubbleCreationType creation_type, |
| 171 int x_offset); |
162 | 172 |
163 // Constructs or re-constructs |notification_bubble_| and populates it with | 173 // Constructs or re-constructs |notification_bubble_| and populates it with |
164 // |notification_items_|, or destroys it if there are no notification items. | 174 // |notification_items_|, or destroys it if there are no notification items. |
165 void UpdateNotificationBubble(); | 175 void UpdateNotificationBubble(); |
166 | 176 |
167 // Called when the anchor (tray or bubble) may have moved or changed. | 177 // Called when the anchor (tray or bubble) may have moved or changed. |
168 void UpdateNotificationAnchor(); | 178 void UpdateNotificationAnchor(); |
169 | 179 |
170 // Overridden from internal::ActionableView. | 180 // Overridden from internal::ActionableView. |
171 virtual bool PerformAction(const views::Event& event) OVERRIDE; | 181 virtual bool PerformAction(const views::Event& event) OVERRIDE; |
172 | 182 |
173 // Overridden from views::View. | 183 // Overridden from views::View. |
174 virtual void OnMouseEntered(const views::MouseEvent& event) OVERRIDE; | 184 virtual void OnMouseEntered(const views::MouseEvent& event) OVERRIDE; |
175 virtual void OnMouseExited(const views::MouseEvent& event) OVERRIDE; | 185 virtual void OnMouseExited(const views::MouseEvent& event) OVERRIDE; |
176 virtual void AboutToRequestFocusFromTabTraversal(bool reverse) OVERRIDE; | 186 virtual void AboutToRequestFocusFromTabTraversal(bool reverse) OVERRIDE; |
177 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; | 187 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; |
178 virtual void OnPaintFocusBorder(gfx::Canvas* canvas) OVERRIDE; | 188 virtual void OnPaintFocusBorder(gfx::Canvas* canvas) OVERRIDE; |
179 | 189 |
180 // Overridden from internal::BackgroundAnimatorDelegate. | 190 // Overridden from internal::BackgroundAnimatorDelegate. |
181 virtual void UpdateBackground(int alpha) OVERRIDE; | 191 virtual void UpdateBackground(int alpha) OVERRIDE; |
182 | 192 |
183 ScopedVector<SystemTrayItem> items_; | 193 ScopedVector<SystemTrayItem> items_; |
184 | 194 |
185 std::vector<SystemTrayItem*> notification_items_; | 195 std::vector<SystemTrayItem*> notification_items_; |
186 | 196 |
187 // The container for all the tray views of the items. | 197 // The container for all the tray views of the items. |
188 views::View* tray_container_; | 198 views::View* tray_container_; |
189 | 199 |
| 200 // Mappings of system tray item and it's view in the tray. |
| 201 std::map<SystemTrayItem*, views::View*> tray_item_map_; |
| 202 |
190 // These observers are not owned by the tray. | 203 // These observers are not owned by the tray. |
191 AccessibilityObserver* accessibility_observer_; | 204 AccessibilityObserver* accessibility_observer_; |
192 AudioObserver* audio_observer_; | 205 AudioObserver* audio_observer_; |
193 BluetoothObserver* bluetooth_observer_; | 206 BluetoothObserver* bluetooth_observer_; |
194 BrightnessObserver* brightness_observer_; | 207 BrightnessObserver* brightness_observer_; |
195 CapsLockObserver* caps_lock_observer_; | 208 CapsLockObserver* caps_lock_observer_; |
196 ClockObserver* clock_observer_; | 209 ClockObserver* clock_observer_; |
197 DriveObserver* drive_observer_; | 210 DriveObserver* drive_observer_; |
198 IMEObserver* ime_observer_; | 211 IMEObserver* ime_observer_; |
199 NetworkObserver* network_observer_; | 212 NetworkObserver* network_observer_; |
(...skipping 20 matching lines...) Expand all Loading... |
220 internal::BackgroundAnimator hover_background_animator_; | 233 internal::BackgroundAnimator hover_background_animator_; |
221 scoped_ptr<internal::SystemTrayLayerAnimationObserver> | 234 scoped_ptr<internal::SystemTrayLayerAnimationObserver> |
222 layer_animation_observer_; | 235 layer_animation_observer_; |
223 | 236 |
224 DISALLOW_COPY_AND_ASSIGN(SystemTray); | 237 DISALLOW_COPY_AND_ASSIGN(SystemTray); |
225 }; | 238 }; |
226 | 239 |
227 } // namespace ash | 240 } // namespace ash |
228 | 241 |
229 #endif // ASH_SYSTEM_TRAY_SYSTEM_TRAY_H_ | 242 #endif // ASH_SYSTEM_TRAY_SYSTEM_TRAY_H_ |
OLD | NEW |