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

Side by Side Diff: chrome/browser/ui/views/ime_driver_mus.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 "chrome/browser/ui/views/ime_driver_mus.h" 5 #include "chrome/browser/ui/views/ime_driver_mus.h"
6 6
7 #include "content/public/browser/browser_thread.h" 7 #include "content/public/browser/browser_thread.h"
8 #include "content/public/common/service_manager_connection.h" 8 #include "content/public/common/service_manager_connection.h"
9 #include "mojo/public/cpp/bindings/strong_binding.h" 9 #include "mojo/public/cpp/bindings/strong_binding.h"
10 #include "services/service_manager/public/cpp/connector.h" 10 #include "services/service_manager/public/cpp/connector.h"
11 #include "services/ui/public/interfaces/constants.mojom.h" 11 #include "services/ui/public/interfaces/constants.mojom.h"
12 #include "services/ui/public/interfaces/ime.mojom.h" 12 #include "services/ui/public/interfaces/ime/ime.mojom.h"
13 13
14 namespace { 14 namespace {
15 15
16 class InputMethod : public ui::mojom::InputMethod { 16 class InputMethod : public ui::mojom::InputMethod {
17 public: 17 public:
18 explicit InputMethod(ui::mojom::TextInputClientPtr client) 18 explicit InputMethod(ui::mojom::TextInputClientPtr client)
19 : client_(std::move(client)) {} 19 : client_(std::move(client)) {}
20 ~InputMethod() override {} 20 ~InputMethod() override {}
21 21
22 private: 22 private:
23 // ui::mojom::InputMethod: 23 // ui::mojom::InputMethod:
24 void OnTextInputModeChanged( 24 void OnTextInputModeChanged(
25 ui::mojom::TextInputMode text_input_mode) override {} 25 ui::mojom::TextInputMode text_input_mode) override {}
26 void OnTextInputTypeChanged( 26 void OnTextInputTypeChanged(
27 ui::mojom::TextInputType text_input_type) override {} 27 ui::mojom::TextInputType text_input_type) override {}
28 void OnCaretBoundsChanged(const gfx::Rect& caret_bounds) override {} 28 void OnCaretBoundsChanged(const gfx::Rect& caret_bounds) override {}
29 void ProcessKeyEvent(std::unique_ptr<ui::Event> key_event, 29 void ProcessKeyEvent(std::unique_ptr<ui::Event> key_event,
30 const ProcessKeyEventCallback& callback) override { 30 const ProcessKeyEventCallback& callback) override {
31 DCHECK(key_event->IsKeyEvent()); 31 DCHECK(key_event->IsKeyEvent());
32 32
33 if (key_event->AsKeyEvent()->is_char()) { 33 if (key_event->AsKeyEvent()->is_char()) {
34 ui::mojom::CompositionEventPtr composition_event = 34 client_->InsertChar(std::move(key_event));
35 ui::mojom::CompositionEvent::New();
36 composition_event->type = ui::mojom::CompositionEventType::INSERT_CHAR;
37 composition_event->key_event = std::move(key_event);
38 client_->OnCompositionEvent(std::move(composition_event));
39 callback.Run(true); 35 callback.Run(true);
40 } else { 36 } else {
41 callback.Run(false); 37 callback.Run(false);
42 } 38 }
43 } 39 }
44 void CancelComposition() override {} 40 void CancelComposition() override {}
45 41
46 ui::mojom::TextInputClientPtr client_; 42 ui::mojom::TextInputClientPtr client_;
47 43
48 DISALLOW_COPY_AND_ASSIGN(InputMethod); 44 DISALLOW_COPY_AND_ASSIGN(InputMethod);
(...skipping 23 matching lines...) Expand all
72 input_method_bindings_[session_id] = 68 input_method_bindings_[session_id] =
73 base::MakeUnique<mojo::Binding<ui::mojom::InputMethod>>( 69 base::MakeUnique<mojo::Binding<ui::mojom::InputMethod>>(
74 new InputMethod(std::move(client)), std::move(input_method_request)); 70 new InputMethod(std::move(client)), std::move(input_method_request));
75 } 71 }
76 72
77 IMEDriver::IMEDriver() {} 73 IMEDriver::IMEDriver() {}
78 74
79 void IMEDriver::CancelSession(int32_t session_id) { 75 void IMEDriver::CancelSession(int32_t session_id) {
80 input_method_bindings_.erase(session_id); 76 input_method_bindings_.erase(session_id);
81 } 77 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698