| 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 4c70a30433cf313549cede562266954b265e04a7..9ef596a2ac5581443852f3914562104c165fd084 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: {
|
| /**
|
| * List of default search engines available.
|
| @@ -16,9 +18,23 @@ 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} */
|
| browserProxy_: Object,
|
| },
|
| @@ -30,11 +46,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 */
|
| @@ -48,4 +72,72 @@ Polymer({
|
| var searchEngine = this.searchEngines_[select.selectedIndex];
|
| this.browserProxy_.setDefaultSearchEngine(searchEngine.modelIndex);
|
| },
|
| +
|
| + /**
|
| + * @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' :
|
| + 'searchOkGoogleSubtextNoDsp');
|
| + },
|
| +
|
| + /**
|
| + * @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();
|
| + }
|
| });
|
|
|