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 "services/ui/ime/ime_server_impl.h" | 5 #include "services/ui/ime/ime_server_impl.h" |
6 | 6 |
| 7 #include "base/memory/ptr_util.h" |
7 #include "services/catalog/public/interfaces/constants.mojom.h" | 8 #include "services/catalog/public/interfaces/constants.mojom.h" |
8 #include "services/service_manager/public/cpp/connector.h" | 9 #include "services/service_manager/public/cpp/connector.h" |
9 #include "services/ui/ime/ime_registrar_impl.h" | 10 #include "services/ui/ime/ime_registrar_impl.h" |
10 | 11 |
11 namespace ui { | 12 namespace ui { |
12 | 13 |
13 IMEServerImpl::IMEServerImpl() : current_id_(0) {} | 14 IMEServerImpl::IMEServerImpl() : current_id_(0) {} |
14 | 15 |
15 IMEServerImpl::~IMEServerImpl() {} | 16 IMEServerImpl::~IMEServerImpl() {} |
16 | 17 |
(...skipping 22 matching lines...) Expand all Loading... |
39 // now we only register the first driver to avoid clients of the previous | 40 // now we only register the first driver to avoid clients of the previous |
40 // driver from hanging. | 41 // driver from hanging. |
41 if (driver_) | 42 if (driver_) |
42 return; | 43 return; |
43 | 44 |
44 // TODO(moshayedi): crbug.com/664267. Make sure this is the driver we | 45 // TODO(moshayedi): crbug.com/664267. Make sure this is the driver we |
45 // requested at OnGotCatalogEntries(). | 46 // requested at OnGotCatalogEntries(). |
46 driver_ = std::move(driver); | 47 driver_ = std::move(driver); |
47 | 48 |
48 while (!pending_requests_.empty()) { | 49 while (!pending_requests_.empty()) { |
49 driver_->StartSession(current_id_++, | 50 driver_->StartSession( |
50 std::move(pending_requests_.front().first), | 51 current_id_++, std::move(pending_requests_.front()->client_info), |
51 std::move(pending_requests_.front().second)); | 52 std::move(pending_requests_.front()->client), |
| 53 std::move(pending_requests_.front()->input_method_request)); |
52 pending_requests_.pop(); | 54 pending_requests_.pop(); |
53 } | 55 } |
54 } | 56 } |
55 | 57 |
56 void IMEServerImpl::StartSession( | 58 void IMEServerImpl::StartSession( |
| 59 mojom::TextInputClientInformationPtr client_info, |
57 mojom::TextInputClientPtr client, | 60 mojom::TextInputClientPtr client, |
58 mojom::InputMethodRequest input_method_request) { | 61 mojom::InputMethodRequest input_method_request) { |
59 if (driver_.get()) { | 62 if (driver_.get()) { |
60 // TODO(moshayedi): crbug.com/634431. This will forward all calls from | 63 // TODO(moshayedi): crbug.com/634431. This will forward all calls from |
61 // clients to the driver as they are. We may need to check |caret_bounds| | 64 // clients to the driver as they are. We may need to check |caret_bounds| |
62 // parameter of InputMethod::OnCaretBoundsChanged() here and limit them to | 65 // parameter of InputMethod::OnCaretBoundsChanged() here and limit them to |
63 // client's focused window. | 66 // client's focused window. |
64 driver_->StartSession(current_id_++, std::move(client), | 67 driver_->StartSession(current_id_++, std::move(client_info), |
65 std::move(input_method_request)); | 68 std::move(client), std::move(input_method_request)); |
66 } else { | 69 } else { |
67 pending_requests_.push( | 70 pending_requests_.push(base::MakeUnique<IMEServerImpl::PendingRequest>( |
68 std::make_pair(std::move(client), std::move(input_method_request))); | 71 std::move(client_info), std::move(client), |
| 72 std::move(input_method_request))); |
69 } | 73 } |
70 } | 74 } |
71 | 75 |
72 void IMEServerImpl::OnGotCatalogEntries( | 76 void IMEServerImpl::OnGotCatalogEntries( |
73 std::vector<catalog::mojom::EntryPtr> entries) { | 77 std::vector<catalog::mojom::EntryPtr> entries) { |
74 // TODO(moshayedi): crbug.com/662157. Decide what to do when number of | 78 // TODO(moshayedi): crbug.com/662157. Decide what to do when number of |
75 // available IME drivers isn't exactly one. | 79 // available IME drivers isn't exactly one. |
76 if (entries.size() == 0) | 80 if (entries.size() == 0) |
77 return; | 81 return; |
78 connector_->Connect((*entries.begin())->name); | 82 connector_->Connect((*entries.begin())->name); |
79 } | 83 } |
80 | 84 |
| 85 IMEServerImpl::PendingRequest::PendingRequest( |
| 86 mojom::TextInputClientInformationPtr client_info, |
| 87 mojom::TextInputClientPtr client, |
| 88 mojom::InputMethodRequest input_method_request) |
| 89 : client_info(std::move(client_info)), |
| 90 client(std::move(client)), |
| 91 input_method_request(std::move(input_method_request)) {} |
| 92 |
| 93 IMEServerImpl::PendingRequest::~PendingRequest() {} |
| 94 |
81 } // namespace ui | 95 } // namespace ui |
OLD | NEW |