| 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/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "chrome/app/chrome_command_ids.h" | 9 #include "chrome/app/chrome_command_ids.h" |
| 10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 if (UserManager::Get()->current_user_is_owner()) { | 100 if (UserManager::Get()->current_user_is_owner()) { |
| 101 PrefService* local_state = g_browser_process->local_state(); | 101 PrefService* local_state = g_browser_process->local_state(); |
| 102 if (local_state) { | 102 if (local_state) { |
| 103 PrefService* prefs = profile_->GetPrefs(); | 103 PrefService* prefs = profile_->GetPrefs(); |
| 104 if (prefs == NULL) { | 104 if (prefs == NULL) { |
| 105 NOTREACHED(); | 105 NOTREACHED(); |
| 106 return; | 106 return; |
| 107 } | 107 } |
| 108 std::string owner_locale = | 108 std::string owner_locale = |
| 109 prefs->GetString(prefs::kApplicationLocale); | 109 prefs->GetString(prefs::kApplicationLocale); |
| 110 if (!owner_locale.empty()) { | 110 if (!owner_locale.empty()) |
| 111 local_state->SetString(prefs::kOwnerLocale, owner_locale); | 111 local_state->SetString(prefs::kOwnerLocale, owner_locale); |
| 112 local_state->ScheduleSavePersistentPrefs(); | |
| 113 } | |
| 114 } | 112 } |
| 115 } | 113 } |
| 116 break; | 114 break; |
| 117 } | 115 } |
| 118 default: { | 116 default: { |
| 119 NOTREACHED(); | 117 NOTREACHED(); |
| 120 break; | 118 break; |
| 121 } | 119 } |
| 122 } | 120 } |
| 123 } | 121 } |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 PrefService* prefs = profile_->GetPrefs(); | 189 PrefService* prefs = profile_->GetPrefs(); |
| 192 if (prefs == NULL) { | 190 if (prefs == NULL) { |
| 193 NOTREACHED(); | 191 NOTREACHED(); |
| 194 return; | 192 return; |
| 195 } | 193 } |
| 196 if (prefs->GetString(prefs::kApplicationLocale) != to_locale_) | 194 if (prefs->GetString(prefs::kApplicationLocale) != to_locale_) |
| 197 return; | 195 return; |
| 198 content::RecordAction(UserMetricsAction("LanguageChange_Accept")); | 196 content::RecordAction(UserMetricsAction("LanguageChange_Accept")); |
| 199 prefs->SetString(prefs::kApplicationLocaleBackup, to_locale_); | 197 prefs->SetString(prefs::kApplicationLocaleBackup, to_locale_); |
| 200 prefs->SetString(prefs::kApplicationLocaleAccepted, to_locale_); | 198 prefs->SetString(prefs::kApplicationLocaleAccepted, to_locale_); |
| 201 prefs->ScheduleSavePersistentPrefs(); | |
| 202 } | 199 } |
| 203 | 200 |
| 204 void LocaleChangeGuard::PrepareChangingLocale( | 201 void LocaleChangeGuard::PrepareChangingLocale( |
| 205 const std::string& from_locale, const std::string& to_locale) { | 202 const std::string& from_locale, const std::string& to_locale) { |
| 206 std::string cur_locale = g_browser_process->GetApplicationLocale(); | 203 std::string cur_locale = g_browser_process->GetApplicationLocale(); |
| 207 if (!from_locale.empty()) | 204 if (!from_locale.empty()) |
| 208 from_locale_ = from_locale; | 205 from_locale_ = from_locale; |
| 209 if (!to_locale.empty()) | 206 if (!to_locale.empty()) |
| 210 to_locale_ = to_locale; | 207 to_locale_ = to_locale; |
| 211 | 208 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 228 if (by_user) | 225 if (by_user) |
| 229 master_->AcceptLocaleChange(); | 226 master_->AcceptLocaleChange(); |
| 230 } | 227 } |
| 231 | 228 |
| 232 std::string LocaleChangeGuard::Delegate::id() const { | 229 std::string LocaleChangeGuard::Delegate::id() const { |
| 233 // Arbitrary unique Id. | 230 // Arbitrary unique Id. |
| 234 return "8c386938-1e3f-11e0-ac7b-18a90520e2e5"; | 231 return "8c386938-1e3f-11e0-ac7b-18a90520e2e5"; |
| 235 } | 232 } |
| 236 | 233 |
| 237 } // namespace chromeos | 234 } // namespace chromeos |
| OLD | NEW |