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 <vector> | 8 #include <vector> |
9 | 9 |
10 #include "ash/ash_export.h" | 10 #include "ash/ash_export.h" |
11 #include "ash/wm/window_cycle_controller.h" | 11 #include "ash/wm/window_cycle_controller.h" |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "ui/aura/window_observer.h" | 15 #include "ui/aura/window_observer.h" |
16 | 16 |
17 namespace ash { | 17 namespace ash { |
18 | 18 |
19 class ScopedShowWindow; | 19 class ScopedShowWindow; |
20 | 20 |
21 // Tracks a set of Windows that can be stepped through. This class is used by | 21 // Tracks a set of Windows that can be stepped through. This class is used by |
22 // the WindowCycleController. | 22 // the WindowCycleController. |
23 class ASH_EXPORT WindowCycleList : public aura::WindowObserver { | 23 class ASH_EXPORT WindowCycleList : public aura::WindowObserver { |
24 public: | 24 public: |
25 typedef std::vector<aura::Window*> WindowList; | 25 typedef std::vector<aura::Window*> WindowList; |
26 | 26 |
27 explicit WindowCycleList(const WindowList& windows); | 27 explicit WindowCycleList(const WindowList& windows); |
28 virtual ~WindowCycleList(); | 28 ~WindowCycleList() override; |
29 | 29 |
30 bool empty() const { return windows_.empty(); } | 30 bool empty() const { return windows_.empty(); } |
31 | 31 |
32 // Cycles to the next or previous window based on |direction|. | 32 // Cycles to the next or previous window based on |direction|. |
33 void Step(WindowCycleController::Direction direction); | 33 void Step(WindowCycleController::Direction direction); |
34 | 34 |
35 const WindowList& windows() const { return windows_; } | 35 const WindowList& windows() const { return windows_; } |
36 | 36 |
37 private: | 37 private: |
38 // aura::WindowObserver overrides: | 38 // aura::WindowObserver overrides: |
39 // 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 |
40 // 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 |
41 // while window cycling. | 41 // while window cycling. |
42 virtual void OnWindowDestroyed(aura::Window* window) override; | 42 void OnWindowDestroyed(aura::Window* window) override; |
43 | 43 |
44 // 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. |
45 // 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 |
46 // 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 |
47 // alt key). | 47 // alt key). |
48 WindowList windows_; | 48 WindowList windows_; |
49 | 49 |
50 // Current position in the |windows_| | 50 // Current position in the |windows_| |
51 int current_index_; | 51 int current_index_; |
52 | 52 |
53 // Wrapper for the window brought to the front. | 53 // Wrapper for the window brought to the front. |
54 scoped_ptr<ScopedShowWindow> showing_window_; | 54 scoped_ptr<ScopedShowWindow> showing_window_; |
55 | 55 |
56 DISALLOW_COPY_AND_ASSIGN(WindowCycleList); | 56 DISALLOW_COPY_AND_ASSIGN(WindowCycleList); |
57 }; | 57 }; |
58 | 58 |
59 } // namespace ash | 59 } // namespace ash |
60 | 60 |
61 #endif // ASH_WM_WINDOW_CYCLE_LIST_H_ | 61 #endif // ASH_WM_WINDOW_CYCLE_LIST_H_ |
OLD | NEW |