Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(200)

Side by Side Diff: ash/keyboard/keyboard_ui.cc

Issue 1684823004: Refactors keyboard related code so mash can use a keyboard (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: always compile mojo_shell Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "ash/keyboard/keyboard_ui.h"
6
7 #include "ash/accessibility_delegate.h"
8 #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 "ui/keyboard/keyboard_controller.h"
13
14 #if defined(MOJO_SHELL_CLIENT)
15 #include "ash/keyboard/keyboard_ui_mus.h"
16 #include "ash/mojo_shell.h"
17 #endif
18
19 namespace ash {
20
21 class KeyboardUIImpl : public KeyboardUI, public AccessibilityObserver {
22 public:
23 KeyboardUIImpl() {
24 // The Shell may not exist in some unit tests.
25 Shell::GetInstance()->system_tray_notifier()->AddAccessibilityObserver(
26 this);
27 }
28
29 ~KeyboardUIImpl() override {}
30
31 // KeyboardUI:
32 void Show() override {
33 keyboard::KeyboardController::GetInstance()->ShowKeyboard(true);
34 }
35 void Hide() override {
36 // Do nothing as this is called from ash::Shell, which also calls through
37 // to the appropriate keyboard functions.
38 }
39 bool IsEnabled() override {
40 return Shell::GetInstance()
41 ->accessibility_delegate()
42 ->IsVirtualKeyboardEnabled();
43 }
44
45 // AccessibilityObserver:
46 void OnAccessibilityModeChanged(
47 ui::AccessibilityNotificationVisibility notify) override {
48 FOR_EACH_OBSERVER(KeyboardUIObserver, *observers(),
49 OnKeyboardEnabledStateChanged(IsEnabled()));
50 }
51
52 private:
53 DISALLOW_COPY_AND_ASSIGN(KeyboardUIImpl);
54 };
55
56 KeyboardUI::~KeyboardUI() {}
57
58 // static
59 scoped_ptr<KeyboardUI> KeyboardUI::Create() {
60 #if defined(MOJO_SHELL_CLIENT)
61 if (GetMojoShell())
62 return make_scoped_ptr(new KeyboardUIMus);
63 #endif
64 return make_scoped_ptr(new KeyboardUIImpl);
65 }
66
67 void KeyboardUI::AddObserver(KeyboardUIObserver* observer) {
68 observers_.AddObserver(observer);
69 }
70
71 void KeyboardUI::RemoveObserver(KeyboardUIObserver* observer) {
72 observers_.RemoveObserver(observer);
73 }
74
75 KeyboardUI::KeyboardUI() {}
76
77 } // namespace ash
OLDNEW
« no previous file with comments | « ash/keyboard/keyboard_ui.h ('k') | ash/keyboard/keyboard_ui_mus.h » ('j') | ash/shell.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698