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 UI_AURA_FOCUS_MANAGER_H_ | 5 #ifndef UI_AURA_FOCUS_MANAGER_H_ |
6 #define UI_AURA_FOCUS_MANAGER_H_ | 6 #define UI_AURA_FOCUS_MANAGER_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/observer_list.h" | 9 #include "base/observer_list.h" |
10 #include "ui/aura/aura_export.h" | 10 #include "ui/aura/aura_export.h" |
| 11 #include "ui/aura/client/focus_client.h" |
11 | 12 |
12 namespace ui { | 13 namespace ui { |
13 class Event; | 14 class Event; |
14 } | 15 } |
15 | 16 |
16 namespace aura { | 17 namespace aura { |
17 | 18 |
18 class FocusChangeObserver; | |
19 class Window; | 19 class Window; |
20 | 20 |
21 // An interface implemented by the Desktop to expose the focused window and | 21 // An interface implemented by the Desktop to expose the focused window and |
22 // allow for it to be changed. | 22 // allow for it to be changed. |
23 class AURA_EXPORT FocusManager { | 23 class AURA_EXPORT FocusManager : public client::FocusClient { |
24 public: | 24 public: |
25 FocusManager(); | 25 FocusManager(); |
26 ~FocusManager(); | 26 virtual ~FocusManager(); |
27 | 27 |
28 void AddObserver(FocusChangeObserver* observer); | 28 private: |
29 void RemoveObserver(FocusChangeObserver* observer); | 29 // Overridden from client::FocusClient: |
30 | 30 virtual void AddObserver(client::FocusChangeObserver* observer) OVERRIDE; |
31 // Sets the currently focused window. Before the currently focused window is | 31 virtual void RemoveObserver(client::FocusChangeObserver* observer) OVERRIDE; |
32 // changed, the previous focused window's delegate is sent a blur | 32 virtual void FocusWindow(Window* window, const ui::Event* event) OVERRIDE; |
33 // notification, and after it is changed the new focused window is sent a | 33 virtual Window* GetFocusedWindow() OVERRIDE; |
34 // focused notification. Nothing happens if |window| and GetFocusedWindow() | |
35 // match. | |
36 void SetFocusedWindow(Window* window, const ui::Event* event); | |
37 | |
38 // Returns the currently focused window or NULL if there is none. | |
39 Window* GetFocusedWindow(); | |
40 | |
41 // Returns true if |window| is the focused window. | |
42 bool IsFocusedWindow(const Window* window) const; | |
43 | 34 |
44 protected: | 35 protected: |
45 aura::Window* focused_window_; | 36 aura::Window* focused_window_; |
46 | 37 |
47 ObserverList<FocusChangeObserver> observers_; | 38 ObserverList<client::FocusChangeObserver> observers_; |
48 | 39 |
49 DISALLOW_COPY_AND_ASSIGN(FocusManager); | 40 DISALLOW_COPY_AND_ASSIGN(FocusManager); |
50 }; | 41 }; |
51 | 42 |
52 } // namespace aura | 43 } // namespace aura |
53 | 44 |
54 #endif // UI_AURA_FOCUS_MANAGER_H_ | 45 #endif // UI_AURA_FOCUS_MANAGER_H_ |
OLD | NEW |