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

Side by Side Diff: bootstrap.js.tmpl

Issue 29337900: Issue 2850 - Get rid of synchronous XMLHttpRequest on startup, embed JSON files directly instead (Closed)
Patch Set: Created March 7, 2016, 12:26 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 | lib/prefs.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* This Source Code Form is subject to the terms of the Mozilla Public 1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this 2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4 4
5 const Cc = Components.classes; 5 const Cc = Components.classes;
6 const Ci = Components.interfaces; 6 const Ci = Components.interfaces;
7 const Cr = Components.results; 7 const Cr = Components.results;
8 const Cu = Components.utils; 8 const Cu = Components.utils;
9 9
10 let {Services, atob, btoa, File, TextDecoder, TextEncoder} = Cu.import("resource ://gre/modules/Services.jsm", null); 10 let {Services, atob, btoa, File, TextDecoder, TextEncoder} = Cu.import("resource ://gre/modules/Services.jsm", null);
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 scope[list[i]] = null; 76 scope[list[i]] = null;
77 } 77 }
78 require.scopes = null; 78 require.scopes = null;
79 addonData = null; 79 addonData = null;
80 } 80 }
81 81
82 function install(params, reason) {} 82 function install(params, reason) {}
83 83
84 function uninstall(params, reason) 84 function uninstall(params, reason)
85 { 85 {
86 {%- if hasVersionPref %} 86 {%- if 'currentVersion' in jsonRequires.get('prefs.json', {}).get('defaults', {}) %}
87 const ADDON_UNINSTALL = 6; // https://developer.mozilla.org/en/Extensions/Boo tstrapped_extensions#Reason_constants 87 const ADDON_UNINSTALL = 6; // https://developer.mozilla.org/en/Extensions/Boo tstrapped_extensions#Reason_constants
88 if (reason == ADDON_UNINSTALL) 88 if (reason == ADDON_UNINSTALL)
89 { 89 {
90 // Users often uninstall/reinstall extension to "fix" issues. Clear current 90 // Users often uninstall/reinstall extension to "fix" issues. Clear current
91 // version number on uninstall to rerun first-run actions in this scenario. 91 // version number on uninstall to rerun first-run actions in this scenario.
92 Services.prefs.clearUserPref("extensions.{{metadata.get('general', 'basename ')}}.currentVersion"); 92 Services.prefs.clearUserPref("extensions.{{metadata.get('general', 'basename ')}}.currentVersion");
93 } 93 }
94 {%- endif %} 94 {%- endif %}
95 } 95 }
96 96
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 }); 166 });
167 {%- endif %} 167 {%- endif %}
168 Services.scriptloader.loadSubScript(url, scopes[module]); 168 Services.scriptloader.loadSubScript(url, scopes[module]);
169 {%- if 'info' in requires %} 169 {%- if 'info' in requires %}
170 } 170 }
171 {%- endif %} 171 {%- endif %}
172 } 172 }
173 return scopes[module].exports; 173 return scopes[module].exports;
174 } 174 }
175 require.scopes = Object.create(null); 175 require.scopes = Object.create(null);
176 {%- for name, data in jsonRequires.iteritems() %}
177 require.scopes[{{name|json}}] = {exports: {{data|json}}};
178 {%- endfor %}
176 179
177 {%- if hasChromeRequires %} 180 {%- if hasChromeRequires %}
178 Cu.import("resource://gre/modules/XPCOMUtils.jsm"); 181 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
179 182
180 let RequireObserver = 183 let RequireObserver =
181 { 184 {
182 observe: function(subject, topic, data) 185 observe: function(subject, topic, data)
183 { 186 {
184 if (topic == "{{metadata.get('general', 'basename')}}-require") 187 if (topic == "{{metadata.get('general', 'basename')}}-require")
185 { 188 {
186 subject.wrappedJSObject.exports = require(data); 189 subject.wrappedJSObject.exports = require(data);
187 } 190 }
188 }, 191 },
189 192
190 QueryInterface: XPCOMUtils.generateQI([Ci.nsISupportsWeakReference, Ci.nsIObse rver]) 193 QueryInterface: XPCOMUtils.generateQI([Ci.nsISupportsWeakReference, Ci.nsIObse rver])
191 }; 194 };
192 {%- endif %} 195 {%- endif %}
OLDNEW
« no previous file with comments | « no previous file | lib/prefs.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld