| Left: | ||
| Right: |
| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * This file is part of Adblock Plus <http://adblockplus.org/>, | 2 * This file is part of Adblock Plus <http://adblockplus.org/>, |
| 3 * Copyright (C) 2006-2013 Eyeo GmbH | 3 * Copyright (C) 2006-2013 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 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 363 onCompleted: new CompletedTabEventTarget(), | 363 onCompleted: new CompletedTabEventTarget(), |
| 364 onActivated: new ActivatedTabEventTarget(), | 364 onActivated: new ActivatedTabEventTarget(), |
| 365 onRemoved: new RemovedTabEventTarget() | 365 onRemoved: new RemovedTabEventTarget() |
| 366 }; | 366 }; |
| 367 | 367 |
| 368 ext.webRequest = { | 368 ext.webRequest = { |
| 369 onBeforeRequest: new BeforeRequestEventTarget(), | 369 onBeforeRequest: new BeforeRequestEventTarget(), |
| 370 handlerBehaviorChanged: chrome.webRequest.handlerBehaviorChanged | 370 handlerBehaviorChanged: chrome.webRequest.handlerBehaviorChanged |
| 371 }; | 371 }; |
| 372 | 372 |
| 373 var contextMenu = []; | |
|
Wladimir Palant
2014/01/17 15:36:55
Nit: Would contextMenuItems be a better name?
Thomas Greiner
2014/01/18 10:32:05
Done.
| |
| 373 ext.contextMenus = { | 374 ext.contextMenus = { |
| 374 create: function(title, contexts, onclick) | 375 addMenuItem: function(title, contexts, onclick) |
| 375 { | 376 { |
| 376 chrome.contextMenus.create({ | 377 contextMenu.push({ |
| 377 title: title, | 378 title: title, |
| 378 contexts: contexts, | 379 contexts: contexts, |
| 379 onclick: function(info, tab) | 380 onclick: function(info, tab) |
| 380 { | 381 { |
| 381 onclick(info.srcUrl, new Tab(tab)); | 382 onclick(info.srcUrl, new Tab(tab)); |
| 382 } | 383 } |
| 383 }); | 384 }); |
| 384 }, | 385 }, |
| 385 removeAll: function(callback) | 386 removeMenuItems: function() |
| 386 { | 387 { |
| 387 chrome.contextMenus.removeAll(callback); | 388 contextMenu = []; |
| 389 }, | |
| 390 showMenu: function() | |
| 391 { | |
| 392 chrome.contextMenus.removeAll(function() | |
| 393 { | |
| 394 for (var i = 0; i < contextMenu.length; i++) | |
| 395 { | |
| 396 var item = contextMenu[i]; | |
| 397 chrome.contextMenus.create({ | |
| 398 title: item.title, | |
| 399 contexts: item.contexts, | |
| 400 onclick: item.onclick | |
| 401 }); | |
| 402 } | |
| 403 }); | |
| 404 }, | |
| 405 hideMenu: function() | |
|
Wladimir Palant
2014/01/17 15:36:55
Nit: These methods should be called showMenuItems/
Thomas Greiner
2014/01/18 10:32:05
Done.
| |
| 406 { | |
| 407 chrome.contextMenus.removeAll(); | |
| 388 } | 408 } |
| 389 }; | 409 }; |
| 410 | |
| 390 })(); | 411 })(); |
|
Wladimir Palant
2014/01/17 15:36:55
The API here is somewhat unexpected - addMenuItem
Thomas Greiner
2014/01/18 10:32:05
Done. However, I decided to go with true as the de
| |
| OLD | NEW |