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. 10, 2014, 11:36 a.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 }
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 if (info.active && info.lastFocusedWindow)
saroyanm 2014/10/10 12:05:58 Not sure about array that should be returned with
Thomas Greiner 2014/10/13 13:18:24 We do need to call the callback function even if t
saroyanm 2014/10/16 11:26:15 Done.
112 {
113 var location = UI.getCurrentLocation(UI.currentWindow);
114 var tab = {
115 url: location.spec
Thomas Greiner 2014/10/13 13:18:24 This will throw an error if location is `null`.
saroyanm 2014/10/16 11:26:15 Done.
116 };
117 callback([new Page(tab)]);
118 }
119 }
120 }
121 };
122 })();
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