Chromium Code Reviews| 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 18 matching lines...) Expand all Loading... | |
| 29 hotwordInfo_: Object, | 29 hotwordInfo_: Object, |
| 30 | 30 |
| 31 /** | 31 /** |
| 32 * This is a local PrefObject used to reflect the enabled state of hotword | 32 * This is a local PrefObject used to reflect the enabled state of hotword |
| 33 * search. It is not tied directly to a pref. (There are two prefs | 33 * search. It is not tied directly to a pref. (There are two prefs |
| 34 * associated with state and they do not map directly to whether or not | 34 * associated with state and they do not map directly to whether or not |
| 35 * hotword search is actually enabled). | 35 * hotword search is actually enabled). |
| 36 * @private {!chrome.settingsPrivate.PrefObject|undefined} | 36 * @private {!chrome.settingsPrivate.PrefObject|undefined} |
| 37 */ | 37 */ |
| 38 hotwordSearchEnablePref_: Object, | 38 hotwordSearchEnablePref_: Object, |
| 39 | |
| 40 /** @private {boolean} */ | |
|
stevenjb
2016/12/14 18:16:06
nit: {boolean} is not needed for Polymer Boolean p
fukino
2016/12/15 04:20:41
Done.
| |
| 41 googleNowAvailable_: Boolean, | |
| 39 }, | 42 }, |
| 40 | 43 |
| 41 /** @private {?settings.SearchEnginesBrowserProxy} */ | 44 /** @private {?settings.SearchEnginesBrowserProxy} */ |
| 42 browserProxy_: null, | 45 browserProxy_: null, |
| 43 | 46 |
| 44 /** @override */ | 47 /** @override */ |
| 45 created: function() { | 48 created: function() { |
| 46 this.browserProxy_ = settings.SearchEnginesBrowserProxyImpl.getInstance(); | 49 this.browserProxy_ = settings.SearchEnginesBrowserProxyImpl.getInstance(); |
| 47 }, | 50 }, |
| 48 | 51 |
| 49 /** @override */ | 52 /** @override */ |
| 50 ready: function() { | 53 ready: function() { |
| 51 // Omnibox search engine | 54 // Omnibox search engine |
| 52 var updateSearchEngines = function(searchEngines) { | 55 var updateSearchEngines = function(searchEngines) { |
| 53 this.set('searchEngines_', searchEngines.defaults); | 56 this.set('searchEngines_', searchEngines.defaults); |
| 54 }.bind(this); | 57 }.bind(this); |
| 55 this.browserProxy_.getSearchEnginesList().then(updateSearchEngines); | 58 this.browserProxy_.getSearchEnginesList().then(updateSearchEngines); |
| 56 cr.addWebUIListener('search-engines-changed', updateSearchEngines); | 59 cr.addWebUIListener('search-engines-changed', updateSearchEngines); |
| 57 | 60 |
| 58 // Hotword (OK Google) | 61 // Hotword (OK Google) |
| 59 cr.addWebUIListener( | 62 cr.addWebUIListener( |
| 60 'hotword-info-update', this.hotwordInfoUpdate_.bind(this)); | 63 'hotword-info-update', this.hotwordInfoUpdate_.bind(this)); |
| 61 this.browserProxy_.getHotwordInfo().then(function(hotwordInfo) { | 64 this.browserProxy_.getHotwordInfo().then(function(hotwordInfo) { |
| 62 this.hotwordInfoUpdate_(hotwordInfo); | 65 this.hotwordInfoUpdate_(hotwordInfo); |
| 63 }.bind(this)); | 66 }.bind(this)); |
| 67 | |
| 68 // Google Now cards in the launcher | |
| 69 cr.addWebUIListener( | |
| 70 'google-now-availability-changed', | |
| 71 this.googleNowAvailabilityUpdate_.bind(this)); | |
| 72 this.browserProxy_.getGoogleNowAvailability().then(function(available) { | |
| 73 this.googleNowAvailabilityUpdate_(available); | |
| 74 }.bind(this)); | |
| 64 }, | 75 }, |
| 65 | 76 |
| 66 /** @private */ | 77 /** @private */ |
| 67 onChange_: function() { | 78 onChange_: function() { |
| 68 var select = /** @type {!HTMLSelectElement} */ (this.$$('select')); | 79 var select = /** @type {!HTMLSelectElement} */ (this.$$('select')); |
| 69 var searchEngine = this.searchEngines_[select.selectedIndex]; | 80 var searchEngine = this.searchEngines_[select.selectedIndex]; |
| 70 this.browserProxy_.setDefaultSearchEngine(searchEngine.modelIndex); | 81 this.browserProxy_.setDefaultSearchEngine(searchEngine.modelIndex); |
| 71 }, | 82 }, |
| 72 | 83 |
| 73 /** @private */ | 84 /** @private */ |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 97 hotwordInfoUpdate_: function(hotwordInfo) { | 108 hotwordInfoUpdate_: function(hotwordInfo) { |
| 98 this.hotwordInfo_ = hotwordInfo; | 109 this.hotwordInfo_ = hotwordInfo; |
| 99 this.hotwordSearchEnablePref_ = { | 110 this.hotwordSearchEnablePref_ = { |
| 100 key: 'unused', // required for PrefObject | 111 key: 'unused', // required for PrefObject |
| 101 type: chrome.settingsPrivate.PrefType.BOOLEAN, | 112 type: chrome.settingsPrivate.PrefType.BOOLEAN, |
| 102 value: this.hotwordInfo_.enabled, | 113 value: this.hotwordInfo_.enabled, |
| 103 }; | 114 }; |
| 104 }, | 115 }, |
| 105 | 116 |
| 106 /** | 117 /** |
| 118 * @param {boolean} available | |
| 119 * @private | |
| 120 */ | |
| 121 googleNowAvailabilityUpdate_: function(available) { | |
| 122 this.googleNowAvailable_ = available; | |
| 123 }, | |
| 124 | |
| 125 /** | |
| 107 * @return {string} | 126 * @return {string} |
| 108 * @private | 127 * @private |
| 109 */ | 128 */ |
| 110 getHotwordSearchEnableSubLabel_: function() { | 129 getHotwordSearchEnableSubLabel_: function() { |
| 111 return this.i18n( | 130 return this.i18n( |
| 112 this.hotwordInfo_.alwaysOn ? 'searchOkGoogleSubtextAlwaysOn' : | 131 this.hotwordInfo_.alwaysOn ? 'searchOkGoogleSubtextAlwaysOn' : |
| 113 'searchOkGoogleSubtextNoHardware'); | 132 'searchOkGoogleSubtextNoHardware'); |
| 114 }, | 133 }, |
| 115 | 134 |
| 116 /** | 135 /** |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 141 }, | 160 }, |
| 142 | 161 |
| 143 /** | 162 /** |
| 144 * @param {Event} event | 163 * @param {Event} event |
| 145 * @private | 164 * @private |
| 146 */ | 165 */ |
| 147 doNothing_: function(event) { | 166 doNothing_: function(event) { |
| 148 event.stopPropagation(); | 167 event.stopPropagation(); |
| 149 } | 168 } |
| 150 }); | 169 }); |
| OLD | NEW |