| 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-2014 Eyeo GmbH | 3  * Copyright (C) 2006-2014 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 | 
| 11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
| 12  * GNU General Public License for more details. | 12  * GNU General Public License for more details. | 
| 13  * | 13  * | 
| 14  * You should have received a copy of the GNU General Public License | 14  * You should have received a copy of the GNU General Public License | 
| 15  * along with Adblock Plus.  If not, see <http://www.gnu.org/licenses/>. | 15  * along with Adblock Plus.  If not, see <http://www.gnu.org/licenses/>. | 
| 16  */ | 16  */ | 
| 17 | 17 | 
| 18 (function() | 18 (function() | 
| 19 { | 19 { | 
| 20   /* Pages */ | 20   /* Pages */ | 
| 21 | 21 | 
| 22   var sendMessage = chrome.tabs.sendMessage || chrome.tabs.sendRequest; |  | 
| 23 |  | 
| 24   var Page = ext.Page = function(tab) | 22   var Page = ext.Page = function(tab) | 
| 25   { | 23   { | 
| 26     this._id = tab.id; | 24     this._id = tab.id; | 
| 27     this._url = tab.url; | 25     this._url = tab.url; | 
| 28 | 26 | 
| 29     this.browserAction = new BrowserAction(tab.id); | 27     this.browserAction = new BrowserAction(tab.id); | 
| 30   }; | 28   }; | 
| 31   Page.prototype = { | 29   Page.prototype = { | 
| 32     get url() | 30     get url() | 
| 33     { | 31     { | 
| (...skipping 12 matching lines...) Expand all  Loading... | 
| 46         if (frame) | 44         if (frame) | 
| 47           return frame.url; | 45           return frame.url; | 
| 48       } | 46       } | 
| 49     }, | 47     }, | 
| 50     activate: function() | 48     activate: function() | 
| 51     { | 49     { | 
| 52       chrome.tabs.update(this._id, {selected: true}); | 50       chrome.tabs.update(this._id, {selected: true}); | 
| 53     }, | 51     }, | 
| 54     sendMessage: function(message, responseCallback) | 52     sendMessage: function(message, responseCallback) | 
| 55     { | 53     { | 
| 56       sendMessage(this._id, message, responseCallback); | 54       chrome.tabs.sendMessage(this._id, message, responseCallback); | 
| 57     } | 55     } | 
| 58   }; | 56   }; | 
| 59 | 57 | 
| 60   ext.pages = { | 58   ext.pages = { | 
| 61     open: function(url, callback) | 59     open: function(url, callback) | 
| 62     { | 60     { | 
| 63       if (callback) | 61       if (callback) | 
| 64       { | 62       { | 
| 65         chrome.tabs.create({url: url}, function(openedTab) | 63         chrome.tabs.create({url: url}, function(openedTab) | 
| 66         { | 64         { | 
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 310         return; | 308         return; | 
| 311 | 309 | 
| 312       chrome.contextMenus.removeAll(); | 310       chrome.contextMenus.removeAll(); | 
| 313       isContextMenuHidden = true; | 311       isContextMenuHidden = true; | 
| 314     } | 312     } | 
| 315   }; | 313   }; | 
| 316 | 314 | 
| 317 | 315 | 
| 318   /* Message passing */ | 316   /* Message passing */ | 
| 319 | 317 | 
| 320   ext._setupMessageListener(function(sender) | 318   chrome.runtime.onMessage.addListener(function(message, rawSender, sendResponse
     ) | 
| 321   { | 319   { | 
| 322     return { | 320     var sender = { | 
| 323       page: new Page(sender.tab), | 321       page: new Page(rawSender.tab), | 
| 324       frame: { | 322       frame: { | 
| 325         url: sender.url, | 323         url: rawSender.url, | 
| 326         get parent() | 324         get parent() | 
| 327         { | 325         { | 
| 328           var frames = framesOfTabs[sender.tab.id]; | 326           var frames = framesOfTabs[rawSender.tab.id]; | 
| 329 | 327 | 
| 330           if (!frames) | 328           if (!frames) | 
| 331             return null; | 329             return null; | 
| 332 | 330 | 
| 333           for (var frameId in frames) | 331           for (var frameId in frames) | 
| 334           { | 332           { | 
| 335             if (frames[frameId].url == sender.url) | 333             if (frames[frameId].url == rawSender.url) | 
| 336               return frames[frameId].parent; | 334               return frames[frameId].parent; | 
| 337           } | 335           } | 
| 338 | 336 | 
| 339           return frames[0]; | 337           return frames[0]; | 
| 340         } | 338         } | 
| 341       } | 339       } | 
| 342     }; | 340     }; | 
|  | 341 | 
|  | 342     return ext.onMessage._dispatch(message, sender, sendResponse); | 
| 343   }); | 343   }); | 
| 344 | 344 | 
| 345 | 345 | 
| 346   /* Storage */ | 346   /* Storage */ | 
| 347 | 347 | 
| 348   ext.storage = localStorage; | 348   ext.storage = localStorage; | 
| 349 })(); | 349 })(); | 
| OLD | NEW | 
|---|