| 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-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 | 
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   42  |   42  | 
|   43     this.browserAction = new BrowserAction(this); |   43     this.browserAction = new BrowserAction(this); | 
|   44   }; |   44   }; | 
|   45   Page.prototype = { |   45   Page.prototype = { | 
|   46     get url() |   46     get url() | 
|   47     { |   47     { | 
|   48       return this._frames[0].url; |   48       return this._frames[0].url; | 
|   49     }, |   49     }, | 
|   50     activate: function() |   50     activate: function() | 
|   51     { |   51     { | 
|   52       pages[this._id]._tab.activate(); |   52       this._tab.activate(); | 
|   53     }, |   53     }, | 
|   54     sendMessage: function(message, responseCallback) |   54     sendMessage: function(message, responseCallback) | 
|   55     { |   55     { | 
|   56       this._messageProxy.sendMessage(message, responseCallback, {pageId: this._i
     d}); |   56       this._messageProxy.sendMessage(message, responseCallback, {pageId: this._i
     d}); | 
|   57     } |   57     } | 
|   58   }; |   58   }; | 
|   59  |   59  | 
|   60   var isPageActive = function(page) |   60   var isPageActive = function(page) | 
|   61   { |   61   { | 
|   62     return page._tab == page._tab.browserWindow.activeTab && !page._prerendered; |   62     return page._tab == page._tab.browserWindow.activeTab && !page._prerendered; | 
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  105  |  105  | 
|  106       for (var id in pages) |  106       for (var id in pages) | 
|  107       { |  107       { | 
|  108         var page = pages[id]; |  108         var page = pages[id]; | 
|  109         var win = page._tab.browserWindow; |  109         var win = page._tab.browserWindow; | 
|  110  |  110  | 
|  111         if ("active" in info && info.active != isPageActive(page)) |  111         if ("active" in info && info.active != isPageActive(page)) | 
|  112           continue; |  112           continue; | 
|  113         if ("lastFocusedWindow" in info && info.lastFocusedWindow != (win == saf
     ari.application.activeBrowserWindow)) |  113         if ("lastFocusedWindow" in info && info.lastFocusedWindow != (win == saf
     ari.application.activeBrowserWindow)) | 
|  114           continue; |  114           continue; | 
|  115         if ("visibleWindow" in info && info.visibleWindow != win.visible) |  | 
|  116           continue; |  | 
|  117  |  115  | 
|  118         matchedPages.push(page); |  116         matchedPages.push(page); | 
|  119       }; |  117       }; | 
|  120  |  118  | 
|  121       callback(matchedPages); |  119       callback(matchedPages); | 
|  122     }, |  120     }, | 
|  123     onLoading: new ext._EventTarget() |  121     onLoading: new ext._EventTarget() | 
|  124   }; |  122   }; | 
|  125  |  123  | 
|  126   safari.application.addEventListener("close", function(event) |  124   safari.application.addEventListener("close", function(event) | 
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  176     } |  174     } | 
|  177   }; |  175   }; | 
|  178  |  176  | 
|  179   var BrowserAction = function(page) |  177   var BrowserAction = function(page) | 
|  180   { |  178   { | 
|  181     this._page = page; |  179     this._page = page; | 
|  182   }; |  180   }; | 
|  183   BrowserAction.prototype = { |  181   BrowserAction.prototype = { | 
|  184     _set: function(name, value) |  182     _set: function(name, value) | 
|  185     { |  183     { | 
|  186       var currentWindow = this._page._tab.browserWindow; |  184       var toolbarItem = getToolbarItemForWindow(this._page._tab.browserWindow); | 
|  187       var toolbarItem = getToolbarItemForWindow(currentWindow); |  | 
|  188       if (!toolbarItem) |  185       if (!toolbarItem) | 
|  189         return; |  186         return; | 
|  190  |  187  | 
|  191       var property = toolbarItemProperties[name]; |  188       var property = toolbarItemProperties[name]; | 
|  192       if (!property) |  189       if (!property) | 
|  193         property = toolbarItemProperties[name] = { |  190         property = toolbarItemProperties[name] = { | 
|  194           pages: new ext.PageMap(), |  191           pages: new ext.PageMap(), | 
|  195           global: toolbarItem[name] |  192           global: toolbarItem[name] | 
|  196         }; |  193         }; | 
|  197  |  194  | 
|  198       property.pages.set(this._page, value); |  195       property.pages.set(this._page, value); | 
|  199  |  196  | 
|  200       if (this._page._tab == currentWindow.activeTab && !this._page._prerendered
     ) |  197       if (isPageActive(this._page)) | 
|  201         toolbarItem[name] = value; |  198         toolbarItem[name] = value; | 
|  202     }, |  199     }, | 
|  203     setIcon: function(path) |  200     setIcon: function(path) | 
|  204     { |  201     { | 
|  205       this._set("image", safari.extension.baseURI + path.replace("$size", "16"))
     ; |  202       this._set("image", safari.extension.baseURI + path.replace("$size", "16"))
     ; | 
|  206     }, |  203     }, | 
|  207     setBadge: function(badge) |  204     setBadge: function(badge) | 
|  208     { |  205     { | 
|  209       if (!badge) |  206       if (!badge) | 
|  210         this._set("badge", 0); |  207         this._set("badge", 0); | 
| (...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  660         replacePage(page); |  657         replacePage(page); | 
|  661         break; |  658         break; | 
|  662     } |  659     } | 
|  663   }); |  660   }); | 
|  664  |  661  | 
|  665  |  662  | 
|  666   /* Storage */ |  663   /* Storage */ | 
|  667  |  664  | 
|  668   ext.storage = safari.extension.settings; |  665   ext.storage = safari.extension.settings; | 
|  669 })(); |  666 })(); | 
| LEFT | RIGHT |