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. 2, 2014, 7:48 a.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/ext/popup.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,142 @@
+/*
Thomas Greiner 2014/10/08 10:40:43 I assume you implemented this before we changed th
saroyanm 2014/10/10 12:05:58 Adapted, but have a little doubt.
Thomas Greiner 2014/10/13 13:18:23 Why is that?
+ * 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 implementation of platform specific general classes and API
Thomas Greiner 2014/10/08 10:40:43 What about "Implemenation of Firefox-specific gene
saroyanm 2014/10/10 12:05:58 Done.
+ */
+
+(function()
+{
+ let UI = require("ui").UI;
+
+ /**
+ * Tab class
+ * @param {Object} tab an object with url parameter
Thomas Greiner 2014/10/08 10:40:43 Nit: It's a property and not a parameter.
+ */
+ function Tab(tab)
+ {
+ this._url = tab.url;
+ }
+ Tab.prototype = {
+ _url: null,
+
+ get url()
+ {
+ return this._url;
+ },
+
+ sendMessage: function(message, responseCallback)
+ {
+ responseCallback();
+ }
+ };
+
+ /**
+ * Window class
+ * @param {Object} win Window object
+ */
+ function Window(win)
+ {
+ this._window = win;
+ }
+ Window.prototype = {
+ _window: null,
+
+ /**
+ * Pass Tab object of current active Window to callback function.
Thomas Greiner 2014/10/08 10:40:43 The text should describe the purpose of the functi
+ * @param {function} callback
+ */
+ getActiveTab: function(callback)
+ {
+ let location = UI.getCurrentLocation(this._window);
+ let tab = {
+ url: location.spec
+ };
+ callback(new Tab(tab));
+ }
+ };
+
+ let backgroundPage = {
+ extractHostFromURL: function(url)
+ {
+ try
+ {
+ return Utils.unwrapURL(url).host;
+ }
+ catch(e)
+ {
+ return null;
+ }
+ },
+
+ openOptions: function()
+ {
+ UI.openFiltersDialog();
+ },
+
+ require: function()
+ {
+ return require;
+ }
+ };
+
+ // Randomize URI to work around bug 719376
+ let pageName = location.pathname.replace(/.*\//, '').replace(/\..*?$/, '');
+ let stringBundle = Services.strings.createBundle("chrome://adblockplus/locale/" + pageName +
+ ".properties?" + Math.random());
+
+
+ ext = {
+ backgroundPage: {
+ getWindow: function()
+ {
+ return backgroundPage;
+ }
+ },
+
+ i18n: {
+ /**
+ * get locale string
Thomas Greiner 2014/10/08 10:40:43 Nit: Start with a capital letter.
+ * @param {String} key name of string
+ * @param {Array} args parameters to pass
+ */
Thomas Greiner 2014/10/08 10:40:43 Please document only where it's appropriate. Apart
saroyanm 2014/10/10 12:05:58 Done.
+ getMessage: function(key, args)
+ {
+ try
+ {
+ return (args ? stringBundle.formatStringFromName(key, args, args.length) : stringBundle.GetStringFromName(key));
+ }
+ catch(e)
+ {
+ Cu.reportError("Missing translation: " + key);
+ }
+ }
+ },
+
+ windows: {
+ /**
+ * pass focused window object to callback function
+ * @param {function} callback
Thomas Greiner 2014/10/08 10:40:43 Nit: Function and description should start with a
+ */
+ getLastFocused: function(callback)
+ {
+ let win = UI.currentWindow;
+ callback(new Window(UI.currentWindow));
+ }
+ }
+ };
+})();
« no previous file with comments | « no previous file | chrome/content/ui/ext/popup.js » ('j') | chrome/content/ui/ext/popup.js » ('J')

Powered by Google App Engine
This is Rietveld