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 <sstream> | 9 #include <sstream> |
10 | 10 |
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
415 | 415 |
416 if (descriptor->id() != current_input_method.id()) { | 416 if (descriptor->id() != current_input_method.id()) { |
417 previous_input_method = current_input_method; | 417 previous_input_method = current_input_method; |
418 current_input_method = *descriptor; | 418 current_input_method = *descriptor; |
419 notify_menu = true; | 419 notify_menu = true; |
420 } | 420 } |
421 | 421 |
422 // Always change input method even if it is the same. | 422 // Always change input method even if it is the same. |
423 // TODO(komatsu): Revisit if this is neccessary. | 423 // TODO(komatsu): Revisit if this is neccessary. |
424 if (IsActive()) | 424 if (IsActive()) |
425 manager_->ChangeInputMethodInternal(*descriptor, show_message, notify_menu); | 425 manager_->ChangeInputMethodInternal(*descriptor, profile, show_message, |
Shu Chen
2015/05/06 02:25:38
Where is |profile| defined?
Shu Chen
2015/05/06 06:14:14
Please ignore this. I found it is this->profile.
| |
426 notify_menu); | |
426 manager_->RecordInputMethodUsage(current_input_method.id()); | 427 manager_->RecordInputMethodUsage(current_input_method.id()); |
427 } | 428 } |
428 | 429 |
429 bool InputMethodManagerImpl::StateImpl::MethodAwaitsExtensionLoad( | 430 bool InputMethodManagerImpl::StateImpl::MethodAwaitsExtensionLoad( |
430 const std::string& input_method_id) const { | 431 const std::string& input_method_id) const { |
431 // For 3rd party IME, when the user just logged in, SetEnabledExtensionImes | 432 // For 3rd party IME, when the user just logged in, SetEnabledExtensionImes |
432 // happens after activating the 3rd party IME. | 433 // happens after activating the 3rd party IME. |
433 // So here to record the 3rd party IME to be activated, and activate it | 434 // So here to record the 3rd party IME to be activated, and activate it |
434 // when SetEnabledExtensionImes happens later. | 435 // when SetEnabledExtensionImes happens later. |
435 return !InputMethodIsActivated(input_method_id) && | 436 return !InputMethodIsActivated(input_method_id) && |
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
818 | 819 |
819 if (state_.get() && state_->active_input_method_ids.size()) { | 820 if (state_.get() && state_->active_input_method_ids.size()) { |
820 // Initialize candidate window controller and widgets such as | 821 // Initialize candidate window controller and widgets such as |
821 // candidate window, infolist and mode indicator. Note, mode | 822 // candidate window, infolist and mode indicator. Note, mode |
822 // indicator is used by only keyboard layout input methods. | 823 // indicator is used by only keyboard layout input methods. |
823 MaybeInitializeCandidateWindowController(); | 824 MaybeInitializeCandidateWindowController(); |
824 | 825 |
825 // Always call ChangeInputMethodInternal even when the input method id | 826 // Always call ChangeInputMethodInternal even when the input method id |
826 // remain unchanged, because onActivate event needs to be sent to IME | 827 // remain unchanged, because onActivate event needs to be sent to IME |
827 // extension to update the current screen type correctly. | 828 // extension to update the current screen type correctly. |
828 ChangeInputMethodInternal(state_->current_input_method, | 829 ChangeInputMethodInternal(state_->current_input_method, state_->profile, |
829 false /* show_message */, | 830 false /* show_message */, true /* notify_menu */); |
830 true /* notify_menu */); | |
831 } | 831 } |
832 } | 832 } |
833 | 833 |
834 scoped_refptr<InputMethodManager::State> | 834 scoped_refptr<InputMethodManager::State> |
835 InputMethodManagerImpl::GetActiveIMEState() { | 835 InputMethodManagerImpl::GetActiveIMEState() { |
836 return scoped_refptr<InputMethodManager::State>(state_.get()); | 836 return scoped_refptr<InputMethodManager::State>(state_.get()); |
837 } | 837 } |
838 | 838 |
839 InputMethodManagerImpl::InputMethodManagerImpl( | 839 InputMethodManagerImpl::InputMethodManagerImpl( |
840 scoped_ptr<InputMethodDelegate> delegate, | 840 scoped_ptr<InputMethodDelegate> delegate, |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
968 util_.GetInputMethodDescriptorFromId(input_method_id_to_switch); | 968 util_.GetInputMethodDescriptorFromId(input_method_id_to_switch); |
969 if (!descriptor) | 969 if (!descriptor) |
970 LOG(ERROR) << "Unknown input method id: " << input_method_id_to_switch; | 970 LOG(ERROR) << "Unknown input method id: " << input_method_id_to_switch; |
971 } | 971 } |
972 DCHECK(descriptor); | 972 DCHECK(descriptor); |
973 return descriptor; | 973 return descriptor; |
974 } | 974 } |
975 | 975 |
976 void InputMethodManagerImpl::ChangeInputMethodInternal( | 976 void InputMethodManagerImpl::ChangeInputMethodInternal( |
977 const InputMethodDescriptor& descriptor, | 977 const InputMethodDescriptor& descriptor, |
978 Profile* profile, | |
978 bool show_message, | 979 bool show_message, |
979 bool notify_menu) { | 980 bool notify_menu) { |
980 // No need to switch input method when terminating. | 981 // No need to switch input method when terminating. |
981 if (ui_session_ == STATE_TERMINATING) | 982 if (ui_session_ == STATE_TERMINATING) |
982 return; | 983 return; |
983 | 984 |
984 if (candidate_window_controller_.get()) | 985 if (candidate_window_controller_.get()) |
985 candidate_window_controller_->Hide(); | 986 candidate_window_controller_->Hide(); |
986 | 987 |
987 if (notify_menu) { | 988 if (notify_menu) { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1026 } | 1027 } |
1027 | 1028 |
1028 // Change the keyboard layout to a preferred layout for the input method. | 1029 // Change the keyboard layout to a preferred layout for the input method. |
1029 if (!keyboard_->SetCurrentKeyboardLayoutByName( | 1030 if (!keyboard_->SetCurrentKeyboardLayoutByName( |
1030 descriptor.GetPreferredKeyboardLayout())) { | 1031 descriptor.GetPreferredKeyboardLayout())) { |
1031 LOG(ERROR) << "Failed to change keyboard layout to " | 1032 LOG(ERROR) << "Failed to change keyboard layout to " |
1032 << descriptor.GetPreferredKeyboardLayout(); | 1033 << descriptor.GetPreferredKeyboardLayout(); |
1033 } | 1034 } |
1034 | 1035 |
1035 // Update input method indicators (e.g. "US", "DV") in Chrome windows. | 1036 // Update input method indicators (e.g. "US", "DV") in Chrome windows. |
1036 FOR_EACH_OBSERVER(InputMethodManager::Observer, | 1037 FOR_EACH_OBSERVER(InputMethodManager::Observer, observers_, |
1037 observers_, | 1038 InputMethodChanged(this, profile, show_message)); |
1038 InputMethodChanged(this, show_message)); | |
1039 } | 1039 } |
1040 | 1040 |
1041 void InputMethodManagerImpl::LoadNecessaryComponentExtensions( | 1041 void InputMethodManagerImpl::LoadNecessaryComponentExtensions( |
1042 InputMethodManagerImpl::StateImpl* state) { | 1042 InputMethodManagerImpl::StateImpl* state) { |
1043 // Load component extensions but also update |active_input_method_ids| as | 1043 // Load component extensions but also update |active_input_method_ids| as |
1044 // some component extension IMEs may have been removed from the Chrome OS | 1044 // some component extension IMEs may have been removed from the Chrome OS |
1045 // image. If specified component extension IME no longer exists, falling back | 1045 // image. If specified component extension IME no longer exists, falling back |
1046 // to an existing IME. | 1046 // to an existing IME. |
1047 DCHECK(state); | 1047 DCHECK(state); |
1048 std::vector<std::string> unfiltered_input_method_ids; | 1048 std::vector<std::string> unfiltered_input_method_ids; |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1162 if (candidate_window_controller_.get()) | 1162 if (candidate_window_controller_.get()) |
1163 return; | 1163 return; |
1164 | 1164 |
1165 candidate_window_controller_.reset( | 1165 candidate_window_controller_.reset( |
1166 CandidateWindowController::CreateCandidateWindowController()); | 1166 CandidateWindowController::CreateCandidateWindowController()); |
1167 candidate_window_controller_->AddObserver(this); | 1167 candidate_window_controller_->AddObserver(this); |
1168 } | 1168 } |
1169 | 1169 |
1170 } // namespace input_method | 1170 } // namespace input_method |
1171 } // namespace chromeos | 1171 } // namespace chromeos |
OLD | NEW |