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

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: merge to trunk 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
« no previous file with comments | « ash/keyboard/keyboard_ui.h ('k') | ash/keyboard/keyboard_ui_observer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 namespace ash {
15
16 class KeyboardUIImpl : public KeyboardUI, public AccessibilityObserver {
17 public:
18 KeyboardUIImpl() {
19 // The Shell may not exist in some unit tests.
20 Shell::GetInstance()->system_tray_notifier()->AddAccessibilityObserver(
21 this);
22 }
23
24 ~KeyboardUIImpl() override {}
25
26 // KeyboardUI:
27 void Show() override {
28 keyboard::KeyboardController::GetInstance()->ShowKeyboard(true);
29 }
30 void Hide() override {
31 // Do nothing as this is called from ash::Shell, which also calls through
32 // to the appropriate keyboard functions.
33 }
34 bool IsEnabled() override {
35 return Shell::GetInstance()
36 ->accessibility_delegate()
37 ->IsVirtualKeyboardEnabled();
38 }
39
40 // AccessibilityObserver:
41 void OnAccessibilityModeChanged(
42 ui::AccessibilityNotificationVisibility notify) override {
43 FOR_EACH_OBSERVER(KeyboardUIObserver, *observers(),
44 OnKeyboardEnabledStateChanged(IsEnabled()));
45 }
46
47 private:
48 DISALLOW_COPY_AND_ASSIGN(KeyboardUIImpl);
49 };
50
51 KeyboardUI::~KeyboardUI() {}
52
53 // static
54 scoped_ptr<KeyboardUI> KeyboardUI::Create() {
55 return make_scoped_ptr(new KeyboardUIImpl);
56 }
57
58 void KeyboardUI::AddObserver(KeyboardUIObserver* observer) {
59 observers_.AddObserver(observer);
60 }
61
62 void KeyboardUI::RemoveObserver(KeyboardUIObserver* observer) {
63 observers_.RemoveObserver(observer);
64 }
65
66 KeyboardUI::KeyboardUI() {}
67
68 } // namespace ash
OLDNEW
« no previous file with comments | « ash/keyboard/keyboard_ui.h ('k') | ash/keyboard/keyboard_ui_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698