| 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 | 6 * @fileoverview |
| 7 * 'settings-search-page' is the settings page containing search settings. | 7 * 'settings-search-page' is the settings page containing search settings. |
| 8 */ | 8 */ |
| 9 Polymer({ | 9 Polymer({ |
| 10 is: 'settings-search-page', | 10 is: 'settings-search-page', |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 /** @override */ | 47 /** @override */ |
| 48 created: function() { | 48 created: function() { |
| 49 this.browserProxy_ = settings.SearchEnginesBrowserProxyImpl.getInstance(); | 49 this.browserProxy_ = settings.SearchEnginesBrowserProxyImpl.getInstance(); |
| 50 }, | 50 }, |
| 51 | 51 |
| 52 /** @override */ | 52 /** @override */ |
| 53 ready: function() { | 53 ready: function() { |
| 54 // Omnibox search engine | 54 // Omnibox search engine |
| 55 var updateSearchEngines = function(searchEngines) { | 55 var updateSearchEngines = function(searchEngines) { |
| 56 this.set('searchEngines_', searchEngines.defaults); | 56 this.set('searchEngines_', searchEngines.defaults); |
| 57 this.requestHotwordInfoUpdate_(); |
| 57 }.bind(this); | 58 }.bind(this); |
| 58 this.browserProxy_.getSearchEnginesList().then(updateSearchEngines); | 59 this.browserProxy_.getSearchEnginesList().then(updateSearchEngines); |
| 59 cr.addWebUIListener('search-engines-changed', updateSearchEngines); | 60 cr.addWebUIListener('search-engines-changed', updateSearchEngines); |
| 60 | 61 |
| 61 // Hotword (OK Google) | 62 // Hotword (OK Google) listener |
| 62 cr.addWebUIListener( | 63 cr.addWebUIListener( |
| 63 'hotword-info-update', this.hotwordInfoUpdate_.bind(this)); | 64 'hotword-info-update', this.hotwordInfoUpdate_.bind(this)); |
| 64 this.browserProxy_.getHotwordInfo().then(function(hotwordInfo) { | |
| 65 this.hotwordInfoUpdate_(hotwordInfo); | |
| 66 }.bind(this)); | |
| 67 | 65 |
| 68 // Google Now cards in the launcher | 66 // Google Now cards in the launcher |
| 69 cr.addWebUIListener( | 67 cr.addWebUIListener( |
| 70 'google-now-availability-changed', | 68 'google-now-availability-changed', |
| 71 this.googleNowAvailabilityUpdate_.bind(this)); | 69 this.googleNowAvailabilityUpdate_.bind(this)); |
| 72 this.browserProxy_.getGoogleNowAvailability().then(function(available) { | 70 this.browserProxy_.getGoogleNowAvailability().then(function(available) { |
| 73 this.googleNowAvailabilityUpdate_(available); | 71 this.googleNowAvailabilityUpdate_(available); |
| 74 }.bind(this)); | 72 }.bind(this)); |
| 75 }, | 73 }, |
| 76 | 74 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 94 /** | 92 /** |
| 95 * @param {Event} event | 93 * @param {Event} event |
| 96 * @private | 94 * @private |
| 97 */ | 95 */ |
| 98 onHotwordSearchEnableChange_: function(event) { | 96 onHotwordSearchEnableChange_: function(event) { |
| 99 // Do not set the pref directly, allow Chrome to run the setup app instead. | 97 // Do not set the pref directly, allow Chrome to run the setup app instead. |
| 100 this.browserProxy_.setHotwordSearchEnabled( | 98 this.browserProxy_.setHotwordSearchEnabled( |
| 101 !!this.hotwordSearchEnablePref_.value); | 99 !!this.hotwordSearchEnablePref_.value); |
| 102 }, | 100 }, |
| 103 | 101 |
| 102 /** @private */ |
| 103 requestHotwordInfoUpdate_: function() { |
| 104 this.browserProxy_.getHotwordInfo().then(function(hotwordInfo) { |
| 105 this.hotwordInfoUpdate_(hotwordInfo); |
| 106 }.bind(this)); |
| 107 }, |
| 108 |
| 104 /** | 109 /** |
| 105 * @param {!SearchPageHotwordInfo} hotwordInfo | 110 * @param {!SearchPageHotwordInfo} hotwordInfo |
| 106 * @private | 111 * @private |
| 107 */ | 112 */ |
| 108 hotwordInfoUpdate_: function(hotwordInfo) { | 113 hotwordInfoUpdate_: function(hotwordInfo) { |
| 109 this.hotwordInfo_ = hotwordInfo; | 114 this.hotwordInfo_ = hotwordInfo; |
| 110 this.hotwordSearchEnablePref_ = { | 115 this.hotwordSearchEnablePref_ = { |
| 111 key: 'unused', // required for PrefObject | 116 key: 'unused', // required for PrefObject |
| 112 type: chrome.settingsPrivate.PrefType.BOOLEAN, | 117 type: chrome.settingsPrivate.PrefType.BOOLEAN, |
| 113 value: this.hotwordInfo_.enabled, | 118 value: this.hotwordInfo_.enabled, |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 }, | 165 }, |
| 161 | 166 |
| 162 /** | 167 /** |
| 163 * @param {Event} event | 168 * @param {Event} event |
| 164 * @private | 169 * @private |
| 165 */ | 170 */ |
| 166 doNothing_: function(event) { | 171 doNothing_: function(event) { |
| 167 event.stopPropagation(); | 172 event.stopPropagation(); |
| 168 } | 173 } |
| 169 }); | 174 }); |
| OLD | NEW |