Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chrome Extensions - onRequest/sendRequest vs onMessage/sendMessage [duplicate]

Tags:

Checking out this sample extension linked by a page in the Chrome Extension center, I see they used

chrome.extension.onRequest.addListener(onRequest); 

in the background.js page in order to listen to the contentscript.js and

  chrome.extension.sendRequest({}, function(response) {}); 

in the contentscript.js in order to talk to the background.js page.

But I can't find the documentation for these functions anywhere in the web and Google's Message Passing guide only mentions

chrome.extension.sendMessage(...) 

to send, and

chrome.extension.onMessage.addListener(...) 

to listen.

Which functions should I use? Is sendRequest/onRequest obsolete? Is the Google's dev guide still up-to-date?

like image 528
FRD Avatar asked Jul 04 '12 21:07

FRD


1 Answers

It seems sendMessage is favored over sendRequest, which is to be deprecated: http://codereview.chromium.org/9965005/

like image 86
Achal Dave Avatar answered Oct 14 '22 17:10

Achal Dave