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

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

Issue 2539453002: IME for Mus: Add ui.mojom.CompositionText and its struct traits. (Closed)
Patch Set: cleanup. Created 4 years 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
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/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, 23 void ProcessKeyEvent(std::unique_ptr<Event> key_event,
24 const ProcessKeyEventCallback& callback) override { 24 const ProcessKeyEventCallback& callback) override {
25 DCHECK(key_event->IsKeyEvent()); 25 DCHECK(key_event->IsKeyEvent());
26 26
27 if (key_event->AsKeyEvent()->is_char()) { 27 if (key_event->AsKeyEvent()->is_char()) {
28 mojom::CompositionEventPtr composition_event = 28 client_->InsertChar(std::move(key_event));
29 mojom::CompositionEvent::New();
30 composition_event->type = mojom::CompositionEventType::INSERT_CHAR;
31 composition_event->key_event = std::move(key_event);
32 client_->OnCompositionEvent(std::move(composition_event));
33 callback.Run(true); 29 callback.Run(true);
34 } else { 30 } else {
35 callback.Run(false); 31 callback.Run(false);
36 } 32 }
37 } 33 }
38 void CancelComposition() override {} 34 void CancelComposition() override {}
39 35
40 mojom::TextInputClientPtr client_; 36 mojom::TextInputClientPtr client_;
41 37
42 DISALLOW_COPY_AND_ASSIGN(TestInputMethod); 38 DISALLOW_COPY_AND_ASSIGN(TestInputMethod);
(...skipping 12 matching lines...) Expand all
55 new TestInputMethod(std::move(client)), 51 new TestInputMethod(std::move(client)),
56 std::move(input_method_request))); 52 std::move(input_method_request)));
57 } 53 }
58 54
59 void TestIMEDriver::CancelSession(int32_t session_id) { 55 void TestIMEDriver::CancelSession(int32_t session_id) {
60 input_method_bindings_.erase(session_id); 56 input_method_bindings_.erase(session_id);
61 } 57 }
62 58
63 } // namespace test 59 } // namespace test
64 } // namespace ui 60 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698