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/ime/input_method_menu_item.h" | |
13 #include "ash/ime/input_method_menu_manager.h" | |
14 #include "ash/shell.h" | |
15 #include "base/logging.h" | 12 #include "base/logging.h" |
16 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
17 #include "base/metrics/histogram.h" | 14 #include "base/metrics/histogram.h" |
18 #include "base/strings/string_number_conversions.h" | 15 #include "base/strings/string_number_conversions.h" |
19 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
20 #include "base/strings/stringprintf.h" | 17 #include "base/strings/stringprintf.h" |
21 #include "base/strings/utf_string_conversions.h" | 18 #include "base/strings/utf_string_conversions.h" |
22 #include "chromeos/ime/component_extension_ime_manager.h" | 19 #include "chromeos/ime/component_extension_ime_manager.h" |
23 #include "chromeos/ime/composition_text.h" | 20 #include "chromeos/ime/composition_text.h" |
24 #include "chromeos/ime/extension_ime_util.h" | 21 #include "chromeos/ime/extension_ime_util.h" |
25 #include "chromeos/ime/input_method_manager.h" | 22 #include "chromeos/ime/input_method_manager.h" |
26 #include "ui/aura/window.h" | 23 #include "ui/aura/window.h" |
27 #include "ui/aura/window_tree_host.h" | 24 #include "ui/aura/window_tree_host.h" |
28 #include "ui/base/ime/candidate_window.h" | 25 #include "ui/base/ime/candidate_window.h" |
29 #include "ui/base/ime/chromeos/ime_keymap.h" | 26 #include "ui/base/ime/chromeos/ime_keymap.h" |
30 #include "ui/base/ime/text_input_flags.h" | 27 #include "ui/base/ime/text_input_flags.h" |
| 28 #include "ui/chromeos/ime/input_method_menu_item.h" |
| 29 #include "ui/chromeos/ime/input_method_menu_manager.h" |
31 #include "ui/events/event.h" | 30 #include "ui/events/event.h" |
32 #include "ui/events/event_processor.h" | 31 #include "ui/events/event_processor.h" |
33 #include "ui/events/keycodes/dom4/keycode_converter.h" | 32 #include "ui/events/keycodes/dom4/keycode_converter.h" |
34 #include "ui/keyboard/keyboard_controller.h" | 33 #include "ui/keyboard/keyboard_controller.h" |
35 #include "ui/keyboard/keyboard_util.h" | 34 #include "ui/keyboard/keyboard_util.h" |
36 | 35 |
37 #if defined(USE_ATHENA) | 36 #if defined(USE_ATHENA) |
38 #include "athena/screen/public/screen_manager.h" | 37 #include "athena/screen/public/screen_manager.h" |
39 #endif | 38 #endif |
40 | 39 |
| 40 #if defined(USE_ASH) |
| 41 #include "ash/shell.h" |
| 42 #endif |
| 43 |
41 namespace chromeos { | 44 namespace chromeos { |
42 | 45 |
43 namespace { | 46 namespace { |
44 | 47 |
45 const char kErrorNotActive[] = "IME is not active"; | 48 const char kErrorNotActive[] = "IME is not active"; |
46 const char kErrorWrongContext[] = "Context is not active"; | 49 const char kErrorWrongContext[] = "Context is not active"; |
47 const char kCandidateNotFound[] = "Candidate not found"; | 50 const char kCandidateNotFound[] = "Candidate not found"; |
48 | 51 |
49 // Notifies InputContextHandler that the composition is changed. | 52 // Notifies InputContextHandler that the composition is changed. |
50 void UpdateComposition(const CompositionText& composition_text, | 53 void UpdateComposition(const CompositionText& composition_text, |
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
452 | 455 |
453 bool InputMethodEngine::SetMenuItems(const std::vector<MenuItem>& items) { | 456 bool InputMethodEngine::SetMenuItems(const std::vector<MenuItem>& items) { |
454 return UpdateMenuItems(items); | 457 return UpdateMenuItems(items); |
455 } | 458 } |
456 | 459 |
457 bool InputMethodEngine::UpdateMenuItems( | 460 bool InputMethodEngine::UpdateMenuItems( |
458 const std::vector<MenuItem>& items) { | 461 const std::vector<MenuItem>& items) { |
459 if (!IsActive()) | 462 if (!IsActive()) |
460 return false; | 463 return false; |
461 | 464 |
462 ash::ime::InputMethodMenuItemList menu_item_list; | 465 ui::ime::InputMethodMenuItemList menu_item_list; |
463 for (std::vector<MenuItem>::const_iterator item = items.begin(); | 466 for (std::vector<MenuItem>::const_iterator item = items.begin(); |
464 item != items.end(); ++item) { | 467 item != items.end(); ++item) { |
465 ash::ime::InputMethodMenuItem property; | 468 ui::ime::InputMethodMenuItem property; |
466 MenuItemToProperty(*item, &property); | 469 MenuItemToProperty(*item, &property); |
467 menu_item_list.push_back(property); | 470 menu_item_list.push_back(property); |
468 } | 471 } |
469 | 472 |
470 ash::ime::InputMethodMenuManager::GetInstance()-> | 473 ui::ime::InputMethodMenuManager::GetInstance()-> |
471 SetCurrentInputMethodMenuItemList( | 474 SetCurrentInputMethodMenuItemList( |
472 menu_item_list); | 475 menu_item_list); |
473 return true; | 476 return true; |
474 } | 477 } |
475 | 478 |
476 bool InputMethodEngine::IsActive() const { | 479 bool InputMethodEngine::IsActive() const { |
477 return !active_component_id_.empty(); | 480 return !active_component_id_.empty(); |
478 } | 481 } |
479 | 482 |
480 bool InputMethodEngine::DeleteSurroundingText(int context_id, | 483 bool InputMethodEngine::DeleteSurroundingText(int context_id, |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
655 uint32 anchor_pos) { | 658 uint32 anchor_pos) { |
656 observer_->OnSurroundingTextChanged(active_component_id_, | 659 observer_->OnSurroundingTextChanged(active_component_id_, |
657 text, | 660 text, |
658 static_cast<int>(cursor_pos), | 661 static_cast<int>(cursor_pos), |
659 static_cast<int>(anchor_pos)); | 662 static_cast<int>(anchor_pos)); |
660 } | 663 } |
661 | 664 |
662 // TODO(uekawa): rename this method to a more reasonable name. | 665 // TODO(uekawa): rename this method to a more reasonable name. |
663 void InputMethodEngine::MenuItemToProperty( | 666 void InputMethodEngine::MenuItemToProperty( |
664 const MenuItem& item, | 667 const MenuItem& item, |
665 ash::ime::InputMethodMenuItem* property) { | 668 ui::ime::InputMethodMenuItem* property) { |
666 property->key = item.id; | 669 property->key = item.id; |
667 | 670 |
668 if (item.modified & MENU_ITEM_MODIFIED_LABEL) { | 671 if (item.modified & MENU_ITEM_MODIFIED_LABEL) { |
669 property->label = item.label; | 672 property->label = item.label; |
670 } | 673 } |
671 if (item.modified & MENU_ITEM_MODIFIED_VISIBLE) { | 674 if (item.modified & MENU_ITEM_MODIFIED_VISIBLE) { |
672 // TODO(nona): Implement it. | 675 // TODO(nona): Implement it. |
673 } | 676 } |
674 if (item.modified & MENU_ITEM_MODIFIED_CHECKED) { | 677 if (item.modified & MENU_ITEM_MODIFIED_CHECKED) { |
675 property->is_selection_item_checked = item.checked; | 678 property->is_selection_item_checked = item.checked; |
(...skipping 19 matching lines...) Expand all Loading... |
695 // TODO(nona): Implement it. | 698 // TODO(nona): Implement it. |
696 break; | 699 break; |
697 } | 700 } |
698 } | 701 } |
699 } | 702 } |
700 | 703 |
701 // TODO(nona): Support item.children. | 704 // TODO(nona): Support item.children. |
702 } | 705 } |
703 | 706 |
704 } // namespace chromeos | 707 } // namespace chromeos |
OLD | NEW |