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 #define XK_MISCELLANY | 7 #define XK_MISCELLANY |
8 #include <X11/keysymdef.h> | 8 #include <X11/keysymdef.h> |
9 #include <X11/X.h> | 9 #include <X11/X.h> |
10 #include <X11/Xlib.h> | 10 #include <X11/Xlib.h> |
11 #include <X11/Xutil.h> | 11 #include <X11/Xutil.h> |
12 #undef FocusIn | 12 #undef FocusIn |
13 #undef FocusOut | 13 #undef FocusOut |
14 #undef RootWindow | 14 #undef RootWindow |
15 #include <map> | 15 #include <map> |
16 | 16 |
| 17 #include "ash/ime/input_method_menu_item.h" |
| 18 #include "ash/ime/input_method_menu_manager.h" |
17 #include "ash/shell.h" | 19 #include "ash/shell.h" |
18 #include "base/logging.h" | 20 #include "base/logging.h" |
19 #include "base/memory/scoped_ptr.h" | 21 #include "base/memory/scoped_ptr.h" |
20 #include "base/strings/string_number_conversions.h" | 22 #include "base/strings/string_number_conversions.h" |
21 #include "base/strings/string_util.h" | 23 #include "base/strings/string_util.h" |
22 #include "base/strings/utf_string_conversions.h" | 24 #include "base/strings/utf_string_conversions.h" |
23 #include "chromeos/ime/component_extension_ime_manager.h" | 25 #include "chromeos/ime/component_extension_ime_manager.h" |
24 #include "chromeos/ime/composition_text.h" | 26 #include "chromeos/ime/composition_text.h" |
25 #include "chromeos/ime/extension_ime_util.h" | 27 #include "chromeos/ime/extension_ime_util.h" |
26 #include "chromeos/ime/ibus_keymap.h" | 28 #include "chromeos/ime/ibus_keymap.h" |
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 | 366 |
365 bool InputMethodEngine::SetMenuItems(const std::vector<MenuItem>& items) { | 367 bool InputMethodEngine::SetMenuItems(const std::vector<MenuItem>& items) { |
366 return UpdateMenuItems(items); | 368 return UpdateMenuItems(items); |
367 } | 369 } |
368 | 370 |
369 bool InputMethodEngine::UpdateMenuItems( | 371 bool InputMethodEngine::UpdateMenuItems( |
370 const std::vector<MenuItem>& items) { | 372 const std::vector<MenuItem>& items) { |
371 if (!active_) | 373 if (!active_) |
372 return false; | 374 return false; |
373 | 375 |
374 input_method::InputMethodPropertyList property_list; | 376 ash::ime::InputMethodMenuItemList menu_item_list; |
375 for (std::vector<MenuItem>::const_iterator item = items.begin(); | 377 for (std::vector<MenuItem>::const_iterator item = items.begin(); |
376 item != items.end(); ++item) { | 378 item != items.end(); ++item) { |
377 input_method::InputMethodProperty property; | 379 ash::ime::InputMethodMenuItem property; |
378 MenuItemToProperty(*item, &property); | 380 MenuItemToProperty(*item, &property); |
379 property_list.push_back(property); | 381 menu_item_list.push_back(property); |
380 } | 382 } |
381 | 383 |
382 input_method::InputMethodManager* manager = | 384 ash::ime::InputMethodMenuManager::Get()->SetCurrentInputMethodMenuItemList( |
383 input_method::InputMethodManager::Get(); | 385 menu_item_list); |
384 if (manager) | |
385 manager->SetCurrentInputMethodProperties(property_list); | |
386 | |
387 return true; | 386 return true; |
388 } | 387 } |
389 | 388 |
390 bool InputMethodEngine::IsActive() const { | 389 bool InputMethodEngine::IsActive() const { |
391 return active_; | 390 return active_; |
392 } | 391 } |
393 | 392 |
394 void InputMethodEngine::KeyEventDone(input_method::KeyEventHandle* key_data, | 393 void InputMethodEngine::KeyEventDone(input_method::KeyEventHandle* key_data, |
395 bool handled) { | 394 bool handled) { |
396 KeyEventDoneCallback* callback = | 395 KeyEventDoneCallback* callback = |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
576 | 575 |
577 void InputMethodEngine::SetSurroundingText(const std::string& text, | 576 void InputMethodEngine::SetSurroundingText(const std::string& text, |
578 uint32 cursor_pos, | 577 uint32 cursor_pos, |
579 uint32 anchor_pos) { | 578 uint32 anchor_pos) { |
580 observer_->OnSurroundingTextChanged(engine_id_, | 579 observer_->OnSurroundingTextChanged(engine_id_, |
581 text, | 580 text, |
582 static_cast<int>(cursor_pos), | 581 static_cast<int>(cursor_pos), |
583 static_cast<int>(anchor_pos)); | 582 static_cast<int>(anchor_pos)); |
584 } | 583 } |
585 | 584 |
| 585 // TODO(uekawa): rename this method to a more reasonable name. |
586 void InputMethodEngine::MenuItemToProperty( | 586 void InputMethodEngine::MenuItemToProperty( |
587 const MenuItem& item, | 587 const MenuItem& item, |
588 input_method::InputMethodProperty* property) { | 588 ash::ime::InputMethodMenuItem* property) { |
589 property->key = item.id; | 589 property->key = item.id; |
590 | 590 |
591 if (item.modified & MENU_ITEM_MODIFIED_LABEL) { | 591 if (item.modified & MENU_ITEM_MODIFIED_LABEL) { |
592 property->label = item.label; | 592 property->label = item.label; |
593 } | 593 } |
594 if (item.modified & MENU_ITEM_MODIFIED_VISIBLE) { | 594 if (item.modified & MENU_ITEM_MODIFIED_VISIBLE) { |
595 // TODO(nona): Implement it. | 595 // TODO(nona): Implement it. |
596 } | 596 } |
597 if (item.modified & MENU_ITEM_MODIFIED_CHECKED) { | 597 if (item.modified & MENU_ITEM_MODIFIED_CHECKED) { |
598 property->is_selection_item_checked = item.checked; | 598 property->is_selection_item_checked = item.checked; |
(...skipping 19 matching lines...) Expand all Loading... |
618 // TODO(nona): Implement it. | 618 // TODO(nona): Implement it. |
619 break; | 619 break; |
620 } | 620 } |
621 } | 621 } |
622 } | 622 } |
623 | 623 |
624 // TODO(nona): Support item.children. | 624 // TODO(nona): Support item.children. |
625 } | 625 } |
626 | 626 |
627 } // namespace chromeos | 627 } // namespace chromeos |
OLD | NEW |