summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/spellchecker.cc32
-rw-r--r--chrome/browser/spellchecker.h8
-rw-r--r--chrome/browser/tab_contents/render_view_context_menu.cc20
-rw-r--r--chrome/browser/views/options/language_combobox_model.cc37
-rw-r--r--chrome/browser/views/options/language_combobox_model.h25
-rw-r--r--chrome/browser/views/options/languages_page_view.cc352
-rw-r--r--chrome/browser/views/options/languages_page_view.h4
-rw-r--r--chrome/common/l10n_util.cc11
-rw-r--r--chrome/common/l10n_util.h4
9 files changed, 233 insertions, 260 deletions
diff --git a/chrome/browser/spellchecker.cc b/chrome/browser/spellchecker.cc
index e1f428d..39aec18 100644
--- a/chrome/browser/spellchecker.cc
+++ b/chrome/browser/spellchecker.cc
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include <set>
-
#include "chrome/browser/spellchecker.h"
#include "base/basictypes.h"
#include "base/compiler_specific.h"
@@ -149,43 +147,37 @@ SpellChecker::Language SpellChecker::GetCorrespondingSpellCheckLanguage(
return Language();
}
-int SpellChecker::GetSpellCheckLanguagesToDisplayInContextMenu(
+int SpellChecker::GetSpellCheckLanguages(
Profile* profile,
- DisplayLanguages* display_languages) {
+ Languages* languages) {
StringPrefMember accept_languages_pref;
StringPrefMember dictionary_language_pref;
accept_languages_pref.Init(prefs::kAcceptLanguages, profile->GetPrefs(),
NULL);
dictionary_language_pref.Init(prefs::kSpellCheckDictionary,
profile->GetPrefs(), NULL);
- std::wstring dictionary_language = dictionary_language_pref.GetValue();
+ std::string dictionary_language =
+ WideToASCII(dictionary_language_pref.GetValue());
// The current dictionary language should be there.
- display_languages->push_back(dictionary_language);
+ languages->push_back(dictionary_language);
// Now scan through the list of accept languages, and find possible mappings
// from this list to the existing list of spell check languages.
Languages accept_languages;
- std::set<Language> unique_languages;
SplitString(WideToASCII(accept_languages_pref.GetValue()), ',',
&accept_languages);
for (Languages::const_iterator i = accept_languages.begin();
i != accept_languages.end(); ++i) {
- Language language(GetCorrespondingSpellCheckLanguage(*i));
- if (!language.empty() && language != WideToASCII(dictionary_language))
- unique_languages.insert(language);
+ std::string language = GetCorrespondingSpellCheckLanguage(*i);
+ if (!language.empty() &&
+ std::find(languages->begin(), languages->end(), language) ==
+ languages->end())
+ languages->push_back(language);
}
- for (std::set<Language>::const_iterator i = unique_languages.begin();
- i != unique_languages.end(); ++i)
- display_languages->push_back(ASCIIToWide(*i));
-
- // Sort using locale specific sorter.
- l10n_util::SortStrings(g_browser_process->GetApplicationLocale(),
- display_languages);
-
- for (size_t i = 0; i < display_languages->size(); ++i) {
- if ((*display_languages)[i] == dictionary_language)
+ for (size_t i = 0; i < languages->size(); ++i) {
+ if ((*languages)[i] == dictionary_language)
return i;
}
return -1;
diff --git a/chrome/browser/spellchecker.h b/chrome/browser/spellchecker.h
index 7b8e72b..e7f4972 100644
--- a/chrome/browser/spellchecker.h
+++ b/chrome/browser/spellchecker.h
@@ -44,10 +44,6 @@ class SpellChecker : public base::RefCountedThreadSafe<SpellChecker> {
// ASCII string representing a language and/or region, e.g. "en-US".
typedef std::string Language;
typedef std::vector<Language> Languages;
- // Languages that are suitable for display to the user.
- // TODO(port): this should be string16, but we need to port
- // l10n_util::SortStrings to string16 first.
- typedef std::vector<std::wstring> DisplayLanguages;
// Creates the spellchecker by reading dictionaries from the given directory,
// and defaulting to the given language. Both strings must be provided.
@@ -92,9 +88,9 @@ class SpellChecker : public base::RefCountedThreadSafe<SpellChecker> {
// returns the index of the current spell check language in the vector.
// TODO(port): this should take a vector of string16, but the implementation
// has some dependencies in l10n util that need porting first.
- static int GetSpellCheckLanguagesToDisplayInContextMenu(
+ static int GetSpellCheckLanguages(
Profile* profile,
- DisplayLanguages* display_languages);
+ Languages* languages);
// This function returns the corresponding language-region code for the
// spell check language. For example, for hi, it returns hi-IN.
diff --git a/chrome/browser/tab_contents/render_view_context_menu.cc b/chrome/browser/tab_contents/render_view_context_menu.cc
index e6ac8eb..979d7e5 100644
--- a/chrome/browser/tab_contents/render_view_context_menu.cc
+++ b/chrome/browser/tab_contents/render_view_context_menu.cc
@@ -169,8 +169,8 @@ void RenderViewContextMenu::AppendEditableItems() {
l10n_util::GetString(IDS_CONTENT_CONTEXT_SPELLCHECK_MENU));
// Add Spell Check languages to sub menu.
- SpellChecker::DisplayLanguages display_languages;
- SpellChecker::GetSpellCheckLanguagesToDisplayInContextMenu(profile_,
+ SpellChecker::Languages display_languages;
+ SpellChecker::GetSpellCheckLanguages(profile_,
&display_languages);
DCHECK(display_languages.size() <
IDC_SPELLCHECK_LANGUAGES_LAST - IDC_SPELLCHECK_LANGUAGES_FIRST);
@@ -318,9 +318,9 @@ bool RenderViewContextMenu::ItemIsChecked(int id) const {
(id >= IDC_SPELLCHECK_LANGUAGES_LAST))
return false;
- SpellChecker::DisplayLanguages display_languages;
- return SpellChecker::GetSpellCheckLanguagesToDisplayInContextMenu(
- source_web_contents_->profile(), &display_languages) ==
+ SpellChecker::Languages languages;
+ return SpellChecker::GetSpellCheckLanguages(
+ source_web_contents_->profile(), &languages) ==
(id - IDC_SPELLCHECK_LANGUAGES_FIRST);
}
@@ -329,14 +329,14 @@ void RenderViewContextMenu::ExecuteItemCommand(int id) {
if (id >= IDC_SPELLCHECK_LANGUAGES_FIRST &&
id < IDC_SPELLCHECK_LANGUAGES_LAST) {
const size_t language_number = id - IDC_SPELLCHECK_LANGUAGES_FIRST;
- SpellChecker::DisplayLanguages display_languages;
- SpellChecker::GetSpellCheckLanguagesToDisplayInContextMenu(
- source_web_contents_->profile(), &display_languages);
- if (language_number < display_languages.size()) {
+ SpellChecker::Languages languages;
+ SpellChecker::GetSpellCheckLanguages(
+ source_web_contents_->profile(), &languages);
+ if (language_number < languages.size()) {
StringPrefMember dictionary_language;
dictionary_language.Init(prefs::kSpellCheckDictionary,
source_web_contents_->profile()->GetPrefs(), NULL);
- dictionary_language.SetValue(display_languages[language_number]);
+ dictionary_language.SetValue(ASCIIToWide(languages[language_number]));
}
return;
diff --git a/chrome/browser/views/options/language_combobox_model.cc b/chrome/browser/views/options/language_combobox_model.cc
index 556cd06..3411a4d 100644
--- a/chrome/browser/views/options/language_combobox_model.cc
+++ b/chrome/browser/views/options/language_combobox_model.cc
@@ -16,39 +16,28 @@
// LanguageComboboxModel used to populate a combobox with native names
// corresponding to the language code (e.g. English (United States) for en-US)
//
+
LanguageComboboxModel::LanguageComboboxModel()
: profile_(NULL) {
// Enumerate the languages we know about.
- const std::vector<std::wstring>& locale_codes =
+ const std::vector<std::string>& locale_codes =
l10n_util::GetAvailableLocales();
InitNativeNames(locale_codes);
}
-// Overload using a profile and customized local_codes vector.
-LanguageComboboxModel::LanguageComboboxModel(
- Profile* profile, const std::vector<std::wstring>& locale_codes)
- : profile_(profile) {
- InitNativeNames(locale_codes);
-}
-
LanguageComboboxModel::LanguageComboboxModel(
Profile* profile, const std::vector<std::string>& locale_codes)
: profile_(profile) {
- std::vector<std::wstring> locale_codes_w;
- for (std::vector<std::string>::const_iterator iter = locale_codes.begin();
- iter != locale_codes.end(); ++iter) {
- locale_codes_w.push_back(ASCIIToWide(*iter));
- }
- InitNativeNames(locale_codes_w);
+ InitNativeNames(locale_codes);
}
-void LanguageComboboxModel::InitNativeNames(const std::vector<std::wstring>&
- locale_codes) {
+void LanguageComboboxModel::InitNativeNames(
+ const std::vector<std::string>& locale_codes) {
const std::string app_locale = WideToASCII(
g_browser_process->GetApplicationLocale());
for (size_t i = 0; i < locale_codes.size(); ++i) {
- std::string locale_code_str = WideToASCII(locale_codes[i]);
- const char* locale_code = locale_code_str.c_str();
+ std::string locale_code_str = locale_codes[i];
+ const char* locale_code = locale_codes[i].c_str();
// Internally, we use the language code of zh-CN and zh-TW, but we want the
// display names to be Chinese (Simplified) and Chinese (Traditional). To
@@ -134,7 +123,7 @@ std::wstring LanguageComboboxModel::GetItemAt(views::ComboBox* source,
}
// Return the locale for the given index. E.g., may return pt-BR.
-std::wstring LanguageComboboxModel::GetLocaleFromIndex(int index) {
+std::string LanguageComboboxModel::GetLocaleFromIndex(int index) {
DCHECK(static_cast<int>(locale_names_.size()) > index);
LocaleDataMap::const_iterator it =
native_names_.find(locale_names_[index]);
@@ -143,7 +132,7 @@ std::wstring LanguageComboboxModel::GetLocaleFromIndex(int index) {
return it->second.locale_code;
}
-int LanguageComboboxModel::GetIndexFromLocale(const std::wstring& locale) {
+int LanguageComboboxModel::GetIndexFromLocale(const std::string& locale) {
for (size_t i = 0; i < locale_names_.size(); ++i) {
LocaleDataMap::const_iterator it =
native_names_.find(locale_names_[i]);
@@ -161,8 +150,7 @@ int LanguageComboboxModel::GetIndexFromLocale(const std::wstring& locale) {
// shouldn't be reflected in this combo box. We return -1 if the value in
// the pref doesn't map to a know language (possible if the user edited the
// prefs file manually).
-int LanguageComboboxModel::GetSelectedLanguageIndex(const std::wstring&
- prefs) {
+int LanguageComboboxModel::GetSelectedLanguageIndex(const std::wstring& prefs) {
PrefService* local_state;
if (!profile_)
local_state = g_browser_process->local_state();
@@ -170,7 +158,8 @@ int LanguageComboboxModel::GetSelectedLanguageIndex(const std::wstring&
local_state = profile_->GetPrefs();
DCHECK(local_state);
- const std::wstring& current_lang = local_state->GetString(prefs.c_str());
+ const std::string& current_locale =
+ WideToASCII(local_state->GetString(prefs.c_str()));
- return GetIndexFromLocale(current_lang);
+ return GetIndexFromLocale(current_locale);
}
diff --git a/chrome/browser/views/options/language_combobox_model.h b/chrome/browser/views/options/language_combobox_model.h
index e10af90..a3dfac6 100644
--- a/chrome/browser/views/options/language_combobox_model.h
+++ b/chrome/browser/views/options/language_combobox_model.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_VIEWS_OPTIONS_LANGUAGE_COMBOBOX_MODEL_H__
-#define CHROME_BROWSER_VIEWS_OPTIONS_LANGUAGE_COMBOBOX_MODEL_H__
+#ifndef CHROME_BROWSER_VIEWS_OPTIONS_LANGUAGE_COMBOBOX_MODEL_H_
+#define CHROME_BROWSER_VIEWS_OPTIONS_LANGUAGE_COMBOBOX_MODEL_H_
#include "chrome/browser/profile.h"
#include "chrome/views/controls/combo_box.h"
@@ -15,28 +15,23 @@ class LanguageComboboxModel : public views::ComboBox::Model {
public:
struct LocaleData {
LocaleData() { }
- LocaleData(const std::wstring& name, const std::wstring& code)
+ LocaleData(const std::wstring& name, const std::string& code)
: native_name(name), locale_code(code) { }
std::wstring native_name;
- std::wstring locale_code; // E.g., en-us.
+ std::string locale_code; // E.g., en-us.
};
typedef std::map<std::wstring, LocaleData> LocaleDataMap;
LanguageComboboxModel();
- // Overload using a profile and customized local_codes vector.
- LanguageComboboxModel(Profile* profile,
- const std::vector<std::wstring>& locale_codes);
-
// Temporary compatibility constructor.
- // TODO(port): remove this once locale codes are all switched to ASCII.
LanguageComboboxModel(Profile* profile,
const std::vector<std::string>& locale_codes);
virtual ~LanguageComboboxModel() {}
- void InitNativeNames(const std::vector<std::wstring>& locale_codes);
+ void InitNativeNames(const std::vector<std::string>& locale_codes);
// Overridden from views::Combobox::Model:
virtual int GetItemCount(views::ComboBox* source);
@@ -44,11 +39,11 @@ class LanguageComboboxModel : public views::ComboBox::Model {
virtual std::wstring GetItemAt(views::ComboBox* source, int index);
// Return the locale for the given index. E.g., may return pt-BR.
- std::wstring GetLocaleFromIndex(int index);
+ std::string GetLocaleFromIndex(int index);
// Returns the index for the given locale. Returns -1 if the locale is not
// in the combobox model.
- int GetIndexFromLocale(const std::wstring& locale);
+ int GetIndexFromLocale(const std::string& locale);
// Returns the index of the language currently specified in the user's
// preference file. Note that it's possible for language A to be picked
@@ -60,7 +55,7 @@ class LanguageComboboxModel : public views::ComboBox::Model {
int GetSelectedLanguageIndex(const std::wstring& prefs);
private:
- // The name all the locales in the current application locale.
+ // The names of all the locales in the current application locale.
std::vector<std::wstring> locale_names_;
// A map of some extra data (LocaleData) keyed off the name of the locale.
@@ -69,7 +64,7 @@ class LanguageComboboxModel : public views::ComboBox::Model {
// Profile.
Profile* profile_;
- DISALLOW_EVIL_CONSTRUCTORS(LanguageComboboxModel);
+ DISALLOW_COPY_AND_ASSIGN(LanguageComboboxModel);
};
-#endif // #ifndef CHROME_BROWSER_VIEWS_OPTIONS_LANGUAGE_COMBOBOX_MODEL_H__
+#endif // #ifndef CHROME_BROWSER_VIEWS_OPTIONS_LANGUAGE_COMBOBOX_MODEL_H_
diff --git a/chrome/browser/views/options/languages_page_view.cc b/chrome/browser/views/options/languages_page_view.cc
index 0ed4f94..2634639 100644
--- a/chrome/browser/views/options/languages_page_view.cc
+++ b/chrome/browser/views/options/languages_page_view.cc
@@ -37,139 +37,138 @@
#include "skia/include/SkBitmap.h"
#include "unicode/uloc.h"
-// TODO(port): this should be a char* list.
-static const wchar_t* const accept_language_list[] = {
- L"af", // Afrikaans
- L"am", // Amharic
- L"ar", // Arabic
- L"az", // Azerbaijani
- L"be", // Belarusian
- L"bg", // Bulgarian
- L"bh", // Bihari
- L"bn", // Bengali
- L"br", // Breton
- L"bs", // Bosnian
- L"ca", // Catalan
- L"co", // Corsican
- L"cs", // Czech
- L"cy", // Welsh
- L"da", // Danish
- L"de", // German
- L"de-AT", // German (Austria)
- L"de-CH", // German (Switzerland)
- L"de-DE", // German (Germany)
- L"el", // Greek
- L"en", // English
- L"en-AU", // English (Austrailia)
- L"en-CA", // English (Canada)
- L"en-GB", // English (UK)
- L"en-NZ", // English (New Zealand)
- L"en-US", // English (US)
- L"en-ZA", // English (South Africa)
- L"eo", // Esperanto
+static const char* const accept_language_list[] = {
+ "af", // Afrikaans
+ "am", // Amharic
+ "ar", // Arabic
+ "az", // Azerbaijani
+ "be", // Belarusian
+ "bg", // Bulgarian
+ "bh", // Bihari
+ "bn", // Bengali
+ "br", // Breton
+ "bs", // Bosnian
+ "ca", // Catalan
+ "co", // Corsican
+ "cs", // Czech
+ "cy", // Welsh
+ "da", // Danish
+ "de", // German
+ "de-AT", // German (Austria)
+ "de-CH", // German (Switzerland)
+ "de-DE", // German (Germany)
+ "el", // Greek
+ "en", // English
+ "en-AU", // English (Austrailia)
+ "en-CA", // English (Canada)
+ "en-GB", // English (UK)
+ "en-NZ", // English (New Zealand)
+ "en-US", // English (US)
+ "en-ZA", // English (South Africa)
+ "eo", // Esperanto
// TODO(jungshik) : Do we want to list all es-Foo for Latin-American
// Spanish speaking countries?
- L"es", // Spanish
- L"et", // Estonian
- L"eu", // Basque
- L"fa", // Persian
- L"fi", // Finnish
- L"fil", // Filipino
- L"fo", // Faroese
- L"fr", // French
- L"fr-CA", // French (Canada)
- L"fr-CH", // French (Switzerland)
- L"fr-FR", // French (France)
- L"fy", // Frisian
- L"ga", // Irish
- L"gd", // Scots Gaelic
- L"gl", // Galician
- L"gn", // Guarani
- L"gu", // Gujarati
- L"he", // Hebrew
- L"hi", // Hindi
- L"hr", // Croatian
- L"hu", // Hungarian
- L"hy", // Armenian
- L"ia", // Interlingua
- L"id", // Indonesian
- L"is", // Icelandic
- L"it", // Italian
- L"it-CH", // Italian (Switzerland)
- L"it-IT", // Italian (Italy)
- L"ja", // Japanese
- L"jw", // Javanese
- L"ka", // Georgian
- L"kk", // Kazakh
- L"km", // Cambodian
- L"kn", // Kannada
- L"ko", // Korean
- L"ku", // Kurdish
- L"ky", // Kyrgyz
- L"la", // Latin
- L"ln", // Lingala
- L"lo", // Laothian
- L"lt", // Lithuanian
- L"lv", // Latvian
- L"mk", // Macedonian
- L"ml", // Malayalam
- L"mn", // Mongolian
- L"mo", // Moldavian
- L"mr", // Marathi
- L"ms", // Malay
- L"mt", // Maltese
- L"nb", // Norwegian (Bokmal)
- L"ne", // Nepali
- L"nl", // Dutch
- L"nn", // Norwegian (Nynorsk)
- L"no", // Norwegian
- L"oc", // Occitan
- L"or", // Oriya
- L"pa", // Punjabi
- L"pl", // Polish
- L"ps", // Pashto
- L"pt", // Portuguese
- L"pt-BR", // Portuguese (Brazil)
- L"pt-PT", // Portuguese (Portugal)
- L"qu", // Quechua
- L"rm", // Romansh
- L"ro", // Romanian
- L"ru", // Russian
- L"sd", // Sindhi
- L"sh", // Serbo-Croatian
- L"si", // Sinhalese
- L"sk", // Slovak
- L"sl", // Slovenian
- L"sn", // Shona
- L"so", // Somali
- L"sq", // Albanian
- L"sr", // Serbian
- L"st", // Sesotho
- L"su", // Sundanese
- L"sv", // Swedish
- L"sw", // Swahili
- L"ta", // Tamil
- L"te", // Telugu
- L"tg", // Tajik
- L"th", // Thai
- L"ti", // Tigrinya
- L"tk", // Turkmen
- L"to", // Tonga
- L"tr", // Turkish
- L"tt", // Tatar
- L"tw", // Twi
- L"ug", // Uighur
- L"uk", // Ukrainian
- L"ur", // Urdu
- L"uz", // Uzbek
- L"vi", // Vietnamese
- L"xh", // Xhosa
- L"yi", // Yiddish
- L"yo", // Yoruba
- L"zh", // Chinese
- L"zh-CN", // Chinese (Simplified)
- L"zh-TW", // Chinese (Traditional)
- L"zu", // Zulu
+ "es", // Spanish
+ "et", // Estonian
+ "eu", // Basque
+ "fa", // Persian
+ "fi", // Finnish
+ "fil", // Filipino
+ "fo", // Faroese
+ "fr", // French
+ "fr-CA", // French (Canada)
+ "fr-CH", // French (Switzerland)
+ "fr-FR", // French (France)
+ "fy", // Frisian
+ "ga", // Irish
+ "gd", // Scots Gaelic
+ "gl", // Galician
+ "gn", // Guarani
+ "gu", // Gujarati
+ "he", // Hebrew
+ "hi", // Hindi
+ "hr", // Croatian
+ "hu", // Hungarian
+ "hy", // Armenian
+ "ia", // Interlingua
+ "id", // Indonesian
+ "is", // Icelandic
+ "it", // Italian
+ "it-CH", // Italian (Switzerland)
+ "it-IT", // Italian (Italy)
+ "ja", // Japanese
+ "jw", // Javanese
+ "ka", // Georgian
+ "kk", // Kazakh
+ "km", // Cambodian
+ "kn", // Kannada
+ "ko", // Korean
+ "ku", // Kurdish
+ "ky", // Kyrgyz
+ "la", // Latin
+ "ln", // Lingala
+ "lo", // Laothian
+ "lt", // Lithuanian
+ "lv", // Latvian
+ "mk", // Macedonian
+ "ml", // Malayalam
+ "mn", // Mongolian
+ "mo", // Moldavian
+ "mr", // Marathi
+ "ms", // Malay
+ "mt", // Maltese
+ "nb", // Norwegian (Bokmal)
+ "ne", // Nepali
+ "nl", // Dutch
+ "nn", // Norwegian (Nynorsk)
+ "no", // Norwegian
+ "oc", // Occitan
+ "or", // Oriya
+ "pa", // Punjabi
+ "pl", // Polish
+ "ps", // Pashto
+ "pt", // Portuguese
+ "pt-BR", // Portuguese (Brazil)
+ "pt-PT", // Portuguese (Portugal)
+ "qu", // Quechua
+ "rm", // Romansh
+ "ro", // Romanian
+ "ru", // Russian
+ "sd", // Sindhi
+ "sh", // Serbo-Croatian
+ "si", // Sinhalese
+ "sk", // Slovak
+ "sl", // Slovenian
+ "sn", // Shona
+ "so", // Somali
+ "sq", // Albanian
+ "sr", // Serbian
+ "st", // Sesotho
+ "su", // Sundanese
+ "sv", // Swedish
+ "sw", // Swahili
+ "ta", // Tamil
+ "te", // Telugu
+ "tg", // Tajik
+ "th", // Thai
+ "ti", // Tigrinya
+ "tk", // Turkmen
+ "to", // Tonga
+ "tr", // Turkish
+ "tt", // Tatar
+ "tw", // Twi
+ "ug", // Uighur
+ "uk", // Ukrainian
+ "ur", // Urdu
+ "uz", // Uzbek
+ "vi", // Vietnamese
+ "xh", // Xhosa
+ "yi", // Yiddish
+ "yo", // Yoruba
+ "zh", // Chinese
+ "zh-CN", // Chinese (Simplified)
+ "zh-TW", // Chinese (Traditional)
+ "zu", // Zulu
};
///////////////////////////////////////////////////////////////////////////////
@@ -216,7 +215,7 @@ class AddLanguageWindowView : public views::View,
// Used for Call back to LanguagePageView that language has been selected.
LanguagesPageView* language_delegate_;
- std::wstring accept_language_selected_;
+ std::string accept_language_selected_;
// Combobox and its corresponding model.
scoped_ptr<LanguageComboboxModel> accept_language_combobox_model_;
@@ -225,7 +224,7 @@ class AddLanguageWindowView : public views::View,
// The Profile associated with this window.
Profile* profile_;
- DISALLOW_EVIL_CONSTRUCTORS(AddLanguageWindowView);
+ DISALLOW_COPY_AND_ASSIGN(AddLanguageWindowView);
};
static const int kDialogPadding = 7;
@@ -288,7 +287,7 @@ void AddLanguageWindowView::ViewHierarchyChanged(bool is_add,
void AddLanguageWindowView::Init() {
// Determine Locale Codes.
- std::vector<std::wstring> locale_codes;
+ std::vector<std::string> locale_codes;
const std::wstring app_locale = g_browser_process->GetApplicationLocale();
for (size_t i = 0; i < arraysize(accept_language_list); ++i) {
std::wstring local_name =
@@ -298,8 +297,10 @@ void AddLanguageWindowView::Init() {
// In that case, we skip it.
// TODO(jungshik) : Put them at the of the list with language codes
// enclosed by brackets.
- if (local_name != accept_language_list[i])
- locale_codes.push_back(accept_language_list[i]);
+ if (IsStringASCII(local_name) &&
+ WideToASCII(local_name) == accept_language_list[i])
+ continue;
+ locale_codes.push_back(accept_language_list[i]);
}
accept_language_combobox_model_.reset(new LanguageComboboxModel(
profile_, locale_codes));
@@ -315,17 +316,17 @@ class LanguageOrderTableModel : public views::TableModel {
LanguageOrderTableModel();
// Set Language List.
- void SetAcceptLanguagesString(const std::wstring& language_list);
+ void SetAcceptLanguagesString(const std::string& language_list);
// Add at the end.
- void Add(const std::wstring& language);
+ void Add(const std::string& language);
// Removes the entry at the specified index.
void Remove(int index);
// Returns index corresponding to a given language. Returns -1 if the
// language is not found.
- int GetIndex(const std::wstring& language);
+ int GetIndex(const std::string& language);
// Move down the entry at the specified index.
void MoveDown(int index);
@@ -334,7 +335,7 @@ class LanguageOrderTableModel : public views::TableModel {
void MoveUp(int index);
// Returns the set of languagess this model contains.
- std::wstring GetLanguageList() { return VectorToList(languages_); }
+ std::string GetLanguageList() { return VectorToList(languages_); }
// views::TableModel overrides:
virtual int RowCount();
@@ -343,19 +344,19 @@ class LanguageOrderTableModel : public views::TableModel {
private:
// This method converts a comma separated list to a vector of strings.
- void ListToVector(const std::wstring& list,
- std::vector<std::wstring>* vector);
+ void ListToVector(const std::string& list,
+ std::vector<std::string>* vector);
// This method returns a comma separated string given a string vector.
- std::wstring VectorToList(const std::vector<std::wstring>& vector);
+ std::string VectorToList(const std::vector<std::string>& vector);
// Set of entries we're showing.
- std::vector<std::wstring> languages_;
- std::wstring comma_separated_language_list_;
+ std::vector<std::string> languages_;
+ std::string comma_separated_language_list_;
views::TableModelObserver* observer_;
- DISALLOW_EVIL_CONSTRUCTORS(LanguageOrderTableModel);
+ DISALLOW_COPY_AND_ASSIGN(LanguageOrderTableModel);
};
LanguageOrderTableModel::LanguageOrderTableModel()
@@ -363,8 +364,8 @@ LanguageOrderTableModel::LanguageOrderTableModel()
}
void LanguageOrderTableModel::SetAcceptLanguagesString(
- const std::wstring& language_list) {
- std::vector<std::wstring> languages_vector;
+ const std::string& language_list) {
+ std::vector<std::string> languages_vector;
ListToVector(language_list, &languages_vector);
for (int i = 0; i < static_cast<int>(languages_vector.size()); i++) {
Add(languages_vector.at(i));
@@ -382,11 +383,11 @@ std::wstring LanguageOrderTableModel::GetText(int row, int column_id) {
return l10n_util::GetLocalName(languages_.at(row), app_locale, true);
}
-void LanguageOrderTableModel::Add(const std::wstring& language) {
+void LanguageOrderTableModel::Add(const std::string& language) {
if (language.empty())
return;
// Check for selecting duplicated language.
- for (std::vector<std::wstring>::const_iterator cit = languages_.begin();
+ for (std::vector<std::string>::const_iterator cit = languages_.begin();
cit != languages_.end(); ++cit)
if (*cit == language)
return;
@@ -402,12 +403,12 @@ void LanguageOrderTableModel::Remove(int index) {
observer_->OnItemsRemoved(index, 1);
}
-int LanguageOrderTableModel::GetIndex(const std::wstring& language) {
+int LanguageOrderTableModel::GetIndex(const std::string& language) {
if (language.empty())
return -1;
int index = 0;
- for (std::vector<std::wstring>::const_iterator cit = languages_.begin();
+ for (std::vector<std::string>::const_iterator cit = languages_.begin();
cit != languages_.end(); ++cit) {
if (*cit == language)
return index;
@@ -421,7 +422,7 @@ int LanguageOrderTableModel::GetIndex(const std::wstring& language) {
void LanguageOrderTableModel::MoveDown(int index) {
if (index < 0 || index >= RowCount() - 1)
return;
- std::wstring item = languages_.at(index);
+ std::string item = languages_.at(index);
languages_.erase(languages_.begin() + index);
if (index == RowCount() - 1)
languages_.push_back(item);
@@ -434,7 +435,7 @@ void LanguageOrderTableModel::MoveDown(int index) {
void LanguageOrderTableModel::MoveUp(int index) {
if (index <= 0 || index >= static_cast<int>(languages_.size()))
return;
- std::wstring item = languages_.at(index);
+ std::string item = languages_.at(index);
languages_.erase(languages_.begin() + index);
languages_.insert(languages_.begin() + index - 1, item);
if (observer_)
@@ -445,14 +446,14 @@ int LanguageOrderTableModel::RowCount() {
return static_cast<int>(languages_.size());
}
-void LanguageOrderTableModel::ListToVector(const std::wstring& list,
- std::vector<std::wstring>* vector) {
- SplitString(list, L',', vector);
+void LanguageOrderTableModel::ListToVector(const std::string& list,
+ std::vector<std::string>* vector) {
+ SplitString(list, ',', vector);
}
-std::wstring LanguageOrderTableModel::VectorToList(
- const std::vector<std::wstring>& vector) {
- std::wstring list;
+std::string LanguageOrderTableModel::VectorToList(
+ const std::vector<std::string>& vector) {
+ std::string list;
for (int i = 0 ; i < static_cast<int>(vector.size()) ; i++) {
list += vector.at(i);
if (i != vector.size() - 1)
@@ -517,7 +518,7 @@ void LanguagesPageView::ButtonPressed(views::Button* sender) {
}
}
-void LanguagesPageView::OnAddLanguage(const std::wstring& new_language) {
+void LanguagesPageView::OnAddLanguage(const std::string& new_language) {
language_order_table_model_->Add(new_language);
language_order_table_->Select(language_order_table_model_->RowCount() - 1);
OnSelectionChanged();
@@ -675,7 +676,7 @@ void LanguagesPageView::InitControlLayout() {
void LanguagesPageView::NotifyPrefChanged(const std::wstring* pref_name) {
if (!pref_name || *pref_name == prefs::kAcceptLanguages) {
language_order_table_model_->SetAcceptLanguagesString(
- accept_languages_.GetValue());
+ WideToASCII(accept_languages_.GetValue()));
}
if (!pref_name || *pref_name == prefs::kApplicationLocale) {
int index = ui_language_model_->GetSelectedLanguageIndex(
@@ -684,7 +685,7 @@ void LanguagesPageView::NotifyPrefChanged(const std::wstring* pref_name) {
// The pref value for locale isn't valid. Use the current app locale
// (which is what we're currently using).
index = ui_language_model_->GetIndexFromLocale(
- g_browser_process->GetApplicationLocale());
+ WideToASCII(g_browser_process->GetApplicationLocale()));
}
DCHECK(-1 != index);
change_ui_language_combobox_->SetSelectedItem(index);
@@ -712,11 +713,10 @@ void LanguagesPageView::NotifyPrefChanged(const std::wstring* pref_name) {
local_state = profile()->GetPrefs();
DCHECK(local_state);
- const std::wstring& lang_region = local_state->GetString(
- prefs::kSpellCheckDictionary);
+ const std::string& lang_region = WideToASCII(
+ local_state->GetString(prefs::kSpellCheckDictionary));
dictionary_language_.SetValue(ASCIIToWide(
- SpellChecker::GetLanguageFromLanguageRegion(
- WideToASCII(lang_region))));
+ SpellChecker::GetLanguageFromLanguageRegion(lang_region)));
index = dictionary_language_model_->GetSelectedLanguageIndex(
prefs::kSpellCheckDictionary);
}
@@ -760,7 +760,7 @@ void LanguagesPageView::ItemChanged(views::ComboBox* sender,
// Add this new spell check language only if it is not already in the
// accept language list.
- std::wstring language =
+ std::string language =
dictionary_language_model_->GetLocaleFromIndex(new_index);
int index = language_order_table_model_->GetIndex(language);
if (index == -1) {
@@ -769,7 +769,7 @@ void LanguagesPageView::ItemChanged(views::ComboBox* sender,
language_table_edited_ = true;
spellcheck_language_added_ = language;
} else {
- spellcheck_language_added_ = L"";
+ spellcheck_language_added_ = "";
}
}
}
@@ -821,14 +821,16 @@ void LanguagesPageView::OnMoveUpLanguage() {
}
void LanguagesPageView::SaveChanges() {
- if (language_order_table_model_.get() && language_table_edited_)
- accept_languages_.SetValue(language_order_table_model_->GetLanguageList());
+ if (language_order_table_model_.get() && language_table_edited_) {
+ accept_languages_.SetValue(ASCIIToWide(
+ language_order_table_model_->GetLanguageList()));
+ }
if (ui_language_index_selected_ != -1) {
UserMetricsRecordAction(L"Options_AppLanguage",
g_browser_process->local_state());
- app_locale_.SetValue(ui_language_model_->
- GetLocaleFromIndex(ui_language_index_selected_));
+ app_locale_.SetValue(ASCIIToWide(ui_language_model_->
+ GetLocaleFromIndex(ui_language_index_selected_)));
// Remove pref values for spellcheck dictionaries forcefully.
PrefService* prefs = profile()->GetPrefs();
@@ -839,7 +841,7 @@ void LanguagesPageView::SaveChanges() {
if (spellcheck_language_index_selected_ != -1) {
UserMetricsRecordAction(L"Options_DictionaryLanguage",
profile()->GetPrefs());
- dictionary_language_.SetValue(dictionary_language_model_->
- GetLocaleFromIndex(spellcheck_language_index_selected_));
+ dictionary_language_.SetValue(ASCIIToWide(dictionary_language_model_->
+ GetLocaleFromIndex(spellcheck_language_index_selected_)));
}
}
diff --git a/chrome/browser/views/options/languages_page_view.h b/chrome/browser/views/options/languages_page_view.h
index f9f6def..9d1b7ff 100644
--- a/chrome/browser/views/options/languages_page_view.h
+++ b/chrome/browser/views/options/languages_page_view.h
@@ -46,7 +46,7 @@ class LanguagesPageView : public OptionsPageView,
// This is public because when user clicks OK in AddLanguageView dialog,
// this is called back in the LanguagePageView delegate in order to add
// this language to the table model in this tab.
- void OnAddLanguage(const std::wstring& new_language);
+ void OnAddLanguage(const std::string& new_language);
protected:
// OptionsPageView implementation:
@@ -101,7 +101,7 @@ class LanguagesPageView : public OptionsPageView,
// This is assigned the new index of spellcheck language if the language
// is changed. Otherwise, it remains -1, and pref members are not updated.
int spellcheck_language_index_selected_;
- std::wstring spellcheck_language_added_;
+ std::string spellcheck_language_added_;
bool language_table_edited_;
bool language_warning_shown_;
diff --git a/chrome/common/l10n_util.cc b/chrome/common/l10n_util.cc
index 5f02b1c..c182c4e 100644
--- a/chrome/common/l10n_util.cc
+++ b/chrome/common/l10n_util.cc
@@ -261,10 +261,9 @@ std::wstring GetApplicationLocale(const std::wstring& pref_locale) {
#endif
}
-std::wstring GetLocalName(const std::wstring& locale_code_wstr,
+std::wstring GetLocalName(const std::string& locale_code_str,
const std::wstring& app_locale_wstr,
bool is_for_ui) {
- std::string locale_code_str = WideToASCII(locale_code_wstr);
const std::string app_locale = WideToASCII(app_locale_wstr);
const char* locale_code = locale_code_str.c_str();
UErrorCode error = U_ZERO_ERROR;
@@ -654,8 +653,8 @@ void SortStrings(const std::wstring& locale,
SortVectorWithStringKey(locale, strings, false);
}
-const std::vector<std::wstring>& GetAvailableLocales() {
- static std::vector<std::wstring> locales;
+const std::vector<std::string>& GetAvailableLocales() {
+ static std::vector<std::string> locales;
if (locales.empty()) {
int num_locales = uloc_countAvailable();
for (int i = 0; i < num_locales; ++i) {
@@ -673,11 +672,11 @@ const std::vector<std::wstring>& GetAvailableLocales() {
} else if (LowerCaseEqualsASCII(locale_name, "zh-hant")) {
locale_name = "zh-TW";
}
- locales.push_back(ASCIIToWide(locale_name));
+ locales.push_back(locale_name);
}
// Manually add 'es-419' to the list. See the comment in IsDuplicateName().
- locales.push_back(L"es-419");
+ locales.push_back("es-419");
}
return locales;
}
diff --git a/chrome/common/l10n_util.h b/chrome/common/l10n_util.h
index 676c691..97c3171 100644
--- a/chrome/common/l10n_util.h
+++ b/chrome/common/l10n_util.h
@@ -55,7 +55,7 @@ std::wstring GetApplicationLocale(const std::wstring& pref_locale);
// GetApplicationLocale();
// If |is_for_ui| is true, U+200F is appended so that it can be
// rendered properly in a RTL Chrome.
-std::wstring GetLocalName(const std::wstring& locale_code_wstr,
+std::wstring GetLocalName(const std::string& locale_code_str,
const std::wstring& app_locale_wstr,
bool is_for_ui);
@@ -318,7 +318,7 @@ void SortStrings(const std::wstring& locale,
// Returns a vector of available locale codes. E.g., a vector containing
// en-US, es, fr, fi, pt-PT, pt-BR, etc.
-const std::vector<std::wstring>& GetAvailableLocales();
+const std::vector<std::string>& GetAvailableLocales();
// A simple wrapper class for the bidirectional iterator of ICU.
// This class uses the bidirectional iterator of ICU to split a line of