Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

converted to chrome.extension.onMessage [Fixes #145] #151

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/chrome/backgroundscript.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ chrome.contextMenus.create({

// Handle rendering requests from the content script.
// See the comment in markdown-render.js for why we do this.
chrome.runtime.onMessage.addListener(function(request, sender, responseCallback) {
chrome.extension.onMessage.addListener(function(request, sender, responseCallback) {
// The content script can load in a not-real tab (like the search box), which
// has an invalid `sender.tab` value. We should just ignore these pages.
if (typeof(sender.tab) === 'undefined' ||
Expand Down
2 changes: 1 addition & 1 deletion src/chrome/contentscript.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ function requestHandler(request, sender, sendResponse) {
return false;
}
}
chrome.runtime.onMessage.addListener(requestHandler);
chrome.extension.onMessage.addListener(requestHandler);


// The rendering service provided to the content script.
Expand Down
6 changes: 3 additions & 3 deletions src/common/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -329,12 +329,12 @@ var PRIVILEGED_REQUEST_EVENT_NAME = 'markdown-here-request-event';
function makeRequestToPrivilegedScript(doc, requestObj, callback) {
if (typeof(chrome) !== 'undefined') {
// If `callback` is undefined and we pass it anyway, Chrome complains with this:
// Uncaught Error: Invocation of form runtime.sendMessage(object, undefined, null) doesn't match definition runtime.sendMessage(optional string extensionId, any message, optional function responseCallback)
// Uncaught Error: Invocation of form extension.sendMessage(object, undefined, null) doesn't match definition extension.sendMessage(optional string extensionId, any message, optional function responseCallback)
if (callback) {
chrome.runtime.sendMessage(requestObj, callback);
chrome.extension.sendMessage(requestObj, callback);
}
else {
chrome.runtime.sendMessage(requestObj);
chrome.extension.sendMessage(requestObj);
}
}
else if (typeof(safari) !== 'undefined') {
Expand Down