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

Delta Between Two Patch Sets: safari/ext/content.js

Issue 29340571: Issue 3687 - Add experimental support for Safari content blockers (Closed)
Left Patch Set: Improve comment about strange API behaviour Created May 17, 2016, 3:53 p.m.
Right Patch Set: Addressed Nits Created May 18, 2016, 11:30 a.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 | « safari/ext/background.js ('k') | safari/include.youtube.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-2016 Eyeo GmbH 3 * Copyright (C) 2006-2016 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
(...skipping 22 matching lines...) Expand all
33 // exception or return true when used.) 33 // exception or return true when used.)
34 var usingContentBlockerAPI = true; 34 var usingContentBlockerAPI = true;
35 try 35 try
36 { 36 {
37 if (safari.self.tab.canLoad(beforeLoadEvent, 37 if (safari.self.tab.canLoad(beforeLoadEvent,
38 {category: "request", 38 {category: "request",
39 payload: {type: "prefs.get", 39 payload: {type: "prefs.get",
40 key: "safariContentBlocker"}}) != tru e) 40 key: "safariContentBlocker"}}) != tru e)
41 usingContentBlockerAPI = false; 41 usingContentBlockerAPI = false;
42 } 42 }
43 catch (e) { }; 43 catch (e)
44 {
45 }
44 46
45 var isTopLevel; 47 var isTopLevel;
46 var isPrerendered; 48 var isPrerendered;
47 var documentId; 49 var documentId;
48 function notifyFrameLoading() 50 function notifyFrameLoading()
49 { 51 {
50 isTopLevel = window == window.top; 52 isTopLevel = window == window.top;
51 isPrerendered = document.visibilityState == "prerender"; 53 isPrerendered = document.visibilityState == "prerender";
52 documentId = Math.random().toString().substr(2); 54 documentId = Math.random().toString().substr(2);
53 55
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 // been prevented from loading by having their "beforeload" event 148 // been prevented from loading by having their "beforeload" event
147 // cancelled. That is a "load" event for blocked frames, and an "error" 149 // cancelled. That is a "load" event for blocked frames, and an "error"
148 // event for other blocked elements. We need to dispatch those events 150 // event for other blocked elements. We need to dispatch those events
149 // manually here to avoid breaking element collapsing and pages that 151 // manually here to avoid breaking element collapsing and pages that
150 // rely on those events. 152 // rely on those events.
151 setTimeout(function() 153 setTimeout(function()
152 { 154 {
153 var evt = document.createEvent("Event"); 155 var evt = document.createEvent("Event");
154 evt.initEvent(eventName); 156 evt.initEvent(eventName);
155 event.target.dispatchEvent(evt); 157 event.target.dispatchEvent(evt);
156 }, 0); 158 });
157 } 159 }
158 }, true); 160 }, true);
159 } 161 }
160 162
161 163
162 /* Context menus */ 164 /* Context menus */
163 165
164 document.addEventListener("contextmenu", function(event) 166 document.addEventListener("contextmenu", function(event)
165 { 167 {
166 var element = event.srcElement; 168 var element = event.srcElement;
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 }); 223 });
222 224
223 225
224 /* Detecting extension reload/disable/uninstall (not supported on Safari) */ 226 /* Detecting extension reload/disable/uninstall (not supported on Safari) */
225 227
226 ext.onExtensionUnloaded = { 228 ext.onExtensionUnloaded = {
227 addListener: function() {}, 229 addListener: function() {},
228 removeListener: function() {} 230 removeListener: function() {}
229 }; 231 };
230 })(); 232 })();
LEFTRIGHT

Powered by Google App Engine
This is Rietveld