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

Side by Side Diff: chrome/browser/resources/hotword/audio_client.js

Issue 2599923002: Run tools/clang-format-js on chrome/browser/resources/hotword/ (Closed)
Patch Set: no dep Created 3 years, 11 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 'use strict'; 5 'use strict';
6 6
7 /** 7 /**
8 * @fileoverview This is the audio client content script injected into eligible 8 * @fileoverview This is the audio client content script injected into eligible
9 * Google.com and New tab pages for interaction between the Webpage and the 9 * Google.com and New tab pages for interaction between the Webpage and the
10 * Hotword extension. 10 * Hotword extension.
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 * @private 126 * @private
127 */ 127 */
128 AudioClient.EXISTS_ = 'chwace'; 128 AudioClient.EXISTS_ = 'chwace';
129 129
130 /** 130 /**
131 * Checks for the presence of speech overlay UI DOM elements. 131 * Checks for the presence of speech overlay UI DOM elements.
132 * @private 132 * @private
133 */ 133 */
134 AudioClient.prototype.checkSpeechOverlayUi_ = function() { 134 AudioClient.prototype.checkSpeechOverlayUi_ = function() {
135 if (!this.speechOverlay_) { 135 if (!this.speechOverlay_) {
136 window.setTimeout(this.delayedCheckSpeechOverlayUi_.bind(this), 136 window.setTimeout(
137 AudioClient.RETRY_TIME_MS_); 137 this.delayedCheckSpeechOverlayUi_.bind(this),
138 AudioClient.RETRY_TIME_MS_);
138 } else { 139 } else {
139 this.checkSpeechUiRetries_ = 0; 140 this.checkSpeechUiRetries_ = 0;
140 } 141 }
141 }; 142 };
142 143
143 /** 144 /**
144 * Function called to check for the speech UI overlay after some time has 145 * Function called to check for the speech UI overlay after some time has
145 * passed since an initial check. Will either retry triggering the speech 146 * passed since an initial check. Will either retry triggering the speech
146 * or sends an error message depending on the number of retries. 147 * or sends an error message depending on the number of retries.
147 * @private 148 * @private
148 */ 149 */
149 AudioClient.prototype.delayedCheckSpeechOverlayUi_ = function() { 150 AudioClient.prototype.delayedCheckSpeechOverlayUi_ = function() {
150 this.speechOverlay_ = document.getElementById( 151 this.speechOverlay_ =
151 AudioClient.SPEECH_UI_OVERLAY_ID_); 152 document.getElementById(AudioClient.SPEECH_UI_OVERLAY_ID_);
152 if (!this.speechOverlay_) { 153 if (!this.speechOverlay_) {
153 if (this.checkSpeechUiRetries_++ < AudioClient.MAX_RETRIES) { 154 if (this.checkSpeechUiRetries_++ < AudioClient.MAX_RETRIES) {
154 this.sendCommandToPage_(AudioClient.CommandToPage.VOICE_TRIGGER); 155 this.sendCommandToPage_(AudioClient.CommandToPage.VOICE_TRIGGER);
155 this.checkSpeechOverlayUi_(); 156 this.checkSpeechOverlayUi_();
156 } else { 157 } else {
157 this.sendCommandToExtension_(AudioClient.Error.NO_SPEECH_UI); 158 this.sendCommandToExtension_(AudioClient.Error.NO_SPEECH_UI);
158 } 159 }
159 } else { 160 } else {
160 this.checkSpeechUiRetries_ = 0; 161 this.checkSpeechUiRetries_ = 0;
161 } 162 }
162 }; 163 };
163 164
164 /** 165 /**
165 * Checks that the triggered UI is actually displayed. 166 * Checks that the triggered UI is actually displayed.
166 * @param {AudioClient.CommandToPage} command Command that was send. 167 * @param {AudioClient.CommandToPage} command Command that was send.
167 * @private 168 * @private
168 */ 169 */
169 AudioClient.prototype.checkUi_ = function(command) { 170 AudioClient.prototype.checkUi_ = function(command) {
170 this.uiStatus_[command].timeoutId = 171 this.uiStatus_[command].timeoutId = window.setTimeout(
171 window.setTimeout(this.failedCheckUi_.bind(this, command), 172 this.failedCheckUi_.bind(this, command), AudioClient.RETRY_TIME_MS_);
172 AudioClient.RETRY_TIME_MS_);
173 }; 173 };
174 174
175 /** 175 /**
176 * Function called when the UI verification is not called in time. Will either 176 * Function called when the UI verification is not called in time. Will either
177 * retry the command or sends an error message, depending on the number of 177 * retry the command or sends an error message, depending on the number of
178 * retries for the command. 178 * retries for the command.
179 * @param {AudioClient.CommandToPage} command Command that was sent. 179 * @param {AudioClient.CommandToPage} command Command that was sent.
180 * @private 180 * @private
181 */ 181 */
182 AudioClient.prototype.failedCheckUi_ = function(command) { 182 AudioClient.prototype.failedCheckUi_ = function(command) {
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 // in most cases, the extension will receive SPEECH_RESET twice, one from 365 // in most cases, the extension will receive SPEECH_RESET twice, one from
366 // this sendCommandToExtension_ and the one forwarded from the page. But 366 // this sendCommandToExtension_ and the one forwarded from the page. But
367 // that's OK and the extension can handle it. 367 // that's OK and the extension can handle it.
368 this.sendCommandToExtension_(AudioClient.CommandFromPage.SPEECH_RESET); 368 this.sendCommandToExtension_(AudioClient.CommandFromPage.SPEECH_RESET);
369 } 369 }
370 }; 370 };
371 371
372 // Initializes as soon as the code is ready, do not wait for the page. 372 // Initializes as soon as the code is ready, do not wait for the page.
373 new AudioClient().initialize(); 373 new AudioClient().initialize();
374 })(); 374 })();
OLDNEW
« no previous file with comments | « chrome/browser/resources/hotword/always_on_manager.js ('k') | chrome/browser/resources/hotword/base_session_manager.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698