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: Addressed further feedback Created May 17, 2016, 7:17 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 23 matching lines...) Expand all
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 { } 44 {
45 }
45 46
46 var isTopLevel; 47 var isTopLevel;
47 var isPrerendered; 48 var isPrerendered;
48 var documentId; 49 var documentId;
49 function notifyFrameLoading() 50 function notifyFrameLoading()
50 { 51 {
51 isTopLevel = window == window.top; 52 isTopLevel = window == window.top;
52 isPrerendered = document.visibilityState == "prerender"; 53 isPrerendered = document.visibilityState == "prerender";
53 documentId = Math.random().toString().substr(2); 54 documentId = Math.random().toString().substr(2);
54 55
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 // been prevented from loading by having their "beforeload" event 148 // been prevented from loading by having their "beforeload" event
148 // 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"
149 // event for other blocked elements. We need to dispatch those events 150 // event for other blocked elements. We need to dispatch those events
150 // manually here to avoid breaking element collapsing and pages that 151 // manually here to avoid breaking element collapsing and pages that
151 // rely on those events. 152 // rely on those events.
152 setTimeout(function() 153 setTimeout(function()
153 { 154 {
154 var evt = document.createEvent("Event"); 155 var evt = document.createEvent("Event");
155 evt.initEvent(eventName); 156 evt.initEvent(eventName);
156 event.target.dispatchEvent(evt); 157 event.target.dispatchEvent(evt);
157 }, 0); 158 });
158 } 159 }
159 }, true); 160 }, true);
160 } 161 }
161 162
162 163
163 /* Context menus */ 164 /* Context menus */
164 165
165 document.addEventListener("contextmenu", function(event) 166 document.addEventListener("contextmenu", function(event)
166 { 167 {
167 var element = event.srcElement; 168 var element = event.srcElement;
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 }); 223 });
223 224
224 225
225 /* Detecting extension reload/disable/uninstall (not supported on Safari) */ 226 /* Detecting extension reload/disable/uninstall (not supported on Safari) */
226 227
227 ext.onExtensionUnloaded = { 228 ext.onExtensionUnloaded = {
228 addListener: function() {}, 229 addListener: function() {},
229 removeListener: function() {} 230 removeListener: function() {}
230 }; 231 };
231 })(); 232 })();
LEFTRIGHT

Powered by Google App Engine
This is Rietveld