OLD | NEW |
| (Empty) |
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. | |
4 | |
5 #ifndef UI_AURA_CLIENT_DEFAULT_ACTIVATION_CLIENT_H_ | |
6 #define UI_AURA_CLIENT_DEFAULT_ACTIVATION_CLIENT_H_ | |
7 | |
8 #include <vector> | |
9 | |
10 #include "base/compiler_specific.h" | |
11 #include "base/logging.h" | |
12 #include "base/observer_list.h" | |
13 #include "ui/aura/aura_export.h" | |
14 #include "ui/aura/window_observer.h" | |
15 #include "ui/wm/public/activation_client.h" | |
16 | |
17 namespace aura { | |
18 namespace client { | |
19 class ActivationChangeObserver; | |
20 } | |
21 | |
22 namespace client { | |
23 | |
24 // Simple ActivationClient implementation for use by tests and other targets | |
25 // that just need basic behavior (e.g. activate windows whenever requested, | |
26 // restack windows at the top when they're activated, etc.). | |
27 class AURA_EXPORT DefaultActivationClient : public client::ActivationClient, | |
28 public WindowObserver { | |
29 public: | |
30 explicit DefaultActivationClient(Window* root_window); | |
31 virtual ~DefaultActivationClient(); | |
32 | |
33 // Overridden from client::ActivationClient: | |
34 virtual void AddObserver(client::ActivationChangeObserver* observer) OVERRIDE; | |
35 virtual void RemoveObserver( | |
36 client::ActivationChangeObserver* observer) OVERRIDE; | |
37 virtual void ActivateWindow(Window* window) OVERRIDE; | |
38 virtual void DeactivateWindow(Window* window) OVERRIDE; | |
39 virtual Window* GetActiveWindow() OVERRIDE; | |
40 virtual Window* GetActivatableWindow(Window* window) OVERRIDE; | |
41 virtual Window* GetToplevelWindow(Window* window) OVERRIDE; | |
42 virtual bool OnWillFocusWindow(Window* window, | |
43 const ui::Event* event) OVERRIDE; | |
44 virtual bool CanActivateWindow(Window* window) const OVERRIDE; | |
45 | |
46 // Overridden from WindowObserver: | |
47 virtual void OnWindowDestroyed(Window* window) OVERRIDE; | |
48 | |
49 private: | |
50 void RemoveActiveWindow(Window* window); | |
51 | |
52 // This class explicitly does NOT store the active window in a window property | |
53 // to make sure that ActivationChangeObserver is not treated as part of the | |
54 // aura API. Assumptions to that end will cause tests that use this client to | |
55 // fail. | |
56 std::vector<Window*> active_windows_; | |
57 | |
58 // The window which was active before the currently active one. | |
59 Window* last_active_; | |
60 | |
61 ObserverList<client::ActivationChangeObserver> observers_; | |
62 | |
63 DISALLOW_COPY_AND_ASSIGN(DefaultActivationClient); | |
64 }; | |
65 | |
66 } // namespace client | |
67 } // namespace aura | |
68 | |
69 #endif // UI_AURA_CLIENT_DEFAULT_ACTIVATION_CLIENT_H_ | |
OLD | NEW |