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

Side by Side Diff: lib/api.js

Issue 5797488346791936: Issue 1107 - Support notifications (Closed)
Patch Set: fix according to the comments Created Jan. 23, 2015, 2:44 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2015 Eyeo GmbH 3 * Copyright (C) 2006-2015 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License 14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */ 16 */
17 17
18 var API = (function() 18 var API = (function()
19 { 19 {
20 var Filter = require("filterClasses").Filter; 20 var Filter = require("filterClasses").Filter;
21 var Subscription = require("subscriptionClasses").Subscription; 21 var Subscription = require("subscriptionClasses").Subscription;
22 var SpecialSubscription = require("subscriptionClasses").SpecialSubscription; 22 var SpecialSubscription = require("subscriptionClasses").SpecialSubscription;
23 var FilterStorage = require("filterStorage").FilterStorage; 23 var FilterStorage = require("filterStorage").FilterStorage;
24 var defaultMatcher = require("matcher").defaultMatcher; 24 var defaultMatcher = require("matcher").defaultMatcher;
25 var ElemHide = require("elemHide").ElemHide; 25 var ElemHide = require("elemHide").ElemHide;
26 var Synchronizer = require("synchronizer").Synchronizer; 26 var Synchronizer = require("synchronizer").Synchronizer;
27 var Prefs = require("prefs").Prefs; 27 var Prefs = require("prefs").Prefs;
28 var checkForUpdates = require("updater").checkForUpdates; 28 var checkForUpdates = require("updater").checkForUpdates;
29 var Notification = require("notification").Notification;
29 30
30 return { 31 return {
31 getFilterFromText: function(text) 32 getFilterFromText: function(text)
32 { 33 {
33 text = Filter.normalize(text); 34 text = Filter.normalize(text);
34 if (!text) 35 if (!text)
35 throw "Attempted to create a filter from empty text"; 36 throw "Attempted to create a filter from empty text";
36 return Filter.fromText(text); 37 return Filter.fromText(text);
37 }, 38 },
38 39
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 130
130 // These aren't normally properties of a Subscription object 131 // These aren't normally properties of a Subscription object
131 subscription.author = subscriptions[i].author; 132 subscription.author = subscriptions[i].author;
132 subscription.prefixes = subscriptions[i].prefixes; 133 subscription.prefixes = subscriptions[i].prefixes;
133 subscription.specialization = subscriptions[i].specialization; 134 subscription.specialization = subscriptions[i].specialization;
134 result.push(subscription); 135 result.push(subscription);
135 } 136 }
136 return result; 137 return result;
137 }, 138 },
138 139
140 getNextNotificationToShow: function(url)
141 {
142 return Notification.getNextToShow(url);
143 },
144
145 getNotificationTexts: function(notification)
146 {
147 return Notification.getLocalizedTexts(notification);
148 },
149
150 markNotificationAsShown: function(id)
151 {
152 Notification.markAsShown(id);
153 },
139 checkFilterMatch: function(url, contentType, documentUrl) 154 checkFilterMatch: function(url, contentType, documentUrl)
140 { 155 {
141 var requestHost = extractHostFromURL(url); 156 var requestHost = extractHostFromURL(url);
142 var documentHost = extractHostFromURL(documentUrl); 157 var documentHost = extractHostFromURL(documentUrl);
143 var thirdParty = isThirdParty(requestHost, documentHost); 158 var thirdParty = isThirdParty(requestHost, documentHost);
144 return defaultMatcher.matchesAny(url, contentType, documentHost, thirdPart y); 159 return defaultMatcher.matchesAny(url, contentType, documentHost, thirdPart y);
145 }, 160 },
146 161
147 getElementHidingSelectors: function(domain) 162 getElementHidingSelectors: function(domain)
148 { 163 {
(...skipping 19 matching lines...) Expand all
168 { 183 {
169 return extractHostFromURL(url); 184 return extractHostFromURL(url);
170 }, 185 },
171 186
172 compareVersions: function(v1, v2) 187 compareVersions: function(v1, v2)
173 { 188 {
174 return Services.vc.compare(v1, v2); 189 return Services.vc.compare(v1, v2);
175 } 190 }
176 }; 191 };
177 })(); 192 })();
OLDNEW

Powered by Google App Engine
This is Rietveld