| 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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 friend class internal::SystemTrayLayerAnimationObserver; | 141 friend class internal::SystemTrayLayerAnimationObserver; |
| 141 friend class internal::SystemTrayBubble; | 142 friend class internal::SystemTrayBubble; |
| 142 | 143 |
| 143 // Called when the widget associated with |bubble| closes. |bubble| should | 144 // Called when the widget associated with |bubble| closes. |bubble| should |
| 144 // always == |bubble_|. This triggers destroying |bubble_| and hiding the | 145 // always == |bubble_|. This triggers destroying |bubble_| and hiding the |
| 145 // launcher if necessary. | 146 // launcher if necessary. |
| 146 void RemoveBubble(internal::SystemTrayBubble* bubble); | 147 void RemoveBubble(internal::SystemTrayBubble* bubble); |
| 147 | 148 |
| 148 const ScopedVector<SystemTrayItem>& items() const { return items_; } | 149 const ScopedVector<SystemTrayItem>& items() const { return items_; } |
| 149 | 150 |
| 151 // Calculates the x-offset for the item in the tray. Returns -1 if its tray |
| 152 // item view is not visible. |
| 153 int GetTrayXOffset(SystemTrayItem* item) const; |
| 154 |
| 155 // Shows the default view and its arrow position is shifted by |x_offset|. |
| 156 void ShowDefaultViewWithOffset(int x_offset); |
| 157 |
| 150 // Constructs or re-constructs |bubble_| and populates it with |items|. | 158 // Constructs or re-constructs |bubble_| and populates it with |items|. |
| 151 void ShowItems(const std::vector<SystemTrayItem*>& items, | 159 void ShowItems(const std::vector<SystemTrayItem*>& items, |
| 152 bool details, | 160 bool details, |
| 153 bool activate); | 161 bool activate, |
| 162 int x_offset); |
| 154 | 163 |
| 155 // Constructs or re-constructs |notification_bubble_| and populates it with | 164 // Constructs or re-constructs |notification_bubble_| and populates it with |
| 156 // |notification_items_|, or destroys it if there are no notification items. | 165 // |notification_items_|, or destroys it if there are no notification items. |
| 157 void UpdateNotificationBubble(); | 166 void UpdateNotificationBubble(); |
| 158 | 167 |
| 159 // Called when the anchor (tray or bubble) may have moved or changed. | 168 // Called when the anchor (tray or bubble) may have moved or changed. |
| 160 void UpdateNotificationAnchor(); | 169 void UpdateNotificationAnchor(); |
| 161 | 170 |
| 162 // Overridden from internal::ActionableView. | 171 // Overridden from internal::ActionableView. |
| 163 virtual bool PerformAction(const views::Event& event) OVERRIDE; | 172 virtual bool PerformAction(const views::Event& event) OVERRIDE; |
| 164 | 173 |
| 165 // Overridden from views::View. | 174 // Overridden from views::View. |
| 166 virtual void OnMouseEntered(const views::MouseEvent& event) OVERRIDE; | 175 virtual void OnMouseEntered(const views::MouseEvent& event) OVERRIDE; |
| 167 virtual void OnMouseExited(const views::MouseEvent& event) OVERRIDE; | 176 virtual void OnMouseExited(const views::MouseEvent& event) OVERRIDE; |
| 168 virtual void AboutToRequestFocusFromTabTraversal(bool reverse) OVERRIDE; | 177 virtual void AboutToRequestFocusFromTabTraversal(bool reverse) OVERRIDE; |
| 169 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; | 178 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; |
| 170 virtual void OnPaintFocusBorder(gfx::Canvas* canvas) OVERRIDE; | 179 virtual void OnPaintFocusBorder(gfx::Canvas* canvas) OVERRIDE; |
| 171 | 180 |
| 172 // Overridden from internal::BackgroundAnimatorDelegate. | 181 // Overridden from internal::BackgroundAnimatorDelegate. |
| 173 virtual void UpdateBackground(int alpha) OVERRIDE; | 182 virtual void UpdateBackground(int alpha) OVERRIDE; |
| 174 | 183 |
| 175 ScopedVector<SystemTrayItem> items_; | 184 ScopedVector<SystemTrayItem> items_; |
| 176 | 185 |
| 177 std::vector<SystemTrayItem*> notification_items_; | 186 std::vector<SystemTrayItem*> notification_items_; |
| 178 | 187 |
| 179 // The container for all the tray views of the items. | 188 // The container for all the tray views of the items. |
| 180 views::View* tray_container_; | 189 views::View* tray_container_; |
| 181 | 190 |
| 191 // Mappings of system tray item and it's view in the tray. |
| 192 std::map<SystemTrayItem*, views::View*> tray_item_map_; |
| 193 |
| 182 // These observers are not owned by the tray. | 194 // These observers are not owned by the tray. |
| 183 AccessibilityObserver* accessibility_observer_; | 195 AccessibilityObserver* accessibility_observer_; |
| 184 AudioObserver* audio_observer_; | 196 AudioObserver* audio_observer_; |
| 185 BluetoothObserver* bluetooth_observer_; | 197 BluetoothObserver* bluetooth_observer_; |
| 186 BrightnessObserver* brightness_observer_; | 198 BrightnessObserver* brightness_observer_; |
| 187 CapsLockObserver* caps_lock_observer_; | 199 CapsLockObserver* caps_lock_observer_; |
| 188 ClockObserver* clock_observer_; | 200 ClockObserver* clock_observer_; |
| 189 DriveObserver* drive_observer_; | 201 DriveObserver* drive_observer_; |
| 190 IMEObserver* ime_observer_; | 202 IMEObserver* ime_observer_; |
| 191 NetworkObserver* network_observer_; | 203 NetworkObserver* network_observer_; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 212 internal::BackgroundAnimator hover_background_animator_; | 224 internal::BackgroundAnimator hover_background_animator_; |
| 213 scoped_ptr<internal::SystemTrayLayerAnimationObserver> | 225 scoped_ptr<internal::SystemTrayLayerAnimationObserver> |
| 214 layer_animation_observer_; | 226 layer_animation_observer_; |
| 215 | 227 |
| 216 DISALLOW_COPY_AND_ASSIGN(SystemTray); | 228 DISALLOW_COPY_AND_ASSIGN(SystemTray); |
| 217 }; | 229 }; |
| 218 | 230 |
| 219 } // namespace ash | 231 } // namespace ash |
| 220 | 232 |
| 221 #endif // ASH_SYSTEM_TRAY_SYSTEM_TRAY_H_ | 233 #endif // ASH_SYSTEM_TRAY_SYSTEM_TRAY_H_ |
| OLD | NEW |