| OLD | NEW | 
|---|
| (Empty) |  | 
|  | 1 /* | 
|  | 2  * This file is part of Adblock Plus <http://adblockplus.org/>, | 
|  | 3  * Copyright (C) 2006-2014 Eyeo GmbH | 
|  | 4  * | 
|  | 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 | 
|  | 7  * published by the Free Software Foundation. | 
|  | 8  * | 
|  | 9  * Adblock Plus is distributed in the hope that it will be useful, | 
|  | 10  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
|  | 11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
|  | 12  * GNU General Public License for more details. | 
|  | 13  * | 
|  | 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/>. | 
|  | 16  */ | 
|  | 17 | 
|  | 18 /** | 
|  | 19  * @fileOverview Implemenation of Firefox-specific general classes | 
|  | 20  */ | 
|  | 21 | 
|  | 22 (function() | 
|  | 23 { | 
|  | 24   var UI = require("ui").UI; | 
|  | 25 | 
|  | 26   /** | 
|  | 27    * Page class | 
|  | 28    * @param {Object} tab an object with url property | 
|  | 29    */ | 
|  | 30   function Page(tab) | 
|  | 31   { | 
|  | 32     this._url = tab.url; | 
|  | 33   } | 
|  | 34 | 
|  | 35   Page.prototype = { | 
|  | 36     _url: null, | 
|  | 37 | 
|  | 38     get url() | 
|  | 39     { | 
|  | 40       return this._url; | 
|  | 41     }, | 
|  | 42 | 
|  | 43     sendMessage: function(message, responseCallback) | 
|  | 44     { | 
|  | 45       responseCallback(); | 
|  | 46     } | 
|  | 47   }; | 
|  | 48 | 
|  | 49   var backgroundPage = { | 
|  | 50     extractHostFromURL: function(url) | 
|  | 51     { | 
|  | 52       try | 
|  | 53       { | 
|  | 54         return Utils.unwrapURL(url).host; | 
|  | 55       } | 
|  | 56       catch(e) | 
|  | 57       { | 
|  | 58         return null; | 
|  | 59       } | 
|  | 60     }, | 
|  | 61 | 
|  | 62     openOptions: function() | 
|  | 63     { | 
|  | 64       UI.openFiltersDialog(); | 
|  | 65     }, | 
|  | 66 | 
|  | 67     require: function() | 
|  | 68     { | 
|  | 69       return require; | 
|  | 70     } | 
|  | 71   }; | 
|  | 72 | 
|  | 73   // Randomize URI to work around bug 719376 | 
|  | 74   var pageName = location.pathname.replace(/.*\//, '').replace(/\..*?$/, ''); | 
|  | 75   var stringBundle = Services.strings.createBundle("chrome://adblockplus/locale/
     " + pageName + | 
|  | 76     ".properties?" + Math.random()); | 
|  | 77 | 
|  | 78 | 
|  | 79   ext = { | 
|  | 80     backgroundPage: { | 
|  | 81       getWindow: function() | 
|  | 82       { | 
|  | 83         return backgroundPage; | 
|  | 84       } | 
|  | 85     }, | 
|  | 86 | 
|  | 87     i18n: { | 
|  | 88       /** | 
|  | 89        * Get locale string | 
|  | 90        * @param {String} key name of string | 
|  | 91        * @param {Array} args parameters to pass | 
|  | 92        * @return {String} string or null if translation is missing | 
|  | 93        */ | 
|  | 94       getMessage: function(key, args) | 
|  | 95       { | 
|  | 96         try | 
|  | 97         { | 
|  | 98           return (args ? stringBundle.formatStringFromName(key, args, args.lengt
     h) : stringBundle.GetStringFromName(key)); | 
|  | 99         } | 
|  | 100         catch(e) | 
|  | 101         { | 
|  | 102           Cu.reportError("Missing translation: " + key); | 
|  | 103           return null; | 
|  | 104         } | 
|  | 105       } | 
|  | 106     }, | 
|  | 107 | 
|  | 108     pages: { | 
|  | 109       query: function(info, callback) | 
|  | 110       { | 
|  | 111         var location = UI.getCurrentLocation(UI.currentWindow); | 
|  | 112         if (info.active && info.lastFocusedWindow && location) | 
|  | 113         { | 
|  | 114           var tab = { | 
|  | 115             url: location.spec | 
|  | 116           }; | 
|  | 117           callback([new Page(tab)]); | 
|  | 118         } | 
|  | 119         else | 
|  | 120           callback([]); | 
|  | 121       } | 
|  | 122     } | 
|  | 123   }; | 
|  | 124 })(); | 
| OLD | NEW | 
|---|