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(current_id_++, std::move(pending_requests_.front())); |
50 std::move(pending_requests_.front().first), | |
51 std::move(pending_requests_.front().second)); | |
52 pending_requests_.pop(); | 51 pending_requests_.pop(); |
53 } | 52 } |
54 } | 53 } |
55 | 54 |
56 void IMEServerImpl::StartSession( | 55 void IMEServerImpl::StartSession(mojom::StartSessionDetailsPtr details) { |
57 mojom::TextInputClientPtr client, | |
58 mojom::InputMethodRequest input_method_request) { | |
59 if (driver_.get()) { | 56 if (driver_.get()) { |
60 // TODO(moshayedi): crbug.com/634431. This will forward all calls from | 57 // 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| | 58 // clients to the driver as they are. We may need to check |caret_bounds| |
62 // parameter of InputMethod::OnCaretBoundsChanged() here and limit them to | 59 // parameter of InputMethod::OnCaretBoundsChanged() here and limit them to |
63 // client's focused window. | 60 // client's focused window. |
64 driver_->StartSession(current_id_++, std::move(client), | 61 driver_->StartSession(current_id_++, std::move(details)); |
65 std::move(input_method_request)); | |
66 } else { | 62 } else { |
67 pending_requests_.push( | 63 pending_requests_.push(std::move(details)); |
68 std::make_pair(std::move(client), std::move(input_method_request))); | |
69 } | 64 } |
70 } | 65 } |
71 | 66 |
72 void IMEServerImpl::OnGotCatalogEntries( | 67 void IMEServerImpl::OnGotCatalogEntries( |
73 std::vector<catalog::mojom::EntryPtr> entries) { | 68 std::vector<catalog::mojom::EntryPtr> entries) { |
74 // TODO(moshayedi): crbug.com/662157. Decide what to do when number of | 69 // TODO(moshayedi): crbug.com/662157. Decide what to do when number of |
75 // available IME drivers isn't exactly one. | 70 // available IME drivers isn't exactly one. |
76 if (entries.size() == 0) | 71 if (entries.size() == 0) |
77 return; | 72 return; |
78 connector_->Connect((*entries.begin())->name); | 73 connector_->Connect((*entries.begin())->name); |
79 } | 74 } |
80 | 75 |
81 } // namespace ui | 76 } // namespace ui |
OLD | NEW |