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

Unified Diff: adblockplus/Api.jsm

Issue 4920541991403520: Create a minimal settings UI (Closed)
Patch Set: Removed default case Created March 22, 2015, 9:23 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 | mobile/android/base/moz.build » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: adblockplus/Api.jsm
diff --git a/adblockplus/Api.jsm b/adblockplus/Api.jsm
index d87c428db1072eacdb8f8ba52a97a52879b1992c..26c8c409aff3ff94cb46255852e775493941bb73 100644
--- a/adblockplus/Api.jsm
+++ b/adblockplus/Api.jsm
@@ -23,6 +23,7 @@ const Cr = Components.results;
const Cu = Components.utils;
Cu.import("resource://gre/modules/Services.jsm");
+Cu.import("resource://gre/modules/Messaging.jsm");
function require(module)
{
@@ -38,6 +39,10 @@ let {UI} = require("ui");
var AdblockPlusApi =
{
+ get filtersLoaded()
+ {
+ return !FilterStorage._loading;
+ },
get acceptableAdsEnabled()
{
return FilterStorage.subscriptions.some(
@@ -47,5 +52,34 @@ var AdblockPlusApi =
{
if (acceptableAdsEnabled != AdblockPlusApi.acceptableAdsEnabled)
UI.toggleAcceptableAds();
+ },
+ initCommunication: function()
+ {
+ RequestService.addListener((function(data)
+ {
+ if (!data)
+ return {"success": false, "error": "malformed request"};
+
+ if (data["action"] == "getFiltersLoaded")
+ return {"success": true, "value": this.filtersLoaded};
+
+ if (!this.filtersLoaded)
+ return {"success": false, "error": "filters not loaded"};
+
+ switch (data["action"])
+ {
+ case "getAcceptableAdsEnabled":
+ return {"success": true, "value": this.acceptableAdsEnabled};
+ case "setAcceptableAdsEnabled":
+ if ("enable" in data)
+ {
+ this.acceptableAdsEnabled = !!data["enable"];
+ return {"success" : true};
+ }
+ return {"success": false, "error": "malformed request"};
+ }
+ return {"success": false, "error": "malformed request"};
+ }).bind(this), "AdblockPlus:Api");
}
};
+
« no previous file with comments | « no previous file | mobile/android/base/moz.build » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld