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/mus/keyboard_ui_mus.h" | 5 #include "ash/mus/keyboard_ui_mus.h" |
6 | 6 |
7 #include "ash/keyboard/keyboard_ui_observer.h" | 7 #include "ash/keyboard/keyboard_ui_observer.h" |
8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
9 #include "ash/shell_delegate.h" | 9 #include "ash/shell_delegate.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
11 #include "services/shell/public/cpp/connector.h" | 11 #include "services/shell/public/cpp/connector.h" |
12 | 12 |
13 namespace ash { | 13 namespace ash { |
14 | 14 |
15 KeyboardUIMus::KeyboardUIMus(mojo::Connector* connector) | 15 KeyboardUIMus::KeyboardUIMus(::shell::Connector* connector) |
16 : is_enabled_(false), observer_binding_(this) { | 16 : is_enabled_(false), observer_binding_(this) { |
17 // TODO(sky): should be something like mojo:keyboard, but need mapping. | 17 // TODO(sky): should be something like mojo:keyboard, but need mapping. |
18 connector->ConnectToInterface("exe:chrome", &keyboard_); | 18 connector->ConnectToInterface("exe:chrome", &keyboard_); |
19 keyboard_->AddObserver(observer_binding_.CreateInterfacePtrAndBind()); | 19 keyboard_->AddObserver(observer_binding_.CreateInterfacePtrAndBind()); |
20 } | 20 } |
21 | 21 |
22 KeyboardUIMus::~KeyboardUIMus() {} | 22 KeyboardUIMus::~KeyboardUIMus() {} |
23 | 23 |
24 // static | 24 // static |
25 std::unique_ptr<KeyboardUI> KeyboardUIMus::Create(mojo::Connector* connector) { | 25 std::unique_ptr<KeyboardUI> KeyboardUIMus::Create( |
| 26 ::shell::Connector* connector) { |
26 return base::WrapUnique(new KeyboardUIMus(connector)); | 27 return base::WrapUnique(new KeyboardUIMus(connector)); |
27 } | 28 } |
28 | 29 |
29 void KeyboardUIMus::Hide() { | 30 void KeyboardUIMus::Hide() { |
30 keyboard_->Hide(); | 31 keyboard_->Hide(); |
31 } | 32 } |
32 | 33 |
33 void KeyboardUIMus::Show() { | 34 void KeyboardUIMus::Show() { |
34 keyboard_->Show(); | 35 keyboard_->Show(); |
35 } | 36 } |
36 | 37 |
37 bool KeyboardUIMus::IsEnabled() { | 38 bool KeyboardUIMus::IsEnabled() { |
38 return is_enabled_; | 39 return is_enabled_; |
39 } | 40 } |
40 | 41 |
41 void KeyboardUIMus::OnKeyboardStateChanged(bool is_enabled, | 42 void KeyboardUIMus::OnKeyboardStateChanged(bool is_enabled, |
42 bool is_visible, | 43 bool is_visible, |
43 uint64_t display_id, | 44 uint64_t display_id, |
44 mojo::RectPtr bounds) { | 45 mojo::RectPtr bounds) { |
45 if (is_enabled_ == is_enabled) | 46 if (is_enabled_ == is_enabled) |
46 return; | 47 return; |
47 | 48 |
48 is_enabled_ = is_enabled; | 49 is_enabled_ = is_enabled; |
49 FOR_EACH_OBSERVER(KeyboardUIObserver, *observers(), | 50 FOR_EACH_OBSERVER(KeyboardUIObserver, *observers(), |
50 OnKeyboardEnabledStateChanged(is_enabled)); | 51 OnKeyboardEnabledStateChanged(is_enabled)); |
51 } | 52 } |
52 | 53 |
53 } // namespace ash | 54 } // namespace ash |
OLD | NEW |