aboutsummaryrefslogtreecommitdiff
path: root/js/io/system
diff options
context:
space:
mode:
Diffstat (limited to 'js/io/system')
-rw-r--r--js/io/system/chromeapi.js19
1 files changed, 14 insertions, 5 deletions
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, {
96 // 96 //
97 f.createWriter(function(writer) { 97 f.createWriter(function(writer) {
98 // 98 //
99 var mime, blob, type = filePath.split('.'); 99 var mime, blob, type = filePath.split('.'), version = parseInt(window.navigator.appVersion.match(/Chrome\/(\d+)\./)[1], 10);
100 type = type[type.length-1]; 100 type = type[type.length-1];
101 switch (type) { 101 switch (type) {
102 case 'bmp': 102 case 'bmp':
@@ -136,8 +136,12 @@ exports.ChromeApi = Montage.create(Object.prototype, {
136 mime = 'text/'+type; 136 mime = 'text/'+type;
137 break; 137 break;
138 } 138 }
139 // 139 //TODO: Remove version checking once Chrome version 22 is stable
140 blob = new Blob([new Uint8Array(content)], {type: type}); 140 if (version > 21) {
141 blob = new Blob([new Uint8Array(content)], {type: type});
142 } else {
143 blob = new Blob([content], {type: type});
144 }
141 // 145 //
142 writer.write(blob); 146 writer.write(blob);
143 // 147 //
@@ -166,10 +170,15 @@ exports.ChromeApi = Montage.create(Object.prototype, {
166 // 170 //
167 this.fileSystem.root.getFile(filePath, {}, function(f) { 171 this.fileSystem.root.getFile(filePath, {}, function(f) {
168 f.file(function(file) { 172 f.file(function(file) {
169 var reader = new FileReader(); 173 var reader = new FileReader(), version = parseInt(window.navigator.appVersion.match(/Chrome\/(\d+)\./)[1], 10);
170 reader.onloadend = function(e) { 174 reader.onloadend = function(e) {
171 if (callback) { 175 if (callback) {
172 callback({content: new Uint8Array(this.result), data: file, file: f, url: f.toURL()}); 176 //TODO: Remove version checking once Chrome version 22 is stable
177 if (version > 21) {
178 callback({content: new Uint8Array(this.result), data: file, file: f, url: f.toURL()});
179 } else {
180 callback({content: this.result, data: file, file: f, url: f.toURL()});
181 }
173 } 182 }
174 }; 183 };
175 reader.readAsArrayBuffer(file); 184 reader.readAsArrayBuffer(file);