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

Unified Diff: background.js

Issue 6235761431019520: Issue 342 - Speed up options page with many user filters on Safari (Closed)
Patch Set: Created April 16, 2014, 3 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 | options.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: background.js
===================================================================
--- a/background.js
+++ b/background.js
@@ -26,6 +26,7 @@
{
this.Subscription = Subscription;
this.DownloadableSubscription = DownloadableSubscription;
+ this.SpecialSubscription = SpecialSubscription;
}
with(require("whitelisting"))
{
@@ -470,6 +471,33 @@
prepareNotificationIconAndPopup();
}
+// This is a hack to speedup loading of the options page on Safari.
+// Once we replaced the background page proxy with message passing
+// this global function should removed.
+function getUserFilter()
Wladimir Palant 2014/04/16 17:25:39 Nit: getUserFilters() please (plural)
+{
+ var filters = [];
+ var exceptions = [];
+
+ for (var i = 0; i < FilterStorage.subscriptions.length; i++)
+ {
+ var subscription = FilterStorage.subscriptions[i];
+ if (!(subscription instanceof SpecialSubscription))
+ continue;
+
+ for (var j = 0; j < subscription.filters.length; j++)
+ {
+ var filter = subscription.filters[j];
+ if (filter instanceof WhitelistFilter && /^@@\|\|([^\/:]+)\^\$document$/.test(filter.text))
+ exceptions.push(RegExp.$1);
+ else
+ filters.push(filter.text);
+ }
+ }
+
+ return {filters: filters, exceptions: exceptions};
+}
+
ext.onMessage.addListener(function (msg, sender, sendResponse)
{
switch (msg.type)
« no previous file with comments | « no previous file | options.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld