| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 var harness = { | 5 var harness = { |
| 6 /** | 6 /** |
| 7 * Kick off the test harness. | 7 * Kick off the test harness. |
| 8 * | 8 * |
| 9 * Called by harness.html after the dom has been parsed. | 9 * Called by harness.html after the dom has been parsed. |
| 10 */ | 10 */ |
| 11 init: function() { | 11 init: function() { |
| 12 console.log('Initializing harness...'); | 12 console.log('Initializing harness...'); |
| 13 | 13 |
| 14 util.installFileErrorToString(); | 14 util.installFileErrorToString(); |
| 15 | 15 |
| 16 var self = this; | 16 var self = this; |
| 17 | 17 |
| 18 function onFilesystem(filesystem) { | 18 function onFilesystem(filesystem) { |
| 19 console.log('Filesystem found.'); | 19 console.log('Filesystem found.'); |
| 20 self.filesystem = filesystem; | 20 self.filesystem = filesystem; |
| 21 util.getOrCreateDirectory(filesystem.root, '/Downloads', function () {}); | 21 util.getOrCreateDirectory(filesystem.root, '/Downloads', function () {}); |
| 22 util.getOrCreateDirectory(filesystem.root, '/removable', function () {}); | 22 util.getOrCreateDirectory(filesystem.root, '/removable', function () {}); |
| 23 util.getOrCreateDirectory(filesystem.root, '/removable/disk1', | 23 util.getOrCreateDirectory(filesystem.root, '/removable/disk1', |
| 24 function () {}); | 24 function () {}); |
| 25 util.getOrCreateDirectory(filesystem.root, '/removable/disk2', | 25 util.getOrCreateDirectory(filesystem.root, '/removable/disk2', |
| 26 function () {}); | 26 function () {}); |
| 27 }; | 27 } |
| 28 | 28 |
| 29 window.webkitRequestFileSystem(window.PERSISTENT, 16 * 1024 * 1024, | 29 window.webkitStorageInfo.requestQuota( |
| 30 onFilesystem, | 30 window.PERSISTENT, |
| 31 util.flog('Error initializing filesystem')); | 31 1024*1024*1024, // 1 Gig should be enough for everybody:) |
| 32 function(grantedBytes) { |
| 33 window.webkitRequestFileSystem( |
| 34 window.PERSISTENT, |
| 35 grantedBytes, |
| 36 onFilesystem, |
| 37 util.flog('Error initializing filesystem')); |
| 38 }, |
| 39 util.flog('Error requesting filesystem quota')); |
| 32 | 40 |
| 33 var paramstr = decodeURIComponent(document.location.search.substr(1)); | 41 var paramstr = decodeURIComponent(document.location.search.substr(1)); |
| 34 this.params = paramstr ? JSON.parse(paramstr) : {}; | 42 this.params = paramstr ? JSON.parse(paramstr) : {}; |
| 35 | 43 |
| 36 var input = document.getElementById('default-path'); | 44 var input = document.getElementById('default-path'); |
| 37 input.value = this.params.defaultPath || ''; | 45 input.value = this.params.defaultPath || ''; |
| 38 input.addEventListener('keyup', this.onInputKeyUp.bind(this)); | 46 input.addEventListener('keyup', this.onInputKeyUp.bind(this)); |
| 39 | 47 |
| 40 var iframe = document.getElementById('dialog'); | 48 var iframe = document.getElementById('dialog'); |
| 41 iframe.setAttribute('src', 'main.html' + document.location.search); | 49 iframe.setAttribute('src', 'main.html' + document.location.search); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 currentDest.fullPath)); | 137 currentDest.fullPath)); |
| 130 } | 138 } |
| 131 | 139 |
| 132 function processNextFile() { | 140 function processNextFile() { |
| 133 if (files.length == 0) { | 141 if (files.length == 0) { |
| 134 console.log('Import complete: ' + importCount + ' file(s)'); | 142 console.log('Import complete: ' + importCount + ' file(s)'); |
| 135 return; | 143 return; |
| 136 } | 144 } |
| 137 | 145 |
| 138 currentSrc = files.shift(); | 146 currentSrc = files.shift(); |
| 139 var destPath = harness.fileManager.currentDirEntry_.fullPath + '/' + | 147 var destPath = harness.fileManager.getCurrentDirectory() + '/' + |
| 140 currentSrc.name.replace(/\^\^/g, '/'); | 148 currentSrc.name.replace(/\^\^/g, '/'); |
| 141 util.getOrCreateFile(self.filesystem.root, destPath, onFileFound, | 149 util.getOrCreateFile(self.filesystem.root, destPath, onFileFound, |
| 142 util.flog('Error finding path: ' + destPath)); | 150 util.flog('Error finding path: ' + destPath)); |
| 143 } | 151 } |
| 144 | 152 |
| 145 console.log('Start import: ' + files.length + ' file(s)'); | 153 console.log('Start import: ' + files.length + ' file(s)'); |
| 146 processNextFile(); | 154 processNextFile(); |
| 147 }, | 155 } |
| 148 }; | 156 }; |
| OLD | NEW |