| 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/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 "content/public/common/service_names.mojom.h" | 9 #include "content/public/common/service_names.mojom.h" |
| 10 #include "services/service_manager/public/cpp/connector.h" | 10 #include "services/service_manager/public/cpp/connector.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 | 22 |
| 23 KeyboardUIMus::~KeyboardUIMus() {} | 23 KeyboardUIMus::~KeyboardUIMus() {} |
| 24 | 24 |
| 25 // static | 25 // static |
| 26 std::unique_ptr<KeyboardUI> KeyboardUIMus::Create( | 26 std::unique_ptr<KeyboardUI> KeyboardUIMus::Create( |
| 27 service_manager::Connector* connector) { | 27 service_manager::Connector* connector) { |
| 28 return base::MakeUnique<KeyboardUIMus>(connector); | 28 return base::MakeUnique<KeyboardUIMus>(connector); |
| 29 } | 29 } |
| 30 | 30 |
| 31 void KeyboardUIMus::Hide() { | 31 void KeyboardUIMus::Hide() { |
| 32 keyboard_->Hide(); | 32 if (keyboard_) |
| 33 keyboard_->Hide(); |
| 33 } | 34 } |
| 34 | 35 |
| 35 void KeyboardUIMus::Show() { | 36 void KeyboardUIMus::Show() { |
| 36 keyboard_->Show(); | 37 if (keyboard_) |
| 38 keyboard_->Show(); |
| 37 } | 39 } |
| 38 | 40 |
| 39 void KeyboardUIMus::ShowInDisplay(const int64_t display_id) { | 41 void KeyboardUIMus::ShowInDisplay(const int64_t display_id) { |
| 40 // TODO(yhanada): Send display id after adding a display_id argument to | 42 // TODO(yhanada): Send display id after adding a display_id argument to |
| 41 // |Keyboard::Show()| in keyboard.mojom. See crbug.com/585253. | 43 // |Keyboard::Show()| in keyboard.mojom. See crbug.com/585253. |
| 42 keyboard_->Show(); | 44 if (keyboard_) |
| 45 keyboard_->Show(); |
| 43 } | 46 } |
| 44 | 47 |
| 45 bool KeyboardUIMus::IsEnabled() { | 48 bool KeyboardUIMus::IsEnabled() { |
| 46 return is_enabled_; | 49 return is_enabled_; |
| 47 } | 50 } |
| 48 | 51 |
| 49 void KeyboardUIMus::OnKeyboardStateChanged(bool is_enabled, | 52 void KeyboardUIMus::OnKeyboardStateChanged(bool is_enabled, |
| 50 bool is_visible, | 53 bool is_visible, |
| 51 uint64_t display_id, | 54 uint64_t display_id, |
| 52 const gfx::Rect& bounds) { | 55 const gfx::Rect& bounds) { |
| 53 if (is_enabled_ == is_enabled) | 56 if (is_enabled_ == is_enabled) |
| 54 return; | 57 return; |
| 55 | 58 |
| 56 is_enabled_ = is_enabled; | 59 is_enabled_ = is_enabled; |
| 57 for (auto& observer : *observers()) | 60 for (auto& observer : *observers()) |
| 58 observer.OnKeyboardEnabledStateChanged(is_enabled); | 61 observer.OnKeyboardEnabledStateChanged(is_enabled); |
| 59 } | 62 } |
| 60 | 63 |
| 61 } // namespace ash | 64 } // namespace ash |
| OLD | NEW |