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