| 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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 *first_char = ch; | 105 *first_char = ch; |
| 106 return category; | 106 return category; |
| 107 } | 107 } |
| 108 | 108 |
| 109 } // namespace | 109 } // namespace |
| 110 | 110 |
| 111 // ------------------------ InputMethodManagerImpl::StateImpl | 111 // ------------------------ InputMethodManagerImpl::StateImpl |
| 112 | 112 |
| 113 InputMethodManagerImpl::StateImpl::StateImpl(InputMethodManagerImpl* manager, | 113 InputMethodManagerImpl::StateImpl::StateImpl(InputMethodManagerImpl* manager, |
| 114 Profile* profile) | 114 Profile* profile) |
| 115 : profile(profile), manager_(manager) { | 115 : profile(profile), manager_(manager), menu_activated(false) {} |
| 116 } | |
| 117 | 116 |
| 118 InputMethodManagerImpl::StateImpl::~StateImpl() { | 117 InputMethodManagerImpl::StateImpl::~StateImpl() { |
| 119 } | 118 } |
| 120 | 119 |
| 121 void InputMethodManagerImpl::StateImpl::InitFrom(const StateImpl& other) { | 120 void InputMethodManagerImpl::StateImpl::InitFrom(const StateImpl& other) { |
| 122 previous_input_method = other.previous_input_method; | 121 previous_input_method = other.previous_input_method; |
| 123 current_input_method = other.current_input_method; | 122 current_input_method = other.current_input_method; |
| 124 | 123 |
| 125 active_input_method_ids = other.active_input_method_ids; | 124 active_input_method_ids = other.active_input_method_ids; |
| 126 | 125 |
| 127 pending_input_method_id = other.pending_input_method_id; | 126 pending_input_method_id = other.pending_input_method_id; |
| 128 | 127 |
| 129 enabled_extension_imes = other.enabled_extension_imes; | 128 enabled_extension_imes = other.enabled_extension_imes; |
| 130 extra_input_methods = other.extra_input_methods; | 129 extra_input_methods = other.extra_input_methods; |
| 130 menu_activated = other.menu_activated; |
| 131 } | 131 } |
| 132 | 132 |
| 133 bool InputMethodManagerImpl::StateImpl::IsActive() const { | 133 bool InputMethodManagerImpl::StateImpl::IsActive() const { |
| 134 return manager_->state_.get() == this; | 134 return manager_->state_.get() == this; |
| 135 } | 135 } |
| 136 | 136 |
| 137 std::string InputMethodManagerImpl::StateImpl::Dump() const { | 137 std::string InputMethodManagerImpl::StateImpl::Dump() const { |
| 138 std::ostringstream os; | 138 std::ostringstream os; |
| 139 | 139 |
| 140 os << "################# " | 140 os << "################# " |
| (...skipping 779 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 920 } | 920 } |
| 921 | 921 |
| 922 InputMethodManager::UISessionState InputMethodManagerImpl::GetUISessionState() { | 922 InputMethodManager::UISessionState InputMethodManagerImpl::GetUISessionState() { |
| 923 return ui_session_; | 923 return ui_session_; |
| 924 } | 924 } |
| 925 | 925 |
| 926 void InputMethodManagerImpl::SetUISessionState(UISessionState new_ui_session) { | 926 void InputMethodManagerImpl::SetUISessionState(UISessionState new_ui_session) { |
| 927 ui_session_ = new_ui_session; | 927 ui_session_ = new_ui_session; |
| 928 if (ui_session_ == STATE_TERMINATING && candidate_window_controller_.get()) | 928 if (ui_session_ == STATE_TERMINATING && candidate_window_controller_.get()) |
| 929 candidate_window_controller_.reset(); | 929 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 } | 930 } |
| 940 | 931 |
| 941 void InputMethodManagerImpl::OnUserAddingStarted() { | 932 void InputMethodManagerImpl::OnUserAddingStarted() { |
| 942 if (ui_session_ == STATE_BROWSER_SCREEN) | 933 if (ui_session_ == STATE_BROWSER_SCREEN) |
| 943 SetUISessionState(STATE_SECONDARY_LOGIN_SCREEN); | 934 SetUISessionState(STATE_SECONDARY_LOGIN_SCREEN); |
| 944 } | 935 } |
| 945 | 936 |
| 946 void InputMethodManagerImpl::OnUserAddingFinished() { | 937 void InputMethodManagerImpl::OnUserAddingFinished() { |
| 947 if (ui_session_ == STATE_SECONDARY_LOGIN_SCREEN) | 938 if (ui_session_ == STATE_SECONDARY_LOGIN_SCREEN) |
| 948 SetUISessionState(STATE_BROWSER_SCREEN); | 939 SetUISessionState(STATE_BROWSER_SCREEN); |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1179 | 1170 |
| 1180 void InputMethodManagerImpl::CandidateWindowClosed() { | 1171 void InputMethodManagerImpl::CandidateWindowClosed() { |
| 1181 FOR_EACH_OBSERVER(InputMethodManager::CandidateWindowObserver, | 1172 FOR_EACH_OBSERVER(InputMethodManager::CandidateWindowObserver, |
| 1182 candidate_window_observers_, | 1173 candidate_window_observers_, |
| 1183 CandidateWindowClosed(this)); | 1174 CandidateWindowClosed(this)); |
| 1184 } | 1175 } |
| 1185 | 1176 |
| 1186 void InputMethodManagerImpl::ImeMenuActivationChanged(bool is_active) { | 1177 void InputMethodManagerImpl::ImeMenuActivationChanged(bool is_active) { |
| 1187 // Saves the state that whether the expanded IME menu has been activated by | 1178 // 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. | 1179 // users. This method is only called when the preference is changing. |
| 1189 is_ime_menu_activated_ = is_active; | 1180 state_->menu_activated = is_active; |
| 1190 FOR_EACH_OBSERVER(InputMethodManager::ImeMenuObserver, ime_menu_observers_, | 1181 MaybeNotifyImeMenuActivationChanged(); |
| 1191 ImeMenuActivationChanged(is_active)); | |
| 1192 UMA_HISTOGRAM_BOOLEAN("InputMethod.ImeMenu.ActivationChanged", | |
| 1193 is_ime_menu_activated_); | |
| 1194 } | 1182 } |
| 1195 | 1183 |
| 1196 void InputMethodManagerImpl::NotifyImeMenuListChanged() { | 1184 void InputMethodManagerImpl::NotifyImeMenuListChanged() { |
| 1197 FOR_EACH_OBSERVER(InputMethodManager::ImeMenuObserver, ime_menu_observers_, | 1185 FOR_EACH_OBSERVER(InputMethodManager::ImeMenuObserver, ime_menu_observers_, |
| 1198 ImeMenuListChanged()); | 1186 ImeMenuListChanged()); |
| 1199 } | 1187 } |
| 1200 | 1188 |
| 1201 void InputMethodManagerImpl::MaybeInitializeCandidateWindowController() { | 1189 void InputMethodManagerImpl::MaybeInitializeCandidateWindowController() { |
| 1202 if (candidate_window_controller_.get()) | 1190 if (candidate_window_controller_.get()) |
| 1203 return; | 1191 return; |
| 1204 | 1192 |
| 1205 candidate_window_controller_.reset( | 1193 candidate_window_controller_.reset( |
| 1206 CandidateWindowController::CreateCandidateWindowController()); | 1194 CandidateWindowController::CreateCandidateWindowController()); |
| 1207 candidate_window_controller_->AddObserver(this); | 1195 candidate_window_controller_->AddObserver(this); |
| 1208 } | 1196 } |
| 1209 | 1197 |
| 1210 void InputMethodManagerImpl::NotifyImeMenuItemsChanged( | 1198 void InputMethodManagerImpl::NotifyImeMenuItemsChanged( |
| 1211 const std::string& engine_id, | 1199 const std::string& engine_id, |
| 1212 const std::vector<InputMethodManager::MenuItem>& items) { | 1200 const std::vector<InputMethodManager::MenuItem>& items) { |
| 1213 FOR_EACH_OBSERVER(InputMethodManager::ImeMenuObserver, ime_menu_observers_, | 1201 FOR_EACH_OBSERVER(InputMethodManager::ImeMenuObserver, ime_menu_observers_, |
| 1214 ImeMenuItemsChanged(engine_id, items)); | 1202 ImeMenuItemsChanged(engine_id, items)); |
| 1215 } | 1203 } |
| 1216 | 1204 |
| 1205 void InputMethodManagerImpl::MaybeNotifyImeMenuActivationChanged() { |
| 1206 if (is_ime_menu_activated_ == state_->menu_activated) |
| 1207 return; |
| 1208 |
| 1209 is_ime_menu_activated_ = state_->menu_activated; |
| 1210 FOR_EACH_OBSERVER(InputMethodManager::ImeMenuObserver, ime_menu_observers_, |
| 1211 ImeMenuActivationChanged(is_ime_menu_activated_)); |
| 1212 UMA_HISTOGRAM_BOOLEAN("InputMethod.ImeMenu.ActivationChanged", |
| 1213 is_ime_menu_activated_); |
| 1214 } |
| 1215 |
| 1217 } // namespace input_method | 1216 } // namespace input_method |
| 1218 } // namespace chromeos | 1217 } // namespace chromeos |
| OLD | NEW |