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

Side by Side 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. 21, 2014, 1:31 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/content/ui/ext/popup.js » ('j') | chrome/content/ui/ext/popup.js » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 }
Wladimir Palant 2014/10/23 21:57:40 Why is this a closure returning the require() func
saroyanm 2014/10/27 21:49:20 Done.
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 = {
Wladimir Palant 2014/10/23 21:57:40 This is an undeclared variable. Please do it like
saroyanm 2014/10/27 21:49:20 I've declared ext in Utils and left a comment ther
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));
Wladimir Palant 2014/10/23 21:57:40 Please don't use stringBundle.formatStringFromName
saroyanm 2014/10/27 21:49:20 Done, please let me know if I'm missing something.
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)]);
Wladimir Palant 2014/10/23 21:57:40 Is the Page class used anywhere else? If not, then
saroyanm 2014/10/27 21:49:20 Done.
118 }
119 else
120 callback([]);
121 }
122 }
123 };
124 })();
OLDNEW
« 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