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

Side by Side Diff: chrome/content/watcher.js

Issue 8396008: Fixed: Don't access string bundle using a constant URL to avoid hitting bug 719376 (Closed)
Patch Set: Created Sept. 20, 2012, 11:11 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/watcher.xul » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This Source Code is subject to the terms of the Mozilla Public License 2 * This Source Code is subject to the terms of the Mozilla Public License
3 * version 2.0 (the "License"). You can obtain a copy of the License at 3 * version 2.0 (the "License"). You can obtain a copy of the License at
4 * http://mozilla.org/MPL/2.0/. 4 * http://mozilla.org/MPL/2.0/.
5 */ 5 */
6 6
7 const Cc = Components.classes; 7 const Cc = Components.classes;
8 const Ci = Components.interfaces; 8 const Ci = Components.interfaces;
9 const Cr = Components.results; 9 const Cr = Components.results;
10 const Cu = Components.utils; 10 const Cu = Components.utils;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 else if ("require" in policyGlobal) // ABP 2.1+ without scope sepa ration 44 else if ("require" in policyGlobal) // ABP 2.1+ without scope sepa ration
45 PolicyPrivate = policyGlobal.require.scopes.contentPolicy.PolicyImplementation ; 45 PolicyPrivate = policyGlobal.require.scopes.contentPolicy.PolicyImplementation ;
46 else 46 else
47 window.close(); 47 window.close();
48 48
49 let origShouldLoad = PolicyPrivate.shouldLoad; 49 let origShouldLoad = PolicyPrivate.shouldLoad;
50 let origProcessNode = Policy.processNode; 50 let origProcessNode = Policy.processNode;
51 51
52 let currentData = null; 52 let currentData = null;
53 let processingQueue = []; 53 let processingQueue = [];
54 let stringBundle;
55 let notifier = null; 54 let notifier = null;
56 55
56 // Randomize URI to work around bug 719376
57 let stringBundle = Services.strings.createBundle("chrome://abpwatcher/locale/glo bal.properties?" + Math.random());
58
57 let clipboardHelper = Cc["@mozilla.org/widget/clipboardhelper;1"].getService(Ci. nsIClipboardHelper); 59 let clipboardHelper = Cc["@mozilla.org/widget/clipboardhelper;1"].getService(Ci. nsIClipboardHelper);
58 60
59 function init() 61 function init()
60 { 62 {
61 stringBundle = document.getElementById("stringbundle-global");
62
63 let list = document.getElementById("list"); 63 let list = document.getElementById("list");
64 list.view = treeView; 64 list.view = treeView;
65 list.focus(); 65 list.focus();
66 66
67 treeView.addObserver(updateProcessingTime); 67 treeView.addObserver(updateProcessingTime);
68 updateProcessingTime(treeView, "refresh"); 68 updateProcessingTime(treeView, "refresh");
69 69
70 // Make sure the tree view has correct filters 70 // Make sure the tree view has correct filters
71 document.getElementById("ignore-early").doCommand(); 71 document.getElementById("ignore-early").doCommand();
72 document.getElementById("filterText").doCommand(); 72 document.getElementById("filterText").doCommand();
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 entry.cols.address = String(entry.location); 201 entry.cols.address = String(entry.location);
202 if (typeof entry.type != "undefined") 202 if (typeof entry.type != "undefined")
203 { 203 {
204 entry.cols.type = String(entry.type); 204 entry.cols.type = String(entry.type);
205 try { 205 try {
206 // Nasty hack: try to get type name from ABP 206 // Nasty hack: try to get type name from ABP
207 if (entry.type in Policy.localizedDescr) 207 if (entry.type in Policy.localizedDescr)
208 entry.cols.type = String(Policy.localizedDescr[entry.type]); 208 entry.cols.type = String(Policy.localizedDescr[entry.type]);
209 } catch(e) {} 209 } catch(e) {}
210 } 210 }
211 entry.cols.result = stringBundle.getString(entry.result ? "decision.allow" : "decision.block"); 211 entry.cols.result = stringBundle.GetStringFromName(entry.result ? "decision. allow" : "decision.block");
212 if (typeof entry.context != "undefined") 212 if (typeof entry.context != "undefined")
213 entry.cols.context = (entry.context ? getNodeLabel(entry.context) : String (entry.context)); 213 entry.cols.context = (entry.context ? getNodeLabel(entry.context) : String (entry.context));
214 if (typeof entry.window != "undefined") 214 if (typeof entry.window != "undefined")
215 entry.cols.document = (entry.window ? getNodeLabel(entry.window) : String( entry.window)); 215 entry.cols.document = (entry.window ? getNodeLabel(entry.window) : String( entry.window));
216 if (typeof entry.origin != "undefined") 216 if (typeof entry.origin != "undefined")
217 entry.cols.origin = String(entry.origin); 217 entry.cols.origin = String(entry.origin);
218 if (entry.filters.length) 218 if (entry.filters.length)
219 entry.cols.filter = entry.filters.join(", "); 219 entry.cols.filter = entry.filters.join(", ");
220 if (typeof entry.processingTime != "undefined") 220 if (typeof entry.processingTime != "undefined")
221 entry.cols.time = String(entry.processingTime); 221 entry.cols.time = String(entry.processingTime);
222 222
223 let additional = []; 223 let additional = [];
224 if (entry.internal) 224 if (entry.internal)
225 additional.push(stringBundle.getString("additional.internalInvocation")); 225 additional.push(stringBundle.GetStringFromName("additional.internalInvocat ion"));
226 if (typeof entry.internalType != "undefined" && entry.type != entry.internal Type) 226 if (typeof entry.internalType != "undefined" && entry.type != entry.internal Type)
227 { 227 {
228 let internalType = String(entry.internalType); 228 let internalType = String(entry.internalType);
229 try { 229 try {
230 // Nasty hack: try to get type name from ABP 230 // Nasty hack: try to get type name from ABP
231 if (entry.internalType in Policy.localizedDescr) 231 if (entry.internalType in Policy.localizedDescr)
232 internalType = String(Policy.localizedDescr[entry.internalType]); 232 internalType = String(Policy.localizedDescr[entry.internalType]);
233 } catch(e) {} 233 } catch(e) {}
234 additional.push(stringBundle.getFormattedString("additional.typeChanged", [internalType])); 234 additional.push(stringBundle.formatStringFromName("additional.typeChanged" , [internalType], 1));
235 } 235 }
236 if (typeof entry.internalLocation != "undefined" && entry.location != entry. internalLocation) 236 if (typeof entry.internalLocation != "undefined" && entry.location != entry. internalLocation)
237 additional.push(stringBundle.getFormattedString("additional.locationChange d", [String(entry.internalLocation)])); 237 additional.push(stringBundle.formatStringFromName("additional.locationChan ged", [String(entry.internalLocation)], 1));
238 238
239 if (additional.length > 0) 239 if (additional.length > 0)
240 entry.cols.additional = additional.join(", "); 240 entry.cols.additional = additional.join(", ");
241 241
242 treeView.add(entry); 242 treeView.add(entry);
243 } 243 }
244 244
245 processingQueue = []; 245 processingQueue = [];
246 } 246 }
247 247
248 function getNodeLabel(node) 248 function getNodeLabel(node)
249 { 249 {
250 if (node instanceof Ci.nsIDOMWindow) 250 if (node instanceof Ci.nsIDOMWindow)
251 return stringBundle.getFormattedString("NodeLabel.window", [node.location.hr ef]); 251 return stringBundle.formatStringFromName("NodeLabel.window", [node.location. href], 1);
252 if (node instanceof Ci.nsIDOMDocument) 252 if (node instanceof Ci.nsIDOMDocument)
253 return stringBundle.getFormattedString("NodeLabel.document", [node.URL]); 253 return stringBundle.formatStringFromName("NodeLabel.document", [node.URL], 1 );
254 else if (node instanceof Ci.nsIDOMXULElement) 254 else if (node instanceof Ci.nsIDOMXULElement)
255 return stringBundle.getFormattedString("NodeLabel.xulElement", [node.tagName ]); 255 return stringBundle.formatStringFromName("NodeLabel.xulElement", [node.tagNa me], 1);
256 else if (node instanceof Ci.nsIDOMHTMLElement) 256 else if (node instanceof Ci.nsIDOMHTMLElement)
257 return stringBundle.getFormattedString("NodeLabel.htmlElement", [node.tagNam e]); 257 return stringBundle.formatStringFromName("NodeLabel.htmlElement", [node.tagN ame], 1);
258 else if (node instanceof Ci.nsIDOMSVGElement) 258 else if (node instanceof Ci.nsIDOMSVGElement)
259 return stringBundle.getFormattedString("NodeLabel.svgElement", [node.tagName ]); 259 return stringBundle.formatStringFromName("NodeLabel.svgElement", [node.tagNa me], 1);
260 else if (node instanceof Ci.nsIDOMElement) 260 else if (node instanceof Ci.nsIDOMElement)
261 return stringBundle.getFormattedString("NodeLabel.element", [node.tagName]); 261 return stringBundle.formatStringFromName("NodeLabel.element", [node.tagName] , 1);
262 else 262 else
263 return stringBundle.getFormattedString("NodeLabel.unknown", [String(node)]); 263 return stringBundle.formatStringFromName("NodeLabel.unknown", [String(node)] , 1);
264 } 264 }
265 265
266 function fillInTooltip(event) 266 function fillInTooltip(event)
267 { 267 {
268 let entry = treeView.getEntryAt(event.clientX, event.clientY); 268 let entry = treeView.getEntryAt(event.clientX, event.clientY);
269 if (!entry) 269 if (!entry)
270 return false; 270 return false;
271 271
272 let rows = document.getElementById("tooltip-rows"); 272 let rows = document.getElementById("tooltip-rows");
273 while (rows.firstChild) 273 while (rows.firstChild)
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
666 for (let i = 0; i < this.observers.length; i++) 666 for (let i = 0; i < this.observers.length; i++)
667 if (this.observers[i] == observer) 667 if (this.observers[i] == observer)
668 this.observers.splice(i--, 1); 668 this.observers.splice(i--, 1);
669 }, 669 },
670 notifyObservers: function(operation, entry) 670 notifyObservers: function(operation, entry)
671 { 671 {
672 for each (let observer in this.observers) 672 for each (let observer in this.observers)
673 observer(this, operation, entry); 673 observer(this, operation, entry);
674 } 674 }
675 }; 675 };
OLDNEW
« no previous file with comments | « no previous file | chrome/content/watcher.xul » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld