| 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 /** | 5 /** |
| 6 * FileManager constructor. | 6 * FileManager constructor. |
| 7 * | 7 * |
| 8 * FileManager objects encapsulate the functionality of the file selector | 8 * FileManager objects encapsulate the functionality of the file selector |
| 9 * dialogs, as well as the full screen file manager application (though the | 9 * dialogs, as well as the full screen file manager application (though the |
| 10 * latter is not yet implemented). | 10 * latter is not yet implemented). |
| 11 * | 11 * |
| 12 * @constructor | 12 * @constructor |
| 13 * @param {HTMLElement} dialogDom The DOM node containing the prototypical | 13 * @param {HTMLElement} dialogDom The DOM node containing the prototypical |
| 14 * dialog UI. | 14 * dialog UI. |
| 15 */ | 15 */ |
| 16 function FileManager(dialogDom) { | 16 function FileManager(dialogDom) { |
| 17 this.dialogDom_ = dialogDom; | 17 this.dialogDom_ = dialogDom; |
| 18 this.filesystem_ = null; | 18 this.filesystem_ = null; |
| 19 this.params_ = location.search ? | 19 this.params_ = location.search ? |
| 20 JSON.parse(decodeURIComponent(location.search.substr(1))) : | 20 JSON.parse(decodeURIComponent(location.search.substr(1))) : |
| 21 {}; | 21 {}; |
| 22 if (this.params_.defaultPath && this.params_.defaultPath.indexOf('/') != 0) |
| 23 this.params_.defaultPath = '/' + this.params_.defaultPath; |
| 22 | 24 |
| 23 this.listType_ = null; | 25 this.listType_ = null; |
| 24 this.showDelayTimeout_ = null; | 26 this.showDelayTimeout_ = null; |
| 25 | 27 |
| 26 this.selection = null; | 28 this.selection = null; |
| 27 | 29 |
| 28 this.butterTimer_ = null; | 30 this.butterTimer_ = null; |
| 29 this.currentButter_ = null; | 31 this.currentButter_ = null; |
| 30 this.butterLastShowTime_ = 0; | 32 this.butterLastShowTime_ = 0; |
| 31 | 33 |
| (...skipping 4167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4199 if (cancelled) return; | 4201 if (cancelled) return; |
| 4200 cleanup(); | 4202 cleanup(); |
| 4201 selection.urls = resolvedUrls; | 4203 selection.urls = resolvedUrls; |
| 4202 // Call next method on a timeout, as it's unsafe to | 4204 // Call next method on a timeout, as it's unsafe to |
| 4203 // close a window from a callback. | 4205 // close a window from a callback. |
| 4204 setTimeout(this.callSelectFilesApiAndClose_.bind(this, selection), 0); | 4206 setTimeout(this.callSelectFilesApiAndClose_.bind(this, selection), 0); |
| 4205 }.bind(this); | 4207 }.bind(this); |
| 4206 | 4208 |
| 4207 var onProperties = function(properties) { | 4209 var onProperties = function(properties) { |
| 4208 for (var i = 0; i < properties.length; i++) { | 4210 for (var i = 0; i < properties.length; i++) { |
| 4209 if (properties[i].present) { | 4211 if (!properties[i] || properties[i].present) { |
| 4210 // For files already in GCache, we don't get any transfer updates. | 4212 // For files already in GCache, we don't get any transfer updates. |
| 4211 filesTotal--; | 4213 filesTotal--; |
| 4212 } | 4214 } |
| 4213 } | 4215 } |
| 4214 this.resolveSelectResults_(selection.urls, onResolved); | 4216 this.resolveSelectResults_(selection.urls, onResolved); |
| 4215 }.bind(this); | 4217 }.bind(this); |
| 4216 | 4218 |
| 4217 setup(); | 4219 setup(); |
| 4218 this.metadataCache_.get(selection.urls, 'gdata', onProperties); | 4220 this.metadataCache_.get(selection.urls, 'gdata', onProperties); |
| 4219 }; | 4221 }; |
| (...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4640 function closeBanner() { | 4642 function closeBanner() { |
| 4641 self.cleanupGDataWelcome_(); | 4643 self.cleanupGDataWelcome_(); |
| 4642 // Stop showing the welcome banner. | 4644 // Stop showing the welcome banner. |
| 4643 localStorage[WELCOME_HEADER_COUNTER_KEY] = WELCOME_HEADER_COUNTER_LIMIT; | 4645 localStorage[WELCOME_HEADER_COUNTER_KEY] = WELCOME_HEADER_COUNTER_LIMIT; |
| 4644 } | 4646 } |
| 4645 | 4647 |
| 4646 return maybeShowBanner; | 4648 return maybeShowBanner; |
| 4647 }; | 4649 }; |
| 4648 })(); | 4650 })(); |
| 4649 | 4651 |
| OLD | NEW |