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

Unified Diff: background.js

Issue 29336084: Issue 2426 - Open block.html as a popup window (Closed)
Patch Set: Assume createData parameter has been given Created Feb. 17, 2016, 8:50 p.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 | « no previous file | block.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: background.js
diff --git a/background.js b/background.js
index d191a940b7356b68379c718ef271b07aa4e31c35..91bf5ddd0e0a127096fedc0e15377169a42ca8db 100644
--- a/background.js
+++ b/background.js
@@ -119,7 +119,7 @@ var contextMenuItem = {
contexts: ["image", "video", "audio"],
onclick: function(page)
{
- page.sendMessage({type: "clickhide-new-filter"});
+ page.sendMessage({type: "blockelement-context-menu-clicked"});
}
};
@@ -283,6 +283,35 @@ ext.onMessage.addListener(function (msg, sender, sendResponse)
{
switch (msg.type)
{
+ case "blockelement-open-popup":
+ ext.windows.create({
+ url: ext.getURL("block.html"),
+ left: 50,
+ top: 50,
+ width: 420,
+ height: 200,
+ focused: true,
+ type: "popup"
+ },
+ function (popupPage) {
+ var popupPageId = popupPage.id;
+ function onRemoved(removedPageId)
+ {
+ if (popupPageId == removedPageId)
+ {
+ sender.page.sendMessage({
+ type: "blockelement-popup-closed",
+ popupId: popupPageId
+ });
+ ext.pages.onRemoved.removeListener(onRemoved);
+ }
+ }
+ ext.pages.onRemoved.addListener(onRemoved);
+
+ sendResponse(popupPageId);
+ });
+ return true;
+ break;
case "get-selectors":
var selectors = [];
var trace = devtools && devtools.hasPanel(sender.page);
@@ -408,15 +437,22 @@ ext.onMessage.addListener(function (msg, sender, sendResponse)
);
break;
case "forward":
- if (sender.page)
+ var targetPage;
+ if (msg.targetPageId)
+ targetPage = ext.getPage(msg.targetPageId);
+ else
+ targetPage = sender.page;
+
+ if (targetPage)
{
+ msg.payload.sender = sender.page.id;
if (msg.expectsResponse)
{
- sender.page.sendMessage(msg.payload, sendResponse);
+ targetPage.sendMessage(msg.payload, sendResponse);
return true;
}
- sender.page.sendMessage(msg.payload);
+ targetPage.sendMessage(msg.payload);
}
break;
}
@@ -425,7 +461,7 @@ ext.onMessage.addListener(function (msg, sender, sendResponse)
// update icon when page changes location
ext.pages.onLoading.addListener(function(page)
{
- page.sendMessage({type: "clickhide-deactivate"});
+ page.sendMessage({type: "blockelement-finished"});
refreshIconAndContextMenu(page);
showNextNotificationForUrl(page.url);
});
« no previous file with comments | « no previous file | block.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld