| 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 browserProxy_: null, | 48 browserProxy_: null, |
| 49 | 49 |
| 50 /** @override */ | 50 /** @override */ |
| 51 created: function() { | 51 created: function() { |
| 52 this.browserProxy_ = settings.SearchEnginesBrowserProxyImpl.getInstance(); | 52 this.browserProxy_ = settings.SearchEnginesBrowserProxyImpl.getInstance(); |
| 53 }, | 53 }, |
| 54 | 54 |
| 55 /** @override */ | 55 /** @override */ |
| 56 ready: function() { | 56 ready: function() { |
| 57 // Omnibox search engine | 57 // Omnibox search engine |
| 58 var updateSearchEngines = function(searchEngines) { | 58 var updateSearchEngines = searchEngines => { |
| 59 this.set('searchEngines_', searchEngines.defaults); | 59 this.set('searchEngines_', searchEngines.defaults); |
| 60 this.requestHotwordInfoUpdate_(); | 60 this.requestHotwordInfoUpdate_(); |
| 61 }.bind(this); | 61 }; |
| 62 this.browserProxy_.getSearchEnginesList().then(updateSearchEngines); | 62 this.browserProxy_.getSearchEnginesList().then(updateSearchEngines); |
| 63 cr.addWebUIListener('search-engines-changed', updateSearchEngines); | 63 cr.addWebUIListener('search-engines-changed', updateSearchEngines); |
| 64 | 64 |
| 65 // Hotword (OK Google) listener | 65 // Hotword (OK Google) listener |
| 66 cr.addWebUIListener( | 66 cr.addWebUIListener( |
| 67 'hotword-info-update', this.hotwordInfoUpdate_.bind(this)); | 67 'hotword-info-update', this.hotwordInfoUpdate_.bind(this)); |
| 68 | 68 |
| 69 // Google Now cards in the launcher | 69 // Google Now cards in the launcher |
| 70 cr.addWebUIListener( | 70 cr.addWebUIListener( |
| 71 'google-now-availability-changed', | 71 'google-now-availability-changed', |
| 72 this.googleNowAvailabilityUpdate_.bind(this)); | 72 this.googleNowAvailabilityUpdate_.bind(this)); |
| 73 this.browserProxy_.getGoogleNowAvailability().then(function(available) { | 73 this.browserProxy_.getGoogleNowAvailability().then(available => { |
| 74 this.googleNowAvailabilityUpdate_(available); | 74 this.googleNowAvailabilityUpdate_(available); |
| 75 }.bind(this)); | 75 }); |
| 76 | 76 |
| 77 this.focusConfig_ = new Map(); | 77 this.focusConfig_ = new Map(); |
| 78 if (settings.routes.SEARCH_ENGINES) { | 78 if (settings.routes.SEARCH_ENGINES) { |
| 79 this.focusConfig_.set( | 79 this.focusConfig_.set( |
| 80 settings.routes.SEARCH_ENGINES.path, | 80 settings.routes.SEARCH_ENGINES.path, |
| 81 '#subpage-trigger .subpage-arrow'); | 81 '#subpage-trigger .subpage-arrow'); |
| 82 } | 82 } |
| 83 }, | 83 }, |
| 84 | 84 |
| 85 /** @private */ | 85 /** @private */ |
| (...skipping 18 matching lines...) Expand all Loading... |
| 104 * @private | 104 * @private |
| 105 */ | 105 */ |
| 106 onHotwordSearchEnableChange_: function(event) { | 106 onHotwordSearchEnableChange_: function(event) { |
| 107 // Do not set the pref directly, allow Chrome to run the setup app instead. | 107 // Do not set the pref directly, allow Chrome to run the setup app instead. |
| 108 this.browserProxy_.setHotwordSearchEnabled( | 108 this.browserProxy_.setHotwordSearchEnabled( |
| 109 !!this.hotwordSearchEnablePref_.value); | 109 !!this.hotwordSearchEnablePref_.value); |
| 110 }, | 110 }, |
| 111 | 111 |
| 112 /** @private */ | 112 /** @private */ |
| 113 requestHotwordInfoUpdate_: function() { | 113 requestHotwordInfoUpdate_: function() { |
| 114 this.browserProxy_.getHotwordInfo().then(function(hotwordInfo) { | 114 this.browserProxy_.getHotwordInfo().then(hotwordInfo => { |
| 115 this.hotwordInfoUpdate_(hotwordInfo); | 115 this.hotwordInfoUpdate_(hotwordInfo); |
| 116 }.bind(this)); | 116 }); |
| 117 }, | 117 }, |
| 118 | 118 |
| 119 /** | 119 /** |
| 120 * @param {!SearchPageHotwordInfo} hotwordInfo | 120 * @param {!SearchPageHotwordInfo} hotwordInfo |
| 121 * @private | 121 * @private |
| 122 */ | 122 */ |
| 123 hotwordInfoUpdate_: function(hotwordInfo) { | 123 hotwordInfoUpdate_: function(hotwordInfo) { |
| 124 this.hotwordInfo_ = hotwordInfo; | 124 this.hotwordInfo_ = hotwordInfo; |
| 125 this.hotwordSearchEnablePref_ = { | 125 this.hotwordSearchEnablePref_ = { |
| 126 key: 'unused', // required for PrefObject | 126 key: 'unused', // required for PrefObject |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 | 188 |
| 189 /** | 189 /** |
| 190 * @param {!chrome.settingsPrivate.PrefObject} pref | 190 * @param {!chrome.settingsPrivate.PrefObject} pref |
| 191 * @return {boolean} | 191 * @return {boolean} |
| 192 * @private | 192 * @private |
| 193 */ | 193 */ |
| 194 isDefaultSearchEngineEnforced_: function(pref) { | 194 isDefaultSearchEngineEnforced_: function(pref) { |
| 195 return pref.enforcement == chrome.settingsPrivate.Enforcement.ENFORCED; | 195 return pref.enforcement == chrome.settingsPrivate.Enforcement.ENFORCED; |
| 196 }, | 196 }, |
| 197 }); | 197 }); |
| OLD | NEW |