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

Unified Diff: chrome/browser/resources/options/language_list.js

Issue 23923007: Bug fix: Append a language to the list after blocking it for Translate on Chrome OS (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nits Created 7 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/options/language_list.js
diff --git a/chrome/browser/resources/options/language_list.js b/chrome/browser/resources/options/language_list.js
index 6d5817a60532ef44bf772aa5ea66edab718139a0..d4ea5bd4f220641a5ed749b14bcaa4989f67a789 100644
--- a/chrome/browser/resources/options/language_list.js
+++ b/chrome/browser/resources/options/language_list.js
@@ -407,46 +407,11 @@ cr.define('options', function() {
* Saves the preference.
*/
savePreference_: function() {
- // Encode the language codes into a CSV string.
- if (cr.isChromeOS)
- Preferences.setStringPref(this.preferredLanguagesPref,
- this.dataModel.slice().join(','), true);
- // Save the same language list as accept languages preference as
- // well, but we need to expand the language list, to make it more
- // acceptable. For instance, some web sites don't understand 'en-US'
- // but 'en'. See crosbug.com/9884.
- var acceptLanguages = this.expandLanguageCodes(this.dataModel.slice());
- Preferences.setStringPref(this.acceptLanguagesPref,
- acceptLanguages.join(','), true);
+ chrome.send('updateLanguageList', [this.dataModel.slice()]);
cr.dispatchSimpleEvent(this, 'save');
},
/**
- * Expands language codes to make these more suitable for Accept-Language.
- * Example: ['en-US', 'ja', 'en-CA'] => ['en-US', 'en', 'ja', 'en-CA'].
- * 'en' won't appear twice as this function eliminates duplicates.
- * @param {Array} languageCodes List of language codes.
- * @private
- */
- expandLanguageCodes: function(languageCodes) {
- var expandedLanguageCodes = [];
- var seen = {}; // Used to eliminiate duplicates.
- for (var i = 0; i < languageCodes.length; i++) {
- var languageCode = languageCodes[i];
- if (!(languageCode in seen)) {
- expandedLanguageCodes.push(languageCode);
- seen[languageCode] = true;
- }
- var parts = languageCode.split('-');
- if (!(parts[0] in seen)) {
- expandedLanguageCodes.push(parts[0]);
- seen[parts[0]] = true;
- }
- }
- return expandedLanguageCodes;
- },
-
- /**
* Filters bad language codes in case bad language codes are
* stored in the preference. Removes duplicates as well.
* @param {Array} languageCodes List of language codes.

Powered by Google App Engine
This is Rietveld 408576698