| 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/browser_state_monitor.h" | 5 #include "chrome/browser/chromeos/input_method/browser_state_monitor.h" |
| 6 | 6 |
| 7 #include "chrome/browser/browser_process.h" | 7 #include "chrome/browser/browser_process.h" |
| 8 #include "chrome/browser/chromeos/input_method/input_method_util.h" | 8 #include "chrome/browser/chromeos/input_method/input_method_util.h" |
| 9 #include "chrome/browser/chromeos/language_preferences.h" | 9 #include "chrome/browser/chromeos/language_preferences.h" |
| 10 #include "chrome/browser/prefs/pref_service.h" | 10 #include "chrome/browser/prefs/pref_service.h" |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 current_input_method_pref_.GetValue(); | 73 current_input_method_pref_.GetValue(); |
| 74 if (current_input_method_on_pref == current_input_method) | 74 if (current_input_method_on_pref == current_input_method) |
| 75 return; | 75 return; |
| 76 previous_input_method_pref_.SetValue(current_input_method_on_pref); | 76 previous_input_method_pref_.SetValue(current_input_method_on_pref); |
| 77 current_input_method_pref_.SetValue(current_input_method); | 77 current_input_method_pref_.SetValue(current_input_method); |
| 78 } | 78 } |
| 79 | 79 |
| 80 void BrowserStateMonitor::InputMethodChanged(InputMethodManager* manager) { | 80 void BrowserStateMonitor::InputMethodChanged(InputMethodManager* manager) { |
| 81 DCHECK_EQ(manager_, manager); | 81 DCHECK_EQ(manager_, manager); |
| 82 const std::string current_input_method = | 82 const std::string current_input_method = |
| 83 manager->GetCurrentInputMethod().id(); | 83 manager->GetCurrentInputMethod().id(); |
| 84 // Save the new input method id depending on the current browser state. | 84 // Save the new input method id depending on the current browser state. |
| 85 switch (state_) { | 85 switch (state_) { |
| 86 case InputMethodManager::STATE_LOGIN_SCREEN: | 86 case InputMethodManager::STATE_LOGIN_SCREEN: |
| 87 if (!InputMethodUtil::IsKeyboardLayout(current_input_method)) { | 87 if (!InputMethodUtil::IsKeyboardLayout(current_input_method)) { |
| 88 LOG(ERROR) << "Only keyboard layouts are supported: " | 88 DVLOG(1) << "Only keyboard layouts are supported: " |
| 89 << current_input_method; | 89 << current_input_method; |
| 90 return; | 90 return; |
| 91 } | 91 } |
| 92 UpdateLocalState(current_input_method); | 92 UpdateLocalState(current_input_method); |
| 93 return; | 93 return; |
| 94 case InputMethodManager::STATE_BROWSER_SCREEN: | 94 case InputMethodManager::STATE_BROWSER_SCREEN: |
| 95 UpdateUserPreferences(current_input_method); | 95 UpdateUserPreferences(current_input_method); |
| 96 return; | 96 return; |
| 97 case InputMethodManager::STATE_LOCK_SCREEN: | 97 case InputMethodManager::STATE_LOCK_SCREEN: |
| 98 // We use a special set of input methods on the screen. Do not update. | 98 // We use a special set of input methods on the screen. Do not update. |
| 99 return; | 99 return; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 114 case content::NOTIFICATION_APP_TERMINATING: { | 114 case content::NOTIFICATION_APP_TERMINATING: { |
| 115 SetState(InputMethodManager::STATE_TERMINATING); | 115 SetState(InputMethodManager::STATE_TERMINATING); |
| 116 break; | 116 break; |
| 117 } | 117 } |
| 118 case chrome::NOTIFICATION_LOGIN_USER_CHANGED: { | 118 case chrome::NOTIFICATION_LOGIN_USER_CHANGED: { |
| 119 // The user logged in, but the browser window for user session is not yet | 119 // The user logged in, but the browser window for user session is not yet |
| 120 // ready. An initial input method hasn't been set to the manager. | 120 // ready. An initial input method hasn't been set to the manager. |
| 121 // Note that the notification is also sent when Chrome crashes/restarts | 121 // Note that the notification is also sent when Chrome crashes/restarts |
| 122 // as of writing, but it might be changed in the future (therefore we need | 122 // as of writing, but it might be changed in the future (therefore we need |
| 123 // to listen to NOTIFICATION_SESSION_STARTED as well.) | 123 // to listen to NOTIFICATION_SESSION_STARTED as well.) |
| 124 VLOG(1) << "Received chrome::NOTIFICATION_LOGIN_USER_CHANGED"; | 124 DVLOG(1) << "Received chrome::NOTIFICATION_LOGIN_USER_CHANGED"; |
| 125 SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 125 SetState(InputMethodManager::STATE_BROWSER_SCREEN); |
| 126 break; | 126 break; |
| 127 } | 127 } |
| 128 case chrome::NOTIFICATION_SESSION_STARTED: { | 128 case chrome::NOTIFICATION_SESSION_STARTED: { |
| 129 // The user logged in, and the browser window for user session is ready. | 129 // The user logged in, and the browser window for user session is ready. |
| 130 // An initial input method has already been set. | 130 // An initial input method has already been set. |
| 131 // We should NOT call InitializePrefMembers() here since the notification | 131 // We should NOT call InitializePrefMembers() here since the notification |
| 132 // is sent in the PreProfileInit phase in case when Chrome crashes and | 132 // is sent in the PreProfileInit phase in case when Chrome crashes and |
| 133 // restarts. | 133 // restarts. |
| 134 VLOG(1) << "Received chrome::NOTIFICATION_SESSION_STARTED"; | 134 DVLOG(1) << "Received chrome::NOTIFICATION_SESSION_STARTED"; |
| 135 SetState(InputMethodManager::STATE_BROWSER_SCREEN); | 135 SetState(InputMethodManager::STATE_BROWSER_SCREEN); |
| 136 break; | 136 break; |
| 137 } | 137 } |
| 138 case chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED: { | 138 case chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED: { |
| 139 const bool is_screen_locked = *content::Details<bool>(details).ptr(); | 139 const bool is_screen_locked = *content::Details<bool>(details).ptr(); |
| 140 SetState(is_screen_locked ? InputMethodManager::STATE_LOCK_SCREEN : | 140 SetState(is_screen_locked ? InputMethodManager::STATE_LOCK_SCREEN : |
| 141 InputMethodManager::STATE_BROWSER_SCREEN); | 141 InputMethodManager::STATE_BROWSER_SCREEN); |
| 142 break; | 142 break; |
| 143 } | 143 } |
| 144 case chrome::NOTIFICATION_PREF_CHANGED: { | 144 case chrome::NOTIFICATION_PREF_CHANGED: { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 DCHECK(pref_service); | 187 DCHECK(pref_service); |
| 188 DCHECK_EQ(InputMethodManager::STATE_BROWSER_SCREEN, state_); | 188 DCHECK_EQ(InputMethodManager::STATE_BROWSER_SCREEN, state_); |
| 189 previous_input_method_pref_.Init( | 189 previous_input_method_pref_.Init( |
| 190 prefs::kLanguagePreviousInputMethod, pref_service, this); | 190 prefs::kLanguagePreviousInputMethod, pref_service, this); |
| 191 current_input_method_pref_.Init( | 191 current_input_method_pref_.Init( |
| 192 prefs::kLanguageCurrentInputMethod, pref_service, this); | 192 prefs::kLanguageCurrentInputMethod, pref_service, this); |
| 193 } | 193 } |
| 194 | 194 |
| 195 } // namespace input_method | 195 } // namespace input_method |
| 196 } // namespace chromeos | 196 } // namespace chromeos |
| OLD | NEW |