Put WeakPtrFactory member last in USBEventRouter
[chromium-blink-merge.git] / ash / wm / mru_window_tracker.h
blob4ed06a3dadc4f6bc9e045072ee0a79594be44ee8
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 // Maintains a most recently used list of windows. This is used for window
28 // cycling using Alt+Tab and overview mode.
29 class ASH_EXPORT MruWindowTracker
30 : public aura::client::ActivationChangeObserver,
31 public aura::WindowObserver {
32 public:
33 typedef std::vector<aura::Window*> WindowList;
35 explicit MruWindowTracker(
36 aura::client::ActivationClient* activation_client);
37 ~MruWindowTracker() override;
39 // Returns the set of windows which can be cycled through. This method creates
40 // the vector based on the current set of windows across all valid root
41 // windows. As a result it is not necessarily the same as the set of
42 // windows being iterated over.
43 // The returned window list will be in descending (top most window first)
44 // order.
45 static WindowList BuildWindowList();
47 // Returns the set of windows which can be cycled through using the tracked
48 // list of most recently used windows.
49 WindowList BuildMruWindowList();
51 // Starts or stops ignoring window activations. If no longer ignoring
52 // activations the currently active window is moved to the front of the
53 // MRU window list. Used by WindowCycleList to avoid adding all cycled
54 // windows to the front of the MRU window list.
55 void SetIgnoreActivations(bool ignore);
57 private:
58 // Updates the mru_windows_ list to insert/move |active_window| at/to the
59 // front.
60 void SetActiveWindow(aura::Window* active_window);
62 // Overridden from aura::client::ActivationChangeObserver:
63 void OnWindowActivated(aura::Window* gained_active,
64 aura::Window* lost_active) override;
66 // Overridden from WindowObserver:
67 void OnWindowDestroyed(aura::Window* window) override;
69 // List of windows that have been activated in containers that we cycle
70 // through, sorted by most recently used.
71 std::list<aura::Window*> mru_windows_;
73 aura::client::ActivationClient* activation_client_;
75 bool ignore_window_activations_;
77 DISALLOW_COPY_AND_ASSIGN(MruWindowTracker);
80 } // namespace ash
82 #endif // ASH_WM_MRU_WINDOW_TRACKER_H_