| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/chromeos/input_method/input_method_engine.h" | 5 #include "chrome/browser/chromeos/input_method/input_method_engine.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #undef FocusIn | 9 #undef FocusIn |
| 10 #undef FocusOut | 10 #undef FocusOut |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 #include "ui/chromeos/ime/input_method_menu_item.h" | 33 #include "ui/chromeos/ime/input_method_menu_item.h" |
| 34 #include "ui/chromeos/ime/input_method_menu_manager.h" | 34 #include "ui/chromeos/ime/input_method_menu_manager.h" |
| 35 #include "ui/events/event.h" | 35 #include "ui/events/event.h" |
| 36 #include "ui/events/event_processor.h" | 36 #include "ui/events/event_processor.h" |
| 37 #include "ui/events/event_utils.h" | 37 #include "ui/events/event_utils.h" |
| 38 #include "ui/events/keycodes/dom/dom_code.h" | 38 #include "ui/events/keycodes/dom/dom_code.h" |
| 39 #include "ui/events/keycodes/dom/keycode_converter.h" | 39 #include "ui/events/keycodes/dom/keycode_converter.h" |
| 40 #include "ui/keyboard/keyboard_controller.h" | 40 #include "ui/keyboard/keyboard_controller.h" |
| 41 #include "ui/keyboard/keyboard_util.h" | 41 #include "ui/keyboard/keyboard_util.h" |
| 42 | 42 |
| 43 using input_method::InputMethodEngineBase; |
| 44 |
| 43 namespace chromeos { | 45 namespace chromeos { |
| 44 | 46 |
| 45 namespace { | 47 namespace { |
| 46 | 48 |
| 47 const char kErrorNotActive[] = "IME is not active"; | 49 const char kErrorNotActive[] = "IME is not active"; |
| 48 const char kErrorWrongContext[] = "Context is not active"; | 50 const char kErrorWrongContext[] = "Context is not active"; |
| 49 const char kCandidateNotFound[] = "Candidate not found"; | 51 const char kCandidateNotFound[] = "Candidate not found"; |
| 50 | 52 |
| 53 // The default entry number of a page in CandidateWindowProperty. |
| 54 const int kDefaultPageSize = 9; |
| 55 |
| 51 } // namespace | 56 } // namespace |
| 52 | 57 |
| 58 InputMethodEngine::MenuItem::MenuItem() {} |
| 59 |
| 60 InputMethodEngine::MenuItem::~MenuItem() {} |
| 61 |
| 62 InputMethodEngine::Candidate::Candidate() {} |
| 63 |
| 64 InputMethodEngine::Candidate::~Candidate() {} |
| 65 |
| 66 // When the default values are changed, please modify |
| 67 // CandidateWindow::CandidateWindowProperty defined in chromeos/ime/ too. |
| 68 InputMethodEngine::CandidateWindowProperty::CandidateWindowProperty() |
| 69 : page_size(kDefaultPageSize), |
| 70 is_cursor_visible(true), |
| 71 is_vertical(false), |
| 72 show_window_at_composition(false) {} |
| 73 |
| 74 InputMethodEngine::CandidateWindowProperty::~CandidateWindowProperty() {} |
| 75 |
| 53 InputMethodEngine::InputMethodEngine() | 76 InputMethodEngine::InputMethodEngine() |
| 54 : candidate_window_(new ui::CandidateWindow()), window_visible_(false) {} | 77 : candidate_window_(new ui::CandidateWindow()), window_visible_(false) {} |
| 55 | 78 |
| 56 InputMethodEngine::~InputMethodEngine() {} | 79 InputMethodEngine::~InputMethodEngine() {} |
| 57 | 80 |
| 58 bool InputMethodEngine::SendKeyEvents( | 81 bool InputMethodEngine::SendKeyEvents( |
| 59 int context_id, | 82 int context_id, |
| 60 const std::vector<KeyboardEvent>& events) { | 83 const std::vector<KeyboardEvent>& events) { |
| 61 if (!IsActive()) { | 84 if (!IsActive()) { |
| 62 return false; | 85 return false; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 return true; | 122 return true; |
| 100 } | 123 } |
| 101 | 124 |
| 102 const InputMethodEngine::CandidateWindowProperty& | 125 const InputMethodEngine::CandidateWindowProperty& |
| 103 InputMethodEngine::GetCandidateWindowProperty() const { | 126 InputMethodEngine::GetCandidateWindowProperty() const { |
| 104 return candidate_window_property_; | 127 return candidate_window_property_; |
| 105 } | 128 } |
| 106 | 129 |
| 107 void InputMethodEngine::SetCandidateWindowProperty( | 130 void InputMethodEngine::SetCandidateWindowProperty( |
| 108 const CandidateWindowProperty& property) { | 131 const CandidateWindowProperty& property) { |
| 109 // Type conversion from IMEEngineHandlerInterface::CandidateWindowProperty to | 132 // Type conversion from InputMethodEngine::CandidateWindowProperty to |
| 110 // CandidateWindow::CandidateWindowProperty defined in chromeos/ime/. | 133 // CandidateWindow::CandidateWindowProperty defined in chromeos/ime/. |
| 111 ui::CandidateWindow::CandidateWindowProperty dest_property; | 134 ui::CandidateWindow::CandidateWindowProperty dest_property; |
| 112 dest_property.page_size = property.page_size; | 135 dest_property.page_size = property.page_size; |
| 113 dest_property.is_cursor_visible = property.is_cursor_visible; | 136 dest_property.is_cursor_visible = property.is_cursor_visible; |
| 114 dest_property.is_vertical = property.is_vertical; | 137 dest_property.is_vertical = property.is_vertical; |
| 115 dest_property.show_window_at_composition = | 138 dest_property.show_window_at_composition = |
| 116 property.show_window_at_composition; | 139 property.show_window_at_composition; |
| 117 dest_property.cursor_position = | 140 dest_property.cursor_position = |
| 118 candidate_window_->GetProperty().cursor_position; | 141 candidate_window_->GetProperty().cursor_position; |
| 119 dest_property.auxiliary_text = property.auxiliary_text; | 142 dest_property.auxiliary_text = property.auxiliary_text; |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 observer_->OnMenuItemActivated(active_component_id_, property_name); | 292 observer_->OnMenuItemActivated(active_component_id_, property_name); |
| 270 } | 293 } |
| 271 | 294 |
| 272 void InputMethodEngine::CandidateClicked(uint32_t index) { | 295 void InputMethodEngine::CandidateClicked(uint32_t index) { |
| 273 if (index > candidate_ids_.size()) { | 296 if (index > candidate_ids_.size()) { |
| 274 return; | 297 return; |
| 275 } | 298 } |
| 276 | 299 |
| 277 // Only left button click is supported at this moment. | 300 // Only left button click is supported at this moment. |
| 278 observer_->OnCandidateClicked(active_component_id_, candidate_ids_.at(index), | 301 observer_->OnCandidateClicked(active_component_id_, candidate_ids_.at(index), |
| 279 ui::IMEEngineObserver::MOUSE_BUTTON_LEFT); | 302 InputMethodEngineBase::MOUSE_BUTTON_LEFT); |
| 280 } | 303 } |
| 281 | 304 |
| 282 // TODO(uekawa): rename this method to a more reasonable name. | 305 // TODO(uekawa): rename this method to a more reasonable name. |
| 283 void InputMethodEngine::MenuItemToProperty( | 306 void InputMethodEngine::MenuItemToProperty( |
| 284 const MenuItem& item, | 307 const MenuItem& item, |
| 285 ui::ime::InputMethodMenuItem* property) { | 308 ui::ime::InputMethodMenuItem* property) { |
| 286 property->key = item.id; | 309 property->key = item.id; |
| 287 | 310 |
| 288 if (item.modified & MENU_ITEM_MODIFIED_LABEL) { | 311 if (item.modified & MENU_ITEM_MODIFIED_LABEL) { |
| 289 property->label = item.label; | 312 property->label = item.label; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 315 // TODO(nona): Implement it. | 338 // TODO(nona): Implement it. |
| 316 break; | 339 break; |
| 317 } | 340 } |
| 318 } | 341 } |
| 319 } | 342 } |
| 320 | 343 |
| 321 // TODO(nona): Support item.children. | 344 // TODO(nona): Support item.children. |
| 322 } | 345 } |
| 323 | 346 |
| 324 } // namespace chromeos | 347 } // namespace chromeos |
| OLD | NEW |