OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_ACTIVATION_CONTROLLER_H_ | 5 #ifndef ASH_WM_ACTIVATION_CONTROLLER_H_ |
6 #define ASH_WM_ACTIVATION_CONTROLLER_H_ | 6 #define ASH_WM_ACTIVATION_CONTROLLER_H_ |
7 | 7 |
8 #include "ash/ash_export.h" | 8 #include "ash/ash_export.h" |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "base/observer_list.h" | 11 #include "base/observer_list.h" |
12 #include "base/scoped_observer.h" | 12 #include "base/scoped_observer.h" |
13 #include "ui/aura/client/activation_client.h" | 13 #include "ui/aura/client/activation_client.h" |
| 14 #include "ui/aura/client/focus_change_observer.h" |
14 #include "ui/aura/env_observer.h" | 15 #include "ui/aura/env_observer.h" |
15 #include "ui/aura/focus_change_observer.h" | |
16 #include "ui/aura/window_observer.h" | 16 #include "ui/aura/window_observer.h" |
17 #include "ui/base/events/event_handler.h" | 17 #include "ui/base/events/event_handler.h" |
18 | 18 |
19 namespace aura { | 19 namespace aura { |
20 namespace client { | 20 namespace client { |
21 class ActivationChangeObserver; | 21 class ActivationChangeObserver; |
| 22 class FocusClient; |
22 } | 23 } |
23 } | 24 } |
24 | 25 |
25 namespace ash { | 26 namespace ash { |
26 namespace internal { | 27 namespace internal { |
27 | 28 |
28 class ActivationControllerDelegate; | 29 class ActivationControllerDelegate; |
29 | 30 |
30 // Exported for unit tests. | 31 // Exported for unit tests. |
31 class ASH_EXPORT ActivationController | 32 class ASH_EXPORT ActivationController |
32 : public aura::client::ActivationClient, | 33 : public aura::client::ActivationClient, |
33 public aura::WindowObserver, | 34 public aura::WindowObserver, |
34 public aura::EnvObserver, | 35 public aura::EnvObserver, |
35 public aura::FocusChangeObserver, | 36 public aura::client::FocusChangeObserver, |
36 public ui::EventHandler { | 37 public ui::EventHandler { |
37 public: | 38 public: |
38 // The ActivationController takes ownership of |delegate|. | 39 // The ActivationController takes ownership of |delegate|. |
39 ActivationController(aura::FocusManager* focus_manager, | 40 ActivationController(aura::client::FocusClient* focus_client, |
40 ActivationControllerDelegate* delegate); | 41 ActivationControllerDelegate* delegate); |
41 virtual ~ActivationController(); | 42 virtual ~ActivationController(); |
42 | 43 |
43 // Returns true if |window| exists within a container that supports | 44 // Returns true if |window| exists within a container that supports |
44 // activation. |event| is the revent responsible for initiating the change, or | 45 // activation. |event| is the event responsible for initiating the change, or |
45 // NULL if there is no event. | 46 // NULL if there is no event. |
46 static aura::Window* GetActivatableWindow(aura::Window* window, | 47 static aura::Window* GetActivatableWindow(aura::Window* window, |
47 const ui::Event* event); | 48 const ui::Event* event); |
48 | 49 |
49 // Overridden from aura::client::ActivationClient: | 50 // Overridden from aura::client::ActivationClient: |
50 virtual void AddObserver( | 51 virtual void AddObserver( |
51 aura::client::ActivationChangeObserver* observer) OVERRIDE; | 52 aura::client::ActivationChangeObserver* observer) OVERRIDE; |
52 virtual void RemoveObserver( | 53 virtual void RemoveObserver( |
53 aura::client::ActivationChangeObserver* observer) OVERRIDE; | 54 aura::client::ActivationChangeObserver* observer) OVERRIDE; |
54 virtual void ActivateWindow(aura::Window* window) OVERRIDE; | 55 virtual void ActivateWindow(aura::Window* window) OVERRIDE; |
55 virtual void DeactivateWindow(aura::Window* window) OVERRIDE; | 56 virtual void DeactivateWindow(aura::Window* window) OVERRIDE; |
56 virtual aura::Window* GetActiveWindow() OVERRIDE; | 57 virtual aura::Window* GetActiveWindow() OVERRIDE; |
57 virtual bool OnWillFocusWindow(aura::Window* window, | 58 virtual bool OnWillFocusWindow(aura::Window* window, |
58 const ui::Event* event) OVERRIDE; | 59 const ui::Event* event) OVERRIDE; |
59 virtual bool CanActivateWindow(aura::Window* window) const OVERRIDE; | 60 virtual bool CanActivateWindow(aura::Window* window) const OVERRIDE; |
60 | 61 |
61 // Overridden from aura::WindowObserver: | 62 // Overridden from aura::WindowObserver: |
62 virtual void OnWindowVisibilityChanged(aura::Window* window, | 63 virtual void OnWindowVisibilityChanged(aura::Window* window, |
63 bool visible) OVERRIDE; | 64 bool visible) OVERRIDE; |
64 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE; | 65 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE; |
65 | 66 |
66 // Overridden from aura::EnvObserver: | 67 // Overridden from aura::EnvObserver: |
67 virtual void OnWindowInitialized(aura::Window* window) OVERRIDE; | 68 virtual void OnWindowInitialized(aura::Window* window) OVERRIDE; |
68 | 69 |
69 // Overridden from aura::FocusChangeObserver: | 70 // Overridden from aura::client::FocusChangeObserver: |
70 virtual void OnWindowFocused(aura::Window* window) OVERRIDE; | 71 virtual void OnWindowFocused(aura::Window* window) OVERRIDE; |
71 | 72 |
72 private: | 73 private: |
73 // Overridden from ui::EventHandler: | 74 // Overridden from ui::EventHandler: |
74 virtual ui::EventResult OnKeyEvent(ui::KeyEvent* event) OVERRIDE; | 75 virtual ui::EventResult OnKeyEvent(ui::KeyEvent* event) OVERRIDE; |
75 virtual ui::EventResult OnMouseEvent(ui::MouseEvent* event) OVERRIDE; | 76 virtual ui::EventResult OnMouseEvent(ui::MouseEvent* event) OVERRIDE; |
76 virtual ui::EventResult OnScrollEvent(ui::ScrollEvent* event) OVERRIDE; | 77 virtual ui::EventResult OnScrollEvent(ui::ScrollEvent* event) OVERRIDE; |
77 virtual ui::EventResult OnTouchEvent(ui::TouchEvent* event) OVERRIDE; | 78 virtual ui::EventResult OnTouchEvent(ui::TouchEvent* event) OVERRIDE; |
78 virtual ui::EventResult OnGestureEvent(ui::GestureEvent* event) OVERRIDE; | 79 virtual ui::EventResult OnGestureEvent(ui::GestureEvent* event) OVERRIDE; |
79 | 80 |
(...skipping 12 matching lines...) Expand all Loading... |
92 // the window |ignore|. | 93 // the window |ignore|. |
93 aura::Window* GetTopmostWindowToActivateInContainer( | 94 aura::Window* GetTopmostWindowToActivateInContainer( |
94 aura::Window* container, | 95 aura::Window* container, |
95 aura::Window* ignore) const; | 96 aura::Window* ignore) const; |
96 | 97 |
97 // Called from the ActivationController's event handler implementation to | 98 // Called from the ActivationController's event handler implementation to |
98 // handle focus to the |event|'s target. Not all targets are focusable or | 99 // handle focus to the |event|'s target. Not all targets are focusable or |
99 // result in focus changes. | 100 // result in focus changes. |
100 void FocusWindowWithEvent(const ui::Event* event); | 101 void FocusWindowWithEvent(const ui::Event* event); |
101 | 102 |
102 aura::FocusManager* focus_manager_; | 103 aura::client::FocusClient* focus_client_; |
103 | 104 |
104 // True inside ActivateWindow(). Used to prevent recursion of focus | 105 // True inside ActivateWindow(). Used to prevent recursion of focus |
105 // change notifications causing activation. | 106 // change notifications causing activation. |
106 bool updating_activation_; | 107 bool updating_activation_; |
107 | 108 |
108 aura::Window* active_window_; | 109 aura::Window* active_window_; |
109 | 110 |
110 ObserverList<aura::client::ActivationChangeObserver> observers_; | 111 ObserverList<aura::client::ActivationChangeObserver> observers_; |
111 | 112 |
112 ScopedObserver<aura::Window, aura::WindowObserver> observer_manager_; | 113 ScopedObserver<aura::Window, aura::WindowObserver> observer_manager_; |
113 | 114 |
114 scoped_ptr<ActivationControllerDelegate> delegate_; | 115 scoped_ptr<ActivationControllerDelegate> delegate_; |
115 | 116 |
116 DISALLOW_COPY_AND_ASSIGN(ActivationController); | 117 DISALLOW_COPY_AND_ASSIGN(ActivationController); |
117 }; | 118 }; |
118 | 119 |
119 } // namespace internal | 120 } // namespace internal |
120 } // namespace ash | 121 } // namespace ash |
121 | 122 |
122 #endif // ASH_WM_ACTIVATION_CONTROLLER_H_ | 123 #endif // ASH_WM_ACTIVATION_CONTROLLER_H_ |
OLD | NEW |