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

Unified Diff: chrome/browser/resources/hotword_helper/manager.js

Issue 587153002: Suppress the exception thrown when responding to message with no response callback. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..7e325ab07e50101b6a9444a7f499364fb173fc06 100644
--- a/chrome/browser/resources/hotword_helper/manager.js
+++ b/chrome/browser/resources/hotword_helper/manager.js
@@ -58,19 +58,28 @@ 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});
+ } 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.
+ if (err.message == 'Attempting to use a disconnected port object')
rpetterson 2014/09/22 23:04:41 Weird question, but is this always going to be in
Anand Mistry (off Chromium) 2014/09/22 23:50:43 It's an untranslated constant in https://code.goog
rpetterson 2014/09/22 23:53:03 Understood. Please add a note to the comment listi
Anand Mistry (off Chromium) 2014/09/23 00:31:30 Done.
+ return;
+ throw err;
+ }
};
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698