OLD | NEW |
1 // Copyright (c) 2010 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/dom_ui/language_options_handler.h" | 5 #include "chrome/browser/chromeos/dom_ui/language_options_handler.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
11 | 11 |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 UserMetrics::RecordAction(UserMetricsAction("LanguageOptions_Open")); | 282 UserMetrics::RecordAction(UserMetricsAction("LanguageOptions_Open")); |
283 } | 283 } |
284 | 284 |
285 void LanguageOptionsHandler::UiLanguageChangeCallback( | 285 void LanguageOptionsHandler::UiLanguageChangeCallback( |
286 const ListValue* args) { | 286 const ListValue* args) { |
287 const std::string language_code = WideToASCII(ExtractStringValue(args)); | 287 const std::string language_code = WideToASCII(ExtractStringValue(args)); |
288 CHECK(!language_code.empty()); | 288 CHECK(!language_code.empty()); |
289 const std::string action = StringPrintf( | 289 const std::string action = StringPrintf( |
290 "LanguageOptions_UiLanguageChange_%s", language_code.c_str()); | 290 "LanguageOptions_UiLanguageChange_%s", language_code.c_str()); |
291 UserMetrics::RecordComputedAction(action); | 291 UserMetrics::RecordComputedAction(action); |
292 | 292 dom_ui_->GetProfile()->ChangeApplicationLocale(language_code, false); |
293 // We maintain kApplicationLocale property in both a global storage | |
294 // and user's profile. Global property determines locale of login screen, | |
295 // while user's profile determines his personal locale preference. | |
296 PrefService* prefs[] = { | |
297 g_browser_process->local_state(), | |
298 dom_ui_->GetProfile()->GetPrefs() | |
299 }; | |
300 for (size_t i = 0; i < arraysize(prefs); ++i) { | |
301 prefs[i]->SetString(prefs::kApplicationLocale, language_code); | |
302 prefs[i]->SavePersistentPrefs(); | |
303 } | |
304 dom_ui_->CallJavascriptFunction( | 293 dom_ui_->CallJavascriptFunction( |
305 L"options.LanguageOptions.uiLanguageSaved"); | 294 L"options.LanguageOptions.uiLanguageSaved"); |
306 } | 295 } |
307 | 296 |
308 void LanguageOptionsHandler::SpellCheckLanguageChangeCallback( | 297 void LanguageOptionsHandler::SpellCheckLanguageChangeCallback( |
309 const ListValue* args) { | 298 const ListValue* args) { |
310 const std::string language_code = WideToASCII(ExtractStringValue(args)); | 299 const std::string language_code = WideToASCII(ExtractStringValue(args)); |
311 CHECK(!language_code.empty()); | 300 CHECK(!language_code.empty()); |
312 const std::string action = StringPrintf( | 301 const std::string action = StringPrintf( |
313 "LanguageOptions_SpellCheckLanguageChange_%s", language_code.c_str()); | 302 "LanguageOptions_SpellCheckLanguageChange_%s", language_code.c_str()); |
314 UserMetrics::RecordComputedAction(action); | 303 UserMetrics::RecordComputedAction(action); |
315 } | 304 } |
316 | 305 |
317 void LanguageOptionsHandler::SignOutCallback(const ListValue* args) { | 306 void LanguageOptionsHandler::SignOutCallback(const ListValue* args) { |
318 UserMetrics::RecordAction(UserMetricsAction("LanguageOptions_SignOut")); | 307 UserMetrics::RecordAction(UserMetricsAction("LanguageOptions_SignOut")); |
319 | 308 |
320 Browser* browser = Browser::GetBrowserForController( | 309 Browser* browser = Browser::GetBrowserForController( |
321 &dom_ui_->tab_contents()->controller(), NULL); | 310 &dom_ui_->tab_contents()->controller(), NULL); |
322 if (browser) | 311 if (browser) |
323 browser->ExecuteCommand(IDC_EXIT); | 312 browser->ExecuteCommand(IDC_EXIT); |
324 } | 313 } |
325 | 314 |
326 } // namespace chromeos | 315 } // namespace chromeos |
OLD | NEW |