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..9aecee1dca8eee0f7d9484a7c35f028c4a71cbd6 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 { |
| + 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'}); |
| + sendResponse({'doNotShowOptinMessage': true}); |
|
Dan Beam
2014/09/23 03:35:38
^ which of these lines actually throw?
Anand Mistry (off Chromium)
2014/09/23 03:55:07
In theory, any of these calls to sendResponse() co
|
| + } catch (err) { |
| + // Suppress the exception thrown when the page doesn't specify a response |
| + // callback. 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 03:35:38
does sendResponse() need to be invoked here?
Anand Mistry (off Chromium)
2014/09/23 03:55:07
No. It's the sendResponse() that threw the excepti
|
| + return; |
| + throw err; |
| + } |
| }; |