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/ui/webui/options/chromeos/cros_language_options_handler .h" | 5 #include "chrome/browser/ui/webui/options/chromeos/cros_language_options_handler .h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <iterator> | 8 #include <iterator> |
9 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/bind.h" | 13 #include "base/bind.h" |
14 #include "base/bind_helpers.h" | 14 #include "base/bind_helpers.h" |
15 #include "base/i18n/rtl.h" | 15 #include "base/i18n/rtl.h" |
16 #include "base/strings/stringprintf.h" | 16 #include "base/strings/stringprintf.h" |
17 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
18 #include "base/values.h" | 18 #include "base/values.h" |
19 #include "chrome/app/chrome_command_ids.h" | 19 #include "chrome/app/chrome_command_ids.h" |
20 #include "chrome/browser/browser_process.h" | 20 #include "chrome/browser/browser_process.h" |
21 #include "chrome/browser/chromeos/customization_document.h" | 21 #include "chrome/browser/chromeos/customization_document.h" |
22 #include "chrome/browser/chromeos/input_method/input_method_util.h" | 22 #include "chrome/browser/chromeos/input_method/input_method_util.h" |
23 #include "chrome/browser/chromeos/login/user_manager.h" | |
23 #include "chrome/browser/extensions/extension_service.h" | 24 #include "chrome/browser/extensions/extension_service.h" |
24 #include "chrome/browser/extensions/extension_tab_util.h" | 25 #include "chrome/browser/extensions/extension_tab_util.h" |
25 #include "chrome/browser/lifetime/application_lifetime.h" | 26 #include "chrome/browser/lifetime/application_lifetime.h" |
26 #include "chrome/browser/profiles/profile.h" | 27 #include "chrome/browser/profiles/profile.h" |
27 #include "chrome/browser/ui/browser.h" | 28 #include "chrome/browser/ui/browser.h" |
28 #include "chrome/browser/ui/browser_finder.h" | 29 #include "chrome/browser/ui/browser_finder.h" |
29 #include "chrome/browser/ui/browser_window.h" | 30 #include "chrome/browser/ui/browser_window.h" |
30 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 31 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
31 #include "chrome/common/extensions/manifest_url_handler.h" | 32 #include "chrome/common/extensions/manifest_url_handler.h" |
32 #include "chromeos/ime/component_extension_ime_manager.h" | 33 #include "chromeos/ime/component_extension_ime_manager.h" |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
382 } | 383 } |
383 return ime_ids_list.release(); | 384 return ime_ids_list.release(); |
384 } | 385 } |
385 | 386 |
386 base::string16 CrosLanguageOptionsHandler::GetProductName() { | 387 base::string16 CrosLanguageOptionsHandler::GetProductName() { |
387 return l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_OS_NAME); | 388 return l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_OS_NAME); |
388 } | 389 } |
389 | 390 |
390 void CrosLanguageOptionsHandler::SetApplicationLocale( | 391 void CrosLanguageOptionsHandler::SetApplicationLocale( |
391 const std::string& language_code) { | 392 const std::string& language_code) { |
392 Profile::FromWebUI(web_ui())->ChangeAppLocale( | 393 Profile* profile = Profile::FromWebUI(web_ui()); |
393 language_code, Profile::APP_LOCALE_CHANGED_VIA_SETTINGS); | 394 UserManager* user_manager = UserManager::Get(); |
395 | |
396 // Only the primary user can change the locale. | |
397 if (user_manager->GetUserByProfile(profile) == | |
Dmitry Polukhin
2014/02/12 18:58:45
I would compare emails here instead of comparing p
michaelpg
2014/02/12 20:29:58
Done.
| |
398 user_manager->GetPrimaryUser()) { | |
399 profile->ChangeAppLocale(language_code, | |
400 Profile::APP_LOCALE_CHANGED_VIA_SETTINGS); | |
401 } | |
394 } | 402 } |
395 | 403 |
396 void CrosLanguageOptionsHandler::RestartCallback(const base::ListValue* args) { | 404 void CrosLanguageOptionsHandler::RestartCallback(const base::ListValue* args) { |
397 content::RecordAction(UserMetricsAction("LanguageOptions_SignOut")); | 405 content::RecordAction(UserMetricsAction("LanguageOptions_SignOut")); |
398 chrome::AttemptUserExit(); | 406 chrome::AttemptUserExit(); |
399 } | 407 } |
400 | 408 |
401 void CrosLanguageOptionsHandler::InputMethodDisableCallback( | 409 void CrosLanguageOptionsHandler::InputMethodDisableCallback( |
402 const base::ListValue* args) { | 410 const base::ListValue* args) { |
403 const std::string input_method_id = UTF16ToASCII(ExtractStringValue(args)); | 411 const std::string input_method_id = UTF16ToASCII(ExtractStringValue(args)); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
485 ConvertInputMethodDescriptosToIMEList( | 493 ConvertInputMethodDescriptosToIMEList( |
486 component_extension_manager->GetAllIMEAsInputMethodDescriptor())); | 494 component_extension_manager->GetAllIMEAsInputMethodDescriptor())); |
487 web_ui()->CallJavascriptFunction( | 495 web_ui()->CallJavascriptFunction( |
488 "options.LanguageOptions.onComponentManagerInitialized", | 496 "options.LanguageOptions.onComponentManagerInitialized", |
489 *ime_list); | 497 *ime_list); |
490 composition_extension_appended_ = true; | 498 composition_extension_appended_ = true; |
491 } | 499 } |
492 | 500 |
493 } // namespace options | 501 } // namespace options |
494 } // namespace chromeos | 502 } // namespace chromeos |
OLD | NEW |