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