| OLD | NEW |
| 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_bridge_impl.h" | 5 #include "components/arc/ime/arc_ime_bridge_impl.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 ArcBridgeService* bridge_service) | 81 ArcBridgeService* bridge_service) |
| 82 : binding_(this), delegate_(delegate), bridge_service_(bridge_service) { | 82 : binding_(this), delegate_(delegate), bridge_service_(bridge_service) { |
| 83 bridge_service_->ime()->AddObserver(this); | 83 bridge_service_->ime()->AddObserver(this); |
| 84 } | 84 } |
| 85 | 85 |
| 86 ArcImeBridgeImpl::~ArcImeBridgeImpl() { | 86 ArcImeBridgeImpl::~ArcImeBridgeImpl() { |
| 87 bridge_service_->ime()->RemoveObserver(this); | 87 bridge_service_->ime()->RemoveObserver(this); |
| 88 } | 88 } |
| 89 | 89 |
| 90 void ArcImeBridgeImpl::OnInstanceReady() { | 90 void ArcImeBridgeImpl::OnInstanceReady() { |
| 91 bridge_service_->ime()->instance()->Init( | 91 auto* instance = bridge_service_->ime()->GetInstanceForMethod("Init"); |
| 92 binding_.CreateInterfacePtrAndBind()); | 92 if (!instance) |
| 93 return; |
| 94 instance->Init(binding_.CreateInterfacePtrAndBind()); |
| 93 } | 95 } |
| 94 | 96 |
| 95 void ArcImeBridgeImpl::SendSetCompositionText( | 97 void ArcImeBridgeImpl::SendSetCompositionText( |
| 96 const ui::CompositionText& composition) { | 98 const ui::CompositionText& composition) { |
| 97 auto* ime_instance = | 99 auto* ime_instance = |
| 98 bridge_service_->ime()->GetInstanceForMethod("SetCompositionText"); | 100 bridge_service_->ime()->GetInstanceForMethod("SetCompositionText"); |
| 99 if (!ime_instance) | 101 if (!ime_instance) |
| 100 return; | 102 return; |
| 101 | 103 |
| 102 ime_instance->SetCompositionText(base::UTF16ToUTF8(composition.text), | 104 ime_instance->SetCompositionText(base::UTF16ToUTF8(composition.text), |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 | 155 |
| 154 void ArcImeBridgeImpl::OnCancelComposition() { | 156 void ArcImeBridgeImpl::OnCancelComposition() { |
| 155 delegate_->OnCancelComposition(); | 157 delegate_->OnCancelComposition(); |
| 156 } | 158 } |
| 157 | 159 |
| 158 void ArcImeBridgeImpl::ShowImeIfNeeded() { | 160 void ArcImeBridgeImpl::ShowImeIfNeeded() { |
| 159 delegate_->ShowImeIfNeeded(); | 161 delegate_->ShowImeIfNeeded(); |
| 160 } | 162 } |
| 161 | 163 |
| 162 } // namespace arc | 164 } // namespace arc |
| OLD | NEW |