| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/locale_change_guard.h" | 5 #include "chrome/browser/chromeos/locale_change_guard.h" |
| 6 | 6 |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "chrome/app/chrome_command_ids.h" | 8 #include "chrome/app/chrome_command_ids.h" |
| 9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
| 10 #include "chrome/browser/chromeos/login/user_manager.h" | 10 #include "chrome/browser/chromeos/login/user_manager.h" |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 if (UserManager::Get()->current_user_is_owner()) { | 96 if (UserManager::Get()->current_user_is_owner()) { |
| 97 PrefService* local_state = g_browser_process->local_state(); | 97 PrefService* local_state = g_browser_process->local_state(); |
| 98 if (local_state) { | 98 if (local_state) { |
| 99 PrefService* prefs = profile_->GetPrefs(); | 99 PrefService* prefs = profile_->GetPrefs(); |
| 100 if (prefs == NULL) { | 100 if (prefs == NULL) { |
| 101 NOTREACHED(); | 101 NOTREACHED(); |
| 102 return; | 102 return; |
| 103 } | 103 } |
| 104 std::string owner_locale = | 104 std::string owner_locale = |
| 105 prefs->GetString(prefs::kApplicationLocale); | 105 prefs->GetString(prefs::kApplicationLocale); |
| 106 if (!owner_locale.empty()) { | 106 if (!owner_locale.empty()) |
| 107 local_state->SetString(prefs::kOwnerLocale, owner_locale); | 107 local_state->SetString(prefs::kOwnerLocale, owner_locale); |
| 108 local_state->ScheduleSavePersistentPrefs(); | |
| 109 } | |
| 110 } | 108 } |
| 111 } | 109 } |
| 112 break; | 110 break; |
| 113 } | 111 } |
| 114 default: { | 112 default: { |
| 115 NOTREACHED(); | 113 NOTREACHED(); |
| 116 break; | 114 break; |
| 117 } | 115 } |
| 118 } | 116 } |
| 119 } | 117 } |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 PrefService* prefs = profile_->GetPrefs(); | 184 PrefService* prefs = profile_->GetPrefs(); |
| 187 if (prefs == NULL) { | 185 if (prefs == NULL) { |
| 188 NOTREACHED(); | 186 NOTREACHED(); |
| 189 return; | 187 return; |
| 190 } | 188 } |
| 191 if (prefs->GetString(prefs::kApplicationLocale) != to_locale_) | 189 if (prefs->GetString(prefs::kApplicationLocale) != to_locale_) |
| 192 return; | 190 return; |
| 193 UserMetrics::RecordAction(UserMetricsAction("LanguageChange_Accept")); | 191 UserMetrics::RecordAction(UserMetricsAction("LanguageChange_Accept")); |
| 194 prefs->SetString(prefs::kApplicationLocaleBackup, to_locale_); | 192 prefs->SetString(prefs::kApplicationLocaleBackup, to_locale_); |
| 195 prefs->SetString(prefs::kApplicationLocaleAccepted, to_locale_); | 193 prefs->SetString(prefs::kApplicationLocaleAccepted, to_locale_); |
| 196 prefs->ScheduleSavePersistentPrefs(); | |
| 197 } | 194 } |
| 198 | 195 |
| 199 void LocaleChangeGuard::PrepareChangingLocale( | 196 void LocaleChangeGuard::PrepareChangingLocale( |
| 200 const std::string& from_locale, const std::string& to_locale) { | 197 const std::string& from_locale, const std::string& to_locale) { |
| 201 std::string cur_locale = g_browser_process->GetApplicationLocale(); | 198 std::string cur_locale = g_browser_process->GetApplicationLocale(); |
| 202 if (!from_locale.empty()) | 199 if (!from_locale.empty()) |
| 203 from_locale_ = from_locale; | 200 from_locale_ = from_locale; |
| 204 if (!to_locale.empty()) | 201 if (!to_locale.empty()) |
| 205 to_locale_ = to_locale; | 202 to_locale_ = to_locale; |
| 206 | 203 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 223 if (by_user) | 220 if (by_user) |
| 224 master_->AcceptLocaleChange(); | 221 master_->AcceptLocaleChange(); |
| 225 } | 222 } |
| 226 | 223 |
| 227 std::string LocaleChangeGuard::Delegate::id() const { | 224 std::string LocaleChangeGuard::Delegate::id() const { |
| 228 // Arbitrary unique Id. | 225 // Arbitrary unique Id. |
| 229 return "8c386938-1e3f-11e0-ac7b-18a90520e2e5"; | 226 return "8c386938-1e3f-11e0-ac7b-18a90520e2e5"; |
| 230 } | 227 } |
| 231 | 228 |
| 232 } // namespace chromeos | 229 } // namespace chromeos |
| OLD | NEW |