From e2200a5545d6125b4c7f760cbfd39b90dea5ccb4 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Thu, 9 Aug 2012 09:58:32 -0700 Subject: Fix: Adding browser check to implement fix for deprecated array/blob APIs This check should be removed once version 22 of Chrome is made stable. Please test before merging. --- js/io/system/chromeapi.js | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'js/io') diff --git a/js/io/system/chromeapi.js b/js/io/system/chromeapi.js index 63bf2093..b13dd9de 100644 --- a/js/io/system/chromeapi.js +++ b/js/io/system/chromeapi.js @@ -96,7 +96,7 @@ exports.ChromeApi = Montage.create(Object.prototype, { // f.createWriter(function(writer) { // - var mime, blob, type = filePath.split('.'); + var mime, blob, type = filePath.split('.'), version = parseInt(window.navigator.appVersion.match(/Chrome\/(\d+)\./)[1], 10); type = type[type.length-1]; switch (type) { case 'bmp': @@ -136,8 +136,12 @@ exports.ChromeApi = Montage.create(Object.prototype, { mime = 'text/'+type; break; } - // - blob = new Blob([new Uint8Array(content)], {type: type}); + //TODO: Remove version checking once Chrome version 22 is stable + if (version > 21) { + blob = new Blob([new Uint8Array(content)], {type: type}); + } else { + blob = new Blob([content], {type: type}); + } // writer.write(blob); // @@ -166,10 +170,15 @@ exports.ChromeApi = Montage.create(Object.prototype, { // this.fileSystem.root.getFile(filePath, {}, function(f) { f.file(function(file) { - var reader = new FileReader(); + var reader = new FileReader(), version = parseInt(window.navigator.appVersion.match(/Chrome\/(\d+)\./)[1], 10); reader.onloadend = function(e) { if (callback) { - callback({content: new Uint8Array(this.result), data: file, file: f, url: f.toURL()}); + //TODO: Remove version checking once Chrome version 22 is stable + if (version > 21) { + callback({content: new Uint8Array(this.result), data: file, file: f, url: f.toURL()}); + } else { + callback({content: this.result, data: file, file: f, url: f.toURL()}); + } } }; reader.readAsArrayBuffer(file); -- cgit v1.2.3