| OLD | NEW |
| 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 cr.define('hotword', function() { | 5 cr.define('hotword', function() { |
| 6 'use strict'; | 6 'use strict'; |
| 7 | 7 |
| 8 /** | 8 /** |
| 9 * Class used to manage the interaction between hotwording and the | 9 * Class used to manage the interaction between hotwording and the |
| 10 * NTP/google.com. Injects a content script to interact with NTP/google.com | 10 * NTP/google.com. Injects a content script to interact with NTP/google.com |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 | 157 |
| 158 /** | 158 /** |
| 159 * Prepare a new or updated tab by injecting the content script. | 159 * Prepare a new or updated tab by injecting the content script. |
| 160 * @param {!Tab} tab Newly updated or created tab. | 160 * @param {!Tab} tab Newly updated or created tab. |
| 161 * @private | 161 * @private |
| 162 */ | 162 */ |
| 163 prepareTab_: function(tab) { | 163 prepareTab_: function(tab) { |
| 164 if (!this.isEligibleUrl_(tab.url)) | 164 if (!this.isEligibleUrl_(tab.url)) |
| 165 return; | 165 return; |
| 166 | 166 |
| 167 chrome.tabs.executeScript(tab.id, {'file': 'audio_client.js'}); | 167 chrome.tabs.executeScript( |
| 168 tab.id, |
| 169 {'file': 'audio_client.js'}, |
| 170 function(results) { |
| 171 if (chrome.runtime.lastError) { |
| 172 // Ignore this error. For new tab pages, even though the URL is |
| 173 // reported to be chrome://newtab/, the actual URL is a |
| 174 // country-specific google domain. Since we don't have permission |
| 175 // to inject on every page, an error will happen when the user is |
| 176 // in an unsupported country. |
| 177 // |
| 178 // The property still needs to be accessed so that the error |
| 179 // condition is cleared. If it isn't, exectureScript will log an |
| 180 // error the next time it is called. |
| 181 } |
| 182 }); |
| 168 }, | 183 }, |
| 169 | 184 |
| 170 /** | 185 /** |
| 171 * Updates hotwording state based on the state of current tabs/windows. | 186 * Updates hotwording state based on the state of current tabs/windows. |
| 172 * @private | 187 * @private |
| 173 */ | 188 */ |
| 174 updateTabState_: function() { | 189 updateTabState_: function() { |
| 175 this.findCurrentTab_(this.activateTab_); | 190 this.findCurrentTab_(this.activateTab_); |
| 176 }, | 191 }, |
| 177 | 192 |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 425 this.stopHotwording_(); | 440 this.stopHotwording_(); |
| 426 this.disconnectAllClients_(); | 441 this.disconnectAllClients_(); |
| 427 } | 442 } |
| 428 } | 443 } |
| 429 }; | 444 }; |
| 430 | 445 |
| 431 return { | 446 return { |
| 432 PageAudioManager: PageAudioManager | 447 PageAudioManager: PageAudioManager |
| 433 }; | 448 }; |
| 434 }); | 449 }); |
| OLD | NEW |