OLD | NEW |
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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 // We must notify the background page when this page is first loadeding (now) | 71 // We must notify the background page when this page is first loadeding (now) |
72 // but also when it is re-shown (if the user uses the back button to return to | 72 // but also when it is re-shown (if the user uses the back button to return to |
73 // this page in the future). | 73 // this page in the future). |
74 notifyFrameLoading(); | 74 notifyFrameLoading(); |
75 window.addEventListener("pageshow", function(event) | 75 window.addEventListener("pageshow", function(event) |
76 { | 76 { |
77 if (event.persisted) | 77 if (event.persisted) |
78 notifyFrameLoading(); | 78 notifyFrameLoading(); |
79 }); | 79 }); |
80 | 80 |
81 if (!usingContentBlockerAPI) | 81 // Notify the background page when a prerendered page is displayed. That way |
| 82 // the existing page of the tab can be replaced with this new one. |
| 83 if (isTopLevel && isPrerendered) |
82 { | 84 { |
83 // Notify the background page when a prerendered page is displayed. That way | 85 var onVisibilitychange = function() |
84 // the existing page of the tab can be replaced with this new one. | |
85 if (isTopLevel && isPrerendered) | |
86 { | 86 { |
87 var onVisibilitychange = function() | 87 safari.self.tab.dispatchMessage("replaced", {documentId: documentId}); |
88 { | 88 document.removeEventListener("visibilitychange", onVisibilitychange); |
89 safari.self.tab.dispatchMessage("replaced", {documentId: documentId}); | 89 }; |
90 document.removeEventListener("visibilitychange", onVisibilitychange); | 90 document.addEventListener("visibilitychange", onVisibilitychange); |
91 }; | 91 } |
92 document.addEventListener("visibilitychange", onVisibilitychange); | |
93 } | |
94 | 92 |
95 /* Web requests */ | 93 /* Web requests */ |
96 | 94 |
| 95 if (!usingContentBlockerAPI) |
| 96 { |
97 document.addEventListener("beforeload", function(event) | 97 document.addEventListener("beforeload", function(event) |
98 { | 98 { |
99 // we don't block non-HTTP requests anyway, so we can bail out | 99 // we don't block non-HTTP requests anyway, so we can bail out |
100 // without asking the background page. This is even necessary | 100 // without asking the background page. This is even necessary |
101 // because passing large data (like a photo encoded as data: URL) | 101 // because passing large data (like a photo encoded as data: URL) |
102 // to the background page, freezes Safari. | 102 // to the background page, freezes Safari. |
103 if (/^(?!https?:)[\w-]+:/.test(event.url)) | 103 if (/^(?!https?:)[\w-]+:/.test(event.url)) |
104 return; | 104 return; |
105 | 105 |
106 var type = "OTHER"; | 106 var type = "OTHER"; |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 }); | 223 }); |
224 | 224 |
225 | 225 |
226 /* Detecting extension reload/disable/uninstall (not supported on Safari) */ | 226 /* Detecting extension reload/disable/uninstall (not supported on Safari) */ |
227 | 227 |
228 ext.onExtensionUnloaded = { | 228 ext.onExtensionUnloaded = { |
229 addListener: function() {}, | 229 addListener: function() {}, |
230 removeListener: function() {} | 230 removeListener: function() {} |
231 }; | 231 }; |
232 })(); | 232 })(); |
OLD | NEW |