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); |
msw
2016/06/18 01:15:06
Shouldn't this be removed on destruction? (if the
James Cook
2016/06/20 17:27:33
Good catch. Done.
| |
21 Shell::GetInstance()->system_tray_notifier()->AddAccessibilityObserver( | |
22 this); | |
23 } | 22 } |
24 | 23 |
25 ~KeyboardUIImpl() override {} | 24 ~KeyboardUIImpl() override {} |
26 | 25 |
27 // KeyboardUI: | 26 // KeyboardUI: |
28 void Show() override { | 27 void Show() override { |
29 keyboard::KeyboardController::GetInstance()->ShowKeyboard(true); | 28 keyboard::KeyboardController::GetInstance()->ShowKeyboard(true); |
30 } | 29 } |
31 void Hide() override { | 30 void Hide() override { |
32 // Do nothing as this is called from ash::Shell, which also calls through | 31 // Do nothing as this is called from ash::Shell, which also calls through |
33 // to the appropriate keyboard functions. | 32 // to the appropriate keyboard functions. |
34 } | 33 } |
35 bool IsEnabled() override { | 34 bool IsEnabled() override { |
36 return Shell::GetInstance() | 35 return WmShell::Get() |
37 ->accessibility_delegate() | 36 ->GetAccessibilityDelegate() |
38 ->IsVirtualKeyboardEnabled(); | 37 ->IsVirtualKeyboardEnabled(); |
39 } | 38 } |
40 | 39 |
41 // AccessibilityObserver: | 40 // AccessibilityObserver: |
42 void OnAccessibilityModeChanged( | 41 void OnAccessibilityModeChanged( |
43 ui::AccessibilityNotificationVisibility notify) override { | 42 ui::AccessibilityNotificationVisibility notify) override { |
44 FOR_EACH_OBSERVER(KeyboardUIObserver, *observers(), | 43 FOR_EACH_OBSERVER(KeyboardUIObserver, *observers(), |
45 OnKeyboardEnabledStateChanged(IsEnabled())); | 44 OnKeyboardEnabledStateChanged(IsEnabled())); |
46 } | 45 } |
47 | 46 |
(...skipping 12 matching lines...) Expand all Loading... | |
60 observers_.AddObserver(observer); | 59 observers_.AddObserver(observer); |
61 } | 60 } |
62 | 61 |
63 void KeyboardUI::RemoveObserver(KeyboardUIObserver* observer) { | 62 void KeyboardUI::RemoveObserver(KeyboardUIObserver* observer) { |
64 observers_.RemoveObserver(observer); | 63 observers_.RemoveObserver(observer); |
65 } | 64 } |
66 | 65 |
67 KeyboardUI::KeyboardUI() {} | 66 KeyboardUI::KeyboardUI() {} |
68 | 67 |
69 } // namespace ash | 68 } // namespace ash |
OLD | NEW |