| 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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 ime_bridge_->SendInsertText(base::string16()); | 181 ime_bridge_->SendInsertText(base::string16()); |
| 182 } | 182 } |
| 183 } | 183 } |
| 184 | 184 |
| 185 void ArcImeService::InsertText(const base::string16& text) { | 185 void ArcImeService::InsertText(const base::string16& text) { |
| 186 has_composition_text_ = false; | 186 has_composition_text_ = false; |
| 187 ime_bridge_->SendInsertText(text); | 187 ime_bridge_->SendInsertText(text); |
| 188 } | 188 } |
| 189 | 189 |
| 190 void ArcImeService::InsertChar(const ui::KeyEvent& event) { | 190 void ArcImeService::InsertChar(const ui::KeyEvent& event) { |
| 191 // According to the document in text_input_client.h, InsertChar() is called |
| 192 // even when the text input type is NONE. We ignore such events, since for |
| 193 // ARC we are only interested in the event as a method of text input. |
| 194 if (ime_type_ == ui::TEXT_INPUT_TYPE_NONE) |
| 195 return; |
| 196 |
| 191 // Drop 0x00-0x1f (C0 controls), 0x7f (DEL), and 0x80-0x9f (C1 controls). | 197 // Drop 0x00-0x1f (C0 controls), 0x7f (DEL), and 0x80-0x9f (C1 controls). |
| 192 // See: https://en.wikipedia.org/wiki/Unicode_control_characters | 198 // See: https://en.wikipedia.org/wiki/Unicode_control_characters |
| 193 // They are control characters and not treated as a text insertion. | 199 // They are control characters and not treated as a text insertion. |
| 194 const base::char16 ch = event.GetCharacter(); | 200 const base::char16 ch = event.GetCharacter(); |
| 195 const bool is_control_char = (0x00 <= ch && ch <= 0x1f) || | 201 const bool is_control_char = (0x00 <= ch && ch <= 0x1f) || |
| 196 (0x7f <= ch && ch <= 0x9f); | 202 (0x7f <= ch && ch <= 0x9f); |
| 197 | 203 |
| 198 if (!is_control_char && !ui::IsSystemKeyModifier(event.flags())) { | 204 if (!is_control_char && !ui::IsSystemKeyModifier(event.flags())) { |
| 199 has_composition_text_ = false; | 205 has_composition_text_ = false; |
| 200 ime_bridge_->SendInsertText(base::string16(1, event.GetText())); | 206 ime_bridge_->SendInsertText(base::string16(1, event.GetText())); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 bool ArcImeService::ChangeTextDirectionAndLayoutAlignment( | 279 bool ArcImeService::ChangeTextDirectionAndLayoutAlignment( |
| 274 base::i18n::TextDirection direction) { | 280 base::i18n::TextDirection direction) { |
| 275 return false; | 281 return false; |
| 276 } | 282 } |
| 277 | 283 |
| 278 bool ArcImeService::IsEditCommandEnabled(int command_id) { | 284 bool ArcImeService::IsEditCommandEnabled(int command_id) { |
| 279 return false; | 285 return false; |
| 280 } | 286 } |
| 281 | 287 |
| 282 } // namespace arc | 288 } // namespace arc |
| OLD | NEW |