Updating XTBs based on .GRDs from branch master
[chromium-blink-merge.git] / ash / wm / mru_window_tracker.h
blob06673a83419d1c0150d0efb655c1f54c667883cb
1 // Copyright 2013 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_MRU_WINDOW_TRACKER_H_
6 #define ASH_WM_MRU_WINDOW_TRACKER_H_
8 #include <list>
9 #include <vector>
11 #include "ash/ash_export.h"
12 #include "base/basictypes.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "ui/aura/window_observer.h"
15 #include "ui/wm/public/activation_change_observer.h"
17 namespace aura {
18 class RootWindow;
19 class Window;
20 namespace client {
21 class ActivationClient;
25 namespace ash {
27 namespace wm {
29 class AshFocusRules;
31 } // namespace wm
34 // Maintains a most recently used list of windows. This is used for window
35 // cycling using Alt+Tab and overview mode.
36 class ASH_EXPORT MruWindowTracker
37 : public aura::client::ActivationChangeObserver,
38 public aura::WindowObserver {
39 public:
40 typedef std::vector<aura::Window*> WindowList;
42 MruWindowTracker(
43 aura::client::ActivationClient* activation_client,
44 ash::wm::AshFocusRules* focus_rules);
45 ~MruWindowTracker() override;
47 // Returns the set of windows which can be cycled through using the tracked
48 // list of most recently used windows.
49 WindowList BuildMruWindowList() const;
51 // This does the same thing as the above, but ignores the system modal dialog
52 // state and hence the returned list could contain more windows if a system
53 // modal dialog window is present.
54 WindowList BuildWindowListIgnoreModal() const;
56 // Starts or stops ignoring window activations. If no longer ignoring
57 // activations the currently active window is moved to the front of the
58 // MRU window list. Used by WindowCycleList to avoid adding all cycled
59 // windows to the front of the MRU window list.
60 void SetIgnoreActivations(bool ignore);
62 private:
63 // Updates the mru_windows_ list to insert/move |active_window| at/to the
64 // front.
65 void SetActiveWindow(aura::Window* active_window);
67 // Overridden from aura::client::ActivationChangeObserver:
68 void OnWindowActivated(
69 aura::client::ActivationChangeObserver::ActivationReason reason,
70 aura::Window* gained_active,
71 aura::Window* lost_active) override;
73 // Overridden from WindowObserver:
74 void OnWindowDestroyed(aura::Window* window) override;
76 // Uses the focus rules to check whether the window can be activateable,
77 // regardless of the state of the System modal dialog.
78 bool IsWindowConsideredActivateable(aura::Window* window) const;
80 // List of windows that have been activated in containers that we cycle
81 // through, sorted by most recently used.
82 std::list<aura::Window*> mru_windows_;
84 aura::client::ActivationClient* activation_client_; // Not owned.
86 wm::AshFocusRules* focus_rules_; // Not owned.
88 bool ignore_window_activations_;
90 DISALLOW_COPY_AND_ASSIGN(MruWindowTracker);
93 } // namespace ash
95 #endif // ASH_WM_MRU_WINDOW_TRACKER_H_