| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_WM_WINDOW_CYCLE_LIST_H_ | 5 #ifndef ASH_WM_WINDOW_CYCLE_LIST_H_ |
| 6 #define ASH_WM_WINDOW_CYCLE_LIST_H_ | 6 #define ASH_WM_WINDOW_CYCLE_LIST_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "ash/ash_export.h" | 11 #include "ash/ash_export.h" |
| 12 #include "ash/common/wm_window_observer.h" |
| 12 #include "ash/wm/window_cycle_controller.h" | 13 #include "ash/wm/window_cycle_controller.h" |
| 13 #include "base/compiler_specific.h" | |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "ui/aura/window_observer.h" | |
| 16 | 15 |
| 17 namespace ash { | 16 namespace ash { |
| 18 | 17 |
| 19 class ScopedShowWindow; | 18 class ScopedShowWindow; |
| 20 | 19 |
| 21 // Tracks a set of Windows that can be stepped through. This class is used by | 20 // Tracks a set of Windows that can be stepped through. This class is used by |
| 22 // the WindowCycleController. | 21 // the WindowCycleController. |
| 23 class ASH_EXPORT WindowCycleList : public aura::WindowObserver { | 22 class ASH_EXPORT WindowCycleList : public WmWindowObserver { |
| 24 public: | 23 public: |
| 25 typedef std::vector<aura::Window*> WindowList; | 24 using WindowList = std::vector<WmWindow*>; |
| 26 | 25 |
| 27 explicit WindowCycleList(const WindowList& windows); | 26 explicit WindowCycleList(const WindowList& windows); |
| 28 ~WindowCycleList() override; | 27 ~WindowCycleList() override; |
| 29 | 28 |
| 30 bool empty() const { return windows_.empty(); } | 29 bool empty() const { return windows_.empty(); } |
| 31 | 30 |
| 32 // Cycles to the next or previous window based on |direction|. | 31 // Cycles to the next or previous window based on |direction|. |
| 33 void Step(WindowCycleController::Direction direction); | 32 void Step(WindowCycleController::Direction direction); |
| 34 | 33 |
| 35 private: | 34 private: |
| 36 friend class WindowCycleControllerTest; | 35 friend class WindowCycleControllerTest; |
| 37 const WindowList& windows() const { return windows_; } | 36 const WindowList& windows() const { return windows_; } |
| 38 | 37 |
| 39 // aura::WindowObserver overrides: | 38 // aura::WindowObserver overrides: |
| 40 // There is a chance a window is destroyed, for example by JS code. We need to | 39 // There is a chance a window is destroyed, for example by JS code. We need to |
| 41 // take care of that even if it is not intended for the user to close a window | 40 // take care of that even if it is not intended for the user to close a window |
| 42 // while window cycling. | 41 // while window cycling. |
| 43 void OnWindowDestroying(aura::Window* window) override; | 42 void OnWindowDestroying(WmWindow* window) override; |
| 44 | 43 |
| 45 // List of weak pointers to windows to use while cycling with the keyboard. | 44 // List of weak pointers to windows to use while cycling with the keyboard. |
| 46 // List is built when the user initiates the gesture (i.e. hits alt-tab the | 45 // List is built when the user initiates the gesture (i.e. hits alt-tab the |
| 47 // first time) and is emptied when the gesture is complete (i.e. releases the | 46 // first time) and is emptied when the gesture is complete (i.e. releases the |
| 48 // alt key). | 47 // alt key). |
| 49 WindowList windows_; | 48 WindowList windows_; |
| 50 | 49 |
| 51 // Current position in the |windows_| | 50 // Current position in the |windows_| |
| 52 int current_index_; | 51 int current_index_; |
| 53 | 52 |
| 54 // Wrapper for the window brought to the front. | 53 // Wrapper for the window brought to the front. |
| 55 std::unique_ptr<ScopedShowWindow> showing_window_; | 54 std::unique_ptr<ScopedShowWindow> showing_window_; |
| 56 | 55 |
| 57 DISALLOW_COPY_AND_ASSIGN(WindowCycleList); | 56 DISALLOW_COPY_AND_ASSIGN(WindowCycleList); |
| 58 }; | 57 }; |
| 59 | 58 |
| 60 } // namespace ash | 59 } // namespace ash |
| 61 | 60 |
| 62 #endif // ASH_WM_WINDOW_CYCLE_LIST_H_ | 61 #endif // ASH_WM_WINDOW_CYCLE_LIST_H_ |
| OLD | NEW |