Chromium Code Reviews| 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_COMMON_SYSTEM_TRAY_SYSTEM_TRAY_H_ | 5 #ifndef ASH_COMMON_SYSTEM_TRAY_SYSTEM_TRAY_H_ |
| 6 #define ASH_COMMON_SYSTEM_TRAY_SYSTEM_TRAY_H_ | 6 #define ASH_COMMON_SYSTEM_TRAY_SYSTEM_TRAY_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "ash/ash_export.h" | 12 #include "ash/ash_export.h" |
| 13 #include "ash/common/system/tray/system_tray_bubble.h" | 13 #include "ash/common/system/tray/system_tray_bubble.h" |
| 14 #include "ash/common/system/tray/tray_background_view.h" | 14 #include "ash/common/system/tray/tray_background_view.h" |
| 15 #include "base/macros.h" | 15 #include "base/macros.h" |
| 16 #include "base/memory/scoped_vector.h" | 16 #include "base/memory/scoped_vector.h" |
| 17 #include "ui/views/bubble/tray_bubble_view.h" | 17 #include "ui/views/bubble/tray_bubble_view.h" |
| 18 #include "ui/views/view.h" | 18 #include "ui/views/view.h" |
| 19 | 19 |
| 20 namespace ash { | 20 namespace ash { |
| 21 | 21 |
| 22 class KeyEventWatcher; | |
| 22 enum class LoginStatus; | 23 enum class LoginStatus; |
| 23 class ScreenTrayItem; | 24 class ScreenTrayItem; |
| 24 class SystemBubbleWrapper; | 25 class SystemBubbleWrapper; |
| 25 class SystemTrayDelegate; | 26 class SystemTrayDelegate; |
| 26 class SystemTrayItem; | 27 class SystemTrayItem; |
| 27 class TrayAccessibility; | 28 class TrayAccessibility; |
| 28 class TrayAudio; | 29 class TrayAudio; |
| 29 class TrayCast; | 30 class TrayCast; |
| 30 class TrayDate; | 31 class TrayDate; |
| 31 class TrayUpdate; | 32 class TrayUpdate; |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 160 return tray_accessibility_; | 161 return tray_accessibility_; |
| 161 } | 162 } |
| 162 | 163 |
| 163 // Get the tray item view (or NULL) for a given |tray_item| in a unit test. | 164 // Get the tray item view (or NULL) for a given |tray_item| in a unit test. |
| 164 views::View* GetTrayItemViewForTest(SystemTrayItem* tray_item); | 165 views::View* GetTrayItemViewForTest(SystemTrayItem* tray_item); |
| 165 | 166 |
| 166 TrayCast* GetTrayCastForTesting() const; | 167 TrayCast* GetTrayCastForTesting() const; |
| 167 TrayDate* GetTrayDateForTesting() const; | 168 TrayDate* GetTrayDateForTesting() const; |
| 168 TrayUpdate* GetTrayUpdateForTesting() const; | 169 TrayUpdate* GetTrayUpdateForTesting() const; |
| 169 | 170 |
| 171 // Activates the system tray bubble. | |
| 172 void ActivateBubble(); | |
| 173 | |
| 170 private: | 174 private: |
| 175 class ActivationObserver; | |
| 176 | |
| 177 // Closes the bubble. Used to bind as a KeyEventWatcher::KeyEventCallback. | |
| 178 void CloseBubble(const ui::KeyEvent& key_event); | |
| 179 | |
| 180 // Activates the bubble and starts key navigation with the |key_event|. | |
| 181 void ActivateAndStartNavigation(const ui::KeyEvent& key_event); | |
| 182 | |
| 183 // Creates the key event watcher. | |
|
James Cook
2016/09/23 16:32:28
nit: "See ShowItems() for why key events are obser
oshima
2016/09/23 19:19:54
Done.
| |
| 184 void CreateKeyEventWatcher(); | |
| 185 | |
| 171 // Creates the default set of items for the sytem tray. | 186 // Creates the default set of items for the sytem tray. |
| 172 void CreateItems(SystemTrayDelegate* delegate); | 187 void CreateItems(SystemTrayDelegate* delegate); |
| 173 | 188 |
| 174 // Resets |system_bubble_| and clears any related state. | 189 // Resets |system_bubble_| and clears any related state. |
| 175 void DestroySystemBubble(); | 190 void DestroySystemBubble(); |
| 176 | 191 |
| 177 // Resets |notification_bubble_| and clears any related state. | 192 // Resets |notification_bubble_| and clears any related state. |
| 178 void DestroyNotificationBubble(); | 193 void DestroyNotificationBubble(); |
| 179 | 194 |
| 180 // Returns a string with the current time for accessibility on the status | 195 // Returns a string with the current time for accessibility on the status |
| 181 // tray bar. | 196 // tray bar. |
| 182 base::string16 GetAccessibleTimeString(const base::Time& now) const; | 197 base::string16 GetAccessibleTimeString(const base::Time& now) const; |
| 183 | 198 |
| 184 // Calculates the x-offset for the item in the tray. Returns -1 if its tray | 199 // Calculates the x-offset for the item in the tray. Returns -1 if its tray |
| 185 // item view is not visible. | 200 // item view is not visible. |
| 186 int GetTrayXOffset(SystemTrayItem* item) const; | 201 int GetTrayXOffset(SystemTrayItem* item) const; |
| 187 | 202 |
| 188 // Shows the default view and its arrow position is shifted by |x_offset|. | 203 // Shows the default view and its arrow position is shifted by |x_offset|. |
| 189 void ShowDefaultViewWithOffset(BubbleCreationType creation_type, | 204 void ShowDefaultViewWithOffset(BubbleCreationType creation_type, |
| 190 int x_offset, | 205 int x_offset, |
| 191 bool persistent); | 206 bool persistent); |
| 192 | 207 |
| 193 // Constructs or re-constructs |system_bubble_| and populates it with |items|. | 208 // Constructs or re-constructs |system_bubble_| and populates it with |items|. |
| 194 // Specify |change_tray_status| to true if want to change the tray background | 209 // Specify |change_tray_status| to true if want to change the tray background |
| 195 // status. | 210 // status. The bubble will be opened in inactive state. If |can_activate| is |
| 211 // true, the bubble will be activated by one of following means. | |
| 212 // * When alt/alt-tab acclerator is used to start navigation. | |
| 213 // * When the bubble is opened by accelerator. | |
| 214 // * When the tray item is set to be focused. | |
|
James Cook
2016/09/23 16:32:28
Nice documentation.
| |
| 196 void ShowItems(const std::vector<SystemTrayItem*>& items, | 215 void ShowItems(const std::vector<SystemTrayItem*>& items, |
| 197 bool details, | 216 bool details, |
| 198 bool activate, | 217 bool can_activate, |
| 199 BubbleCreationType creation_type, | 218 BubbleCreationType creation_type, |
| 200 int x_offset, | 219 int x_offset, |
| 201 bool persistent); | 220 bool persistent); |
| 202 | 221 |
| 203 // Constructs or re-constructs |notification_bubble_| and populates it with | 222 // Constructs or re-constructs |notification_bubble_| and populates it with |
| 204 // |notification_items_|, or destroys it if there are no notification items. | 223 // |notification_items_|, or destroys it if there are no notification items. |
| 205 void UpdateNotificationBubble(); | 224 void UpdateNotificationBubble(); |
| 206 | 225 |
| 207 // Checks the current status of the system tray and updates the web | 226 // Checks the current status of the system tray and updates the web |
| 208 // notification tray according to the current status. | 227 // notification tray according to the current status. |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 256 TrayAccessibility* tray_accessibility_; | 275 TrayAccessibility* tray_accessibility_; |
| 257 TrayAudio* tray_audio_; // May be null. | 276 TrayAudio* tray_audio_; // May be null. |
| 258 TrayCast* tray_cast_; | 277 TrayCast* tray_cast_; |
| 259 TrayDate* tray_date_; | 278 TrayDate* tray_date_; |
| 260 TrayUpdate* tray_update_; | 279 TrayUpdate* tray_update_; |
| 261 | 280 |
| 262 // A reference to the Screen share and capture item. | 281 // A reference to the Screen share and capture item. |
| 263 ScreenTrayItem* screen_capture_tray_item_; // not owned | 282 ScreenTrayItem* screen_capture_tray_item_; // not owned |
| 264 ScreenTrayItem* screen_share_tray_item_; // not owned | 283 ScreenTrayItem* screen_share_tray_item_; // not owned |
| 265 | 284 |
| 285 std::unique_ptr<KeyEventWatcher> key_event_watcher_; | |
| 286 | |
| 287 std::unique_ptr<ActivationObserver> activation_observer_; | |
| 288 | |
| 266 DISALLOW_COPY_AND_ASSIGN(SystemTray); | 289 DISALLOW_COPY_AND_ASSIGN(SystemTray); |
| 267 }; | 290 }; |
| 268 | 291 |
| 269 } // namespace ash | 292 } // namespace ash |
| 270 | 293 |
| 271 #endif // ASH_COMMON_SYSTEM_TRAY_SYSTEM_TRAY_H_ | 294 #endif // ASH_COMMON_SYSTEM_TRAY_SYSTEM_TRAY_H_ |
| OLD | NEW |