platformKeys: Add per-extension sign permissions.
[chromium-blink-merge.git] / ash / wm / window_cycle_controller.h
blob4120bc05c48a5ec08b39efd5aa90d771187fe27d
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
3 // found in the LICENSE file.
5 #ifndef ASH_WM_WINDOW_CYCLE_CONTROLLER_H_
6 #define ASH_WM_WINDOW_CYCLE_CONTROLLER_H_
8 #include "ash/ash_export.h"
9 #include "base/basictypes.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/time/time.h"
13 namespace ui {
14 class EventHandler;
17 namespace ash {
19 class WindowCycleList;
21 // Controls cycling through windows with the keyboard via alt-tab.
22 // Windows are sorted primarily by most recently used, and then by screen order.
23 // We activate windows as you cycle through them, so the order on the screen
24 // may change during the gesture, but the most recently used list isn't updated
25 // until the cycling ends. Thus we maintain the state of the windows
26 // at the beginning of the gesture so you can cycle through in a consistent
27 // order.
28 class ASH_EXPORT WindowCycleController {
29 public:
30 enum Direction {
31 FORWARD,
32 BACKWARD
35 WindowCycleController();
36 virtual ~WindowCycleController();
38 // Returns true if cycling through windows is enabled. This is false at
39 // certain times, such as when the lock screen is visible.
40 static bool CanCycle();
42 // Cycles between windows in the given |direction|.
43 void HandleCycleWindow(Direction direction);
45 // Returns true if we are in the middle of a window cycling gesture.
46 bool IsCycling() const { return window_cycle_list_.get() != NULL; }
48 // Call to start cycling windows. This funtion adds a pre-target handler to
49 // listen to the alt key release.
50 void StartCycling();
52 // Stops the current window cycle and removes the event filter.
53 void StopCycling();
55 // Returns the WindowCycleList. Really only useful for testing.
56 const WindowCycleList* window_cycle_list() const {
57 return window_cycle_list_.get();
60 private:
61 // Cycles to the next or previous window based on |direction|.
62 void Step(Direction direction);
64 scoped_ptr<WindowCycleList> window_cycle_list_;
66 // Event handler to watch for release of alt key.
67 scoped_ptr<ui::EventHandler> event_handler_;
69 base::Time cycle_start_time_;
71 DISALLOW_COPY_AND_ASSIGN(WindowCycleController);
74 } // namespace ash
76 #endif // ASH_WM_WINDOW_CYCLE_CONTROLLER_H_