Issue 1682: don't use FUEL in pdf.js
This commit is contained in:
parent
adbe74c7a6
commit
b607147368
21
extensions/firefox/bootstrap.js
vendored
21
extensions/firefox/bootstrap.js
vendored
@ -10,13 +10,26 @@ let Cc = Components.classes;
|
|||||||
let Ci = Components.interfaces;
|
let Ci = Components.interfaces;
|
||||||
let Cm = Components.manager;
|
let Cm = Components.manager;
|
||||||
let Cu = Components.utils;
|
let Cu = Components.utils;
|
||||||
let application = Cc['@mozilla.org/fuel/application;1']
|
|
||||||
.getService(Ci.fuelIApplication);
|
|
||||||
|
|
||||||
Cu.import('resource://gre/modules/Services.jsm');
|
Cu.import('resource://gre/modules/Services.jsm');
|
||||||
|
|
||||||
|
function getBoolPref(pref, default) {
|
||||||
|
try {
|
||||||
|
return Services.prefs.getBoolPref(pref);
|
||||||
|
} catch (ex) {
|
||||||
|
return default;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function setStringPref(pref, value) {
|
||||||
|
let str = Cc["@mozilla.org/supports-string;1"]
|
||||||
|
.createInstance(Ci.nsISupportsString);
|
||||||
|
str.data = value;
|
||||||
|
Services.prefs.setComplexValue(pref, Ci.nsISupportsString, str);
|
||||||
|
}
|
||||||
|
|
||||||
function log(str) {
|
function log(str) {
|
||||||
if (!application.prefs.getValue(EXT_PREFIX + '.pdfBugEnabled', false))
|
if (!getBoolPref(EXT_PREFIX + '.pdfBugEnabled', false))
|
||||||
return;
|
return;
|
||||||
dump(str + '\n');
|
dump(str + '\n');
|
||||||
}
|
}
|
||||||
@ -93,6 +106,6 @@ function install(aData, aReason) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function uninstall(aData, aReason) {
|
function uninstall(aData, aReason) {
|
||||||
application.prefs.setValue(EXT_PREFIX + '.database', '{}');
|
setStringPref(EXT_PREFIX + '.database', '{}');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,14 +17,35 @@ const MAX_DATABASE_LENGTH = 4096;
|
|||||||
Cu.import('resource://gre/modules/XPCOMUtils.jsm');
|
Cu.import('resource://gre/modules/XPCOMUtils.jsm');
|
||||||
Cu.import('resource://gre/modules/Services.jsm');
|
Cu.import('resource://gre/modules/Services.jsm');
|
||||||
|
|
||||||
let application = Cc['@mozilla.org/fuel/application;1']
|
|
||||||
.getService(Ci.fuelIApplication);
|
|
||||||
let privateBrowsing = Cc['@mozilla.org/privatebrowsing;1']
|
let privateBrowsing = Cc['@mozilla.org/privatebrowsing;1']
|
||||||
.getService(Ci.nsIPrivateBrowsingService);
|
.getService(Ci.nsIPrivateBrowsingService);
|
||||||
let inPrivateBrowswing = privateBrowsing.privateBrowsingEnabled;
|
let inPrivateBrowswing = privateBrowsing.privateBrowsingEnabled;
|
||||||
|
|
||||||
|
function getBoolPref(pref, default) {
|
||||||
|
try {
|
||||||
|
return Services.prefs.getBoolPref(pref);
|
||||||
|
} catch (ex) {
|
||||||
|
return default;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function setStringPref(pref, value) {
|
||||||
|
let str = Cc["@mozilla.org/supports-string;1"]
|
||||||
|
.createInstance(Ci.nsISupportsString);
|
||||||
|
str.data = value;
|
||||||
|
Services.prefs.setComplexValue(pref, Ci.nsISupportsString, str);
|
||||||
|
}
|
||||||
|
|
||||||
|
function getStringPref(pref, default) {
|
||||||
|
try {
|
||||||
|
return Services.prefs.getComplexValue(pref, Ci.nsISupportsString).data;
|
||||||
|
} catch (ex) {
|
||||||
|
return default;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function log(aMsg) {
|
function log(aMsg) {
|
||||||
if (!application.prefs.getValue(EXT_PREFIX + '.pdfBugEnabled', false))
|
if (!getBoolPref(EXT_PREFIX + '.pdfBugEnabled', false))
|
||||||
return;
|
return;
|
||||||
let msg = 'PdfStreamConverter.js: ' + (aMsg.join ? aMsg.join('') : aMsg);
|
let msg = 'PdfStreamConverter.js: ' + (aMsg.join ? aMsg.join('') : aMsg);
|
||||||
Services.console.logStringMessage(msg);
|
Services.console.logStringMessage(msg);
|
||||||
@ -51,18 +72,18 @@ ChromeActions.prototype = {
|
|||||||
// Protect against something sending tons of data to setDatabase.
|
// Protect against something sending tons of data to setDatabase.
|
||||||
if (data.length > MAX_DATABASE_LENGTH)
|
if (data.length > MAX_DATABASE_LENGTH)
|
||||||
return;
|
return;
|
||||||
application.prefs.setValue(EXT_PREFIX + '.database', data);
|
setStringPref(EXT_PREFIX + '.database', data);
|
||||||
},
|
},
|
||||||
getDatabase: function() {
|
getDatabase: function() {
|
||||||
if (this.inPrivateBrowswing)
|
if (this.inPrivateBrowswing)
|
||||||
return '{}';
|
return '{}';
|
||||||
return application.prefs.getValue(EXT_PREFIX + '.database', '{}');
|
return getStringPref(EXT_PREFIX + '.database', '{}');
|
||||||
},
|
},
|
||||||
getLocale: function() {
|
getLocale: function() {
|
||||||
return application.prefs.getValue('general.useragent.locale', 'en-US');
|
return getStringPref('general.useragent.locale', 'en-US');
|
||||||
},
|
},
|
||||||
pdfBugEnabled: function() {
|
pdfBugEnabled: function() {
|
||||||
return application.prefs.getValue(EXT_PREFIX + '.pdfBugEnabled', false);
|
return getBoolPref(EXT_PREFIX + '.pdfBugEnabled', false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user