Chromium Code Reviews| 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_service.h" | 5 #include "components/arc/ime/arc_ime_service.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "components/arc/ime/arc_ime_bridge_impl.h" | 8 #include "components/arc/ime/arc_ime_bridge_impl.h" |
| 9 #include "components/exo/shell_surface.h" | 9 #include "components/exo/shell_surface.h" |
| 10 #include "components/exo/surface.h" | 10 #include "components/exo/surface.h" |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 119 ui::InputMethod* const input_method = GetInputMethod(); | 119 ui::InputMethod* const input_method = GetInputMethod(); |
| 120 if (input_method) | 120 if (input_method) |
| 121 input_method->SetFocusedTextInputClient(this); | 121 input_method->SetFocusedTextInputClient(this); |
| 122 } | 122 } |
| 123 } | 123 } |
| 124 | 124 |
| 125 //////////////////////////////////////////////////////////////////////////////// | 125 //////////////////////////////////////////////////////////////////////////////// |
| 126 // Overridden from arc::ArcImeBridge::Delegate | 126 // Overridden from arc::ArcImeBridge::Delegate |
| 127 | 127 |
| 128 void ArcImeService::OnTextInputTypeChanged(ui::TextInputType type) { | 128 void ArcImeService::OnTextInputTypeChanged(ui::TextInputType type) { |
| 129 if (ime_type_ == type) | 129 ui::TextInputType previous_type = ime_type_; |
|
kinaba
2016/06/14 04:22:08
Although it's a matter of taste, can we keep this
takaoka
2016/06/14 05:55:51
Done.
| |
| 130 return; | |
| 131 ime_type_ = type; | 130 ime_type_ = type; |
| 132 | |
| 133 ui::InputMethod* const input_method = GetInputMethod(); | 131 ui::InputMethod* const input_method = GetInputMethod(); |
| 134 if (input_method) { | 132 if (input_method && ime_type_ != previous_type) { |
| 135 input_method->OnTextInputTypeChanged(this); | 133 input_method->OnTextInputTypeChanged(this); |
| 136 if (input_method->GetTextInputClient() == this && | |
| 137 ime_type_ != ui::TEXT_INPUT_TYPE_NONE) { | |
| 138 // TODO(kinaba): crbug.com/581282. This is tentative short-term solution. | |
| 139 // | |
| 140 // For fully correct implementation, rather than to piggyback the "show" | |
| 141 // request with the input type change, we need dedicated IPCs to share the | |
| 142 // virtual keyboard show/hide states between Chromium and ARC. | |
| 143 input_method->ShowImeIfNeeded(); | |
|
kinaba
2016/06/14 04:22:08
Removing this code at once causes a regression in
takaoka
2016/06/14 05:55:51
Done.
| |
| 144 } | |
| 145 } | 134 } |
| 146 } | 135 } |
| 147 | 136 |
| 148 void ArcImeService::OnCursorRectChanged(const gfx::Rect& rect) { | 137 void ArcImeService::OnCursorRectChanged(const gfx::Rect& rect) { |
| 149 if (cursor_rect_ == rect) | 138 if (cursor_rect_ == rect) |
| 150 return; | 139 return; |
| 151 cursor_rect_ = rect; | 140 cursor_rect_ = rect; |
| 152 | 141 |
| 153 ui::InputMethod* const input_method = GetInputMethod(); | 142 ui::InputMethod* const input_method = GetInputMethod(); |
| 154 if (input_method) | 143 if (input_method) |
| 155 input_method->OnCaretBoundsChanged(this); | 144 input_method->OnCaretBoundsChanged(this); |
| 156 } | 145 } |
| 157 | 146 |
| 158 void ArcImeService::OnCancelComposition() { | 147 void ArcImeService::OnCancelComposition() { |
| 159 ui::InputMethod* const input_method = GetInputMethod(); | 148 ui::InputMethod* const input_method = GetInputMethod(); |
| 160 if (input_method) | 149 if (input_method) |
| 161 input_method->CancelComposition(this); | 150 input_method->CancelComposition(this); |
| 162 } | 151 } |
| 163 | 152 |
| 153 void ArcImeService::ShowImeIfNeeded() { | |
| 154 ui::InputMethod* const input_method = GetInputMethod(); | |
| 155 if (input_method && input_method->GetTextInputClient() == this) { | |
| 156 input_method->ShowImeIfNeeded(); | |
| 157 } | |
| 158 } | |
| 159 | |
| 164 //////////////////////////////////////////////////////////////////////////////// | 160 //////////////////////////////////////////////////////////////////////////////// |
| 165 // Oberridden from ui::TextInputClient: | 161 // Oberridden from ui::TextInputClient: |
| 166 | 162 |
| 167 void ArcImeService::SetCompositionText( | 163 void ArcImeService::SetCompositionText( |
| 168 const ui::CompositionText& composition) { | 164 const ui::CompositionText& composition) { |
| 169 has_composition_text_ = !composition.text.empty(); | 165 has_composition_text_ = !composition.text.empty(); |
| 170 ime_bridge_->SendSetCompositionText(composition); | 166 ime_bridge_->SendSetCompositionText(composition); |
| 171 } | 167 } |
| 172 | 168 |
| 173 void ArcImeService::ConfirmCompositionText() { | 169 void ArcImeService::ConfirmCompositionText() { |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 279 bool ArcImeService::ChangeTextDirectionAndLayoutAlignment( | 275 bool ArcImeService::ChangeTextDirectionAndLayoutAlignment( |
| 280 base::i18n::TextDirection direction) { | 276 base::i18n::TextDirection direction) { |
| 281 return false; | 277 return false; |
| 282 } | 278 } |
| 283 | 279 |
| 284 bool ArcImeService::IsEditCommandEnabled(int command_id) { | 280 bool ArcImeService::IsEditCommandEnabled(int command_id) { |
| 285 return false; | 281 return false; |
| 286 } | 282 } |
| 287 | 283 |
| 288 } // namespace arc | 284 } // namespace arc |
| OLD | NEW |