Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(66)

Side by Side Diff: chrome/browser/chromeos/dom_ui/language_options_handler.cc

Issue 2808106: Show native language names in the add language overlay. (Closed)
Patch Set: minor change Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "app/l10n_util.h" 7 #include "app/l10n_util.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "chrome/browser/browser_process.h" 10 #include "chrome/browser/browser_process.h"
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 91
92 ListValue* LanguageOptionsHandler::GetLanguageList() { 92 ListValue* LanguageOptionsHandler::GetLanguageList() {
93 ListValue* language_list = new ListValue(); 93 ListValue* language_list = new ListValue();
94 94
95 const std::vector<std::string>& locales = l10n_util::GetAvailableLocales(); 95 const std::vector<std::string>& locales = l10n_util::GetAvailableLocales();
96 for (size_t i = 0; i < locales.size(); ++i) { 96 for (size_t i = 0; i < locales.size(); ++i) {
97 DictionaryValue* dictionary = new DictionaryValue(); 97 DictionaryValue* dictionary = new DictionaryValue();
98 dictionary->SetString(L"code", UTF8ToWide(locales[i])); 98 dictionary->SetString(L"code", UTF8ToWide(locales[i]));
99 dictionary->SetString(L"displayName", 99 dictionary->SetString(L"displayName",
100 chromeos::input_method::GetLanguageDisplayNameFromCode(locales[i])); 100 chromeos::input_method::GetLanguageDisplayNameFromCode(locales[i]));
101 dictionary->SetString(L"nativeDisplayName",
102 chromeos::input_method::GetLanguageNativeDisplayNameFromCode(
103 locales[i]));
101 language_list->Append(dictionary); 104 language_list->Append(dictionary);
102 } 105 }
103 106
104 return language_list; 107 return language_list;
105 } 108 }
106 109
107 void LanguageOptionsHandler::UiLanguageChangeCallback( 110 void LanguageOptionsHandler::UiLanguageChangeCallback(
108 const Value* value) { 111 const Value* value) {
109 if (!value || !value->IsType(Value::TYPE_LIST)) { 112 if (!value || !value->IsType(Value::TYPE_LIST)) {
110 NOTREACHED(); 113 NOTREACHED();
111 LOG(INFO) << "NOTREACHED"; 114 LOG(INFO) << "NOTREACHED";
112 return; 115 return;
113 } 116 }
114 const ListValue* list_value = static_cast<const ListValue*>(value); 117 const ListValue* list_value = static_cast<const ListValue*>(value);
115 std::string language_code; 118 std::string language_code;
116 if (list_value->GetSize() != 1 || 119 if (list_value->GetSize() != 1 ||
117 !list_value->GetString(0, &language_code)) { 120 !list_value->GetString(0, &language_code)) {
118 NOTREACHED(); 121 NOTREACHED();
119 LOG(INFO) << "NOTREACHED"; 122 LOG(INFO) << "NOTREACHED";
120 return; 123 return;
121 } 124 }
122 PrefService* prefs = g_browser_process->local_state(); 125 PrefService* prefs = g_browser_process->local_state();
123 prefs->SetString(prefs::kApplicationLocale, language_code); 126 prefs->SetString(prefs::kApplicationLocale, language_code);
124 prefs->SavePersistentPrefs(); 127 prefs->SavePersistentPrefs();
125 dom_ui_->CallJavascriptFunction( 128 dom_ui_->CallJavascriptFunction(
126 L"options.LanguageOptions.uiLanguageSaved"); 129 L"options.LanguageOptions.uiLanguageSaved");
127 } 130 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698