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

Side by Side Diff: options.js

Issue 29829615: Issue 6786 - Switch Safari 12+ users to content blocking API (Closed)
Patch Set: Created July 13, 2018, 6:18 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
« no previous file with comments | « no previous file | safari/contentBlocking.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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-present eyeo GmbH 3 * Copyright (C) 2006-present 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 "use strict"; 18 "use strict";
19 19
20 var applicatonVersion = navigator.userAgent.match(/Version\/([\d.]+)/)[1];
21 var majorApplicationVersion = parseInt(applicatonVersion.split(".")[0], 10);
Sebastian Noack 2018/07/13 18:27:53 If you remove the dot from the regex above this st
kzar 2018/07/13 18:58:33 Done.
22
20 /** 23 /**
21 * Creates a wrapping function used to conveniently send a type of message. 24 * Creates a wrapping function used to conveniently send a type of message.
22 * 25 *
23 * @param {Object} baseMessage The part of the message that's always sent 26 * @param {Object} baseMessage The part of the message that's always sent
24 * @param {..string} paramKeys Any message keys that have dynamic values. The 27 * @param {..string} paramKeys Any message keys that have dynamic values. The
25 * returned function will take the corresponding 28 * returned function will take the corresponding
26 * values as arguments. 29 * values as arguments.
27 * @return The generated messaging function, optionally taking any values as 30 * @return The generated messaging function, optionally taking any values as
28 * specified by the paramKeys and finally an optional callback. 31 * specified by the paramKeys and finally an optional callback.
29 * (Although the value arguments are optional their index must be 32 * (Although the value arguments are optional their index must be
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 154
152 getInfo("features", function(features) 155 getInfo("features", function(features)
153 { 156 {
154 if (!features.devToolsPanel) 157 if (!features.devToolsPanel)
155 document.getElementById("showDevtoolsPanelContainer").hidden = true; 158 document.getElementById("showDevtoolsPanelContainer").hidden = true;
156 159
157 // Only show the option for Safari content blocking API if the user is 160 // Only show the option for Safari content blocking API if the user is
158 // running Safari and both the legacy and content blocking APIs are 161 // running Safari and both the legacy and content blocking APIs are
159 // available. 162 // available.
160 document.getElementById("safariContentBlockerContainer").hidden = !( 163 document.getElementById("safariContentBlockerContainer").hidden = !(
161 features.safariContentBlocker && 164 majorApplicationVersion >= 12 || (
162 typeof safari != "undefined" && 165 features.safariContentBlocker &&
163 "canLoad" in safari.self.tab && 166 typeof safari != "undefined" &&
164 "onbeforeload" in Element.prototype 167 "canLoad" in safari.self.tab &&
168 "onbeforeload" in Element.prototype
169 )
165 ); 170 );
166 }); 171 });
167 getPref("notifications_showui", function(notifications_showui) 172 getPref("notifications_showui", function(notifications_showui)
168 { 173 {
169 if (!notifications_showui) 174 if (!notifications_showui)
170 document.getElementById("shouldShowNotificationsContainer").hidden = true; 175 document.getElementById("shouldShowNotificationsContainer").hidden = true;
171 }); 176 });
172 177
173 // Register listeners in the background message responder 178 // Register listeners in the background message responder
174 ext.backgroundPage.sendMessage({ 179 ext.backgroundPage.sendMessage({
(...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after
767 onFilterMessage(message.action, message.args[0]); 772 onFilterMessage(message.action, message.args[0]);
768 break; 773 break;
769 case "prefs.respond": 774 case "prefs.respond":
770 onPrefMessage(message.action, message.args[0]); 775 onPrefMessage(message.action, message.args[0]);
771 break; 776 break;
772 case "subscriptions.respond": 777 case "subscriptions.respond":
773 onSubscriptionMessage(message.action, message.args[0]); 778 onSubscriptionMessage(message.action, message.args[0]);
774 break; 779 break;
775 } 780 }
776 }); 781 });
OLDNEW
« no previous file with comments | « no previous file | safari/contentBlocking.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld