| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "ash/keyboard/keyboard_observer_register.h" | 5 #include "ash/keyboard/keyboard_observer_register.h" |
| 6 | 6 |
| 7 #include "ui/keyboard/keyboard_controller.h" | 7 #include "ui/keyboard/keyboard_controller.h" |
| 8 | 8 |
| 9 namespace ash { | 9 namespace ash { |
| 10 | 10 |
| 11 void UpdateKeyboardObserverFromStateChanged( | 11 void UpdateKeyboardObserverFromStateChanged( |
| 12 bool keyboard_activated, | 12 bool keyboard_activated, |
| 13 WmWindow* keyboard_root_window, | 13 aura::Window* keyboard_root_window, |
| 14 WmWindow* observer_root_window, | 14 aura::Window* observer_root_window, |
| 15 ScopedObserver<keyboard::KeyboardController, | 15 ScopedObserver<keyboard::KeyboardController, |
| 16 keyboard::KeyboardControllerObserver>* keyboard_observer) { | 16 keyboard::KeyboardControllerObserver>* keyboard_observer) { |
| 17 if (keyboard_root_window != observer_root_window) | 17 if (keyboard_root_window != observer_root_window) |
| 18 return; | 18 return; |
| 19 | 19 |
| 20 keyboard::KeyboardController* const keyboard_controller = | 20 keyboard::KeyboardController* const keyboard_controller = |
| 21 keyboard::KeyboardController::GetInstance(); | 21 keyboard::KeyboardController::GetInstance(); |
| 22 if (keyboard_activated && | 22 if (keyboard_activated && |
| 23 !keyboard_observer->IsObserving(keyboard_controller)) { | 23 !keyboard_observer->IsObserving(keyboard_controller)) { |
| 24 keyboard_observer->Add(keyboard_controller); | 24 keyboard_observer->Add(keyboard_controller); |
| 25 } else if (!keyboard_activated && | 25 } else if (!keyboard_activated && |
| 26 keyboard_observer->IsObserving(keyboard_controller)) { | 26 keyboard_observer->IsObserving(keyboard_controller)) { |
| 27 keyboard_observer->Remove(keyboard_controller); | 27 keyboard_observer->Remove(keyboard_controller); |
| 28 } | 28 } |
| 29 } | 29 } |
| 30 | 30 |
| 31 } // namespace ash | 31 } // namespace ash |
| OLD | NEW |