| 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/message_pump_observer.h" | |
| 16 #include "base/memory/scoped_vector.h" | 15 #include "base/memory/scoped_vector.h" |
| 17 #include "ui/views/view.h" | 16 #include "ui/views/view.h" |
| 18 #include "ui/views/widget/widget.h" | |
| 19 | 17 |
| 20 #include <vector> | 18 #include <vector> |
| 21 | 19 |
| 22 namespace ash { | 20 namespace ash { |
| 23 | 21 |
| 24 class AccessibilityObserver; | 22 class AccessibilityObserver; |
| 25 class AudioObserver; | 23 class AudioObserver; |
| 26 class BluetoothObserver; | 24 class BluetoothObserver; |
| 27 class BrightnessObserver; | 25 class BrightnessObserver; |
| 28 class CapsLockObserver; | 26 class CapsLockObserver; |
| 29 class ClockObserver; | 27 class ClockObserver; |
| 30 class IMEObserver; | 28 class IMEObserver; |
| 31 class NetworkObserver; | 29 class NetworkObserver; |
| 32 class PowerStatusObserver; | 30 class PowerStatusObserver; |
| 33 class UpdateObserver; | 31 class UpdateObserver; |
| 34 class UserObserver; | 32 class UserObserver; |
| 35 | 33 |
| 36 class SystemTrayItem; | 34 class SystemTrayItem; |
| 37 | 35 |
| 38 namespace internal { | 36 namespace internal { |
| 39 class SystemTrayBackground; | 37 class SystemTrayBackground; |
| 40 class SystemTrayBubble; | 38 class SystemTrayBubble; |
| 41 } | 39 } |
| 42 | 40 |
| 43 class ASH_EXPORT SystemTray : NON_EXPORTED_BASE( | 41 class ASH_EXPORT SystemTray : NON_EXPORTED_BASE( |
| 44 public internal::ActionableView), | 42 public internal::ActionableView), |
| 45 public views::Widget::Observer, | 43 public internal::BackgroundAnimatorDelegate { |
| 46 public internal::BackgroundAnimatorDelegate, | |
| 47 public base::MessagePumpObserver { | |
| 48 public: | 44 public: |
| 49 SystemTray(); | 45 SystemTray(); |
| 50 virtual ~SystemTray(); | 46 virtual ~SystemTray(); |
| 51 | 47 |
| 52 // Creates the default set of items for the sytem tray. | 48 // Creates the default set of items for the sytem tray. |
| 53 void CreateItems(); | 49 void CreateItems(); |
| 54 | 50 |
| 55 // Creates the widget for the tray. | 51 // Creates the widget for the tray. |
| 56 void CreateWidget(); | 52 void CreateWidget(); |
| 57 | 53 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 70 int close_delay_in_seconds, | 66 int close_delay_in_seconds, |
| 71 bool activate); | 67 bool activate); |
| 72 | 68 |
| 73 // Continue showing the existing detailed view, if any, for |close_delay| | 69 // Continue showing the existing detailed view, if any, for |close_delay| |
| 74 // seconds. | 70 // seconds. |
| 75 void SetDetailedViewCloseDelay(int close_delay); | 71 void SetDetailedViewCloseDelay(int close_delay); |
| 76 | 72 |
| 77 // Updates the items when the login status of the system changes. | 73 // Updates the items when the login status of the system changes. |
| 78 void UpdateAfterLoginStatusChange(user::LoginStatus login_status); | 74 void UpdateAfterLoginStatusChange(user::LoginStatus login_status); |
| 79 | 75 |
| 76 // Called when the widget associated with |bubble| closes. |bubble| should |
| 77 // always == |bubble_|. This triggers destroying |bubble_| and hiding the |
| 78 // launcher if necessary. |
| 79 void RemoveBubble(internal::SystemTrayBubble* bubble); |
| 80 |
| 80 const ScopedVector<SystemTrayItem>& items() const { return items_; } | 81 const ScopedVector<SystemTrayItem>& items() const { return items_; } |
| 81 | 82 |
| 82 // Sets whether the tray paints a background. Default is true, but is set to | 83 // Sets whether the tray paints a background. Default is true, but is set to |
| 83 // false if a window overlaps the shelf. | 84 // false if a window overlaps the shelf. |
| 84 void SetPaintsBackground( | 85 void SetPaintsBackground( |
| 85 bool value, | 86 bool value, |
| 86 internal::BackgroundAnimator::ChangeType change_type); | 87 internal::BackgroundAnimator::ChangeType change_type); |
| 87 | 88 |
| 88 // Returns true if the launcher should show. | 89 // Returns true if the launcher should show. |
| 89 bool should_show_launcher() const { return popup_ && should_show_launcher_; } | 90 bool should_show_launcher() const { return bubble_ && should_show_launcher_; } |
| 90 | 91 |
| 91 views::Widget* widget() const { return widget_; } | 92 views::Widget* widget() const { return widget_; } |
| 92 | 93 |
| 93 AccessibilityObserver* accessibility_observer() const { | 94 AccessibilityObserver* accessibility_observer() const { |
| 94 return accessibility_observer_; | 95 return accessibility_observer_; |
| 95 } | 96 } |
| 96 AudioObserver* audio_observer() const { | 97 AudioObserver* audio_observer() const { |
| 97 return audio_observer_; | 98 return audio_observer_; |
| 98 } | 99 } |
| 99 BluetoothObserver* bluetooth_observer() const { | 100 BluetoothObserver* bluetooth_observer() const { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 // Overridden from internal::ActionableView. | 133 // Overridden from internal::ActionableView. |
| 133 virtual bool PerformAction(const views::Event& event) OVERRIDE; | 134 virtual bool PerformAction(const views::Event& event) OVERRIDE; |
| 134 | 135 |
| 135 // Overridden from views::View. | 136 // Overridden from views::View. |
| 136 virtual void OnMouseEntered(const views::MouseEvent& event) OVERRIDE; | 137 virtual void OnMouseEntered(const views::MouseEvent& event) OVERRIDE; |
| 137 virtual void OnMouseExited(const views::MouseEvent& event) OVERRIDE; | 138 virtual void OnMouseExited(const views::MouseEvent& event) OVERRIDE; |
| 138 virtual void AboutToRequestFocusFromTabTraversal(bool reverse) OVERRIDE; | 139 virtual void AboutToRequestFocusFromTabTraversal(bool reverse) OVERRIDE; |
| 139 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; | 140 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; |
| 140 virtual void OnPaintFocusBorder(gfx::Canvas* canvas) OVERRIDE; | 141 virtual void OnPaintFocusBorder(gfx::Canvas* canvas) OVERRIDE; |
| 141 | 142 |
| 142 // Overridden from views::Widget::Observer. | |
| 143 virtual void OnWidgetClosing(views::Widget* widget) OVERRIDE; | |
| 144 virtual void OnWidgetVisibilityChanged(views::Widget* widget, | |
| 145 bool visible) OVERRIDE; | |
| 146 | |
| 147 // Overridden from internal::BackgroundAnimatorDelegate. | 143 // Overridden from internal::BackgroundAnimatorDelegate. |
| 148 virtual void UpdateBackground(int alpha) OVERRIDE; | 144 virtual void UpdateBackground(int alpha) OVERRIDE; |
| 149 | 145 |
| 150 // Overidden from base::MessagePumpObserver | |
| 151 virtual base::EventStatus WillProcessEvent( | |
| 152 const base::NativeEvent& event) OVERRIDE; | |
| 153 virtual void DidProcessEvent(const base::NativeEvent& event) OVERRIDE; | |
| 154 | |
| 155 ScopedVector<SystemTrayItem> items_; | 146 ScopedVector<SystemTrayItem> items_; |
| 156 | 147 |
| 157 // The container for all the tray views of the items. | 148 // The container for all the tray views of the items. |
| 158 views::View* container_; | 149 views::View* container_; |
| 159 | 150 |
| 160 // These observers are not owned by the tray. | 151 // These observers are not owned by the tray. |
| 161 AccessibilityObserver* accessibility_observer_; | 152 AccessibilityObserver* accessibility_observer_; |
| 162 AudioObserver* audio_observer_; | 153 AudioObserver* audio_observer_; |
| 163 BluetoothObserver* bluetooth_observer_; | 154 BluetoothObserver* bluetooth_observer_; |
| 164 BrightnessObserver* brightness_observer_; | 155 BrightnessObserver* brightness_observer_; |
| 165 CapsLockObserver* caps_lock_observer_; | 156 CapsLockObserver* caps_lock_observer_; |
| 166 ClockObserver* clock_observer_; | 157 ClockObserver* clock_observer_; |
| 167 IMEObserver* ime_observer_; | 158 IMEObserver* ime_observer_; |
| 168 NetworkObserver* network_observer_; | 159 NetworkObserver* network_observer_; |
| 169 PowerStatusObserver* power_status_observer_; | 160 PowerStatusObserver* power_status_observer_; |
| 170 UpdateObserver* update_observer_; | 161 UpdateObserver* update_observer_; |
| 171 UserObserver* user_observer_; | 162 UserObserver* user_observer_; |
| 172 | 163 |
| 173 // The widget hosting the tray. | 164 // The widget hosting the tray. |
| 174 views::Widget* widget_; | 165 views::Widget* widget_; |
| 175 | 166 |
| 176 // The popup widget and the delegate. | 167 // The popup widget and the delegate. |
| 177 internal::SystemTrayBubble* bubble_; | 168 internal::SystemTrayBubble* bubble_; |
| 178 views::Widget* popup_; | |
| 179 | 169 |
| 180 // Owned by the view it's installed on. | 170 // Owned by the view it's installed on. |
| 181 internal::SystemTrayBackground* background_; | 171 internal::SystemTrayBackground* background_; |
| 182 | 172 |
| 183 // See description agove getter. | 173 // See description agove getter. |
| 184 bool should_show_launcher_; | 174 bool should_show_launcher_; |
| 185 | 175 |
| 186 internal::BackgroundAnimator hide_background_animator_; | 176 internal::BackgroundAnimator hide_background_animator_; |
| 187 internal::BackgroundAnimator hover_background_animator_; | 177 internal::BackgroundAnimator hover_background_animator_; |
| 188 | 178 |
| 189 DISALLOW_COPY_AND_ASSIGN(SystemTray); | 179 DISALLOW_COPY_AND_ASSIGN(SystemTray); |
| 190 }; | 180 }; |
| 191 | 181 |
| 192 } // namespace ash | 182 } // namespace ash |
| 193 | 183 |
| 194 #endif // ASH_SYSTEM_TRAY_SYSTEM_TRAY_H_ | 184 #endif // ASH_SYSTEM_TRAY_SYSTEM_TRAY_H_ |
| OLD | NEW |