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

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

Issue 2284003002: Revert of IME for Mus: Make InputMethodMus use the IME Mojo API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 3 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/test_ime_driver/main.cc ('k') | services/ui/public/interfaces/ime.mojom » ('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/test_ime_driver/test_ime_driver.h" 5 #include "services/ui/ime/test_ime_driver/test_ime_driver.h"
6 6
7 #include "services/ui/public/interfaces/ime.mojom.h" 7 #include "services/ui/public/interfaces/ime.mojom.h"
8 8
9 namespace ui { 9 namespace ui {
10 namespace test { 10 namespace test {
11 11
12 class TestInputMethod : public mojom::InputMethod { 12 class TestInputMethod : public mojom::InputMethod {
13 public: 13 public:
14 explicit TestInputMethod(mojom::TextInputClientPtr client) 14 explicit TestInputMethod(mojom::TextInputClientPtr client)
15 : client_(std::move(client)) {} 15 : client_(std::move(client)) {}
16 ~TestInputMethod() override {} 16 ~TestInputMethod() override {}
17 17
18 private: 18 private:
19 // mojom::InputMethod: 19 // mojom::InputMethod:
20 void OnTextInputModeChanged(mojom::TextInputMode text_input_mode) override {} 20 void OnTextInputModeChanged(mojom::TextInputMode text_input_mode) override {}
21 void OnTextInputTypeChanged(mojom::TextInputType text_input_type) override {} 21 void OnTextInputTypeChanged(mojom::TextInputType text_input_type) override {}
22 void OnCaretBoundsChanged(const gfx::Rect& caret_bounds) override {} 22 void OnCaretBoundsChanged(const gfx::Rect& caret_bounds) override {}
23 void ProcessKeyEvent(std::unique_ptr<Event> key_event) override { 23 void ProcessKeyEvent(std::unique_ptr<Event> key_event) override {
24 DCHECK(key_event->IsKeyEvent()); 24 DCHECK(key_event->IsKeyEvent());
25 mojom::CompositionEventPtr composition_event =
26 mojom::CompositionEvent::New();
27 composition_event->type = mojom::CompositionEventType::INSERT_CHAR;
28 composition_event->key_event = std::move(key_event);
25 29
26 if (key_event->AsKeyEvent()->is_char()) { 30 client_->OnCompositionEvent(std::move(composition_event));
27 mojom::CompositionEventPtr composition_event =
28 mojom::CompositionEvent::New();
29 composition_event->type = mojom::CompositionEventType::INSERT_CHAR;
30 composition_event->key_event = std::move(key_event);
31 client_->OnCompositionEvent(std::move(composition_event));
32 } else {
33 client_->OnUnhandledEvent(std::move(key_event));
34 }
35 }; 31 };
36 void CancelComposition() override {} 32 void CancelComposition() override {}
37 33
38 mojom::TextInputClientPtr client_; 34 mojom::TextInputClientPtr client_;
39 35
40 DISALLOW_COPY_AND_ASSIGN(TestInputMethod); 36 DISALLOW_COPY_AND_ASSIGN(TestInputMethod);
41 }; 37 };
42 38
43 TestIMEDriver::TestIMEDriver(mojom::IMEDriverRequest request) 39 TestIMEDriver::TestIMEDriver(mojom::IMEDriverRequest request)
44 : driver_binding_(this, std::move(request)) {} 40 : driver_binding_(this, std::move(request)) {}
45 41
46 TestIMEDriver::~TestIMEDriver() {} 42 TestIMEDriver::~TestIMEDriver() {}
47 43
48 void TestIMEDriver::StartSession( 44 void TestIMEDriver::StartSession(
49 int32_t session_id, 45 int32_t session_id,
50 mojom::TextInputClientPtr client, 46 mojom::TextInputClientPtr client,
51 mojom::InputMethodRequest input_method_request) { 47 mojom::InputMethodRequest input_method_request) {
52 input_method_bindings_[session_id].reset( 48 input_method_bindings_[session_id].reset(
53 new mojo::Binding<mojom::InputMethod>( 49 new mojo::Binding<mojom::InputMethod>(
54 new TestInputMethod(std::move(client)), 50 new TestInputMethod(std::move(client)),
55 std::move(input_method_request))); 51 std::move(input_method_request)));
56 } 52 }
57 53
58 void TestIMEDriver::CancelSession(int32_t session_id) { 54 void TestIMEDriver::CancelSession(int32_t session_id) {
59 input_method_bindings_.erase(session_id); 55 input_method_bindings_.erase(session_id);
60 } 56 }
61 57
62 } // namespace test 58 } // namespace test
63 } // namespace ui 59 } // namespace ui
OLDNEW
« no previous file with comments | « services/ui/ime/test_ime_driver/main.cc ('k') | services/ui/public/interfaces/ime.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698