Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(342)

Side by Side Diff: services/ui/ime/ime_server_impl.cc

Issue 2645683007: mash: Makes mash and service:ui not establish outgoing connections (Closed)
Patch Set: update catalog Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « services/ui/ime/ime_server_impl.h ('k') | services/ui/manifest.json » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/memory/ptr_util.h"
8 #include "services/catalog/public/interfaces/constants.mojom.h"
9 #include "services/service_manager/public/cpp/connector.h" 8 #include "services/service_manager/public/cpp/connector.h"
10 #include "services/ui/ime/ime_registrar_impl.h" 9 #include "services/ui/ime/ime_registrar_impl.h"
11 10
12 namespace ui { 11 namespace ui {
13 12
14 IMEServerImpl::IMEServerImpl() : current_id_(0) {} 13 IMEServerImpl::IMEServerImpl() : current_id_(0) {}
15 14
16 IMEServerImpl::~IMEServerImpl() {} 15 IMEServerImpl::~IMEServerImpl() {}
17 16
18 void IMEServerImpl::Init(service_manager::Connector* connector, 17 void IMEServerImpl::Init(service_manager::Connector* connector,
19 bool is_test_config) { 18 bool is_test_config) {
20 connector_ = connector; 19 if (is_test_config)
21 connector_->BindInterface(catalog::mojom::kServiceName, &catalog_); 20 connector->Connect("test_ime_driver");
22 // TODO(moshayedi): crbug.com/664264. The catalog service should provide 21 // For non test configs we assume a client registers with us.
23 // different set of entries for test and non-test. Once that is implemented,
24 // we won't need this check here.
25 if (is_test_config) {
26 connector_->Connect("test_ime_driver");
27 } else {
28 catalog_->GetEntriesProvidingCapability(
29 "ime:ime_driver", base::Bind(&IMEServerImpl::OnGotCatalogEntries,
30 base::Unretained(this)));
31 }
32 } 22 }
33 23
34 void IMEServerImpl::AddBinding(mojom::IMEServerRequest request) { 24 void IMEServerImpl::AddBinding(mojom::IMEServerRequest request) {
35 bindings_.AddBinding(this, std::move(request)); 25 bindings_.AddBinding(this, std::move(request));
36 } 26 }
37 27
38 void IMEServerImpl::OnDriverChanged(mojom::IMEDriverPtr driver) { 28 void IMEServerImpl::OnDriverChanged(mojom::IMEDriverPtr driver) {
39 // TODO(moshayedi): crbug.com/669681. Handle switching drivers properly. For 29 // TODO(moshayedi): crbug.com/669681. Handle switching drivers properly. For
40 // now we only register the first driver to avoid clients of the previous 30 // now we only register the first driver to avoid clients of the previous
41 // driver from hanging. 31 // driver from hanging.
42 if (driver_) 32 if (driver_)
43 return; 33 return;
44 34
45 // TODO(moshayedi): crbug.com/664267. Make sure this is the driver we
46 // requested at OnGotCatalogEntries().
47 driver_ = std::move(driver); 35 driver_ = std::move(driver);
48 36
49 while (!pending_requests_.empty()) { 37 while (!pending_requests_.empty()) {
50 driver_->StartSession(current_id_++, std::move(pending_requests_.front())); 38 driver_->StartSession(current_id_++, std::move(pending_requests_.front()));
51 pending_requests_.pop(); 39 pending_requests_.pop();
52 } 40 }
53 } 41 }
54 42
55 void IMEServerImpl::StartSession(mojom::StartSessionDetailsPtr details) { 43 void IMEServerImpl::StartSession(mojom::StartSessionDetailsPtr details) {
56 if (driver_.get()) { 44 if (driver_.get()) {
57 // TODO(moshayedi): crbug.com/634431. This will forward all calls from 45 // TODO(moshayedi): crbug.com/634431. This will forward all calls from
58 // clients to the driver as they are. We may need to check |caret_bounds| 46 // clients to the driver as they are. We may need to check |caret_bounds|
59 // parameter of InputMethod::OnCaretBoundsChanged() here and limit them to 47 // parameter of InputMethod::OnCaretBoundsChanged() here and limit them to
60 // client's focused window. 48 // client's focused window.
61 driver_->StartSession(current_id_++, std::move(details)); 49 driver_->StartSession(current_id_++, std::move(details));
62 } else { 50 } else {
63 pending_requests_.push(std::move(details)); 51 pending_requests_.push(std::move(details));
64 } 52 }
65 } 53 }
66 54
67 void IMEServerImpl::OnGotCatalogEntries(
68 std::vector<catalog::mojom::EntryPtr> entries) {
69 // TODO(moshayedi): crbug.com/662157. Decide what to do when number of
70 // available IME drivers isn't exactly one.
71 if (entries.size() == 0)
72 return;
73 connector_->Connect((*entries.begin())->name);
74 }
75
76 } // namespace ui 55 } // namespace ui
OLDNEW
« no previous file with comments | « services/ui/ime/ime_server_impl.h ('k') | services/ui/manifest.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698