OLD | NEW |
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 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 * @param {string} languageCode | 297 * @param {string} languageCode |
298 */ | 298 */ |
299 setUILanguage: function(languageCode) { | 299 setUILanguage: function(languageCode) { |
300 chrome.send('setUILanguage', [languageCode]); | 300 chrome.send('setUILanguage', [languageCode]); |
301 }, | 301 }, |
302 | 302 |
303 /** Resets the prospective UI language back to the actual UI language. */ | 303 /** Resets the prospective UI language back to the actual UI language. */ |
304 resetUILanguage: function() { | 304 resetUILanguage: function() { |
305 chrome.send('setUILanguage', [navigator.language]); | 305 chrome.send('setUILanguage', [navigator.language]); |
306 }, | 306 }, |
| 307 </if> |
307 | 308 |
308 /** | 309 /** |
309 * Returns the "prospective" UI language, i.e. the one to be used on next | 310 * Returns the "prospective" UI language, i.e. the one to be used on next |
310 * restart. If the pref is not set, the current UI language is also the | 311 * restart. If the pref is not set, the current UI language is also the |
311 * "prospective" language. | 312 * "prospective" language. |
312 * @return {string} Language code of the prospective UI language. | 313 * @return {string} Language code of the prospective UI language. |
313 */ | 314 */ |
314 getProspectiveUILanguage: function() { | 315 getProspectiveUILanguage: function() { |
315 return /** @type {string} */(this.getPref('intl.app_locale').value) || | 316 return /** @type {string} */(this.getPref('intl.app_locale').value) || |
316 navigator.language; | 317 navigator.language; |
317 }, | 318 }, |
318 </if> | |
319 | 319 |
320 /** | 320 /** |
321 * @param {string} languageCode | 321 * @param {string} languageCode |
322 * @return {boolean} True if the language is enabled. | 322 * @return {boolean} True if the language is enabled. |
323 */ | 323 */ |
324 isLanguageEnabled: function(languageCode) { | 324 isLanguageEnabled: function(languageCode) { |
325 return !!this.enabledLanguageMap_[languageCode]; | 325 return !!this.enabledLanguageMap_[languageCode]; |
326 }, | 326 }, |
327 | 327 |
328 /** | 328 /** |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
508 * manually sending a change notification for our 'languages' property (since | 508 * manually sending a change notification for our 'languages' property (since |
509 * it's the same object as the singleton's property, but isn't bound by | 509 * it's the same object as the singleton's property, but isn't bound by |
510 * Polymer). | 510 * Polymer). |
511 * @private | 511 * @private |
512 */ | 512 */ |
513 singletonLanguagesChanged_: function(e) { | 513 singletonLanguagesChanged_: function(e) { |
514 // Forward the change notification to the host. | 514 // Forward the change notification to the host. |
515 this.fire(e.type, e.detail, {bubbles: false}); | 515 this.fire(e.type, e.detail, {bubbles: false}); |
516 }, | 516 }, |
517 }); | 517 }); |
OLD | NEW |