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> |
11 | 11 |
12 #include "ash/shell.h" | 12 #include "ash/shell.h" |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "base/metrics/histogram.h" | 15 #include "base/metrics/histogram.h" |
16 #include "base/strings/string_number_conversions.h" | 16 #include "base/strings/string_number_conversions.h" |
17 #include "base/strings/string_util.h" | 17 #include "base/strings/string_util.h" |
18 #include "base/strings/stringprintf.h" | 18 #include "base/strings/stringprintf.h" |
19 #include "base/strings/utf_string_conversions.h" | 19 #include "base/strings/utf_string_conversions.h" |
20 #include "chrome/browser/profiles/profile_manager.h" | 20 #include "chrome/browser/profiles/profile_manager.h" |
21 #include "ui/aura/window.h" | 21 #include "ui/aura/window.h" |
22 #include "ui/aura/window_tree_host.h" | 22 #include "ui/aura/window_tree_host.h" |
23 #include "ui/base/ime/candidate_window.h" | 23 #include "ui/base/ime/candidate_window.h" |
24 #include "ui/base/ime/chromeos/component_extension_ime_manager.h" | 24 #include "ui/base/ime/chromeos/component_extension_ime_manager.h" |
25 #include "ui/base/ime/chromeos/composition_text_chromeos.h" | 25 #include "ui/base/ime/chromeos/composition_text_chromeos.h" |
26 #include "ui/base/ime/chromeos/extension_ime_util.h" | 26 #include "ui/base/ime/chromeos/extension_ime_util.h" |
27 #include "ui/base/ime/chromeos/ime_keymap.h" | 27 #include "ui/base/ime/chromeos/ime_keymap.h" |
28 #include "ui/base/ime/chromeos/input_method_manager.h" | 28 #include "ui/base/ime/chromeos/input_method_manager.h" |
| 29 #include "ui/base/ime/input_method.h" |
29 #include "ui/base/ime/text_input_flags.h" | 30 #include "ui/base/ime/text_input_flags.h" |
30 #include "ui/chromeos/ime/input_method_menu_item.h" | 31 #include "ui/chromeos/ime/input_method_menu_item.h" |
31 #include "ui/chromeos/ime/input_method_menu_manager.h" | 32 #include "ui/chromeos/ime/input_method_menu_manager.h" |
32 #include "ui/events/event.h" | 33 #include "ui/events/event.h" |
33 #include "ui/events/event_processor.h" | 34 #include "ui/events/event_processor.h" |
34 #include "ui/events/event_utils.h" | 35 #include "ui/events/event_utils.h" |
35 #include "ui/events/keycodes/dom/dom_code.h" | 36 #include "ui/events/keycodes/dom/dom_code.h" |
36 #include "ui/events/keycodes/dom/keycode_converter.h" | 37 #include "ui/events/keycodes/dom/keycode_converter.h" |
37 #include "ui/keyboard/keyboard_controller.h" | 38 #include "ui/keyboard/keyboard_controller.h" |
38 #include "ui/keyboard/keyboard_util.h" | 39 #include "ui/keyboard/keyboard_util.h" |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 const std::vector<KeyboardEvent>& events) { | 285 const std::vector<KeyboardEvent>& events) { |
285 if (!IsActive()) { | 286 if (!IsActive()) { |
286 return false; | 287 return false; |
287 } | 288 } |
288 // context_id == 0, means sending key events to non-input field. | 289 // context_id == 0, means sending key events to non-input field. |
289 // context_id_ == -1, means the focus is not in an input field. | 290 // context_id_ == -1, means the focus is not in an input field. |
290 if (context_id != 0 && (context_id != context_id_ || context_id_ == -1)) { | 291 if (context_id != 0 && (context_id != context_id_ || context_id_ == -1)) { |
291 return false; | 292 return false; |
292 } | 293 } |
293 | 294 |
294 ui::EventProcessor* dispatcher = | 295 ui::InputMethod* input_method = |
295 ash::Shell::GetPrimaryRootWindow()->GetHost()->event_processor(); | 296 ash::Shell::GetTargetRootWindow()->GetHost()->GetInputMethod(); |
296 | 297 |
297 for (size_t i = 0; i < events.size(); ++i) { | 298 for (size_t i = 0; i < events.size(); ++i) { |
298 const KeyboardEvent& event = events[i]; | 299 const KeyboardEvent& event = events[i]; |
299 const ui::EventType type = | 300 const ui::EventType type = |
300 (event.type == "keyup") ? ui::ET_KEY_RELEASED : ui::ET_KEY_PRESSED; | 301 (event.type == "keyup") ? ui::ET_KEY_RELEASED : ui::ET_KEY_PRESSED; |
301 ui::KeyboardCode key_code = static_cast<ui::KeyboardCode>(event.key_code); | 302 ui::KeyboardCode key_code = static_cast<ui::KeyboardCode>(event.key_code); |
302 if (key_code == ui::VKEY_UNKNOWN) | 303 if (key_code == ui::VKEY_UNKNOWN) |
303 key_code = ui::DomKeycodeToKeyboardCode(event.code); | 304 key_code = ui::DomKeycodeToKeyboardCode(event.code); |
304 | 305 |
305 int flags = ui::EF_NONE; | 306 int flags = ui::EF_NONE; |
(...skipping 10 matching lines...) Expand all Loading... |
316 if (key_char.size() == 1) | 317 if (key_char.size() == 1) |
317 ch = key_char[0]; | 318 ch = key_char[0]; |
318 } | 319 } |
319 ui::KeyEvent ui_event( | 320 ui::KeyEvent ui_event( |
320 type, key_code, | 321 type, key_code, |
321 ui::KeycodeConverter::CodeStringToDomCode(event.code.c_str()), flags, | 322 ui::KeycodeConverter::CodeStringToDomCode(event.code.c_str()), flags, |
322 ui::KeycodeConverter::KeyStringToDomKey(event.key.c_str()), ch, | 323 ui::KeycodeConverter::KeyStringToDomKey(event.key.c_str()), ch, |
323 ui::EventTimeForNow()); | 324 ui::EventTimeForNow()); |
324 base::AutoReset<const ui::KeyEvent*> reset_sent_key(&sent_key_event_, | 325 base::AutoReset<const ui::KeyEvent*> reset_sent_key(&sent_key_event_, |
325 &ui_event); | 326 &ui_event); |
326 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&ui_event); | 327 input_method->DispatchKeyEvent(ui_event); |
327 if (details.dispatcher_destroyed) | |
328 break; | |
329 } | 328 } |
330 | 329 |
331 return true; | 330 return true; |
332 } | 331 } |
333 | 332 |
334 const InputMethodEngine::CandidateWindowProperty& | 333 const InputMethodEngine::CandidateWindowProperty& |
335 InputMethodEngine::GetCandidateWindowProperty() const { | 334 InputMethodEngine::GetCandidateWindowProperty() const { |
336 return candidate_window_property_; | 335 return candidate_window_property_; |
337 } | 336 } |
338 | 337 |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
707 // TODO(nona): Implement it. | 706 // TODO(nona): Implement it. |
708 break; | 707 break; |
709 } | 708 } |
710 } | 709 } |
711 } | 710 } |
712 | 711 |
713 // TODO(nona): Support item.children. | 712 // TODO(nona): Support item.children. |
714 } | 713 } |
715 | 714 |
716 } // namespace chromeos | 715 } // namespace chromeos |
OLD | NEW |