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

Side by Side Diff: components/arc/ime/arc_ime_ipc_host.cc

Issue 1596663002: arc-bridge: Introduce the ArcService class (Closed) Base URL: https://chromium.googlesource.com/a/chromium/src.git@master
Patch Set: Moved race avoidance boilerplate to ArcBridgeService Created 4 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
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 "components/arc/ime/arc_ime_ipc_host.h" 5 #include "components/arc/ime/arc_ime_ipc_host.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "components/arc/arc_bridge_service.h" 9 #include "components/arc/arc_bridge_service.h"
10 #include "ui/base/ime/composition_text.h" 10 #include "ui/base/ime/composition_text.h"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 composition.selection.end() == underline.end_offset)); 64 composition.selection.end() == underline.end_offset));
65 segments.push_back(std::move(segment)); 65 segments.push_back(std::move(segment));
66 } 66 }
67 return segments; 67 return segments;
68 } 68 }
69 69
70 } // namespace 70 } // namespace
71 71
72 ArcImeIpcHost::ArcImeIpcHost(Delegate* delegate, 72 ArcImeIpcHost::ArcImeIpcHost(Delegate* delegate,
73 ArcBridgeService* bridge_service) 73 ArcBridgeService* bridge_service)
74 : binding_(this), delegate_(delegate), bridge_service_(bridge_service) { 74 : arc_bridge_service_(bridge_service), binding_(this), delegate_(delegate) {
75 bridge_service_->AddObserver(this); 75 arc_bridge_service_->AddObserver(this);
76 } 76 }
77 77
78 ArcImeIpcHost::~ArcImeIpcHost() { 78 ArcImeIpcHost::~ArcImeIpcHost() {
79 bridge_service_->RemoveObserver(this); 79 arc_bridge_service_->RemoveObserver(this);
80 } 80 }
81 81
82 void ArcImeIpcHost::OnImeInstanceReady() { 82 void ArcImeIpcHost::OnImeInstanceReady() {
83 arc::ImeHostPtr host; 83 arc::ImeHostPtr host;
84 binding_.Bind(mojo::GetProxy(&host)); 84 binding_.Bind(mojo::GetProxy(&host));
85 bridge_service_->ime_instance()->Init(std::move(host)); 85 arc_bridge_service_->ime_instance()->Init(std::move(host));
86 } 86 }
87 87
88 void ArcImeIpcHost::SendSetCompositionText( 88 void ArcImeIpcHost::SendSetCompositionText(
89 const ui::CompositionText& composition) { 89 const ui::CompositionText& composition) {
90 ImeInstance* ime_instance = bridge_service_->ime_instance(); 90 ImeInstance* ime_instance = arc_bridge_service_->ime_instance();
91 if (!ime_instance) { 91 if (!ime_instance) {
92 LOG(ERROR) << "ArcImeInstance method called before being ready."; 92 LOG(ERROR) << "ArcImeInstance method called before being ready.";
93 return; 93 return;
94 } 94 }
95 95
96 ime_instance->SetCompositionText(base::UTF16ToUTF8(composition.text), 96 ime_instance->SetCompositionText(base::UTF16ToUTF8(composition.text),
97 ConvertSegments(composition)); 97 ConvertSegments(composition));
98 } 98 }
99 99
100 void ArcImeIpcHost::SendConfirmCompositionText() { 100 void ArcImeIpcHost::SendConfirmCompositionText() {
101 ImeInstance* ime_instance = bridge_service_->ime_instance(); 101 ImeInstance* ime_instance = arc_bridge_service_->ime_instance();
102 if (!ime_instance) { 102 if (!ime_instance) {
103 LOG(ERROR) << "ArcImeInstance method called before being ready."; 103 LOG(ERROR) << "ArcImeInstance method called before being ready.";
104 return; 104 return;
105 } 105 }
106 106
107 ime_instance->ConfirmCompositionText(); 107 ime_instance->ConfirmCompositionText();
108 } 108 }
109 109
110 void ArcImeIpcHost::SendInsertText(const base::string16& text) { 110 void ArcImeIpcHost::SendInsertText(const base::string16& text) {
111 ImeInstance* ime_instance = bridge_service_->ime_instance(); 111 ImeInstance* ime_instance = arc_bridge_service_->ime_instance();
112 if (!ime_instance) { 112 if (!ime_instance) {
113 LOG(ERROR) << "ArcImeInstance method called before being ready."; 113 LOG(ERROR) << "ArcImeInstance method called before being ready.";
114 return; 114 return;
115 } 115 }
116 116
117 ime_instance->InsertText(base::UTF16ToUTF8(text)); 117 ime_instance->InsertText(base::UTF16ToUTF8(text));
118 } 118 }
119 119
120 void ArcImeIpcHost::OnTextInputTypeChanged(arc::TextInputType type) { 120 void ArcImeIpcHost::OnTextInputTypeChanged(arc::TextInputType type) {
121 delegate_->OnTextInputTypeChanged(ConvertTextInputType(type)); 121 delegate_->OnTextInputTypeChanged(ConvertTextInputType(type));
122 } 122 }
123 123
124 void ArcImeIpcHost::OnCursorRectChanged(arc::CursorRectPtr rect) { 124 void ArcImeIpcHost::OnCursorRectChanged(arc::CursorRectPtr rect) {
125 delegate_->OnCursorRectChanged(gfx::Rect( 125 delegate_->OnCursorRectChanged(gfx::Rect(
126 rect->left, 126 rect->left,
127 rect->top, 127 rect->top,
128 rect->right - rect->left, 128 rect->right - rect->left,
129 rect->bottom - rect->top)); 129 rect->bottom - rect->top));
130 } 130 }
131 131
132 } // namespace arc 132 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698