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 var backgroundPage = { |
| 27 extractHostFromURL: function(url) |
| 28 { |
| 29 try |
| 30 { |
| 31 return Utils.unwrapURL(url).host; |
| 32 } |
| 33 catch(e) |
| 34 { |
| 35 return null; |
| 36 } |
| 37 }, |
| 38 |
| 39 openOptions: function() |
| 40 { |
| 41 UI.openFiltersDialog(); |
| 42 }, |
| 43 |
| 44 require: require |
| 45 }; |
| 46 |
| 47 // Randomize URI to work around bug 719376 |
| 48 var pageName = location.pathname.replace(/.*\//, '').replace(/\..*?$/, ''); |
| 49 var stringBundle = Services.strings.createBundle("chrome://adblockplus/locale/
" + pageName + |
| 50 ".properties?" + Math.random()); |
| 51 |
| 52 |
| 53 ext = { |
| 54 backgroundPage: { |
| 55 getWindow: function() |
| 56 { |
| 57 return backgroundPage; |
| 58 } |
| 59 }, |
| 60 |
| 61 i18n: { |
| 62 /** |
| 63 * Get locale string |
| 64 * @param {String} key name of string |
| 65 * @param {Array} args parameters to pass |
| 66 * @return {String} string or null if translation is missing |
| 67 */ |
| 68 getMessage: function(key, args) |
| 69 { |
| 70 try |
| 71 { |
| 72 return stringBundle.GetStringFromName(key); |
| 73 } |
| 74 catch(e) |
| 75 { |
| 76 Cu.reportError("Missing translation: " + key); |
| 77 return null; |
| 78 } |
| 79 } |
| 80 }, |
| 81 |
| 82 pages: { |
| 83 query: function(info, callback) |
| 84 { |
| 85 var location = UI.getCurrentLocation(UI.currentWindow); |
| 86 if (info.active && info.lastFocusedWindow && location) |
| 87 { |
| 88 callback([{ |
| 89 url: location.spec, |
| 90 sendMessage: (message, responseCallback) => responseCallback() |
| 91 }]); |
| 92 } |
| 93 else |
| 94 callback([]); |
| 95 } |
| 96 } |
| 97 }; |
| 98 })(); |
OLD | NEW |