diff options
Diffstat (limited to 'chrome/common')
-rw-r--r-- | chrome/common/extensions/docs/messaging.html | 8 | ||||
-rw-r--r-- | chrome/common/extensions/docs/static/messaging.html | 8 |
2 files changed, 4 insertions, 12 deletions
diff --git a/chrome/common/extensions/docs/messaging.html b/chrome/common/extensions/docs/messaging.html index 951f969b..0123757 100644 --- a/chrome/common/extensions/docs/messaging.html +++ b/chrome/common/extensions/docs/messaging.html @@ -273,9 +273,7 @@ chrome.tabs.getSelected(null, function(tab) { On the receiving end, you need to set up an <a href="extension.html#event-onRequest">chrome.extension.onRequest</a> event listener to handle the message. This looks the same from a content -script or extension page. The request will remain open until you call -sendResponse, so it is good practice to call sendResponse with an empty -object to allow the request to be cleaned up. +script or extension page. </p><pre>chrome.extension.onRequest.addListener( function(request, sender, sendResponse) { console.log(sender.tab ? @@ -283,8 +281,6 @@ object to allow the request to be cleaned up. "from the extension"); if (request.greeting == "hello") sendResponse({farewell: "goodbye"}); - else - sendResponse({}); // snub them. }); </pre> <p class="note"> @@ -379,7 +375,7 @@ methods. Here's an example of each: chrome.extension.onRequestExternal.addListener( function(request, sender, sendResponse) { if (sender.id == blacklistedExtension) - sendResponse({}); // don't allow this extension access + return; // don't allow this extension access else if (request.getTargetData) sendResponse({targetData: targetData}); else if (request.activateLasers) { diff --git a/chrome/common/extensions/docs/static/messaging.html b/chrome/common/extensions/docs/static/messaging.html index 1391e7e..c4774a5 100644 --- a/chrome/common/extensions/docs/static/messaging.html +++ b/chrome/common/extensions/docs/static/messaging.html @@ -63,9 +63,7 @@ chrome.tabs.getSelected(null, function(tab) { On the receiving end, you need to set up an <a href="extension.html#event-onRequest">chrome.extension.onRequest</a> event listener to handle the message. This looks the same from a content -script or extension page. The request will remain open until you call -sendResponse, so it is good practice to call sendResponse with an empty -object to allow the request to be cleaned up. +script or extension page. <pre> chrome.extension.onRequest.addListener( function(request, sender, sendResponse) { @@ -74,8 +72,6 @@ chrome.extension.onRequest.addListener( "from the extension"); if (request.greeting == "hello") sendResponse({farewell: "goodbye"}); - else - sendResponse({}); // snub them. }); </pre> @@ -185,7 +181,7 @@ methods. Here's an example of each: chrome.extension.onRequestExternal.addListener( function(request, sender, sendResponse) { if (sender.id == blacklistedExtension) - sendResponse({}); // don't allow this extension access + return; // don't allow this extension access else if (request.getTargetData) sendResponse({targetData: targetData}); else if (request.activateLasers) { |