| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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/test/test_focus_client.h" | 5 #include "ui/aura/test/test_focus_client.h" |
| 6 | 6 |
| 7 #include "ui/aura/client/focus_change_observer.h" | 7 #include "ui/aura/client/focus_change_observer.h" |
| 8 #include "ui/aura/window.h" | 8 #include "ui/aura/window.h" |
| 9 | 9 |
| 10 namespace aura { | 10 namespace aura { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 return; | 37 return; |
| 38 | 38 |
| 39 aura::Window* lost_focus = focused_window_; | 39 aura::Window* lost_focus = focused_window_; |
| 40 if (focused_window_) | 40 if (focused_window_) |
| 41 observer_manager_.Remove(focused_window_); | 41 observer_manager_.Remove(focused_window_); |
| 42 aura::Window* old_focused_window = focused_window_; | 42 aura::Window* old_focused_window = focused_window_; |
| 43 focused_window_ = window; | 43 focused_window_ = window; |
| 44 if (focused_window_) | 44 if (focused_window_) |
| 45 observer_manager_.Add(focused_window_); | 45 observer_manager_.Add(focused_window_); |
| 46 | 46 |
| 47 FOR_EACH_OBSERVER(aura::client::FocusChangeObserver, | 47 for (aura::client::FocusChangeObserver& observer : focus_observers_) |
| 48 focus_observers_, | 48 observer.OnWindowFocused(focused_window_, lost_focus); |
| 49 OnWindowFocused(focused_window_, lost_focus)); | |
| 50 client::FocusChangeObserver* observer = | 49 client::FocusChangeObserver* observer = |
| 51 client::GetFocusChangeObserver(old_focused_window); | 50 client::GetFocusChangeObserver(old_focused_window); |
| 52 if (observer) | 51 if (observer) |
| 53 observer->OnWindowFocused(focused_window_, old_focused_window); | 52 observer->OnWindowFocused(focused_window_, old_focused_window); |
| 54 observer = client::GetFocusChangeObserver(focused_window_); | 53 observer = client::GetFocusChangeObserver(focused_window_); |
| 55 if (observer) | 54 if (observer) |
| 56 observer->OnWindowFocused(focused_window_, old_focused_window); | 55 observer->OnWindowFocused(focused_window_, old_focused_window); |
| 57 } | 56 } |
| 58 | 57 |
| 59 void TestFocusClient::ResetFocusWithinActiveWindow(Window* window) { | 58 void TestFocusClient::ResetFocusWithinActiveWindow(Window* window) { |
| 60 if (!window->Contains(focused_window_)) | 59 if (!window->Contains(focused_window_)) |
| 61 FocusWindow(window); | 60 FocusWindow(window); |
| 62 } | 61 } |
| 63 | 62 |
| 64 Window* TestFocusClient::GetFocusedWindow() { | 63 Window* TestFocusClient::GetFocusedWindow() { |
| 65 return focused_window_; | 64 return focused_window_; |
| 66 } | 65 } |
| 67 | 66 |
| 68 //////////////////////////////////////////////////////////////////////////////// | 67 //////////////////////////////////////////////////////////////////////////////// |
| 69 // TestFocusClient, WindowObserver implementation: | 68 // TestFocusClient, WindowObserver implementation: |
| 70 | 69 |
| 71 void TestFocusClient::OnWindowDestroying(Window* window) { | 70 void TestFocusClient::OnWindowDestroying(Window* window) { |
| 72 DCHECK_EQ(window, focused_window_); | 71 DCHECK_EQ(window, focused_window_); |
| 73 FocusWindow(NULL); | 72 FocusWindow(NULL); |
| 74 } | 73 } |
| 75 | 74 |
| 76 } // namespace test | 75 } // namespace test |
| 77 } // namespace aura | 76 } // namespace aura |
| OLD | NEW |