| 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 <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <algorithm> // std::find | 9 #include <algorithm> // std::find |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 1025 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1036 } | 1036 } |
| 1037 | 1037 |
| 1038 // Change the keyboard layout to a preferred layout for the input method. | 1038 // Change the keyboard layout to a preferred layout for the input method. |
| 1039 if (!keyboard_->SetCurrentKeyboardLayoutByName( | 1039 if (!keyboard_->SetCurrentKeyboardLayoutByName( |
| 1040 descriptor.GetPreferredKeyboardLayout())) { | 1040 descriptor.GetPreferredKeyboardLayout())) { |
| 1041 LOG(ERROR) << "Failed to change keyboard layout to " | 1041 LOG(ERROR) << "Failed to change keyboard layout to " |
| 1042 << descriptor.GetPreferredKeyboardLayout(); | 1042 << descriptor.GetPreferredKeyboardLayout(); |
| 1043 } | 1043 } |
| 1044 | 1044 |
| 1045 // Update input method indicators (e.g. "US", "DV") in Chrome windows. | 1045 // Update input method indicators (e.g. "US", "DV") in Chrome windows. |
| 1046 FOR_EACH_OBSERVER(InputMethodManager::Observer, observers_, | 1046 for (auto& observer : observers_) |
| 1047 InputMethodChanged(this, profile, show_message)); | 1047 observer.InputMethodChanged(this, profile, show_message); |
| 1048 // Update the current input method in IME menu. | 1048 // Update the current input method in IME menu. |
| 1049 NotifyImeMenuListChanged(); | 1049 NotifyImeMenuListChanged(); |
| 1050 } | 1050 } |
| 1051 | 1051 |
| 1052 void InputMethodManagerImpl::LoadNecessaryComponentExtensions( | 1052 void InputMethodManagerImpl::LoadNecessaryComponentExtensions( |
| 1053 InputMethodManagerImpl::StateImpl* state) { | 1053 InputMethodManagerImpl::StateImpl* state) { |
| 1054 // Load component extensions but also update |active_input_method_ids| as | 1054 // Load component extensions but also update |active_input_method_ids| as |
| 1055 // some component extension IMEs may have been removed from the Chrome OS | 1055 // some component extension IMEs may have been removed from the Chrome OS |
| 1056 // image. If specified component extension IME no longer exists, falling back | 1056 // image. If specified component extension IME no longer exists, falling back |
| 1057 // to an existing IME. | 1057 // to an existing IME. |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1159 } | 1159 } |
| 1160 | 1160 |
| 1161 void InputMethodManagerImpl::CandidateClicked(int index) { | 1161 void InputMethodManagerImpl::CandidateClicked(int index) { |
| 1162 ui::IMEEngineHandlerInterface* engine = | 1162 ui::IMEEngineHandlerInterface* engine = |
| 1163 ui::IMEBridge::Get()->GetCurrentEngineHandler(); | 1163 ui::IMEBridge::Get()->GetCurrentEngineHandler(); |
| 1164 if (engine) | 1164 if (engine) |
| 1165 engine->CandidateClicked(index); | 1165 engine->CandidateClicked(index); |
| 1166 } | 1166 } |
| 1167 | 1167 |
| 1168 void InputMethodManagerImpl::CandidateWindowOpened() { | 1168 void InputMethodManagerImpl::CandidateWindowOpened() { |
| 1169 FOR_EACH_OBSERVER(InputMethodManager::CandidateWindowObserver, | 1169 for (auto& observer : candidate_window_observers_) |
| 1170 candidate_window_observers_, | 1170 observer.CandidateWindowOpened(this); |
| 1171 CandidateWindowOpened(this)); | |
| 1172 } | 1171 } |
| 1173 | 1172 |
| 1174 void InputMethodManagerImpl::CandidateWindowClosed() { | 1173 void InputMethodManagerImpl::CandidateWindowClosed() { |
| 1175 FOR_EACH_OBSERVER(InputMethodManager::CandidateWindowObserver, | 1174 for (auto& observer : candidate_window_observers_) |
| 1176 candidate_window_observers_, | 1175 observer.CandidateWindowClosed(this); |
| 1177 CandidateWindowClosed(this)); | |
| 1178 } | 1176 } |
| 1179 | 1177 |
| 1180 void InputMethodManagerImpl::ImeMenuActivationChanged(bool is_active) { | 1178 void InputMethodManagerImpl::ImeMenuActivationChanged(bool is_active) { |
| 1181 // Saves the state that whether the expanded IME menu has been activated by | 1179 // Saves the state that whether the expanded IME menu has been activated by |
| 1182 // users. This method is only called when the preference is changing. | 1180 // users. This method is only called when the preference is changing. |
| 1183 state_->menu_activated = is_active; | 1181 state_->menu_activated = is_active; |
| 1184 MaybeNotifyImeMenuActivationChanged(); | 1182 MaybeNotifyImeMenuActivationChanged(); |
| 1185 } | 1183 } |
| 1186 | 1184 |
| 1187 void InputMethodManagerImpl::NotifyImeMenuListChanged() { | 1185 void InputMethodManagerImpl::NotifyImeMenuListChanged() { |
| 1188 FOR_EACH_OBSERVER(InputMethodManager::ImeMenuObserver, ime_menu_observers_, | 1186 for (auto& observer : ime_menu_observers_) |
| 1189 ImeMenuListChanged()); | 1187 observer.ImeMenuListChanged(); |
| 1190 } | 1188 } |
| 1191 | 1189 |
| 1192 void InputMethodManagerImpl::MaybeInitializeCandidateWindowController() { | 1190 void InputMethodManagerImpl::MaybeInitializeCandidateWindowController() { |
| 1193 if (candidate_window_controller_.get()) | 1191 if (candidate_window_controller_.get()) |
| 1194 return; | 1192 return; |
| 1195 | 1193 |
| 1196 candidate_window_controller_.reset( | 1194 candidate_window_controller_.reset( |
| 1197 CandidateWindowController::CreateCandidateWindowController()); | 1195 CandidateWindowController::CreateCandidateWindowController()); |
| 1198 candidate_window_controller_->AddObserver(this); | 1196 candidate_window_controller_->AddObserver(this); |
| 1199 } | 1197 } |
| 1200 | 1198 |
| 1201 void InputMethodManagerImpl::NotifyImeMenuItemsChanged( | 1199 void InputMethodManagerImpl::NotifyImeMenuItemsChanged( |
| 1202 const std::string& engine_id, | 1200 const std::string& engine_id, |
| 1203 const std::vector<InputMethodManager::MenuItem>& items) { | 1201 const std::vector<InputMethodManager::MenuItem>& items) { |
| 1204 FOR_EACH_OBSERVER(InputMethodManager::ImeMenuObserver, ime_menu_observers_, | 1202 for (auto& observer : ime_menu_observers_) |
| 1205 ImeMenuItemsChanged(engine_id, items)); | 1203 observer.ImeMenuItemsChanged(engine_id, items); |
| 1206 } | 1204 } |
| 1207 | 1205 |
| 1208 void InputMethodManagerImpl::MaybeNotifyImeMenuActivationChanged() { | 1206 void InputMethodManagerImpl::MaybeNotifyImeMenuActivationChanged() { |
| 1209 if (is_ime_menu_activated_ == state_->menu_activated) | 1207 if (is_ime_menu_activated_ == state_->menu_activated) |
| 1210 return; | 1208 return; |
| 1211 | 1209 |
| 1212 is_ime_menu_activated_ = state_->menu_activated; | 1210 is_ime_menu_activated_ = state_->menu_activated; |
| 1213 FOR_EACH_OBSERVER(InputMethodManager::ImeMenuObserver, ime_menu_observers_, | 1211 for (auto& observer : ime_menu_observers_) |
| 1214 ImeMenuActivationChanged(is_ime_menu_activated_)); | 1212 observer.ImeMenuActivationChanged(is_ime_menu_activated_); |
| 1215 UMA_HISTOGRAM_BOOLEAN("InputMethod.ImeMenu.ActivationChanged", | 1213 UMA_HISTOGRAM_BOOLEAN("InputMethod.ImeMenu.ActivationChanged", |
| 1216 is_ime_menu_activated_); | 1214 is_ime_menu_activated_); |
| 1217 } | 1215 } |
| 1218 | 1216 |
| 1219 void InputMethodManagerImpl::OverrideKeyboardUrlRef(const std::string& keyset) { | 1217 void InputMethodManagerImpl::OverrideKeyboardUrlRef(const std::string& keyset) { |
| 1220 GURL url = keyboard::GetOverrideContentUrl(); | 1218 GURL url = keyboard::GetOverrideContentUrl(); |
| 1221 | 1219 |
| 1222 // If fails to find ref or tag "id" in the ref, it means the current IME is | 1220 // If fails to find ref or tag "id" in the ref, it means the current IME is |
| 1223 // not system IME, and we don't support show emoji, handwriting or voice | 1221 // not system IME, and we don't support show emoji, handwriting or voice |
| 1224 // input for such IME extension. | 1222 // input for such IME extension. |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1252 replacements.SetRefStr(overridden_ref); | 1250 replacements.SetRefStr(overridden_ref); |
| 1253 keyboard::SetOverrideContentUrl(url.ReplaceComponents(replacements)); | 1251 keyboard::SetOverrideContentUrl(url.ReplaceComponents(replacements)); |
| 1254 } | 1252 } |
| 1255 | 1253 |
| 1256 bool InputMethodManagerImpl::IsEmojiHandwritingVoiceOnImeMenuEnabled() { | 1254 bool InputMethodManagerImpl::IsEmojiHandwritingVoiceOnImeMenuEnabled() { |
| 1257 return base::FeatureList::IsEnabled(features::kEHVInputOnImeMenu); | 1255 return base::FeatureList::IsEnabled(features::kEHVInputOnImeMenu); |
| 1258 } | 1256 } |
| 1259 | 1257 |
| 1260 } // namespace input_method | 1258 } // namespace input_method |
| 1261 } // namespace chromeos | 1259 } // namespace chromeos |
| OLD | NEW |