| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "services/ui/ime/ime_server_impl.h" | |
| 6 | |
| 7 #include "base/memory/ptr_util.h" | |
| 8 #include "services/service_manager/public/cpp/connector.h" | |
| 9 #include "services/ui/ime/ime_registrar_impl.h" | |
| 10 | |
| 11 namespace ui { | |
| 12 | |
| 13 IMEServerImpl::IMEServerImpl() : current_id_(0) {} | |
| 14 | |
| 15 IMEServerImpl::~IMEServerImpl() {} | |
| 16 | |
| 17 void IMEServerImpl::Init(service_manager::Connector* connector, | |
| 18 bool is_test_config) { | |
| 19 if (is_test_config) | |
| 20 connector->StartService("test_ime_driver"); | |
| 21 // For non test configs we assume a client registers with us. | |
| 22 } | |
| 23 | |
| 24 void IMEServerImpl::AddBinding(mojom::IMEServerRequest request) { | |
| 25 bindings_.AddBinding(this, std::move(request)); | |
| 26 } | |
| 27 | |
| 28 void IMEServerImpl::OnDriverChanged(mojom::IMEDriverPtr driver) { | |
| 29 // TODO(moshayedi): crbug.com/669681. Handle switching drivers properly. For | |
| 30 // now we only register the first driver to avoid clients of the previous | |
| 31 // driver from hanging. | |
| 32 if (driver_) | |
| 33 return; | |
| 34 | |
| 35 driver_ = std::move(driver); | |
| 36 | |
| 37 while (!pending_requests_.empty()) { | |
| 38 driver_->StartSession(current_id_++, std::move(pending_requests_.front())); | |
| 39 pending_requests_.pop(); | |
| 40 } | |
| 41 } | |
| 42 | |
| 43 void IMEServerImpl::StartSession(mojom::StartSessionDetailsPtr details) { | |
| 44 if (driver_.get()) { | |
| 45 // TODO(moshayedi): crbug.com/634431. This will forward all calls from | |
| 46 // clients to the driver as they are. We may need to check |caret_bounds| | |
| 47 // parameter of InputMethod::OnCaretBoundsChanged() here and limit them to | |
| 48 // client's focused window. | |
| 49 driver_->StartSession(current_id_++, std::move(details)); | |
| 50 } else { | |
| 51 pending_requests_.push(std::move(details)); | |
| 52 } | |
| 53 } | |
| 54 | |
| 55 } // namespace ui | |
| OLD | NEW |