blob: e9d9c20fad8eeb4d1c3f48d516444b25d4a276e2 [file] [log] [blame]
skyfee520c2016-02-11 19:57:461// 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
msw15156bf2016-09-13 21:49:175#include "ash/mus/keyboard_ui_mus.h"
skyfee520c2016-02-11 19:57:466
jamescook8cd6bf72016-06-21 16:31:127#include "ash/common/keyboard/keyboard_ui_observer.h"
dchenga94547472016-04-08 08:41:118#include "base/memory/ptr_util.h"
rockot734fb662016-10-15 16:41:309#include "services/service_manager/public/cpp/connector.h"
skyfee520c2016-02-11 19:57:4610
11namespace ash {
12
rockot400ea35b2016-10-15 19:15:3213KeyboardUIMus::KeyboardUIMus(service_manager::Connector* connector)
skyfee520c2016-02-11 19:57:4614 : is_enabled_(false), observer_binding_(this) {
msw15156bf2016-09-13 21:49:1715 if (connector) {
16 // TODO(sky): should be something like mojo:keyboard, but need mapping.
rockot3216b1232016-10-07 06:02:2417 connector->ConnectToInterface("service:content_browser", &keyboard_);
msw15156bf2016-09-13 21:49:1718 keyboard_->AddObserver(observer_binding_.CreateInterfacePtrAndBind());
19 }
skyfee520c2016-02-11 19:57:4620}
21
22KeyboardUIMus::~KeyboardUIMus() {}
23
24// static
rockotb00e6462016-04-14 02:24:0325std::unique_ptr<KeyboardUI> KeyboardUIMus::Create(
rockot400ea35b2016-10-15 19:15:3226 service_manager::Connector* connector) {
msw15156bf2016-09-13 21:49:1727 return base::MakeUnique<KeyboardUIMus>(connector);
skyfee520c2016-02-11 19:57:4628}
29
30void KeyboardUIMus::Hide() {
31 keyboard_->Hide();
32}
33
34void KeyboardUIMus::Show() {
35 keyboard_->Show();
36}
37
38bool KeyboardUIMus::IsEnabled() {
39 return is_enabled_;
40}
41
42void KeyboardUIMus::OnKeyboardStateChanged(bool is_enabled,
43 bool is_visible,
44 uint64_t display_id,
sammc813a8eb32016-05-28 03:34:0745 const gfx::Rect& bounds) {
skyfee520c2016-02-11 19:57:4646 if (is_enabled_ == is_enabled)
47 return;
48
49 is_enabled_ = is_enabled;
ericwilligers5eff47d2016-10-17 19:19:1850 for (auto& observer : *observers())
51 observer.OnKeyboardEnabledStateChanged(is_enabled);
skyfee520c2016-02-11 19:57:4652}
53
54} // namespace ash