Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(639)

Side by Side Diff: chrome/browser/resources/settings/search_page/search_page.js

Issue 2804593003: MD Settings: Search engine: Request hotword info on engine change (Closed)
Patch Set: Fix tests Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/test/data/webui/settings/search_page_test.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
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 });
OLDNEW
« no previous file with comments | « no previous file | chrome/test/data/webui/settings/search_page_test.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698