| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/chromeos/input_method/input_method_delegate_impl.h" |
| 6 |
| 7 #include "base/prefs/public/pref_service_base.h" |
| 8 #include "chrome/browser/browser_process.h" |
| 9 #include "chrome/browser/chromeos/language_preferences.h" |
| 10 #include "chrome/browser/profiles/profile.h" |
| 11 #include "chrome/browser/profiles/profile_manager.h" |
| 12 #include "chrome/common/pref_names.h" |
| 13 |
| 14 namespace chromeos { |
| 15 namespace input_method { |
| 16 |
| 17 InputMethodDelegateImpl::InputMethodDelegateImpl() {} |
| 18 |
| 19 void InputMethodDelegateImpl::SetSystemInputMethod( |
| 20 const std::string& input_method) { |
| 21 if (g_browser_process) { |
| 22 PrefServiceBase* local_state = g_browser_process->local_state(); |
| 23 if (local_state) { |
| 24 local_state->SetString(language_prefs::kPreferredKeyboardLayout, |
| 25 input_method); |
| 26 return; |
| 27 } |
| 28 } |
| 29 |
| 30 NOTREACHED(); |
| 31 } |
| 32 |
| 33 void InputMethodDelegateImpl::SetUserInputMethod( |
| 34 const std::string& input_method) { |
| 35 PrefServiceBase* user_prefs = NULL; |
| 36 Profile* profile = ProfileManager::GetDefaultProfile(); |
| 37 if (profile) |
| 38 user_prefs = profile->GetPrefs(); |
| 39 if (!user_prefs) |
| 40 return; |
| 41 |
| 42 const std::string current_input_method_on_pref = |
| 43 user_prefs->GetString(prefs::kLanguageCurrentInputMethod); |
| 44 if (current_input_method_on_pref == input_method) |
| 45 return; |
| 46 |
| 47 user_prefs->SetString(prefs::kLanguagePreviousInputMethod, |
| 48 current_input_method_on_pref); |
| 49 user_prefs->SetString(prefs::kLanguageCurrentInputMethod, |
| 50 input_method); |
| 51 } |
| 52 |
| 53 std::string InputMethodDelegateImpl::GetHardwareKeyboardLayout() const { |
| 54 if (g_browser_process) { |
| 55 PrefServiceBase* local_state = g_browser_process->local_state(); |
| 56 if (local_state) |
| 57 return local_state->GetString(prefs::kHardwareKeyboardLayout); |
| 58 } |
| 59 // This shouldn't happen but just in case. |
| 60 DVLOG(1) << "Local state is not yet ready."; |
| 61 return std::string(); |
| 62 } |
| 63 |
| 64 std::string InputMethodDelegateImpl::GetActiveLocale() const { |
| 65 if (g_browser_process) |
| 66 return g_browser_process->GetApplicationLocale(); |
| 67 |
| 68 NOTREACHED(); |
| 69 return std::string(); |
| 70 } |
| 71 |
| 72 } // namespace input_method |
| 73 } // namespace chromeos |
| OLD | NEW |