| 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 #undef FocusIn | 7 #undef FocusIn |
| 8 #undef FocusOut | 8 #undef FocusOut |
| 9 #undef RootWindow | 9 #undef RootWindow |
| 10 #include <map> | 10 #include <map> |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 const std::vector<KeyboardEvent>& events) { | 284 const std::vector<KeyboardEvent>& events) { |
| 285 if (!IsActive()) { | 285 if (!IsActive()) { |
| 286 return false; | 286 return false; |
| 287 } | 287 } |
| 288 // context_id == 0, means sending key events to non-input field. | 288 // context_id == 0, means sending key events to non-input field. |
| 289 // context_id_ == -1, means the focus is not in an input field. | 289 // context_id_ == -1, means the focus is not in an input field. |
| 290 if (context_id != 0 && (context_id != context_id_ || context_id_ == -1)) { | 290 if (context_id != 0 && (context_id != context_id_ || context_id_ == -1)) { |
| 291 return false; | 291 return false; |
| 292 } | 292 } |
| 293 | 293 |
| 294 ui::EventProcessor* dispatcher = | 294 ui::InputMethod* input_method = |
| 295 ash::Shell::GetPrimaryRootWindow()->GetHost()->event_processor(); | 295 ash::Shell::GetPrimaryRootWindow()->GetHost()->GetInputMethod(); |
| 296 | 296 |
| 297 for (size_t i = 0; i < events.size(); ++i) { | 297 for (size_t i = 0; i < events.size(); ++i) { |
| 298 const KeyboardEvent& event = events[i]; | 298 const KeyboardEvent& event = events[i]; |
| 299 const ui::EventType type = | 299 const ui::EventType type = |
| 300 (event.type == "keyup") ? ui::ET_KEY_RELEASED : ui::ET_KEY_PRESSED; | 300 (event.type == "keyup") ? ui::ET_KEY_RELEASED : ui::ET_KEY_PRESSED; |
| 301 ui::KeyboardCode key_code = static_cast<ui::KeyboardCode>(event.key_code); | 301 ui::KeyboardCode key_code = static_cast<ui::KeyboardCode>(event.key_code); |
| 302 if (key_code == ui::VKEY_UNKNOWN) | 302 if (key_code == ui::VKEY_UNKNOWN) |
| 303 key_code = ui::DomKeycodeToKeyboardCode(event.code); | 303 key_code = ui::DomKeycodeToKeyboardCode(event.code); |
| 304 | 304 |
| 305 int flags = ui::EF_NONE; | 305 int flags = ui::EF_NONE; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 316 if (key_char.size() == 1) | 316 if (key_char.size() == 1) |
| 317 ch = key_char[0]; | 317 ch = key_char[0]; |
| 318 } | 318 } |
| 319 ui::KeyEvent ui_event( | 319 ui::KeyEvent ui_event( |
| 320 type, key_code, | 320 type, key_code, |
| 321 ui::KeycodeConverter::CodeStringToDomCode(event.code.c_str()), flags, | 321 ui::KeycodeConverter::CodeStringToDomCode(event.code.c_str()), flags, |
| 322 ui::KeycodeConverter::KeyStringToDomKey(event.key.c_str()), ch, | 322 ui::KeycodeConverter::KeyStringToDomKey(event.key.c_str()), ch, |
| 323 ui::EventTimeForNow()); | 323 ui::EventTimeForNow()); |
| 324 base::AutoReset<const ui::KeyEvent*> reset_sent_key(&sent_key_event_, | 324 base::AutoReset<const ui::KeyEvent*> reset_sent_key(&sent_key_event_, |
| 325 &ui_event); | 325 &ui_event); |
| 326 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&ui_event); | 326 input_method->DispatchKeyEvent(ui_event); |
| 327 if (details.dispatcher_destroyed) | |
| 328 break; | |
| 329 } | 327 } |
| 330 | 328 |
| 331 return true; | 329 return true; |
| 332 } | 330 } |
| 333 | 331 |
| 334 const InputMethodEngine::CandidateWindowProperty& | 332 const InputMethodEngine::CandidateWindowProperty& |
| 335 InputMethodEngine::GetCandidateWindowProperty() const { | 333 InputMethodEngine::GetCandidateWindowProperty() const { |
| 336 return candidate_window_property_; | 334 return candidate_window_property_; |
| 337 } | 335 } |
| 338 | 336 |
| (...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 707 // TODO(nona): Implement it. | 705 // TODO(nona): Implement it. |
| 708 break; | 706 break; |
| 709 } | 707 } |
| 710 } | 708 } |
| 711 } | 709 } |
| 712 | 710 |
| 713 // TODO(nona): Support item.children. | 711 // TODO(nona): Support item.children. |
| 714 } | 712 } |
| 715 | 713 |
| 716 } // namespace chromeos | 714 } // namespace chromeos |
| OLD | NEW |