OLD | NEW |
1 // Copyright (c) 2012 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 // Setting the src of an img to an empty string can crash the browser, so we | 5 // Setting the src of an img to an empty string can crash the browser, so we |
6 // use an empty 1x1 gif instead. | 6 // use an empty 1x1 gif instead. |
7 | 7 |
8 /** | 8 /** |
9 * FileManager constructor. | 9 * FileManager constructor. |
10 * | 10 * |
(...skipping 3910 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3921 gdataFileUrls, | 3921 gdataFileUrls, |
3922 function(localPaths) { | 3922 function(localPaths) { |
3923 // Add "localPath" parameter to the gdata file URLs. | 3923 // Add "localPath" parameter to the gdata file URLs. |
3924 for (var i = 0; i < gdataFileIndexes.length; ++i) { | 3924 for (var i = 0; i < gdataFileIndexes.length; ++i) { |
3925 var gdataIndex = gdataFileIndexes[i]; | 3925 var gdataIndex = gdataFileIndexes[i]; |
3926 if (localPaths[i]) { | 3926 if (localPaths[i]) { |
3927 fileUrls[gdataIndex] += '?localPath=' + | 3927 fileUrls[gdataIndex] += '?localPath=' + |
3928 encodeURIComponent(localPaths[i]); | 3928 encodeURIComponent(localPaths[i]); |
3929 } | 3929 } |
3930 } | 3930 } |
| 3931 // Call doSelectFiles_ on a timeout, as it's unsafe to close a |
| 3932 // window from a callback. |
| 3933 setTimeout(self.doSelectFiles_.bind(self, fileUrls), 0); |
3931 }); | 3934 }); |
3932 } else { // All files are local. | 3935 } else { // All files are local. |
3933 // Call doSelectFiles_ on a timeout, as it's unsafe to close a | |
3934 // window from a callback. | |
3935 setTimeout(self.doSelectFiles_.bind(self, fileUrls), 0); | 3936 setTimeout(self.doSelectFiles_.bind(self, fileUrls), 0); |
3936 } | 3937 } |
3937 }); | 3938 }); |
3938 }; | 3939 }; |
3939 | 3940 |
3940 /** | 3941 /** |
3941 * Selects multiple files. Closes the window. | 3942 * Selects multiple files. Closes the window. |
3942 * TODO(jamescook): Make unload handler work automatically, crbug.com/104811 | 3943 * TODO(jamescook): Make unload handler work automatically, crbug.com/104811 |
3943 * | 3944 * |
3944 * @param {Array.<string>} fileUrls Array of filename URLs. | 3945 * @param {Array.<string>} fileUrls Array of filename URLs. |
3945 */ | 3946 */ |
3946 FileManager.prototype.doSlectFiles_ = function(fileUrls) { | 3947 FileManager.prototype.doSelectFiles_ = function(fileUrls) { |
3947 chrome.fileBrowserPrivate.selectFiles(fileUrls); | 3948 chrome.fileBrowserPrivate.selectFiles(fileUrls); |
3948 this.onUnload_(); | 3949 this.onUnload_(); |
3949 window.close(); | 3950 window.close(); |
3950 }; | 3951 }; |
3951 | 3952 |
3952 /** | 3953 /** |
3953 * Handle a click of the ok button. | 3954 * Handle a click of the ok button. |
3954 * | 3955 * |
3955 * The ok button has different UI labels depending on the type of dialog, but | 3956 * The ok button has different UI labels depending on the type of dialog, but |
3956 * in code it's always referred to as 'ok'. | 3957 * in code it's always referred to as 'ok'. |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4129 }); | 4130 }); |
4130 }, onError); | 4131 }, onError); |
4131 | 4132 |
4132 function onError(err) { | 4133 function onError(err) { |
4133 console.log('Error while checking free space: ' + err); | 4134 console.log('Error while checking free space: ' + err); |
4134 setTimeout(doCheck, 1000 * 60); | 4135 setTimeout(doCheck, 1000 * 60); |
4135 } | 4136 } |
4136 } | 4137 } |
4137 } | 4138 } |
4138 })(); | 4139 })(); |
OLD | NEW |