blob: 53ba9a0899d4dc4772e14203824b733c20614dc5 [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
Scott Violet4c79b0d2017-11-17 21:47:135#include "ash/keyboard/keyboard_ui_mash.h"
skyfee520c2016-02-11 19:57:466
Mitsuru Oshima04b54d02017-10-09 14:22:457#include <memory>
8
James Cookb0bf8e82017-04-09 17:01:449#include "ash/keyboard/keyboard_ui_observer.h"
rockot734fb662016-10-15 16:41:3010#include "services/service_manager/public/cpp/connector.h"
skyfee520c2016-02-11 19:57:4611
12namespace ash {
13
Scott Violetf5de121f2017-11-16 00:43:1014KeyboardUIMash::KeyboardUIMash(service_manager::Connector* connector)
skyfee520c2016-02-11 19:57:4615 : is_enabled_(false), observer_binding_(this) {
sky1340ff22017-01-20 21:30:5316 // TODO: chrome should register the keyboard interface with ash.
17 // http://crbug.com/683289.
skyfee520c2016-02-11 19:57:4618}
19
Chris Watkinsc24daf62017-11-28 03:43:0920KeyboardUIMash::~KeyboardUIMash() = default;
skyfee520c2016-02-11 19:57:4621
22// static
Scott Violetf5de121f2017-11-16 00:43:1023std::unique_ptr<KeyboardUI> KeyboardUIMash::Create(
rockot400ea35b2016-10-15 19:15:3224 service_manager::Connector* connector) {
Scott Violetf5de121f2017-11-16 00:43:1025 return std::make_unique<KeyboardUIMash>(connector);
skyfee520c2016-02-11 19:57:4626}
27
Scott Violetf5de121f2017-11-16 00:43:1028void KeyboardUIMash::Hide() {
skyabcae812017-01-18 17:01:3429 if (keyboard_)
30 keyboard_->Hide();
skyfee520c2016-02-11 19:57:4631}
32
Scott Violetf5de121f2017-11-16 00:43:1033void KeyboardUIMash::ShowInDisplay(const int64_t display_id) {
yhanada7e20c9b2016-11-25 00:03:1934 // TODO(yhanada): Send display id after adding a display_id argument to
35 // |Keyboard::Show()| in keyboard.mojom. See crbug.com/585253.
skyabcae812017-01-18 17:01:3436 if (keyboard_)
37 keyboard_->Show();
yhanada7e20c9b2016-11-25 00:03:1938}
39
Scott Violetf5de121f2017-11-16 00:43:1040bool KeyboardUIMash::IsEnabled() {
skyfee520c2016-02-11 19:57:4641 return is_enabled_;
42}
43
Scott Violetf5de121f2017-11-16 00:43:1044void KeyboardUIMash::OnKeyboardStateChanged(bool is_enabled,
45 bool is_visible,
46 uint64_t display_id,
47 const gfx::Rect& bounds) {
skyfee520c2016-02-11 19:57:4648 if (is_enabled_ == is_enabled)
49 return;
50
51 is_enabled_ = is_enabled;
ericwilligers5eff47d2016-10-17 19:19:1852 for (auto& observer : *observers())
53 observer.OnKeyboardEnabledStateChanged(is_enabled);
skyfee520c2016-02-11 19:57:4654}
55
56} // namespace ash