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

Unified Diff: lib/filterComposer.js

Issue 29338491: Issue 3823 - Split up message responder code (Closed)
Patch Set: Use require() inline Created March 21, 2016, 7:53 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 | « lib/devtools.js ('k') | lib/messaging.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/filterComposer.js
===================================================================
--- a/lib/filterComposer.js
+++ b/lib/filterComposer.js
@@ -17,10 +17,13 @@
/** @module filterComposer */
+"use strict";
+
let {extractHostFromFrame, stringifyURL, isThirdParty} = require("url");
let {getKey, checkWhitelisted} = require("whitelisting");
let {defaultMatcher} = require("matcher");
let {RegExpFilter} = require("filterClasses");
+let {port} = require("messaging");
function isValidString(s) {
return s && s.indexOf("\0") == -1;
@@ -66,25 +69,7 @@
return '"' + value.replace(/["\\\{\}\x00-\x1F\x7F]/g, escapeChar) + '"';
};
-/**
- * Generates filters to block an element.
- * @param {Object} details
- * @param {string} details.tagName The element's tag name
- * @param {string} details.id The element's "id" attribute
- * @param {string} details.src The element's "src" attribute
- * @param {string} details.style The element's "style" attribute
- * @param {string[]} details.classes The classes given by the element's "class" attribute
- * @param {string[]} details.urls The URLs considered when loading the element
- * @param {string} details.type The request type (will be ignored if there are no URLs)
- * @param {string} details.baseURL The URL of the document containing the element
- * @param {Page} details.page The page containing the element
- * @param {Frame} details.frame The frame containing the element
- *
- * @return {object} An object holding the list of generated filters and
- * the list of CSS selectors for the included element
- * hiding filters: {filters: [...], selectors: [...]}
- */
-exports.composeFilters = function(details)
+function composeFilters(details)
{
let filters = [];
let selectors = [];
@@ -151,4 +136,59 @@
}
return {filters: filters, selectors: selectors};
-};
+}
+
+port.on("composer.ready", (message, sender) =>
+{
+ htmlPages.set(sender.page, null);
+ refreshIconAndContextMenu(sender.page);
+});
+
+port.on("composer.openDialog", (message, sender) =>
+{
+ return new Promise(resolve =>
+ {
+ ext.windows.create({
+ url: ext.getURL("block.html"),
+ left: 50,
+ top: 50,
+ width: 420,
+ height: 200,
+ focused: true,
+ type: "popup"
+ },
+ popupPage =>
+ {
+ let 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);
+ resolve(popupPageId);
+ });
+ });
+});
+
+port.on("composer.getFilters", (message, sender) =>
+{
+ return composeFilters({
+ tagName: message.tagName,
+ id: message.id,
+ src: message.src,
+ style: message.style,
+ classes: message.classes,
+ urls: message.urls,
+ type: message.mediatype,
+ baseURL: message.baseURL,
+ page: sender.page,
+ frame: sender.frame
+ });
+});
« no previous file with comments | « lib/devtools.js ('k') | lib/messaging.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld