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

Side by Side Diff: chrome/browser/resources/settings/languages_page/languages.js

Issue 1372053002: Flesh out the location-page class to make it more general. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address feedback from Michael Created 5 years, 1 month 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 /** 5 /**
6 * @fileoverview 'settings-languages' provides convenient access to 6 * @fileoverview 'settings-languages' provides convenient access to
7 * Chrome's language and input method settings. 7 * Chrome's language and input method settings.
8 * 8 *
9 * Instances of this element have a 'languages' property, which reflects the 9 * Instances of this element have a 'languages' property, which reflects the
10 * current language settings. The 'languages' property is read-only, meaning 10 * current language settings. The 'languages' property is read-only, meaning
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 'settings.language.preferred_languages' : 'intl.accept_languages'; 183 'settings.language.preferred_languages' : 'intl.accept_languages';
184 184
185 /** 185 /**
186 * Singleton element created when settings-languages is registered. 186 * Singleton element created when settings-languages is registered.
187 * Generates the languages model on start-up, and updates it whenever Chrome's 187 * Generates the languages model on start-up, and updates it whenever Chrome's
188 * pref store and other settings change. These updates propagate to each 188 * pref store and other settings change. These updates propagate to each
189 * <settings-language> instance so that their 'languages' property updates 189 * <settings-language> instance so that their 'languages' property updates
190 * like any other Polymer property. 190 * like any other Polymer property.
191 */ 191 */
192 Polymer({ 192 Polymer({
193 is: 'settings-languages-singleton', 193 is: 'settings-languages-singleton',
Dan Beam 2015/10/29 21:10:39 nit: \n
Finnur 2015/10/30 12:13:46 Done.
194 behaviors: [PrefsBehavior],
194 195
195 properties: { 196 properties: {
196 /** 197 /**
197 * @type {LanguagesModel|undefined} 198 * @type {LanguagesModel|undefined}
198 */ 199 */
199 languages: { 200 languages: {
200 type: Object, 201 type: Object,
201 notify: true, 202 notify: true,
202 }, 203 },
203 204
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 for (var i = 0; i < this.languages.enabledLanguages.length; i++) { 399 for (var i = 0; i < this.languages.enabledLanguages.length; i++) {
399 var translateCode = this.convertLanguageCodeForTranslate( 400 var translateCode = this.convertLanguageCodeForTranslate(
400 this.languages.enabledLanguages[i].language.code); 401 this.languages.enabledLanguages[i].language.code);
401 this.set( 402 this.set(
402 'languages.enabledLanguages.' + i + '.state.translateEnabled', 403 'languages.enabledLanguages.' + i + '.state.translateEnabled',
403 !translateBlockedMap[translateCode]); 404 !translateBlockedMap[translateCode]);
404 } 405 }
405 }, 406 },
406 407
407 /** 408 /**
408 * Gets the pref at the given key. Asserts if the pref is not found.
409 * @param {string} key
410 * @return {!chrome.settingsPrivate.PrefObject}
411 */
412 getPref_: function(key) {
413 var pref = /** @type {!chrome.settingsPrivate.PrefObject} */(
414 this.get(key, this.prefs));
415 assert(typeof pref != 'undefined', 'Pref is missing: ' + key);
416 return pref;
417 },
418
419 /**
420 * Sets the value of the pref at the given key. Asserts if the pref is not
421 * found.
422 * @param {string} key
423 * @param {*} value
424 */
425 setPrefValue_: function(key, value) {
426 this.getPref_(key);
427 this.set('prefs.' + key + '.value', value);
428 },
429
430 /**
431 * Deletes the given item from the pref at the given key if the item is found. 409 * Deletes the given item from the pref at the given key if the item is found.
432 * Asserts if the pref itself is not found or is not an Array type. 410 * Asserts if the pref itself is not found or is not an Array type.
433 * @param {string} key 411 * @param {string} key
434 * @param {*} item 412 * @param {*} item
435 */ 413 */
436 deletePrefItem_: function(key, item) { 414 deletePrefItem_: function(key, item) {
437 assert(this.getPref_(key).type == chrome.settingsPrivate.PrefType.LIST); 415 assert(this.getPref_(key).type == chrome.settingsPrivate.PrefType.LIST);
438 this.arrayDelete('prefs.' + key + '.value', item); 416 this.arrayDelete('prefs.' + key + '.value', item);
439 }, 417 },
440 418
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 // necessary as a language code for the Translate server. 556 // necessary as a language code for the Translate server.
579 return languageCode; 557 return languageCode;
580 } 558 }
581 if (main in kTranslateLanguageSynonyms) 559 if (main in kTranslateLanguageSynonyms)
582 return kTranslateLanguageSynonyms[main]; 560 return kTranslateLanguageSynonyms[main];
583 561
584 return main; 562 return main;
585 }, 563 },
586 }); 564 });
587 })(); 565 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698