Bug 1044108 - Part 2: Disable QR decoder on Fennec for now. r=paul,gps

This commit is contained in:
J. Ryan Stinnett 2014-07-30 14:32:00 +02:00
Родитель 7748453d18
Коммит d5006659db
2 изменённых файлов: 20 добавлений и 2 удалений

Просмотреть файл

@ -19,7 +19,14 @@ Object.defineProperty(this, "QRErrorCorrectLevel", {
get: () => require("./encoder/index").QRErrorCorrectLevel
});
Object.defineProperty(this, "decoder", {
get: () => require("./decoder/index")
get: () => {
// Some applications don't ship the decoder, see moz.build
try {
return require("./decoder/index");
} catch(e) {
return null;
}
}
});
/**
@ -86,6 +93,9 @@ exports.encodeToDataURI = function(message, quality, version) {
* the QR code.
*/
exports.decodeFromURI = function(URI) {
if (!decoder) {
return promise.reject();
}
let deferred = promise.defer();
decoder.decodeFromURI(URI, deferred.resolve, deferred.reject);
return deferred.promise;
@ -99,5 +109,8 @@ exports.decodeFromURI = function(URI) {
* The data inside the QR code
*/
exports.decodeFromCanvas = function(canvas) {
if (!decoder) {
throw new Error("Decoder not available");
}
return decoder.decodeFromCanvas(canvas);
};

Просмотреть файл

@ -5,10 +5,15 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
DIRS += [
'decoder',
'encoder'
]
# Save file size on Fennec until there are active plans to use the decoder there
if CONFIG['MOZ_BUILD_APP'] != 'mobile/android':
DIRS += [
'decoder'
]
JS_MODULES_PATH = 'modules/devtools/qrcode'
EXTRA_JS_MODULES += [