| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_ui.h" | 5 #include "ash/keyboard/keyboard_ui.h" |
| 6 | 6 |
| 7 #include "ash/common/accessibility_delegate.h" | 7 #include "ash/common/accessibility_delegate.h" |
| 8 #include "ash/common/system/accessibility_observer.h" |
| 9 #include "ash/common/system/tray/wm_system_tray_notifier.h" |
| 10 #include "ash/common/wm_shell.h" |
| 8 #include "ash/keyboard/keyboard_ui_observer.h" | 11 #include "ash/keyboard/keyboard_ui_observer.h" |
| 9 #include "ash/shell.h" | |
| 10 #include "ash/system/tray/system_tray_notifier.h" | |
| 11 #include "ash/system/tray_accessibility.h" | 12 #include "ash/system/tray_accessibility.h" |
| 12 #include "base/memory/ptr_util.h" | 13 #include "base/memory/ptr_util.h" |
| 13 #include "ui/keyboard/keyboard_controller.h" | 14 #include "ui/keyboard/keyboard_controller.h" |
| 14 | 15 |
| 15 namespace ash { | 16 namespace ash { |
| 16 | 17 |
| 17 class KeyboardUIImpl : public KeyboardUI, public AccessibilityObserver { | 18 class KeyboardUIImpl : public KeyboardUI, public AccessibilityObserver { |
| 18 public: | 19 public: |
| 19 KeyboardUIImpl() { | 20 KeyboardUIImpl() { |
| 20 // The Shell may not exist in some unit tests. | 21 WmShell::Get()->system_tray_notifier()->AddAccessibilityObserver(this); |
| 21 Shell::GetInstance()->system_tray_notifier()->AddAccessibilityObserver( | |
| 22 this); | |
| 23 } | 22 } |
| 24 | 23 |
| 25 ~KeyboardUIImpl() override {} | 24 ~KeyboardUIImpl() override { |
| 25 if (WmShell::HasInstance() && WmShell::Get()->system_tray_notifier()) |
| 26 WmShell::Get()->system_tray_notifier()->RemoveAccessibilityObserver(this); |
| 27 } |
| 26 | 28 |
| 27 // KeyboardUI: | 29 // KeyboardUI: |
| 28 void Show() override { | 30 void Show() override { |
| 29 keyboard::KeyboardController::GetInstance()->ShowKeyboard(true); | 31 keyboard::KeyboardController::GetInstance()->ShowKeyboard(true); |
| 30 } | 32 } |
| 31 void Hide() override { | 33 void Hide() override { |
| 32 // Do nothing as this is called from ash::Shell, which also calls through | 34 // Do nothing as this is called from ash::Shell, which also calls through |
| 33 // to the appropriate keyboard functions. | 35 // to the appropriate keyboard functions. |
| 34 } | 36 } |
| 35 bool IsEnabled() override { | 37 bool IsEnabled() override { |
| 36 return Shell::GetInstance() | 38 return WmShell::Get() |
| 37 ->accessibility_delegate() | 39 ->GetAccessibilityDelegate() |
| 38 ->IsVirtualKeyboardEnabled(); | 40 ->IsVirtualKeyboardEnabled(); |
| 39 } | 41 } |
| 40 | 42 |
| 41 // AccessibilityObserver: | 43 // AccessibilityObserver: |
| 42 void OnAccessibilityModeChanged( | 44 void OnAccessibilityModeChanged( |
| 43 ui::AccessibilityNotificationVisibility notify) override { | 45 ui::AccessibilityNotificationVisibility notify) override { |
| 44 FOR_EACH_OBSERVER(KeyboardUIObserver, *observers(), | 46 FOR_EACH_OBSERVER(KeyboardUIObserver, *observers(), |
| 45 OnKeyboardEnabledStateChanged(IsEnabled())); | 47 OnKeyboardEnabledStateChanged(IsEnabled())); |
| 46 } | 48 } |
| 47 | 49 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 60 observers_.AddObserver(observer); | 62 observers_.AddObserver(observer); |
| 61 } | 63 } |
| 62 | 64 |
| 63 void KeyboardUI::RemoveObserver(KeyboardUIObserver* observer) { | 65 void KeyboardUI::RemoveObserver(KeyboardUIObserver* observer) { |
| 64 observers_.RemoveObserver(observer); | 66 observers_.RemoveObserver(observer); |
| 65 } | 67 } |
| 66 | 68 |
| 67 KeyboardUI::KeyboardUI() {} | 69 KeyboardUI::KeyboardUI() {} |
| 68 | 70 |
| 69 } // namespace ash | 71 } // namespace ash |
| OLD | NEW |