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

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: Fixed Chrome OS builds 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 (composition.selection.start() == underline.start_offset && 63 (composition.selection.start() == underline.start_offset &&
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* arc_bridge_service)
74 : binding_(this), delegate_(delegate), bridge_service_(bridge_service) { 74 : arc_bridge_service_(arc_bridge_service),
75 bridge_service_->AddObserver(this); 75 binding_(this),
76 delegate_(delegate) {
77 DCHECK(arc_bridge_service_);
78 arc_bridge_service_->AddObserver(this);
79
80 // If ImeInstance was ready before we AddObserver(), we won't get
81 // OnImeInstanceReady events. For such case, we have to call it
82 // explicitly.
83 if (arc_bridge_service_->ime_instance())
elijahtaylor1 2016/01/20 00:41:19 I don't think I understand why this can't be done
Luis Héctor Chávez 2016/01/20 17:39:59 Hmmm adding it to AddObserver might work. Regardle
Luis Héctor Chávez 2016/01/20 18:40:46 This is now done.
84 OnImeInstanceReady();
76 } 85 }
77 86
78 ArcImeIpcHost::~ArcImeIpcHost() { 87 ArcImeIpcHost::~ArcImeIpcHost() {
79 bridge_service_->RemoveObserver(this); 88 arc_bridge_service_->RemoveObserver(this);
80 } 89 }
81 90
82 void ArcImeIpcHost::OnImeInstanceReady() { 91 void ArcImeIpcHost::OnImeInstanceReady() {
83 arc::ImeHostPtr host; 92 arc::ImeHostPtr host;
84 binding_.Bind(mojo::GetProxy(&host)); 93 binding_.Bind(mojo::GetProxy(&host));
85 bridge_service_->ime_instance()->Init(std::move(host)); 94 arc_bridge_service_->ime_instance()->Init(std::move(host));
86 } 95 }
87 96
88 void ArcImeIpcHost::SendSetCompositionText( 97 void ArcImeIpcHost::SendSetCompositionText(
89 const ui::CompositionText& composition) { 98 const ui::CompositionText& composition) {
90 ImeInstance* ime_instance = bridge_service_->ime_instance(); 99 ImeInstance* ime_instance = arc_bridge_service_->ime_instance();
91 if (!ime_instance) { 100 if (!ime_instance) {
92 LOG(ERROR) << "ArcImeInstance method called before being ready."; 101 LOG(ERROR) << "ArcImeInstance method called before being ready.";
93 return; 102 return;
94 } 103 }
95 104
96 ime_instance->SetCompositionText(base::UTF16ToUTF8(composition.text), 105 ime_instance->SetCompositionText(base::UTF16ToUTF8(composition.text),
97 ConvertSegments(composition)); 106 ConvertSegments(composition));
98 } 107 }
99 108
100 void ArcImeIpcHost::SendConfirmCompositionText() { 109 void ArcImeIpcHost::SendConfirmCompositionText() {
101 ImeInstance* ime_instance = bridge_service_->ime_instance(); 110 ImeInstance* ime_instance = arc_bridge_service_->ime_instance();
102 if (!ime_instance) { 111 if (!ime_instance) {
103 LOG(ERROR) << "ArcImeInstance method called before being ready."; 112 LOG(ERROR) << "ArcImeInstance method called before being ready.";
104 return; 113 return;
105 } 114 }
106 115
107 ime_instance->ConfirmCompositionText(); 116 ime_instance->ConfirmCompositionText();
108 } 117 }
109 118
110 void ArcImeIpcHost::SendInsertText(const base::string16& text) { 119 void ArcImeIpcHost::SendInsertText(const base::string16& text) {
111 ImeInstance* ime_instance = bridge_service_->ime_instance(); 120 ImeInstance* ime_instance = arc_bridge_service_->ime_instance();
112 if (!ime_instance) { 121 if (!ime_instance) {
113 LOG(ERROR) << "ArcImeInstance method called before being ready."; 122 LOG(ERROR) << "ArcImeInstance method called before being ready.";
114 return; 123 return;
115 } 124 }
116 125
117 ime_instance->InsertText(base::UTF16ToUTF8(text)); 126 ime_instance->InsertText(base::UTF16ToUTF8(text));
118 } 127 }
119 128
120 void ArcImeIpcHost::OnTextInputTypeChanged(arc::TextInputType type) { 129 void ArcImeIpcHost::OnTextInputTypeChanged(arc::TextInputType type) {
121 delegate_->OnTextInputTypeChanged(ConvertTextInputType(type)); 130 delegate_->OnTextInputTypeChanged(ConvertTextInputType(type));
122 } 131 }
123 132
124 void ArcImeIpcHost::OnCursorRectChanged(arc::CursorRectPtr rect) { 133 void ArcImeIpcHost::OnCursorRectChanged(arc::CursorRectPtr rect) {
125 delegate_->OnCursorRectChanged(gfx::Rect( 134 delegate_->OnCursorRectChanged(gfx::Rect(
126 rect->left, 135 rect->left,
127 rect->top, 136 rect->top,
128 rect->right - rect->left, 137 rect->right - rect->left,
129 rect->bottom - rect->top)); 138 rect->bottom - rect->top));
130 } 139 }
131 140
132 } // namespace arc 141 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698