Chromium Code Reviews| Index: chrome/browser/resources/hotword_helper/manager.js |
| diff --git a/chrome/browser/resources/hotword_helper/manager.js b/chrome/browser/resources/hotword_helper/manager.js |
| index 4ce86db62959d7fb42ade923a8d80fb11daa24f2..03739fa64d68950ce5b6f5eea424db448a67d68b 100644 |
| --- a/chrome/browser/resources/hotword_helper/manager.js |
| +++ b/chrome/browser/resources/hotword_helper/manager.js |
| @@ -58,19 +58,30 @@ OptInManager.CommandFromPage = { |
| */ |
| OptInManager.prototype.injectTab_ = function( |
| tab, sendResponse, hotwordStatus) { |
| - if (tab.incognito || !hotwordStatus.available) { |
| - sendResponse({'doNotShowOptinMessage': true}); |
| - return; |
| - } |
| + try { |
|
Dan Beam
2014/09/23 04:14:00
nit: if sendReponse() is what throws, i'd think it
Anand Mistry (off Chromium)
2014/09/24 01:11:40
Done.
|
| + if (tab.incognito || !hotwordStatus.available) { |
| + sendResponse({'doNotShowOptinMessage': true}); |
| + return; |
| + } |
| - if (!hotwordStatus.enabledSet) { |
| - sendResponse(hotwordStatus); |
| - return; |
| - } |
| + if (!hotwordStatus.enabledSet) { |
| + sendResponse(hotwordStatus); |
| + return; |
| + } |
| - if (hotwordStatus.enabled) |
| - chrome.tabs.executeScript(tab.id, {'file': 'audio_client.js'}); |
| - sendResponse({'doNotShowOptinMessage': true}); |
| + if (hotwordStatus.enabled) |
| + chrome.tabs.executeScript(tab.id, {'file': 'audio_client.js'}); |
|
Dan Beam
2014/09/23 04:14:00
nit: \n
Anand Mistry (off Chromium)
2014/09/24 01:11:41
Done.
|
| + sendResponse({'doNotShowOptinMessage': true}); |
| + } catch (err) { |
| + // Suppress the exception thrown by sendResponse() when the page doesn't |
| + // specify a response callback in the call to chrome.runtime.sendMessage(). |
| + // Unfortunately, there doesn't appear to be a way to detect one-way |
| + // messages without explicitly saying in the message itself. This message |
| + // is defined as a constant in extensions/renderer/messaging_bindings.cc |
| + if (err.message == 'Attempting to use a disconnected port object') |
|
Dan Beam
2014/09/23 04:14:00
can you write a test that exercises this case? (so
Anand Mistry (off Chromium)
2014/09/24 01:11:41
I've given it a shot.
|
| + return; |
| + throw err; |
| + } |
| }; |