| 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/common/keyboard/keyboard_ui.h" | 5 #include "ash/common/keyboard/keyboard_ui.h" |
| 6 | 6 |
| 7 #include "ash/common/accessibility_delegate.h" | 7 #include "ash/common/accessibility_delegate.h" |
| 8 #include "ash/common/keyboard/keyboard_ui_observer.h" | 8 #include "ash/common/keyboard/keyboard_ui_observer.h" |
| 9 #include "ash/common/system/accessibility_observer.h" | 9 #include "ash/common/system/accessibility_observer.h" |
| 10 #include "ash/common/system/tray/system_tray_notifier.h" | 10 #include "ash/common/system/tray/system_tray_notifier.h" |
| 11 #include "ash/common/system/tray_accessibility.h" | 11 #include "ash/common/system/tray_accessibility.h" |
| 12 #include "ash/common/wm_shell.h" | 12 #include "ash/common/wm_shell.h" |
| 13 #include "ash/shell.h" |
| 13 #include "base/memory/ptr_util.h" | 14 #include "base/memory/ptr_util.h" |
| 14 #include "ui/keyboard/keyboard_controller.h" | 15 #include "ui/keyboard/keyboard_controller.h" |
| 15 | 16 |
| 16 namespace ash { | 17 namespace ash { |
| 17 | 18 |
| 18 class KeyboardUIImpl : public KeyboardUI, public AccessibilityObserver { | 19 class KeyboardUIImpl : public KeyboardUI, public AccessibilityObserver { |
| 19 public: | 20 public: |
| 20 KeyboardUIImpl() : enabled_(false) { | 21 KeyboardUIImpl() : enabled_(false) { |
| 21 WmShell::Get()->system_tray_notifier()->AddAccessibilityObserver(this); | 22 WmShell::Get()->system_tray_notifier()->AddAccessibilityObserver(this); |
| 22 } | 23 } |
| 23 | 24 |
| 24 ~KeyboardUIImpl() override { | 25 ~KeyboardUIImpl() override { |
| 25 if (WmShell::HasInstance() && WmShell::Get()->system_tray_notifier()) | 26 if (WmShell::HasInstance() && WmShell::Get()->system_tray_notifier()) |
| 26 WmShell::Get()->system_tray_notifier()->RemoveAccessibilityObserver(this); | 27 WmShell::Get()->system_tray_notifier()->RemoveAccessibilityObserver(this); |
| 27 } | 28 } |
| 28 | 29 |
| 29 // KeyboardUI: | 30 // KeyboardUI: |
| 30 void Show() override { | 31 void Show() override { |
| 31 keyboard::KeyboardController::GetInstance()->ShowKeyboard(true); | 32 keyboard::KeyboardController::GetInstance()->ShowKeyboard(true); |
| 32 } | 33 } |
| 33 void ShowInDisplay(const int64_t display_id) override { | 34 void ShowInDisplay(const int64_t display_id) override { |
| 34 keyboard::KeyboardController::GetInstance()->ShowKeyboardInDisplay( | 35 keyboard::KeyboardController::GetInstance()->ShowKeyboardInDisplay( |
| 35 display_id); | 36 display_id); |
| 36 } | 37 } |
| 37 void Hide() override { | 38 void Hide() override { |
| 38 // Do nothing as this is called from ash::Shell, which also calls through | 39 // Do nothing as this is called from ash::Shell, which also calls through |
| 39 // to the appropriate keyboard functions. | 40 // to the appropriate keyboard functions. |
| 40 } | 41 } |
| 41 bool IsEnabled() override { | 42 bool IsEnabled() override { |
| 42 return WmShell::Get()->accessibility_delegate()->IsVirtualKeyboardEnabled(); | 43 return Shell::GetInstance() |
| 44 ->accessibility_delegate() |
| 45 ->IsVirtualKeyboardEnabled(); |
| 43 } | 46 } |
| 44 | 47 |
| 45 // AccessibilityObserver: | 48 // AccessibilityObserver: |
| 46 void OnAccessibilityModeChanged( | 49 void OnAccessibilityModeChanged( |
| 47 AccessibilityNotificationVisibility notify) override { | 50 AccessibilityNotificationVisibility notify) override { |
| 48 bool enabled = IsEnabled(); | 51 bool enabled = IsEnabled(); |
| 49 if (enabled_ == enabled) | 52 if (enabled_ == enabled) |
| 50 return; | 53 return; |
| 51 | 54 |
| 52 enabled_ = enabled; | 55 enabled_ = enabled; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 71 observers_.AddObserver(observer); | 74 observers_.AddObserver(observer); |
| 72 } | 75 } |
| 73 | 76 |
| 74 void KeyboardUI::RemoveObserver(KeyboardUIObserver* observer) { | 77 void KeyboardUI::RemoveObserver(KeyboardUIObserver* observer) { |
| 75 observers_.RemoveObserver(observer); | 78 observers_.RemoveObserver(observer); |
| 76 } | 79 } |
| 77 | 80 |
| 78 KeyboardUI::KeyboardUI() {} | 81 KeyboardUI::KeyboardUI() {} |
| 79 | 82 |
| 80 } // namespace ash | 83 } // namespace ash |
| OLD | NEW |