| Index: chrome/browser/resources/settings/search_page/search_page.js
|
| diff --git a/chrome/browser/resources/settings/search_page/search_page.js b/chrome/browser/resources/settings/search_page/search_page.js
|
| index 328df5bd0351d400cb89a6eada3e760923e42281..675730ba1462de360a42d39015c8f52ea1397338 100644
|
| --- a/chrome/browser/resources/settings/search_page/search_page.js
|
| +++ b/chrome/browser/resources/settings/search_page/search_page.js
|
| @@ -9,6 +9,8 @@
|
| Polymer({
|
| is: 'settings-search-page',
|
|
|
| + behaviors: [I18nBehavior],
|
| +
|
| properties: {
|
| prefs: Object,
|
|
|
| @@ -18,8 +20,22 @@ Polymer({
|
| */
|
| searchEngines_: {
|
| type: Array,
|
| - value: function() { return []; }
|
| + value: function() {
|
| + return [];
|
| + }
|
| },
|
| +
|
| + /** @private {!SearchPageHotwordInfo|undefined} */
|
| + hotwordInfo_: Object,
|
| +
|
| + /**
|
| + * This is a local PrefObject used to reflect the enabled state of hotword
|
| + * search. It is not tied directly to a pref. (There are two prefs
|
| + * associated with state and they do not map directly to whether or not
|
| + * hotword search is actually enabled).
|
| + * @private {!chrome.settingsPrivate.PrefObject|undefined}
|
| + */
|
| + hotwordSearchEnablePref_: Object,
|
| },
|
|
|
| /** @private {?settings.SearchEnginesBrowserProxy} */
|
| @@ -32,11 +48,19 @@ Polymer({
|
|
|
| /** @override */
|
| ready: function() {
|
| + // Omnibox search engine
|
| var updateSearchEngines = function(searchEngines) {
|
| this.set('searchEngines_', searchEngines.defaults);
|
| }.bind(this);
|
| this.browserProxy_.getSearchEnginesList().then(updateSearchEngines);
|
| cr.addWebUIListener('search-engines-changed', updateSearchEngines);
|
| +
|
| + // Hotword (OK Google)
|
| + cr.addWebUIListener(
|
| + 'hotword-info-update', this.hotwordInfoUpdate_.bind(this));
|
| + this.browserProxy_.getHotwordInfo().then(function(hotwordInfo) {
|
| + this.hotwordInfoUpdate_(hotwordInfo);
|
| + }.bind(this));
|
| },
|
|
|
| /** @private */
|
| @@ -55,4 +79,72 @@ Polymer({
|
| onManageSearchEnginesTap_: function() {
|
| settings.navigateTo(settings.Route.SEARCH_ENGINES);
|
| },
|
| +
|
| + /**
|
| + * @param {Event} event
|
| + * @private
|
| + */
|
| + onHotwordSearchEnableChange_: function(event) {
|
| + // Do not set the pref directly, allow Chrome to run the setup app instead.
|
| + this.browserProxy_.setHotwordSearchEnabled(
|
| + !!this.hotwordSearchEnablePref_.value);
|
| + },
|
| +
|
| + /**
|
| + * @param {!SearchPageHotwordInfo} hotwordInfo
|
| + * @private
|
| + */
|
| + hotwordInfoUpdate_: function(hotwordInfo) {
|
| + this.hotwordInfo_ = hotwordInfo;
|
| + this.hotwordSearchEnablePref_ = {
|
| + key: 'unused', // required for PrefObject
|
| + type: chrome.settingsPrivate.PrefType.BOOLEAN,
|
| + value: this.hotwordInfo_.enabled,
|
| + };
|
| + },
|
| +
|
| + /**
|
| + * @return {string}
|
| + * @private
|
| + */
|
| + getHotwordSearchEnableSubLabel_: function() {
|
| + return this.i18n(
|
| + this.hotwordInfo_.alwaysOn ? 'searchOkGoogleSubtextAlwaysOn' :
|
| + 'searchOkGoogleSubtextNoHardware');
|
| + },
|
| +
|
| + /**
|
| + * @return {boolean}
|
| + * @private
|
| + */
|
| + getShowHotwordSearchRetrain_: function() {
|
| + return this.hotwordInfo_.enabled && this.hotwordInfo_.alwaysOn;
|
| + },
|
| +
|
| + /**
|
| + * @return {boolean} True if the pref is enabled but hotword is not.
|
| + * @private
|
| + */
|
| + getShowHotwordError_: function() {
|
| + return this.hotwordInfo_.enabled && !!this.hotwordInfo_.errorMessage;
|
| + },
|
| +
|
| + /** @private */
|
| + onRetrainTap_: function() {
|
| + // Re-enable hotword search enable; this will trigger the retrain UI.
|
| + this.browserProxy_.setHotwordSearchEnabled(this.hotwordInfo_.enabled);
|
| + },
|
| +
|
| + /** @private */
|
| + onManageAudioHistoryTap_: function() {
|
| + window.open(loadTimeData.getString('manageAudioHistoryUrl'));
|
| + },
|
| +
|
| + /**
|
| + * @param {Event} event
|
| + * @private
|
| + */
|
| + doNothing_: function(event) {
|
| + event.stopPropagation();
|
| + }
|
| });
|
|
|