Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: chrome/content/ui/ext/common.js

Issue 5294633391226880: issue 1435 - Port popup.html from Chrome/Safari/Opera to Firefox (Closed)
Patch Set: Created Oct. 27, 2014, 9:40 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/content/ui/ext/popup.js » ('j') | chrome/content/ui/utils.js » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/content/ui/ext/common.js
===================================================================
new file mode 100644
--- /dev/null
+++ b/chrome/content/ui/ext/common.js
@@ -0,0 +1,98 @@
+/*
+ * This file is part of Adblock Plus <http://adblockplus.org/>,
+ * Copyright (C) 2006-2014 Eyeo GmbH
+ *
+ * Adblock Plus is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 3 as
+ * published by the Free Software Foundation.
+ *
+ * Adblock Plus is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ * @fileOverview Implemenation of Firefox-specific general classes
+ */
+
+(function()
+{
+ var UI = require("ui").UI;
+
+ var backgroundPage = {
+ extractHostFromURL: function(url)
+ {
+ try
+ {
+ return Utils.unwrapURL(url).host;
+ }
+ catch(e)
+ {
+ return null;
+ }
+ },
+
+ openOptions: function()
+ {
+ UI.openFiltersDialog();
+ },
+
+ require: require
+ };
+
+ // Randomize URI to work around bug 719376
+ var pageName = location.pathname.replace(/.*\//, '').replace(/\..*?$/, '');
+ var stringBundle = Services.strings.createBundle("chrome://adblockplus/locale/" + pageName +
+ ".properties?" + Math.random());
+
+
+ ext = {
+ backgroundPage: {
+ getWindow: function()
+ {
+ return backgroundPage;
+ }
+ },
+
+ i18n: {
+ /**
+ * Get locale string
+ * @param {String} key name of string
+ * @param {Array} args parameters to pass
+ * @return {String} string or null if translation is missing
+ */
+ getMessage: function(key, args)
+ {
+ try
+ {
+ return stringBundle.GetStringFromName(key);
+ }
+ catch(e)
+ {
+ Cu.reportError("Missing translation: " + key);
+ return null;
+ }
+ }
+ },
+
+ pages: {
+ query: function(info, callback)
+ {
+ var location = UI.getCurrentLocation(UI.currentWindow);
+ if (info.active && info.lastFocusedWindow && location)
+ {
+ callback([{
+ url: location.spec,
+ sendMessage: (message, responseCallback) => responseCallback()
+ }]);
+ }
+ else
+ callback([]);
+ }
+ }
+ };
+})();
« no previous file with comments | « no previous file | chrome/content/ui/ext/popup.js » ('j') | chrome/content/ui/utils.js » ('J')

Powered by Google App Engine
This is Rietveld