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

Side by Side Diff: lib/utils.js

Issue 5055554716172288: Issue 653 -Object.defineProperty instead of defineGetter / defineSetter (Closed)
Patch Set: I am generally not a big fan of iterating over property names. It seems like for most objects here … Created June 26, 2014, 8:33 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 | « lib/io.js ('k') | no next file » | 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 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
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 }, 48 },
49 49
50 /** 50 /**
51 * Returns whether we are running in Fennec, for Fennec-specific hacks 51 * Returns whether we are running in Fennec, for Fennec-specific hacks
52 * @type Boolean 52 * @type Boolean
53 */ 53 */
54 get isFennec() 54 get isFennec()
55 { 55 {
56 let {application} = require("info"); 56 let {application} = require("info");
57 let result = (application == "fennec" || application == "fennec2"); 57 let result = (application == "fennec" || application == "fennec2");
58 Utils.__defineGetter__("isFennec", () => result); 58 Object.defineProperty(this, "isFennec", {value: result});
59 return result; 59 return result;
60 }, 60 },
61 61
62 /** 62 /**
63 * Returns the user interface locale selected for adblockplus chrome package. 63 * Returns the user interface locale selected for adblockplus chrome package.
64 */ 64 */
65 get appLocale() 65 get appLocale()
66 { 66 {
67 let locale = "en-US"; 67 let locale = "en-US";
68 try 68 try
69 { 69 {
70 locale = Utils.chromeRegistry.getSelectedLocale("adblockplus"); 70 locale = Utils.chromeRegistry.getSelectedLocale("adblockplus");
71 } 71 }
72 catch (e) 72 catch (e)
73 { 73 {
74 Cu.reportError(e); 74 Cu.reportError(e);
75 } 75 }
76 Utils.__defineGetter__("appLocale", () => locale); 76 Object.defineProperty(this, "appLocale", {value: locale});
77 return Utils.appLocale; 77 return locale;
78 }, 78 },
79 79
80 /** 80 /**
81 * Returns version of the Gecko platform 81 * Returns version of the Gecko platform
82 */ 82 */
83 get platformVersion() 83 get platformVersion()
84 { 84 {
85 let platformVersion = Services.appinfo.platformVersion; 85 let platformVersion = Services.appinfo.platformVersion;
86 Utils.__defineGetter__("platformVersion", () => platformVersion); 86 Object.defineProperty(this, "platformVersion", {value: platformVersion});
87 return Utils.platformVersion; 87 return platformVersion;
88 }, 88 },
89 89
90 /** 90 /**
91 * Retrieves a string from global.properties string bundle, will throw if stri ng isn't found. 91 * Retrieves a string from global.properties string bundle, will throw if stri ng isn't found.
92 * 92 *
93 * @param {String} name string name 93 * @param {String} name string name
94 * @return {String} 94 * @return {String}
95 */ 95 */
96 getString: function(name) 96 getString: function(name)
97 { 97 {
(...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after
778 Cu.reportError(e); 778 Cu.reportError(e);
779 // Expected, ctypes isn't supported in Gecko 1.9.2 779 // Expected, ctypes isn't supported in Gecko 1.9.2
780 return null; 780 return null;
781 } 781 }
782 }); 782 });
783 783
784 if ("@mozilla.org/messenger/headerparser;1" in Cc) 784 if ("@mozilla.org/messenger/headerparser;1" in Cc)
785 XPCOMUtils.defineLazyServiceGetter(Utils, "headerParser", "@mozilla.org/messen ger/headerparser;1", "nsIMsgHeaderParser"); 785 XPCOMUtils.defineLazyServiceGetter(Utils, "headerParser", "@mozilla.org/messen ger/headerparser;1", "nsIMsgHeaderParser");
786 else 786 else
787 Utils.headerParser = null; 787 Utils.headerParser = null;
OLDNEW
« no previous file with comments | « lib/io.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld