Chromium Code Reviews| 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 837 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 848 } | 848 } |
| 849 | 849 |
| 850 InputMethodManagerImpl::InputMethodManagerImpl( | 850 InputMethodManagerImpl::InputMethodManagerImpl( |
| 851 std::unique_ptr<InputMethodDelegate> delegate, | 851 std::unique_ptr<InputMethodDelegate> delegate, |
| 852 bool enable_extension_loading) | 852 bool enable_extension_loading) |
| 853 : delegate_(std::move(delegate)), | 853 : delegate_(std::move(delegate)), |
| 854 ui_session_(STATE_LOGIN_SCREEN), | 854 ui_session_(STATE_LOGIN_SCREEN), |
| 855 state_(NULL), | 855 state_(NULL), |
| 856 util_(delegate_.get()), | 856 util_(delegate_.get()), |
| 857 component_extension_ime_manager_(new ComponentExtensionIMEManager()), | 857 component_extension_ime_manager_(new ComponentExtensionIMEManager()), |
| 858 enable_extension_loading_(enable_extension_loading), | 858 enable_extension_loading_(enable_extension_loading) { |
| 859 is_ime_menu_activated_(false) { | |
| 860 // TODO(mohsen): Revisit using FakeImeKeyboard with mash when InputController | 859 // TODO(mohsen): Revisit using FakeImeKeyboard with mash when InputController |
| 861 // work is ready. http://crbug.com/601981 | 860 // work is ready. http://crbug.com/601981 |
| 862 if (base::SysInfo::IsRunningOnChromeOS() && !chrome::IsRunningInMash()) | 861 if (base::SysInfo::IsRunningOnChromeOS() && !chrome::IsRunningInMash()) |
| 863 keyboard_.reset(ImeKeyboard::Create()); | 862 keyboard_.reset(ImeKeyboard::Create()); |
| 864 else | 863 else |
| 865 keyboard_.reset(new FakeImeKeyboard()); | 864 keyboard_.reset(new FakeImeKeyboard()); |
| 866 | 865 |
| 867 // Initializes the system IME list. | 866 // Initializes the system IME list. |
| 868 std::unique_ptr<ComponentExtensionIMEManagerDelegate> comp_delegate( | 867 std::unique_ptr<ComponentExtensionIMEManagerDelegate> comp_delegate( |
| 869 new ComponentExtensionIMEManagerImpl()); | 868 new ComponentExtensionIMEManagerImpl()); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 920 } | 919 } |
| 921 | 920 |
| 922 InputMethodManager::UISessionState InputMethodManagerImpl::GetUISessionState() { | 921 InputMethodManager::UISessionState InputMethodManagerImpl::GetUISessionState() { |
| 923 return ui_session_; | 922 return ui_session_; |
| 924 } | 923 } |
| 925 | 924 |
| 926 void InputMethodManagerImpl::SetUISessionState(UISessionState new_ui_session) { | 925 void InputMethodManagerImpl::SetUISessionState(UISessionState new_ui_session) { |
| 927 ui_session_ = new_ui_session; | 926 ui_session_ = new_ui_session; |
| 928 if (ui_session_ == STATE_TERMINATING && candidate_window_controller_.get()) | 927 if (ui_session_ == STATE_TERMINATING && candidate_window_controller_.get()) |
| 929 candidate_window_controller_.reset(); | 928 candidate_window_controller_.reset(); |
| 930 | |
| 931 // The expanded IME menu is only supportive with 'normal' screen type. It | |
| 932 // should be deactivated when the screen type is not 'normal', and be | |
| 933 // re-activated when changing back. | |
| 934 if (is_ime_menu_activated_ && ui_session_ != STATE_TERMINATING) { | |
| 935 FOR_EACH_OBSERVER( | |
| 936 InputMethodManager::ImeMenuObserver, ime_menu_observers_, | |
| 937 ImeMenuActivationChanged(ui_session_ == STATE_BROWSER_SCREEN)); | |
| 938 } | |
| 939 } | 929 } |
| 940 | 930 |
| 941 void InputMethodManagerImpl::OnUserAddingStarted() { | 931 void InputMethodManagerImpl::OnUserAddingStarted() { |
| 942 if (ui_session_ == STATE_BROWSER_SCREEN) | 932 if (ui_session_ == STATE_BROWSER_SCREEN) |
| 943 SetUISessionState(STATE_SECONDARY_LOGIN_SCREEN); | 933 SetUISessionState(STATE_SECONDARY_LOGIN_SCREEN); |
| 944 } | 934 } |
| 945 | 935 |
| 946 void InputMethodManagerImpl::OnUserAddingFinished() { | 936 void InputMethodManagerImpl::OnUserAddingFinished() { |
| 947 if (ui_session_ == STATE_SECONDARY_LOGIN_SCREEN) | 937 if (ui_session_ == STATE_SECONDARY_LOGIN_SCREEN) |
| 948 SetUISessionState(STATE_BROWSER_SCREEN); | 938 SetUISessionState(STATE_BROWSER_SCREEN); |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1179 | 1169 |
| 1180 void InputMethodManagerImpl::CandidateWindowClosed() { | 1170 void InputMethodManagerImpl::CandidateWindowClosed() { |
| 1181 FOR_EACH_OBSERVER(InputMethodManager::CandidateWindowObserver, | 1171 FOR_EACH_OBSERVER(InputMethodManager::CandidateWindowObserver, |
| 1182 candidate_window_observers_, | 1172 candidate_window_observers_, |
| 1183 CandidateWindowClosed(this)); | 1173 CandidateWindowClosed(this)); |
| 1184 } | 1174 } |
| 1185 | 1175 |
| 1186 void InputMethodManagerImpl::ImeMenuActivationChanged(bool is_active) { | 1176 void InputMethodManagerImpl::ImeMenuActivationChanged(bool is_active) { |
| 1187 // Saves the state that whether the expanded IME menu has been activated by | 1177 // Saves the state that whether the expanded IME menu has been activated by |
| 1188 // users. This method is only called when the preference is changing. | 1178 // users. This method is only called when the preference is changing. |
| 1189 is_ime_menu_activated_ = is_active; | 1179 menu_map_[state_->profile] = is_active; |
| 1190 FOR_EACH_OBSERVER(InputMethodManager::ImeMenuObserver, ime_menu_observers_, | 1180 FOR_EACH_OBSERVER(InputMethodManager::ImeMenuObserver, ime_menu_observers_, |
| 1191 ImeMenuActivationChanged(is_active)); | 1181 ImeMenuActivationChanged(is_active)); |
| 1192 UMA_HISTOGRAM_BOOLEAN("InputMethod.ImeMenu.ActivationChanged", | 1182 UMA_HISTOGRAM_BOOLEAN("InputMethod.ImeMenu.ActivationChanged", is_active); |
| 1193 is_ime_menu_activated_); | |
| 1194 } | 1183 } |
| 1195 | 1184 |
| 1196 void InputMethodManagerImpl::NotifyImeMenuListChanged() { | 1185 void InputMethodManagerImpl::NotifyImeMenuListChanged() { |
| 1197 FOR_EACH_OBSERVER(InputMethodManager::ImeMenuObserver, ime_menu_observers_, | 1186 FOR_EACH_OBSERVER(InputMethodManager::ImeMenuObserver, ime_menu_observers_, |
| 1198 ImeMenuListChanged()); | 1187 ImeMenuListChanged()); |
| 1199 } | 1188 } |
| 1200 | 1189 |
| 1201 void InputMethodManagerImpl::MaybeInitializeCandidateWindowController() { | 1190 void InputMethodManagerImpl::MaybeInitializeCandidateWindowController() { |
| 1202 if (candidate_window_controller_.get()) | 1191 if (candidate_window_controller_.get()) |
| 1203 return; | 1192 return; |
| 1204 | 1193 |
| 1205 candidate_window_controller_.reset( | 1194 candidate_window_controller_.reset( |
| 1206 CandidateWindowController::CreateCandidateWindowController()); | 1195 CandidateWindowController::CreateCandidateWindowController()); |
| 1207 candidate_window_controller_->AddObserver(this); | 1196 candidate_window_controller_->AddObserver(this); |
| 1208 } | 1197 } |
| 1209 | 1198 |
| 1210 void InputMethodManagerImpl::NotifyImeMenuItemsChanged( | 1199 void InputMethodManagerImpl::NotifyImeMenuItemsChanged( |
| 1211 const std::string& engine_id, | 1200 const std::string& engine_id, |
| 1212 const std::vector<InputMethodManager::MenuItem>& items) { | 1201 const std::vector<InputMethodManager::MenuItem>& items) { |
| 1213 FOR_EACH_OBSERVER(InputMethodManager::ImeMenuObserver, ime_menu_observers_, | 1202 FOR_EACH_OBSERVER(InputMethodManager::ImeMenuObserver, ime_menu_observers_, |
| 1214 ImeMenuItemsChanged(engine_id, items)); | 1203 ImeMenuItemsChanged(engine_id, items)); |
| 1215 } | 1204 } |
| 1216 | 1205 |
| 1206 bool InputMethodManagerImpl::GetImeMenuActivation(Profile* profile) { | |
| 1207 return menu_map_.find(profile) != menu_map_.end() && menu_map_[profile]; | |
|
stevenjb
2016/08/26 17:15:02
Instead of doing two lookups, use an iterator, e.g
Azure Wei
2016/08/26 21:59:59
Done.
| |
| 1208 } | |
| 1209 | |
| 1217 } // namespace input_method | 1210 } // namespace input_method |
| 1218 } // namespace chromeos | 1211 } // namespace chromeos |
| OLD | NEW |