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

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

Issue 2736573002: chromeos: Move files in //ash/common to //ash, part 2 (Closed)
Patch Set: Created 3 years, 9 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/common/keyboard/keyboard_ui.h ('k') | ash/common/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/common/keyboard/keyboard_ui.h"
6
7 #include "ash/common/accessibility_delegate.h"
8 #include "ash/common/keyboard/keyboard_ui_observer.h"
9 #include "ash/common/wm_shell.h"
10 #include "ash/system/accessibility_observer.h"
11 #include "ash/system/tray/system_tray_notifier.h"
12 #include "ash/system/tray_accessibility.h"
13 #include "base/memory/ptr_util.h"
14 #include "ui/keyboard/keyboard_controller.h"
15
16 namespace ash {
17
18 class KeyboardUIImpl : public KeyboardUI, public AccessibilityObserver {
19 public:
20 KeyboardUIImpl() : enabled_(false) {
21 WmShell::Get()->system_tray_notifier()->AddAccessibilityObserver(this);
22 }
23
24 ~KeyboardUIImpl() override {
25 if (WmShell::HasInstance() && WmShell::Get()->system_tray_notifier())
26 WmShell::Get()->system_tray_notifier()->RemoveAccessibilityObserver(this);
27 }
28
29 // KeyboardUI:
30 void Show() override {
31 keyboard::KeyboardController::GetInstance()->ShowKeyboard(true);
32 }
33 void ShowInDisplay(const int64_t display_id) override {
34 keyboard::KeyboardController::GetInstance()->ShowKeyboardInDisplay(
35 display_id);
36 }
37 void Hide() override {
38 // Do nothing as this is called from ash::Shell, which also calls through
39 // to the appropriate keyboard functions.
40 }
41 bool IsEnabled() override {
42 return WmShell::Get()->accessibility_delegate()->IsVirtualKeyboardEnabled();
43 }
44
45 // AccessibilityObserver:
46 void OnAccessibilityModeChanged(
47 AccessibilityNotificationVisibility notify) override {
48 bool enabled = IsEnabled();
49 if (enabled_ == enabled)
50 return;
51
52 enabled_ = enabled;
53 for (auto& observer : *observers())
54 observer.OnKeyboardEnabledStateChanged(enabled);
55 }
56
57 private:
58 bool enabled_;
59
60 DISALLOW_COPY_AND_ASSIGN(KeyboardUIImpl);
61 };
62
63 KeyboardUI::~KeyboardUI() {}
64
65 // static
66 std::unique_ptr<KeyboardUI> KeyboardUI::Create() {
67 return base::WrapUnique(new KeyboardUIImpl);
68 }
69
70 void KeyboardUI::AddObserver(KeyboardUIObserver* observer) {
71 observers_.AddObserver(observer);
72 }
73
74 void KeyboardUI::RemoveObserver(KeyboardUIObserver* observer) {
75 observers_.RemoveObserver(observer);
76 }
77
78 KeyboardUI::KeyboardUI() {}
79
80 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/keyboard/keyboard_ui.h ('k') | ash/common/keyboard/keyboard_ui_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698