| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_manager_impl.h" | 5 #include "chrome/browser/chromeos/input_method/input_method_manager_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> // std::find | 7 #include <algorithm> // std::find |
| 8 | 8 |
| 9 #include "ash/ime/input_method_menu_item.h" | 9 #include "ash/ime/input_method_menu_item.h" |
| 10 #include "ash/ime/input_method_menu_manager.h" | 10 #include "ash/ime/input_method_menu_manager.h" |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 bool InputMethodManagerImpl::ChangeInputMethodInternal( | 310 bool InputMethodManagerImpl::ChangeInputMethodInternal( |
| 311 const std::string& input_method_id, | 311 const std::string& input_method_id, |
| 312 bool show_message) { | 312 bool show_message) { |
| 313 if (state_ == STATE_TERMINATING) | 313 if (state_ == STATE_TERMINATING) |
| 314 return false; | 314 return false; |
| 315 | 315 |
| 316 std::string input_method_id_to_switch = input_method_id; | 316 std::string input_method_id_to_switch = input_method_id; |
| 317 | 317 |
| 318 // Sanity check. | 318 // Sanity check. |
| 319 if (!InputMethodIsActivated(input_method_id)) { | 319 if (!InputMethodIsActivated(input_method_id)) { |
| 320 // For 3rd party IME, when the user just logged in, SetEnabledExtensionImes |
| 321 // happens after activating the 3rd party IME. |
| 322 // So here to record the 3rd party IME to be activated, and activate it |
| 323 // when SetEnabledExtensionImes happens later. |
| 324 if (extension_ime_util::IsExtensionIME(input_method_id)) |
| 325 pending_input_method_id_ = input_method_id; |
| 326 |
| 320 scoped_ptr<InputMethodDescriptors> input_methods(GetActiveInputMethods()); | 327 scoped_ptr<InputMethodDescriptors> input_methods(GetActiveInputMethods()); |
| 321 DCHECK(!input_methods->empty()); | 328 DCHECK(!input_methods->empty()); |
| 322 input_method_id_to_switch = input_methods->at(0).id(); | 329 input_method_id_to_switch = input_methods->at(0).id(); |
| 323 if (!input_method_id.empty()) { | 330 if (!input_method_id.empty()) { |
| 324 DVLOG(1) << "Can't change the current input method to " | 331 DVLOG(1) << "Can't change the current input method to " |
| 325 << input_method_id << " since the engine is not enabled. " | 332 << input_method_id << " since the engine is not enabled. " |
| 326 << "Switch to " << input_method_id_to_switch << " instead."; | 333 << "Switch to " << input_method_id_to_switch << " instead."; |
| 327 } | 334 } |
| 328 } | 335 } |
| 329 | 336 |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 519 } | 526 } |
| 520 | 527 |
| 521 void InputMethodManagerImpl::SetEnabledExtensionImes( | 528 void InputMethodManagerImpl::SetEnabledExtensionImes( |
| 522 std::vector<std::string>* ids) { | 529 std::vector<std::string>* ids) { |
| 523 enabled_extension_imes_.clear(); | 530 enabled_extension_imes_.clear(); |
| 524 enabled_extension_imes_.insert(enabled_extension_imes_.end(), | 531 enabled_extension_imes_.insert(enabled_extension_imes_.end(), |
| 525 ids->begin(), | 532 ids->begin(), |
| 526 ids->end()); | 533 ids->end()); |
| 527 | 534 |
| 528 bool active_imes_changed = false; | 535 bool active_imes_changed = false; |
| 536 bool switch_to_pending = false; |
| 529 | 537 |
| 530 for (std::map<std::string, InputMethodDescriptor>::iterator extra_iter = | 538 for (std::map<std::string, InputMethodDescriptor>::iterator extra_iter = |
| 531 extra_input_methods_.begin(); extra_iter != extra_input_methods_.end(); | 539 extra_input_methods_.begin(); extra_iter != extra_input_methods_.end(); |
| 532 ++extra_iter) { | 540 ++extra_iter) { |
| 533 if (extension_ime_util::IsComponentExtensionIME( | 541 if (extension_ime_util::IsComponentExtensionIME( |
| 534 extra_iter->first)) | 542 extra_iter->first)) |
| 535 continue; // Do not filter component extension. | 543 continue; // Do not filter component extension. |
| 544 |
| 545 if (pending_input_method_id_ == extra_iter->first) |
| 546 switch_to_pending = true; |
| 547 |
| 536 std::vector<std::string>::iterator active_iter = std::find( | 548 std::vector<std::string>::iterator active_iter = std::find( |
| 537 active_input_method_ids_.begin(), active_input_method_ids_.end(), | 549 active_input_method_ids_.begin(), active_input_method_ids_.end(), |
| 538 extra_iter->first); | 550 extra_iter->first); |
| 539 | 551 |
| 540 bool active = active_iter != active_input_method_ids_.end(); | 552 bool active = active_iter != active_input_method_ids_.end(); |
| 541 bool enabled = Contains(enabled_extension_imes_, extra_iter->first); | 553 bool enabled = Contains(enabled_extension_imes_, extra_iter->first); |
| 542 | 554 |
| 543 if (active && !enabled) | 555 if (active && !enabled) |
| 544 active_input_method_ids_.erase(active_iter); | 556 active_input_method_ids_.erase(active_iter); |
| 545 | 557 |
| 546 if (!active && enabled) | 558 if (!active && enabled) |
| 547 active_input_method_ids_.push_back(extra_iter->first); | 559 active_input_method_ids_.push_back(extra_iter->first); |
| 548 | 560 |
| 549 if (active == !enabled) | 561 if (active == !enabled) |
| 550 active_imes_changed = true; | 562 active_imes_changed = true; |
| 551 } | 563 } |
| 552 | 564 |
| 553 if (active_imes_changed) { | 565 if (active_imes_changed) { |
| 554 MaybeInitializeCandidateWindowController(); | 566 MaybeInitializeCandidateWindowController(); |
| 555 | 567 |
| 556 // If |current_input_method| is no longer in |active_input_method_ids_|, | 568 if (switch_to_pending) { |
| 557 // switch to the first one in |active_input_method_ids_|. | 569 ChangeInputMethod(pending_input_method_id_); |
| 558 ChangeInputMethod(current_input_method_.id()); | 570 pending_input_method_id_.clear(); |
| 571 } else { |
| 572 // If |current_input_method| is no longer in |active_input_method_ids_|, |
| 573 // switch to the first one in |active_input_method_ids_|. |
| 574 ChangeInputMethod(current_input_method_.id()); |
| 575 } |
| 559 } | 576 } |
| 560 } | 577 } |
| 561 | 578 |
| 562 void InputMethodManagerImpl::SetInputMethodLoginDefaultFromVPD( | 579 void InputMethodManagerImpl::SetInputMethodLoginDefaultFromVPD( |
| 563 const std::string& locale, const std::string& oem_layout) { | 580 const std::string& locale, const std::string& oem_layout) { |
| 564 std::string layout; | 581 std::string layout; |
| 565 if (!oem_layout.empty()) { | 582 if (!oem_layout.empty()) { |
| 566 // If the OEM layout information is provided, use it. | 583 // If the OEM layout information is provided, use it. |
| 567 layout = oem_layout; | 584 layout = oem_layout; |
| 568 } else { | 585 } else { |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 874 if (candidate_window_controller_.get()) | 891 if (candidate_window_controller_.get()) |
| 875 return; | 892 return; |
| 876 | 893 |
| 877 candidate_window_controller_.reset( | 894 candidate_window_controller_.reset( |
| 878 CandidateWindowController::CreateCandidateWindowController()); | 895 CandidateWindowController::CreateCandidateWindowController()); |
| 879 candidate_window_controller_->AddObserver(this); | 896 candidate_window_controller_->AddObserver(this); |
| 880 } | 897 } |
| 881 | 898 |
| 882 } // namespace input_method | 899 } // namespace input_method |
| 883 } // namespace chromeos | 900 } // namespace chromeos |
| OLD | NEW |