| 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_ipc_host_impl.h" | 5 #include "components/arc/ime/arc_ime_ipc_host_impl.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" |
| 11 #include "ui/base/ime/text_input_type.h" | 11 #include "ui/base/ime/text_input_type.h" |
| 12 #include "ui/gfx/geometry/rect.h" | 12 #include "ui/gfx/geometry/rect.h" |
| 13 | 13 |
| 14 namespace arc { | 14 namespace arc { |
| 15 namespace { | 15 namespace { |
| 16 | 16 |
| 17 ui::TextInputType ConvertTextInputType(arc::TextInputType ipc_type) { | 17 ui::TextInputType ConvertTextInputType(arc::TextInputType ipc_type) { |
| 18 // The two enum types are similar, but intentionally made not identical. | 18 // The two enum types are similar, but intentionally made not identical. |
| 19 // We cannot force them to be in sync. If we do, updates in ui::TextInputType | 19 // We cannot force them to be in sync. If we do, updates in ui::TextInputType |
| 20 // must always be propagated to the arc::TextInputType mojo definition in | 20 // must always be propagated to the arc::TextInputType mojo definition in |
| 21 // ARC container side, which is in a different repository than Chromium. | 21 // ARC container side, which is in a different repository than Chromium. |
| 22 // We don't want such dependency. | 22 // We don't want such dependency. |
| 23 // | 23 // |
| 24 // That's why we need a lengthy switch statement instead of static_cast | 24 // That's why we need a lengthy switch statement instead of static_cast |
| 25 // guarded by a static assert on the two enums to be in sync. | 25 // guarded by a static assert on the two enums to be in sync. |
| 26 switch (ipc_type) { | 26 switch (ipc_type) { |
| 27 case arc::TEXT_INPUT_TYPE_NONE: | 27 case arc::TextInputType::NONE: |
| 28 return ui::TEXT_INPUT_TYPE_NONE; | 28 return ui::TEXT_INPUT_TYPE_NONE; |
| 29 case arc::TEXT_INPUT_TYPE_TEXT: | 29 case arc::TextInputType::TEXT: |
| 30 return ui::TEXT_INPUT_TYPE_TEXT; | 30 return ui::TEXT_INPUT_TYPE_TEXT; |
| 31 case arc::TEXT_INPUT_TYPE_PASSWORD: | 31 case arc::TextInputType::PASSWORD: |
| 32 return ui::TEXT_INPUT_TYPE_PASSWORD; | 32 return ui::TEXT_INPUT_TYPE_PASSWORD; |
| 33 case arc::TEXT_INPUT_TYPE_SEARCH: | 33 case arc::TextInputType::SEARCH: |
| 34 return ui::TEXT_INPUT_TYPE_SEARCH; | 34 return ui::TEXT_INPUT_TYPE_SEARCH; |
| 35 case arc::TEXT_INPUT_TYPE_EMAIL: | 35 case arc::TextInputType::EMAIL: |
| 36 return ui::TEXT_INPUT_TYPE_EMAIL; | 36 return ui::TEXT_INPUT_TYPE_EMAIL; |
| 37 case arc::TEXT_INPUT_TYPE_NUMBER: | 37 case arc::TextInputType::NUMBER: |
| 38 return ui::TEXT_INPUT_TYPE_NUMBER; | 38 return ui::TEXT_INPUT_TYPE_NUMBER; |
| 39 case arc::TEXT_INPUT_TYPE_TELEPHONE: | 39 case arc::TextInputType::TELEPHONE: |
| 40 return ui::TEXT_INPUT_TYPE_TELEPHONE; | 40 return ui::TEXT_INPUT_TYPE_TELEPHONE; |
| 41 case arc::TEXT_INPUT_TYPE_URL: | 41 case arc::TextInputType::URL: |
| 42 return ui::TEXT_INPUT_TYPE_URL; | 42 return ui::TEXT_INPUT_TYPE_URL; |
| 43 case arc::TEXT_INPUT_TYPE_DATE: | 43 case arc::TextInputType::DATE: |
| 44 return ui::TEXT_INPUT_TYPE_DATE; | 44 return ui::TEXT_INPUT_TYPE_DATE; |
| 45 case arc::TEXT_INPUT_TYPE_TIME: | 45 case arc::TextInputType::TIME: |
| 46 return ui::TEXT_INPUT_TYPE_TIME; | 46 return ui::TEXT_INPUT_TYPE_TIME; |
| 47 case arc::TEXT_INPUT_TYPE_DATETIME: | 47 case arc::TextInputType::DATETIME: |
| 48 return ui::TEXT_INPUT_TYPE_DATE_TIME_LOCAL; | 48 return ui::TEXT_INPUT_TYPE_DATE_TIME_LOCAL; |
| 49 default: | 49 default: |
| 50 return ui::TEXT_INPUT_TYPE_TEXT; | 50 return ui::TEXT_INPUT_TYPE_TEXT; |
| 51 } | 51 } |
| 52 } | 52 } |
| 53 | 53 |
| 54 mojo::Array<arc::CompositionSegmentPtr> ConvertSegments( | 54 mojo::Array<arc::CompositionSegmentPtr> ConvertSegments( |
| 55 const ui::CompositionText& composition) { | 55 const ui::CompositionText& composition) { |
| 56 mojo::Array<arc::CompositionSegmentPtr> segments = | 56 mojo::Array<arc::CompositionSegmentPtr> segments = |
| 57 mojo::Array<arc::CompositionSegmentPtr>::New(0); | 57 mojo::Array<arc::CompositionSegmentPtr>::New(0); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 | 123 |
| 124 void ArcImeIpcHostImpl::OnCursorRectChanged(arc::CursorRectPtr rect) { | 124 void ArcImeIpcHostImpl::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 |
| OLD | NEW |