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 #include "ui/aura/focus_manager.h" | 5 #include "ui/aura/focus_manager.h" |
6 | 6 |
7 #include "ui/aura/client/activation_client.h" | 7 #include "ui/aura/client/activation_client.h" |
8 #include "ui/aura/focus_change_observer.h" | 8 #include "ui/aura/focus_change_observer.h" |
9 #include "ui/aura/window_delegate.h" | 9 #include "ui/aura/window_delegate.h" |
10 | 10 |
11 namespace aura { | 11 namespace aura { |
12 FocusManager::FocusManager() : focused_window_(NULL) { | 12 FocusManager::FocusManager() : focused_window_(NULL) { |
13 } | 13 } |
14 | 14 |
15 FocusManager::~FocusManager() { | 15 FocusManager::~FocusManager() { |
16 } | 16 } |
17 | 17 |
18 void FocusManager::AddObserver(FocusChangeObserver* observer) { | 18 void FocusManager::AddObserver(FocusChangeObserver* observer) { |
19 observers_.AddObserver(observer); | 19 observers_.AddObserver(observer); |
20 } | 20 } |
21 | 21 |
22 void FocusManager::RemoveObserver(FocusChangeObserver* observer) { | 22 void FocusManager::RemoveObserver(FocusChangeObserver* observer) { |
23 observers_.RemoveObserver(observer); | 23 observers_.RemoveObserver(observer); |
24 } | 24 } |
25 | 25 |
26 void FocusManager::SetFocusedWindow(Window* focused_window, | 26 void FocusManager::SetFocusedWindow(Window* focused_window, |
27 const Event* event) { | 27 const ui::Event* event) { |
28 if (focused_window == focused_window_) | 28 if (focused_window == focused_window_) |
29 return; | 29 return; |
30 if (focused_window && !focused_window->CanFocus()) | 30 if (focused_window && !focused_window->CanFocus()) |
31 return; | 31 return; |
32 // The NULL-check of |focused_window| is essential here before asking the | 32 // The NULL-check of |focused_window| is essential here before asking the |
33 // activation client, since it is valid to clear the focus by calling | 33 // activation client, since it is valid to clear the focus by calling |
34 // SetFocusedWindow() to NULL. | 34 // SetFocusedWindow() to NULL. |
35 | 35 |
36 if (focused_window) { | 36 if (focused_window) { |
37 RootWindow* root = focused_window->GetRootWindow(); | 37 RootWindow* root = focused_window->GetRootWindow(); |
(...skipping 19 matching lines...) Expand all Loading... |
57 | 57 |
58 Window* FocusManager::GetFocusedWindow() { | 58 Window* FocusManager::GetFocusedWindow() { |
59 return focused_window_; | 59 return focused_window_; |
60 } | 60 } |
61 | 61 |
62 bool FocusManager::IsFocusedWindow(const Window* window) const { | 62 bool FocusManager::IsFocusedWindow(const Window* window) const { |
63 return focused_window_ == window; | 63 return focused_window_ == window; |
64 } | 64 } |
65 | 65 |
66 } // namespace ash | 66 } // namespace ash |
OLD | NEW |