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: Open block.html as a popup window Created Feb. 8, 2016, 12:32 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') | chrome/ext/background.js » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: background.js
diff --git a/background.js b/background.js
index 355905b59296b91571fc4739253be3b1f6dd8be7..99b462f9a992351f7c225d40303723d928251646 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,40 @@ ext.onMessage.addListener(function (msg, sender, sendResponse)
{
switch (msg.type)
{
+ case "blockelement-open-popup":
+ var url = ext.getURL("block.html") + "?targetPageId=" + sender.page._id +
Sebastian Noack 2016/02/10 12:26:56 Alternatively, you could send this data to the pop
kzar 2016/02/10 14:20:16 I think this would work for Chrome but not Safari.
Sebastian Noack 2016/02/10 14:43:24 As I said, we already do so for the options page.
Sebastian Noack 2016/02/12 17:00:00 So what's about that comment?
kzar 2016/02/13 14:18:12 Well I tried it and it didn't work for me. Lookin
Sebastian Noack 2016/02/15 14:50:17 Well, when opening the options page, we look for a
+ "&filters=" + encodeURIComponent(JSON.stringify(msg.filters));
+ ext.windows.create({
+ url: url,
+ 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);
+
+ sender.page.sendMessage({
+ type: "blockelement-popup-opened",
+ popupId: popupPageId
+ });
+ });
+ return true;
Sebastian Noack 2016/02/10 12:26:56 By returning true but never calling sendResponse()
kzar 2016/02/10 14:20:16 Done.
+ break;
case "get-selectors":
var selectors = [];
var trace = devtools && devtools.hasPanel(sender.page);
@@ -402,15 +436,21 @@ ext.onMessage.addListener(function (msg, sender, sendResponse)
);
break;
case "forward":
- if (sender.page)
+ var targetPage;
+ if (msg.targetPageId)
+ targetPage = ext._getPage(msg.targetPageId);
Sebastian Noack 2016/02/10 12:26:56 I guess it's time, to remove the prefix from ext._
kzar 2016/02/10 14:20:16 Done.
+ else
+ targetPage = sender.page;
+
+ if (targetPage)
{
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;
}
@@ -419,7 +459,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') | chrome/ext/background.js » ('J')

Powered by Google App Engine
This is Rietveld