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 cr.define('options', function() { | 5 cr.define('options', function() { |
6 /** @const */ var ArrayDataModel = cr.ui.ArrayDataModel; | 6 /** @const */ var ArrayDataModel = cr.ui.ArrayDataModel; |
7 /** @const */ var DeletableItem = options.DeletableItem; | 7 /** @const */ var DeletableItem = options.DeletableItem; |
8 /** @const */ var DeletableItemList = options.DeletableItemList; | 8 /** @const */ var DeletableItemList = options.DeletableItemList; |
9 /** @const */ var List = cr.ui.List; | 9 /** @const */ var List = cr.ui.List; |
10 /** @const */ var ListItem = cr.ui.ListItem; | 10 /** @const */ var ListItem = cr.ui.ListItem; |
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 } | 396 } |
397 }, | 397 }, |
398 | 398 |
399 /** | 399 /** |
400 * Saves the preference. | 400 * Saves the preference. |
401 */ | 401 */ |
402 savePreference_: function() { | 402 savePreference_: function() { |
403 // Encode the language codes into a CSV string. | 403 // Encode the language codes into a CSV string. |
404 if (cr.isChromeOS) | 404 if (cr.isChromeOS) |
405 Preferences.setStringPref(this.preferredLanguagesPref, | 405 Preferences.setStringPref(this.preferredLanguagesPref, |
406 this.dataModel.slice().join(',')); | 406 this.dataModel.slice().join(','), |
| 407 true); |
407 // Save the same language list as accept languages preference as | 408 // Save the same language list as accept languages preference as |
408 // well, but we need to expand the language list, to make it more | 409 // well, but we need to expand the language list, to make it more |
409 // acceptable. For instance, some web sites don't understand 'en-US' | 410 // acceptable. For instance, some web sites don't understand 'en-US' |
410 // but 'en'. See crosbug.com/9884. | 411 // but 'en'. See crosbug.com/9884. |
411 var acceptLanguages = this.expandLanguageCodes(this.dataModel.slice()); | 412 var acceptLanguages = this.expandLanguageCodes(this.dataModel.slice()); |
412 Preferences.setStringPref(this.acceptLanguagesPref, | 413 Preferences.setStringPref(this.acceptLanguagesPref, |
413 acceptLanguages.join(',')); | 414 acceptLanguages.join(','), |
| 415 true); |
414 cr.dispatchSimpleEvent(this, 'save'); | 416 cr.dispatchSimpleEvent(this, 'save'); |
415 }, | 417 }, |
416 | 418 |
417 /** | 419 /** |
418 * Expands language codes to make these more suitable for Accept-Language. | 420 * Expands language codes to make these more suitable for Accept-Language. |
419 * Example: ['en-US', 'ja', 'en-CA'] => ['en-US', 'en', 'ja', 'en-CA']. | 421 * Example: ['en-US', 'ja', 'en-CA'] => ['en-US', 'en', 'ja', 'en-CA']. |
420 * 'en' won't appear twice as this function eliminates duplicates. | 422 * 'en' won't appear twice as this function eliminates duplicates. |
421 * @param {Array} languageCodes List of language codes. | 423 * @param {Array} languageCodes List of language codes. |
422 * @private | 424 * @private |
423 */ | 425 */ |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
459 } | 461 } |
460 return filteredLanguageCodes; | 462 return filteredLanguageCodes; |
461 }, | 463 }, |
462 }; | 464 }; |
463 | 465 |
464 return { | 466 return { |
465 LanguageList: LanguageList, | 467 LanguageList: LanguageList, |
466 LanguageListItem: LanguageListItem | 468 LanguageListItem: LanguageListItem |
467 }; | 469 }; |
468 }); | 470 }); |
OLD | NEW |