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

Delta Between Two Patch Sets: chrome/content/ui/ext/common.js

Issue 5294633391226880: issue 1435 - Port popup.html from Chrome/Safari/Opera to Firefox (Closed)
Left Patch Set: Created Oct. 17, 2014, 11:23 a.m.
Right Patch Set: Created Oct. 27, 2014, 9:40 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | chrome/content/ui/ext/popup.js » ('j') | chrome/content/ui/utils.js » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 /* 1 /*
2 * This file is part of Adblock Plus <http://adblockplus.org/>, 2 * This file is part of Adblock Plus <http://adblockplus.org/>,
3 * Copyright (C) 2006-2014 Eyeo GmbH 3 * Copyright (C) 2006-2014 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 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 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License 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/>. 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */ 16 */
17 17
18 /** 18 /**
19 * @fileOverview Implemenation of Firefox-specific general classes 19 * @fileOverview Implemenation of Firefox-specific general classes
20 */ 20 */
21 21
22 (function() 22 (function()
23 { 23 {
24 var UI = require("ui").UI; 24 var UI = require("ui").UI;
25 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 = { 26 var backgroundPage = {
50 extractHostFromURL: function(url) 27 extractHostFromURL: function(url)
51 { 28 {
52 try 29 try
53 { 30 {
54 return Utils.unwrapURL(url).host; 31 return Utils.unwrapURL(url).host;
55 } 32 }
56 catch(e) 33 catch(e)
57 { 34 {
58 return null; 35 return null;
59 } 36 }
60 }, 37 },
61 38
62 openOptions: function() 39 openOptions: function()
63 { 40 {
64 UI.openFiltersDialog(); 41 UI.openFiltersDialog();
65 }, 42 },
66 43
67 require: function() 44 require: require
68 {
69 return require;
70 }
71 }; 45 };
72 46
73 // Randomize URI to work around bug 719376 47 // Randomize URI to work around bug 719376
74 var pageName = location.pathname.replace(/.*\//, '').replace(/\..*?$/, ''); 48 var pageName = location.pathname.replace(/.*\//, '').replace(/\..*?$/, '');
75 var stringBundle = Services.strings.createBundle("chrome://adblockplus/locale/ " + pageName + 49 var stringBundle = Services.strings.createBundle("chrome://adblockplus/locale/ " + pageName +
76 ".properties?" + Math.random()); 50 ".properties?" + Math.random());
77 51
78 52
79 ext = { 53 ext = {
80 backgroundPage: { 54 backgroundPage: {
81 getWindow: function() 55 getWindow: function()
82 { 56 {
83 return backgroundPage; 57 return backgroundPage;
84 } 58 }
85 }, 59 },
86 60
87 i18n: { 61 i18n: {
88 /** 62 /**
89 * Get locale string 63 * Get locale string
90 * @param {String} key name of string 64 * @param {String} key name of string
91 * @param {Array} args parameters to pass 65 * @param {Array} args parameters to pass
92 * @return {String} string or null if translation is missing 66 * @return {String} string or null if translation is missing
93 */ 67 */
94 getMessage: function(key, args) 68 getMessage: function(key, args)
95 { 69 {
96 try 70 try
97 { 71 {
98 return (args ? stringBundle.formatStringFromName(key, args, args.lengt h) : stringBundle.GetStringFromName(key)); 72 return stringBundle.GetStringFromName(key);
99 } 73 }
100 catch(e) 74 catch(e)
101 { 75 {
102 Cu.reportError("Missing translation: " + key); 76 Cu.reportError("Missing translation: " + key);
103 return null; 77 return null;
104 } 78 }
105 } 79 }
106 }, 80 },
107 81
108 pages: { 82 pages: {
109 query: function(info, callback) 83 query: function(info, callback)
110 { 84 {
111 var location = UI.getCurrentLocation(UI.currentWindow); 85 var location = UI.getCurrentLocation(UI.currentWindow);
112 if (info.active && info.lastFocusedWindow && location) 86 if (info.active && info.lastFocusedWindow && location)
113 { 87 {
114 var tab = { 88 callback([{
115 url: location.spec 89 url: location.spec,
116 }; 90 sendMessage: (message, responseCallback) => responseCallback()
117 callback([new Page(tab)]); 91 }]);
118 } 92 }
119 else 93 else
120 callback([]); 94 callback([]);
121 } 95 }
122 } 96 }
123 }; 97 };
124 })(); 98 })();
LEFTRIGHT

Powered by Google App Engine
This is Rietveld