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

Unified Diff: lib/init.js

Issue 10862008: Automatically add default filter subscription when necessary. (Closed)
Patch Set: Created May 27, 2013, 2:12 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 | « include/AdblockPlus/JsEngine.h ('k') | lib/utils.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/init.js
===================================================================
--- a/lib/init.js
+++ b/lib/init.js
@@ -1,5 +1,32 @@
require("filterNotifier").FilterNotifier.addListener(function(action)
{
if (action === "load")
+ {
+ let {FilterStorage} = require("filterStorage");
+ if (FilterStorage.subscriptions.length == 0)
+ {
+ // No data, must be a new user or someone with corrupted data - initialize
+ // with default settings
+ let {Subscription, DownloadableSubscription} = require("subscriptionClasses");
+ let {Synchronizer} = require("synchronizer");
+ let {Prefs} = require("prefs");
+ let {Utils} = require("utils");
+
+ // Choose default subscription and add it
+ let subscriptions = require("subscriptions.xml");
+ let node = Utils.chooseFilterSubscription(subscriptions);
+ if (node)
+ {
+ let subscription = Subscription.fromURL(node.url);
+ FilterStorage.addSubscription(subscription);
+ subscription.disabled = false;
+ subscription.title = node.title;
+ subscription.homepage = node.homepage;
+ if (subscription instanceof DownloadableSubscription && !subscription.lastDownload)
+ Synchronizer.execute(subscription);
+ }
+ }
+
_triggerEvent("init");
+ }
});
« no previous file with comments | « include/AdblockPlus/JsEngine.h ('k') | lib/utils.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld