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

Delta Between Two Patch Sets: options.js

Issue 29829615: Issue 6786 - Switch Safari 12+ users to content blocking API (Closed)
Left Patch Set: Created July 13, 2018, 6:18 p.m.
Right Patch Set: Simplify Safari version parsing logic Created July 13, 2018, 6:57 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | safari/contentBlocking.js » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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]; 20 var majorApplicationVersion = parseInt(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 21
23 /** 22 /**
24 * Creates a wrapping function used to conveniently send a type of message. 23 * Creates a wrapping function used to conveniently send a type of message.
25 * 24 *
26 * @param {Object} baseMessage The part of the message that's always sent 25 * @param {Object} baseMessage The part of the message that's always sent
27 * @param {..string} paramKeys Any message keys that have dynamic values. The 26 * @param {..string} paramKeys Any message keys that have dynamic values. The
28 * returned function will take the corresponding 27 * returned function will take the corresponding
29 * values as arguments. 28 * values as arguments.
30 * @return The generated messaging function, optionally taking any values as 29 * @return The generated messaging function, optionally taking any values as
31 * specified by the paramKeys and finally an optional callback. 30 * specified by the paramKeys and finally an optional callback.
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 // running Safari and both the legacy and content blocking APIs are 160 // running Safari and both the legacy and content blocking APIs are
162 // available. 161 // available.
163 document.getElementById("safariContentBlockerContainer").hidden = !( 162 document.getElementById("safariContentBlockerContainer").hidden = !(
164 majorApplicationVersion >= 12 || ( 163 majorApplicationVersion >= 12 || (
165 features.safariContentBlocker && 164 features.safariContentBlocker &&
166 typeof safari != "undefined" && 165 typeof safari != "undefined" &&
167 "canLoad" in safari.self.tab && 166 "canLoad" in safari.self.tab &&
168 "onbeforeload" in Element.prototype 167 "onbeforeload" in Element.prototype
169 ) 168 )
170 ); 169 );
170 document.getElementById("safariContentBlocker").disabled = majorApplicationV ersion >= 12;
171 }); 171 });
172 getPref("notifications_showui", function(notifications_showui) 172 getPref("notifications_showui", function(notifications_showui)
173 { 173 {
174 if (!notifications_showui) 174 if (!notifications_showui)
175 document.getElementById("shouldShowNotificationsContainer").hidden = true; 175 document.getElementById("shouldShowNotificationsContainer").hidden = true;
176 }); 176 });
177 177
178 // Register listeners in the background message responder 178 // Register listeners in the background message responder
179 ext.backgroundPage.sendMessage({ 179 ext.backgroundPage.sendMessage({
180 type: "app.listen", 180 type: "app.listen",
(...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after
772 onFilterMessage(message.action, message.args[0]); 772 onFilterMessage(message.action, message.args[0]);
773 break; 773 break;
774 case "prefs.respond": 774 case "prefs.respond":
775 onPrefMessage(message.action, message.args[0]); 775 onPrefMessage(message.action, message.args[0]);
776 break; 776 break;
777 case "subscriptions.respond": 777 case "subscriptions.respond":
778 onSubscriptionMessage(message.action, message.args[0]); 778 onSubscriptionMessage(message.action, message.args[0]);
779 break; 779 break;
780 } 780 }
781 }); 781 });
LEFTRIGHT

Powered by Google App Engine
This is Rietveld