Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: composer.postload.js

Issue 29573726: Issue 4580 - Replace ext.backgroundPage.sendMessage with runtime.sendMessage (Closed) Base URL: https://hg.adblockplus.org/adblockpluschrome/
Patch Set: Rebase Created Oct. 13, 2017, 5:07 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « composer.js ('k') | desktop-options.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: composer.postload.js
===================================================================
--- a/composer.postload.js
+++ b/composer.postload.js
@@ -40,17 +40,17 @@
let lastRightClickEventIsMostRecent = false;
/* Utilities */
function getFiltersForElement(element, callback)
{
let src = element.getAttribute("src");
- ext.backgroundPage.sendMessage({
+ chrome.runtime.sendMessage({
type: "composer.getFilters",
tagName: element.localName,
id: element.id,
src: src && src.length <= 1000 ? src : null,
style: element.getAttribute("style"),
classes: Array.prototype.slice.call(element.classList),
urls: getURLsFromElement(element),
mediatype: typeMap.get(element.localName),
@@ -384,36 +384,36 @@
return;
let element = currentElement.prisoner || currentElement;
getFiltersForElement(element, (filters, selectors) =>
{
if (currentlyPickingElement)
stopPickingElement();
- ext.backgroundPage.sendMessage({
+ chrome.runtime.sendMessage({
type: "composer.openDialog"
},
popupId =>
{
- ext.backgroundPage.sendMessage({
+ chrome.runtime.sendMessage({
type: "forward",
targetPageId: popupId,
payload: {type: "composer.dialog.init", filters}
});
// Only the top frame keeps a record of the popup window's ID,
// so if this isn't the top frame we need to pass the ID on.
if (window == window.top)
{
blockelementPopupId = popupId;
}
else
{
- ext.backgroundPage.sendMessage({
+ chrome.runtime.sendMessage({
type: "forward",
payload: {type: "composer.content.dialogOpened", popupId}
});
}
});
if (selectors.length > 0)
highlightElements(selectors.join(","));
@@ -446,17 +446,17 @@
// We're done with the block element feature for now, tidy everything up.
function deactivateBlockElement()
{
if (currentlyPickingElement)
stopPickingElement();
if (blockelementPopupId != null)
{
- ext.backgroundPage.sendMessage({
+ chrome.runtime.sendMessage({
type: "forward",
targetPageId: blockelementPopupId,
payload:
{
type: "composer.dialog.close"
}
});
@@ -488,17 +488,17 @@
// We also need to make sure that the previous right click event,
// if there is one, is removed. We don't know which frame it is in so we must
// send a message to the other frames to clear their old right click events.
document.addEventListener("contextmenu", event =>
{
lastRightClickEvent = event;
lastRightClickEventIsMostRecent = true;
- ext.backgroundPage.sendMessage({
+ chrome.runtime.sendMessage({
type: "forward",
payload:
{
type: "composer.content.clearPreviousRightClickEvent"
}
});
}, true);
@@ -557,23 +557,23 @@
if (window == window.top)
blockelementPopupId = msg.popupId;
break;
case "composer.content.dialogClosed":
// The onRemoved hook for the popup can create a race condition, so we
// to be careful here. (This is not perfect, but best we can do.)
if (window == window.top && blockelementPopupId == msg.popupId)
{
- ext.backgroundPage.sendMessage({
+ chrome.runtime.sendMessage({
type: "forward",
payload:
{
type: "composer.content.finished"
}
});
}
break;
}
});
if (window == window.top)
- ext.backgroundPage.sendMessage({type: "composer.ready"});
+ chrome.runtime.sendMessage({type: "composer.ready"});
}
« no previous file with comments | « composer.js ('k') | desktop-options.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld