| LEFT | RIGHT |
| 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 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 for (var frameId in frames) | 407 for (var frameId in frames) |
| 408 { | 408 { |
| 409 if (frames[frameId].url == this._url) | 409 if (frames[frameId].url == this._url) |
| 410 { | 410 { |
| 411 frame = frames[frameId]; | 411 frame = frames[frameId]; |
| 412 break; | 412 break; |
| 413 } | 413 } |
| 414 } | 414 } |
| 415 } | 415 } |
| 416 | 416 |
| 417 if (frame && frame.parent != -1) | 417 if (!frame || frame.parent == -1) |
| 418 return new Frame({id: frame.parent, tab: this._tab}); | |
| 419 else | |
| 420 return null; | 418 return null; |
| 419 |
| 420 return new Frame({id: frame.parent, tab: this._tab}); |
| 421 } | 421 } |
| 422 } | 422 } |
| 423 }; | 423 }; |
| 424 | 424 |
| 425 | 425 |
| 426 /* Web request blocking */ | 426 /* Web request blocking */ |
| 427 | 427 |
| 428 chrome.webRequest.onBeforeRequest.addListener(function(details) | 428 chrome.webRequest.onBeforeRequest.addListener(function(details) |
| 429 { | 429 { |
| 430 // the high-level code isn't interested in requests that aren't related | 430 // the high-level code isn't interested in requests that aren't related |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 507 onCompleted: new CompletedTabEventTarget(), | 507 onCompleted: new CompletedTabEventTarget(), |
| 508 onActivated: new ActivatedTabEventTarget(), | 508 onActivated: new ActivatedTabEventTarget(), |
| 509 onRemoved: new RemovedTabEventTarget() | 509 onRemoved: new RemovedTabEventTarget() |
| 510 }; | 510 }; |
| 511 | 511 |
| 512 ext.webRequest = { | 512 ext.webRequest = { |
| 513 onBeforeRequest: new SimpleEventTarget(), | 513 onBeforeRequest: new SimpleEventTarget(), |
| 514 handlerBehaviorChanged: chrome.webRequest.handlerBehaviorChanged | 514 handlerBehaviorChanged: chrome.webRequest.handlerBehaviorChanged |
| 515 }; | 515 }; |
| 516 | 516 |
| 517 var contextMenu = []; | 517 var contextMenuItems = []; |
| 518 var isContextMenuHidden = true; |
| 518 ext.contextMenus = { | 519 ext.contextMenus = { |
| 519 addMenuItem: function(title, contexts, onclick) | 520 addMenuItem: function(title, contexts, onclick) |
| 520 { | 521 { |
| 521 contextMenu.push({ | 522 contextMenuItems.push({ |
| 522 title: title, | 523 title: title, |
| 523 contexts: contexts, | 524 contexts: contexts, |
| 524 onclick: function(info, tab) | 525 onclick: function(info, tab) |
| 525 { | 526 { |
| 526 onclick(info.srcUrl, new Tab(tab)); | 527 onclick(info.srcUrl, new Tab(tab)); |
| 527 } | 528 } |
| 528 }); | 529 }); |
| 530 this.showMenuItems(); |
| 529 }, | 531 }, |
| 530 removeMenuItems: function() | 532 removeMenuItems: function() |
| 531 { | 533 { |
| 532 contextMenu = []; | 534 contextMenuItems = []; |
| 533 }, | 535 this.hideMenuItems(); |
| 534 showMenu: function() | 536 }, |
| 535 { | 537 showMenuItems: function() |
| 538 { |
| 539 if (!isContextMenuHidden) |
| 540 return; |
| 541 |
| 536 chrome.contextMenus.removeAll(function() | 542 chrome.contextMenus.removeAll(function() |
| 537 { | 543 { |
| 538 for (var i = 0; i < contextMenu.length; i++) | 544 for (var i = 0; i < contextMenuItems.length; i++) |
| 539 { | 545 { |
| 540 var item = contextMenu[i]; | 546 var item = contextMenuItems[i]; |
| 541 chrome.contextMenus.create({ | 547 chrome.contextMenus.create({ |
| 542 title: item.title, | 548 title: item.title, |
| 543 contexts: item.contexts, | 549 contexts: item.contexts, |
| 544 onclick: item.onclick | 550 onclick: item.onclick |
| 545 }); | 551 }); |
| 546 } | 552 } |
| 547 }); | 553 }); |
| 548 }, | 554 isContextMenuHidden = false; |
| 549 hideMenu: function() | 555 }, |
| 550 { | 556 hideMenuItems: function() |
| 557 { |
| 558 if (isContextMenuHidden) |
| 559 return; |
| 560 |
| 551 chrome.contextMenus.removeAll(); | 561 chrome.contextMenus.removeAll(); |
| 562 isContextMenuHidden = true; |
| 552 } | 563 } |
| 553 }; | 564 }; |
| 554 | 565 |
| 555 ext.onMessage = new BackgroundMessageEventTarget(); | 566 ext.onMessage = new BackgroundMessageEventTarget(); |
| 556 })(); | 567 })(); |
| LEFT | RIGHT |