OLD | NEW |
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 }; | 57 }; |
58 | 58 |
59 | 59 |
60 /** | 60 /** |
61 * Messages received from the page used to indicate voice search state. | 61 * Messages received from the page used to indicate voice search state. |
62 * @enum {string} | 62 * @enum {string} |
63 */ | 63 */ |
64 AudioClient.CommandFromPage = { | 64 AudioClient.CommandFromPage = { |
65 SPEECH_START: 'ss', | 65 SPEECH_START: 'ss', |
66 SPEECH_END: 'se', | 66 SPEECH_END: 'se', |
| 67 SPEECH_RESET: 'sr', |
67 SHOWING_HOTWORD_START: 'shs', | 68 SHOWING_HOTWORD_START: 'shs', |
68 SHOWING_ERROR_MESSAGE: 'sem', | 69 SHOWING_ERROR_MESSAGE: 'sem', |
69 SHOWING_TIMEOUT_MESSAGE: 'stm', | 70 SHOWING_TIMEOUT_MESSAGE: 'stm', |
70 CLICKED_RESUME: 'hcc', | 71 CLICKED_RESUME: 'hcc', |
71 CLICKED_RESTART: 'hcr', | 72 CLICKED_RESTART: 'hcr', |
72 CLICKED_DEBUG: 'hcd' | 73 CLICKED_DEBUG: 'hcd' |
73 }; | 74 }; |
74 | 75 |
75 | 76 |
76 /** | 77 /** |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 var command = messageEvent.data.type; | 281 var command = messageEvent.data.type; |
281 switch (command) { | 282 switch (command) { |
282 case AudioClient.CommandFromPage.SPEECH_START: | 283 case AudioClient.CommandFromPage.SPEECH_START: |
283 this.speechActive_ = true; | 284 this.speechActive_ = true; |
284 this.sendCommandToExtension_(command); | 285 this.sendCommandToExtension_(command); |
285 break; | 286 break; |
286 case AudioClient.CommandFromPage.SPEECH_END: | 287 case AudioClient.CommandFromPage.SPEECH_END: |
287 this.speechActive_ = false; | 288 this.speechActive_ = false; |
288 this.sendCommandToExtension_(command); | 289 this.sendCommandToExtension_(command); |
289 break; | 290 break; |
| 291 case AudioClient.CommandFromPage.SPEECH_RESET: |
| 292 this.speechActive_ = false; |
| 293 this.sendCommandToExtension_(command); |
| 294 break; |
290 case 'SPEECH_RESET': // Legacy, for embedded NTP. | 295 case 'SPEECH_RESET': // Legacy, for embedded NTP. |
291 this.speechActive_ = false; | 296 this.speechActive_ = false; |
292 this.sendCommandToExtension_(AudioClient.CommandFromPage.SPEECH_END); | 297 this.sendCommandToExtension_(AudioClient.CommandFromPage.SPEECH_END); |
293 break; | 298 break; |
294 case AudioClient.CommandFromPage.CLICKED_RESUME: | 299 case AudioClient.CommandFromPage.CLICKED_RESUME: |
295 this.sendCommandToExtension_(command); | 300 this.sendCommandToExtension_(command); |
296 break; | 301 break; |
297 case AudioClient.CommandFromPage.CLICKED_RESTART: | 302 case AudioClient.CommandFromPage.CLICKED_RESTART: |
298 this.sendCommandToExtension_(command); | 303 this.sendCommandToExtension_(command); |
299 break; | 304 break; |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 this.handleCommandFromExtension_.bind(this)); | 378 this.handleCommandFromExtension_.bind(this)); |
374 | 379 |
375 if (this.speechActive_) | 380 if (this.speechActive_) |
376 this.sendCommandToExtension_(AudioClient.CommandFromPage.SPEECH_START); | 381 this.sendCommandToExtension_(AudioClient.CommandFromPage.SPEECH_START); |
377 }; | 382 }; |
378 | 383 |
379 | 384 |
380 // Initializes as soon as the code is ready, do not wait for the page. | 385 // Initializes as soon as the code is ready, do not wait for the page. |
381 new AudioClient().initialize(); | 386 new AudioClient().initialize(); |
382 })(); | 387 })(); |
OLD | NEW |