| 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 // See http://crbug.com/68705. | 49 // See http://crbug.com/68705. |
| 50 var noStyleRulesHosts = ["mail.google.com", "mail.yahoo.com", "www.google.com"]; | 50 var noStyleRulesHosts = ["mail.google.com", "mail.yahoo.com", "www.google.com"]; |
| 51 | 51 |
| 52 var htmlPages = new ext.PageMap(); | 52 var htmlPages = new ext.PageMap(); |
| 53 | 53 |
| 54 var contextMenuItem = { | 54 var contextMenuItem = { |
| 55 title: ext.i18n.getMessage("block_element"), | 55 title: ext.i18n.getMessage("block_element"), |
| 56 contexts: ["image", "video", "audio"], | 56 contexts: ["image", "video", "audio"], |
| 57 onclick: function(page) | 57 onclick: function(page) |
| 58 { | 58 { |
| 59 page.sendMessage({type: "blockelement-context-menu-clicked"}); | 59 page.sendMessage({type: "composer.content.contextMenuClicked"}); |
| 60 } | 60 } |
| 61 }; | 61 }; |
| 62 | 62 |
| 63 // Adds or removes browser action icon according to options. | 63 // Adds or removes browser action icon according to options. |
| 64 function refreshIconAndContextMenu(page) | 64 function refreshIconAndContextMenu(page) |
| 65 { | 65 { |
| 66 var whitelisted = !!checkWhitelisted(page); | 66 var whitelisted = !!checkWhitelisted(page); |
| 67 updateIcon(page, whitelisted); | 67 updateIcon(page, whitelisted); |
| 68 | 68 |
| 69 // show or hide the context menu entry dependent on whether | 69 // show or hide the context menu entry dependent on whether |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 } | 117 } |
| 118 } | 118 } |
| 119 | 119 |
| 120 return {filters: filters, exceptions: exceptions}; | 120 return {filters: filters, exceptions: exceptions}; |
| 121 } | 121 } |
| 122 | 122 |
| 123 ext.onMessage.addListener(function (msg, sender, sendResponse) | 123 ext.onMessage.addListener(function (msg, sender, sendResponse) |
| 124 { | 124 { |
| 125 switch (msg.type) | 125 switch (msg.type) |
| 126 { | 126 { |
| 127 case "blockelement-open-popup": | 127 case "composer.openDialog": |
| 128 ext.windows.create({ | 128 ext.windows.create({ |
| 129 url: ext.getURL("block.html"), | 129 url: ext.getURL("block.html"), |
| 130 left: 50, | 130 left: 50, |
| 131 top: 50, | 131 top: 50, |
| 132 width: 420, | 132 width: 420, |
| 133 height: 200, | 133 height: 200, |
| 134 focused: true, | 134 focused: true, |
| 135 type: "popup" | 135 type: "popup" |
| 136 }, | 136 }, |
| 137 function (popupPage) { | 137 function (popupPage) { |
| 138 var popupPageId = popupPage.id; | 138 var popupPageId = popupPage.id; |
| 139 function onRemoved(removedPageId) | 139 function onRemoved(removedPageId) |
| 140 { | 140 { |
| 141 if (popupPageId == removedPageId) | 141 if (popupPageId == removedPageId) |
| 142 { | 142 { |
| 143 sender.page.sendMessage({ | 143 sender.page.sendMessage({ |
| 144 type: "blockelement-popup-closed", | 144 type: "composer.content.dialogClosed", |
| 145 popupId: popupPageId | 145 popupId: popupPageId |
| 146 }); | 146 }); |
| 147 ext.pages.onRemoved.removeListener(onRemoved); | 147 ext.pages.onRemoved.removeListener(onRemoved); |
| 148 } | 148 } |
| 149 } | 149 } |
| 150 ext.pages.onRemoved.addListener(onRemoved); | 150 ext.pages.onRemoved.addListener(onRemoved); |
| 151 | 151 |
| 152 sendResponse(popupPageId); | 152 sendResponse(popupPageId); |
| 153 }); | 153 }); |
| 154 return true; | 154 return true; |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 // The browser action popup asks us this. | 232 // The browser action popup asks us this. |
| 233 if(sender.page) | 233 if(sender.page) |
| 234 { | 234 { |
| 235 sendResponse({enabled: !checkWhitelisted(sender.page)}); | 235 sendResponse({enabled: !checkWhitelisted(sender.page)}); |
| 236 return; | 236 return; |
| 237 } | 237 } |
| 238 break; | 238 break; |
| 239 case "add-sitekey": | 239 case "add-sitekey": |
| 240 processKey(msg.token, sender.page, sender.frame); | 240 processKey(msg.token, sender.page, sender.frame); |
| 241 break; | 241 break; |
| 242 case "report-html-page": | 242 case "composer.ready": |
| 243 htmlPages.set(sender.page, null); | 243 htmlPages.set(sender.page, null); |
| 244 refreshIconAndContextMenu(sender.page); | 244 refreshIconAndContextMenu(sender.page); |
| 245 break; | 245 break; |
| 246 case "compose-filters": | 246 case "composer.getFilters": |
| 247 sendResponse(composeFilters({ | 247 sendResponse(composeFilters({ |
| 248 tagName: msg.tagName, | 248 tagName: msg.tagName, |
| 249 id: msg.id, | 249 id: msg.id, |
| 250 src: msg.src, | 250 src: msg.src, |
| 251 style: msg.style, | 251 style: msg.style, |
| 252 classes: msg.classes, | 252 classes: msg.classes, |
| 253 urls: msg.urls, | 253 urls: msg.urls, |
| 254 type: msg.mediatype, | 254 type: msg.mediatype, |
| 255 baseURL: msg.baseURL, | 255 baseURL: msg.baseURL, |
| 256 page: sender.page, | 256 page: sender.page, |
| (...skipping 27 matching lines...) Expand all Loading... |
| 284 | 284 |
| 285 targetPage.sendMessage(msg.payload); | 285 targetPage.sendMessage(msg.payload); |
| 286 } | 286 } |
| 287 break; | 287 break; |
| 288 } | 288 } |
| 289 }); | 289 }); |
| 290 | 290 |
| 291 // update icon when page changes location | 291 // update icon when page changes location |
| 292 ext.pages.onLoading.addListener(function(page) | 292 ext.pages.onLoading.addListener(function(page) |
| 293 { | 293 { |
| 294 page.sendMessage({type: "blockelement-finished"}); | 294 page.sendMessage({type: "composer.content.finished"}); |
| 295 refreshIconAndContextMenu(page); | 295 refreshIconAndContextMenu(page); |
| 296 showNextNotificationForUrl(page.url); | 296 showNextNotificationForUrl(page.url); |
| 297 }); | 297 }); |
| OLD | NEW |