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: Prevent Safari 12+ users switch content blocking mode off Created July 13, 2018, 6:23 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') | safari/ext/content.js » ('J')
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);
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 );
171 document.getElementById("safariContentBlocker").disabled = majorApplicationV ersion >= 12;
166 }); 172 });
167 getPref("notifications_showui", function(notifications_showui) 173 getPref("notifications_showui", function(notifications_showui)
168 { 174 {
169 if (!notifications_showui) 175 if (!notifications_showui)
170 document.getElementById("shouldShowNotificationsContainer").hidden = true; 176 document.getElementById("shouldShowNotificationsContainer").hidden = true;
171 }); 177 });
172 178
173 // Register listeners in the background message responder 179 // Register listeners in the background message responder
174 ext.backgroundPage.sendMessage({ 180 ext.backgroundPage.sendMessage({
175 type: "app.listen", 181 type: "app.listen",
(...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after
767 onFilterMessage(message.action, message.args[0]); 773 onFilterMessage(message.action, message.args[0]);
768 break; 774 break;
769 case "prefs.respond": 775 case "prefs.respond":
770 onPrefMessage(message.action, message.args[0]); 776 onPrefMessage(message.action, message.args[0]);
771 break; 777 break;
772 case "subscriptions.respond": 778 case "subscriptions.respond":
773 onSubscriptionMessage(message.action, message.args[0]); 779 onSubscriptionMessage(message.action, message.args[0]);
774 break; 780 break;
775 } 781 }
776 }); 782 });
OLDNEW
« no previous file with comments | « no previous file | safari/contentBlocking.js » ('j') | safari/ext/content.js » ('J')

Powered by Google App Engine
This is Rietveld