1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
9 loadBundle('chrome://browser-region/locale/region.properties');
10 loadBundle('chrome://branding/content/searchconfig.properties');
11 loadBundle('resource:/browserconfig.properties');
15 function userOnBeforePage()
17 dlog('userOnBeforePage()');
20 function userOnPause()
22 dlog('userOnPause()');
25 function userOnAfterPage()
27 dlog('userOnAfterPage()');
29 var win = gSpider.mDocument.defaultView;
30 if (win.wrappedJSObject)
32 win = win.wrappedJSObject;
36 cdump('win.location.href =' + win.location.href);
37 cdump('win.appInfo.toSource() = ' + win.appInfo.toSource());
39 var xmlhttp = new XMLHttpRequest();
40 var date = new Date();
42 if (!('toLocalFormat' in Date.prototype))
44 date.toLocaleFormat = function(fmt) {
45 var year = this.getFullYear().toString();
46 var mon = (this.getMonth() + 1).toString()
47 var day = (this.getDate()).toString();
57 return year + mon + day;
61 xmlhttp.open('get', 'http://test.mozilla.com/credentials/builds.xml', false);
64 if (!xmlhttp.responseXML)
66 cdump('Unable to retrieve credentials');
67 gPageCompleted = true;
71 var password = xmlhttp.responseXML.documentElement.getAttribute('password');
74 'http://bclary.com/log/2006/02/24/update/index.pl',
79 xmlhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
82 var preferencesList = [
84 'app.distributor.channel',
85 'app.releaseNotesURL',
88 'app.update.url.details',
89 'app.update.url.manual',
90 'browser.contentHandlers.types.0.title',
91 'browser.contentHandlers.types.0.uri',
92 'browser.contentHandlers.types.1.title',
93 'browser.contentHandlers.types.1.uri',
94 'browser.contentHandlers.types.2.title',
95 'browser.contentHandlers.types.2.uri',
96 'browser.search.defaultenginename',
97 'browser.search.order.1',
98 'browser.search.order.2',
99 'browser.search.order.3',
100 'browser.search.order.4',
101 'browser.search.order.5',
102 'browser.search.order.6',
103 'browser.search.order.7',
104 'browser.search.order.8',
105 'browser.search.order.Yahoo',
106 'browser.search.order.Yahoo.1',
107 'browser.search.order.Yahoo.2',
108 'browser.search.param.Google.1.custom',
109 'browser.search.param.Google.1.default',
110 'browser.search.param.Google.release',
111 'browser.search.param.Yahoo.release',
112 'browser.search.param.yahoo-f-CN',
113 'browser.search.param.yahoo-fr',
114 'browser.search.param.yahoo-fr-cjkt',
115 'browser.search.searchEnginesURL',
116 'browser.search.selectedEngine',
117 'browser.search.suggest.enabled',
118 'browser.search.useDBForOrder',
119 'browser.startup.homepage',
121 'mozilla.partner.id',
122 'startup.homepage_override_url',
123 'startup.homepage_welcome_url'
126 var preferences = new Preferences('');
129 for (var i = 0; i < preferencesList.length; i++)
131 var prefName = preferencesList[i];
132 var prefValue = preferences.getPref(prefName);
133 if (/^(chrome:\/\/|resource:\/)/.test(prefValue))
136 var override = getOverridePref(prefName, prefValue);
137 prefValue += '->' + override;
140 cdump('preference ' + prefName + '=' + prefValue);
141 data[prefName] = prefValue;
144 data['000 runDate'] = date.toLocaleFormat('%Y%c%d');
146 data['001 appInfo.vendor'] = win.appInfo.vendor;
147 data['002 appInfo.name'] = win.appInfo.name;
148 data['003 appInfo.version'] = win.appInfo.version;
149 data['004 appInfo.platformVersion'] = win.appInfo.platformVersion;
150 data['005 navigator.language'] = navigator.language;
151 data['006 navigator.platform'] = navigator.platform;
152 data['007 appInfo.platformBuildID'] = win.appInfo.platformBuildID;
153 data['008 appInfo.buildID'] = win.appInfo.appBuildID;
154 data['009 navigator.buildID'] = navigator.buildID;
155 data['010 appInfo.ID'] = win.appInfo.ID;
161 qs += n + '=' + encodeURIComponent(data[n]) + '&';
163 qs = qs.substring(0, qs.length - 1);
168 gPageCompleted = true;
172 function userOnStop()
174 dlog('userOnStop()');
177 function Preferences(aPrefRoot)
179 this.privs = 'UniversalXPConnect UniversalPreferencesRead UniversalPreferencesWrite';
181 if (typeof netscape != 'undefined' &&
182 'security' in netscape &&
183 'PrivilegeManager' in netscape.security &&
184 'enablePrivilege' in netscape.security.PrivilegeManager)
186 netscape.security.PrivilegeManager.enablePrivilege(this.privs);
189 const nsIPrefService = Components.interfaces.nsIPrefService;
190 const nsIPrefBranch = Components.interfaces.nsIPrefBranch;
191 const nsPrefService_CONTRACTID = "@mozilla.org/preferences-service;1";
193 this.prefRoot = aPrefRoot;
194 this.prefService = Components.classes[nsPrefService_CONTRACTID].getService(nsIPrefService);
195 this.prefBranch = this.prefService.getBranch(aPrefRoot).QueryInterface(Components.interfaces.nsIPrefBranch2);
199 function Preferences_getPrefRoot()
201 if (typeof netscape != 'undefined' &&
202 'security' in netscape &&
203 'PrivilegeManager' in netscape.security &&
204 'enablePrivilege' in netscape.security.PrivilegeManager)
206 netscape.security.PrivilegeManager.enablePrivilege(this.privs);
209 return this.prefBranch.root;
212 function Preferences_getPrefType(aPrefName)
214 if (typeof netscape != 'undefined' &&
215 'security' in netscape &&
216 'PrivilegeManager' in netscape.security &&
217 'enablePrivilege' in netscape.security.PrivilegeManager)
219 netscape.security.PrivilegeManager.enablePrivilege(this.privs);
222 return this.prefBranch.getPrefType(aPrefName);
225 function Preferences_getPref(aPrefName)
227 if (typeof netscape != 'undefined' &&
228 'security' in netscape &&
229 'PrivilegeManager' in netscape.security &&
230 'enablePrivilege' in netscape.security.PrivilegeManager)
232 netscape.security.PrivilegeManager.enablePrivilege(this.privs);
235 var prefType = this.prefBranch.getPrefType(aPrefName);
239 if (prefType == this.prefBranch.PREF_INVALID)
241 cdump('Preferences.prototype.getPref: ' + aPrefName + ' invalid type ' + prefType);
242 cdump('Assuming string');
243 prefType = this.prefBranch.PREF_STRING;
248 case this.prefBranch.PREF_STRING:
251 value = this.prefBranch.getCharPref(aPrefName);
255 cdump('Ignoring ' + ex);
258 case this.prefBranch.PREF_INT:
261 value = this.prefBranch.getIntPref(aPrefName);
265 cdump('Ignoring ' + ex);
268 case this.prefBranch.PREF_BOOL:
270 { value = this.prefBranch.getBoolPref(aPrefName);
274 cdump('Ignoring ' + ex);
278 cdump('Preferences.prototype.getPref: ' + aPrefName + ' unknown type ' + prefType);
284 function Preferences_setPref(aPrefName, aPrefValue)
286 if (typeof netscape != 'undefined' &&
287 'security' in netscape &&
288 'PrivilegeManager' in netscape.security &&
289 'enablePrivilege' in netscape.security.PrivilegeManager)
291 netscape.security.PrivilegeManager.enablePrivilege(this.privs);
294 var prefType = this.getPrefType(aPrefName);
296 if (prefType == this.prefBranch.PREF_INVALID)
298 cdump('Preferences.prototype.getPref: ' + aPrefName + ' invalid type ' + prefType);
299 cdump('Assuming string');
300 prefType = this.prefBranch.PREF_STRING;
305 case this.prefBranch.PREF_INVALID:
306 cdump('Preferences.prototype.setPref: ' + aPrefName + ' invalid type ' + prefType);
308 case this.prefBranch.PREF_STRING:
309 if (typeof aPrefValue != 'string')
311 cdump('Preferences.prototype.setPref: ' + aPrefName + ' invalid value for type string ' + aPrefValue);
317 value = this.prefBranch.setCharPref(aPrefName, aPrefValue);
321 cdump('Ignoring ' + ex);
325 case this.prefBranch.PREF_INT:
326 if (typeof aPrefValue != 'number')
328 cdump('Preferences.prototype.setPref: ' + aPrefName + ' invalid value for type number ' + aPrefValue);
334 value = this.prefBranch.setIntPref(aPrefName, aPrefValue);
338 cdump('Ignoring ' + ex);
342 case this.prefBranch.PREF_BOOL:
343 if (typeof aPrefValue != 'boolean')
345 cdump('Preferences.prototype.setPref: ' + aPrefName + ' invalid value for type boolean ' + aPrefValue);
351 value = this.prefBranch.setBoolPref(aPrefName, aPrefValue);
355 cdump('Ignoring ' + ex);
360 cdump('Preferences.prototype.setPref: ' + aPrefName + ' unknown type ' + prefType);
365 Preferences.prototype.getPref = Preferences_getPref;
366 Preferences.prototype.setPref = Preferences_setPref;
368 function loadBundle(uri)
372 var bundleService = Components.classes["@mozilla.org/intl/stringbundle;1"].
373 getService(Components.interfaces.nsIStringBundleService);
375 var bundle = bundleService.createBundle(uri);
376 var enumBundle = bundle.getSimpleEnumeration();
378 while (enumBundle.hasMoreElements())
380 var item = enumBundle.getNext().QueryInterface(Components.interfaces.nsIPropertyElement);
381 cdump('bundle ' + uri + ' key : ' + item.key + ', value : ' + item.value);
386 cdump('Error loading bundle ' + uri + ': ' + ex);
391 function getOverridePref(prefName, uri)
393 var bundleService = Components.classes["@mozilla.org/intl/stringbundle;1"].
394 getService(Components.interfaces.nsIStringBundleService);
396 var bundle = bundleService.createBundle(uri);
401 value = bundle.GetStringFromName(prefName);
405 cdump('Ignoring ' + ex);