| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 A helper object used from the languages section | 6 * @fileoverview A helper object used from the languages section |
| 7 * to interact with the browser. | 7 * to interact with the browser. |
| 8 */ | 8 */ |
| 9 | 9 |
| 10 cr.define('settings', function() { | 10 cr.define('settings', function() { |
| 11 /** @interface */ | 11 /** @interface */ |
| 12 function LanguagesBrowserProxy() {} | 12 class LanguagesBrowserProxy { |
| 13 | |
| 14 LanguagesBrowserProxy.prototype = { | |
| 15 // <if expr="chromeos or is_win"> | 13 // <if expr="chromeos or is_win"> |
| 16 /** | 14 /** |
| 17 * Sets the prospective UI language to the chosen language. This won't | 15 * Sets the prospective UI language to the chosen language. This won't |
| 18 * affect the actual UI language until a restart. | 16 * affect the actual UI language until a restart. |
| 19 * @param {string} languageCode | 17 * @param {string} languageCode |
| 20 */ | 18 */ |
| 21 setProspectiveUILanguage: function(languageCode) {}, | 19 setProspectiveUILanguage(languageCode) {} |
| 22 | 20 |
| 23 /** @return {!Promise<string>} */ | 21 /** @return {!Promise<string>} */ |
| 24 getProspectiveUILanguage: function() {}, | 22 getProspectiveUILanguage() {} |
| 23 |
| 25 // </if> | 24 // </if> |
| 26 | 25 |
| 27 /** @return {!LanguageSettingsPrivate} */ | 26 /** @return {!LanguageSettingsPrivate} */ |
| 28 getLanguageSettingsPrivate: function() {}, | 27 getLanguageSettingsPrivate() {} |
| 29 | 28 |
| 30 // <if expr="chromeos"> | 29 // <if expr="chromeos"> |
| 31 /** @return {!InputMethodPrivate} */ | 30 /** @return {!InputMethodPrivate} */ |
| 32 getInputMethodPrivate: function() {}, | 31 getInputMethodPrivate() {} |
| 33 // </if> | 32 // </if> |
| 34 }; | 33 } |
| 35 | 34 |
| 36 /** | 35 /** |
| 37 * @constructor | |
| 38 * @implements {settings.LanguagesBrowserProxy} | 36 * @implements {settings.LanguagesBrowserProxy} |
| 39 */ | 37 */ |
| 40 function LanguagesBrowserProxyImpl() {} | 38 class LanguagesBrowserProxyImpl { |
| 39 // <if expr="chromeos or is_win"> |
| 40 /** @override */ |
| 41 setProspectiveUILanguage(languageCode) { |
| 42 chrome.send('setProspectiveUILanguage', [languageCode]); |
| 43 } |
| 44 |
| 45 /** @override */ |
| 46 getProspectiveUILanguage() { |
| 47 return cr.sendWithPromise('getProspectiveUILanguage'); |
| 48 } |
| 49 |
| 50 // </if> |
| 51 |
| 52 /** @override */ |
| 53 getLanguageSettingsPrivate() { |
| 54 return /** @type {!LanguageSettingsPrivate} */ ( |
| 55 chrome.languageSettingsPrivate); |
| 56 } |
| 57 |
| 58 // <if expr="chromeos"> |
| 59 /** @override */ |
| 60 getInputMethodPrivate() { |
| 61 return /** @type {!InputMethodPrivate} */ (chrome.inputMethodPrivate); |
| 62 } |
| 63 // </if> |
| 64 } |
| 65 |
| 41 // The singleton instance_ is replaced with a test version of this wrapper | 66 // The singleton instance_ is replaced with a test version of this wrapper |
| 42 // during testing. | 67 // during testing. |
| 43 cr.addSingletonGetter(LanguagesBrowserProxyImpl); | 68 cr.addSingletonGetter(LanguagesBrowserProxyImpl); |
| 44 | 69 |
| 45 LanguagesBrowserProxyImpl.prototype = { | |
| 46 // <if expr="chromeos or is_win"> | |
| 47 /** @override */ | |
| 48 setProspectiveUILanguage: function(languageCode) { | |
| 49 chrome.send('setProspectiveUILanguage', [languageCode]); | |
| 50 }, | |
| 51 | |
| 52 /** @override */ | |
| 53 getProspectiveUILanguage: function() { | |
| 54 return cr.sendWithPromise('getProspectiveUILanguage'); | |
| 55 }, | |
| 56 // </if> | |
| 57 | |
| 58 /** @override */ | |
| 59 getLanguageSettingsPrivate: function() { | |
| 60 return /** @type {!LanguageSettingsPrivate} */ ( | |
| 61 chrome.languageSettingsPrivate); | |
| 62 }, | |
| 63 | |
| 64 // <if expr="chromeos"> | |
| 65 /** @override */ | |
| 66 getInputMethodPrivate: function() { | |
| 67 return /** @type {!InputMethodPrivate} */ (chrome.inputMethodPrivate); | |
| 68 }, | |
| 69 // </if> | |
| 70 }; | |
| 71 | |
| 72 return { | 70 return { |
| 73 LanguagesBrowserProxy: LanguagesBrowserProxy, | 71 LanguagesBrowserProxy: LanguagesBrowserProxy, |
| 74 LanguagesBrowserProxyImpl: LanguagesBrowserProxyImpl, | 72 LanguagesBrowserProxyImpl: LanguagesBrowserProxyImpl, |
| 75 }; | 73 }; |
| 76 }); | 74 }); |
| OLD | NEW |