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; | |
24 | |
25 this.listType_ = null; | 22 this.listType_ = null; |
26 this.showDelayTimeout_ = null; | 23 this.showDelayTimeout_ = null; |
27 | 24 |
28 this.selection = null; | 25 this.selection = null; |
29 | 26 |
30 this.butterTimer_ = null; | 27 this.butterTimer_ = null; |
31 this.currentButter_ = null; | 28 this.currentButter_ = null; |
32 this.butterLastShowTime_ = 0; | 29 this.butterLastShowTime_ = 0; |
33 | 30 |
34 this.filesystemObserverId_ = null; | 31 this.filesystemObserverId_ = null; |
(...skipping 1465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1500 */ | 1497 */ |
1501 FileManager.prototype.setupCurrentDirectory_ = function(pageLoading) { | 1498 FileManager.prototype.setupCurrentDirectory_ = function(pageLoading) { |
1502 var path = location.hash ? // Location hash has the highest priority. | 1499 var path = location.hash ? // Location hash has the highest priority. |
1503 decodeURI(location.hash.substr(1)) : | 1500 decodeURI(location.hash.substr(1)) : |
1504 this.params_.defaultPath; | 1501 this.params_.defaultPath; |
1505 | 1502 |
1506 if (!pageLoading && path == this.directoryModel_.getCurrentDirPath()) | 1503 if (!pageLoading && path == this.directoryModel_.getCurrentDirPath()) |
1507 return; | 1504 return; |
1508 | 1505 |
1509 if (!path) { | 1506 if (!path) { |
1510 this.directoryModel_.setupDefaultPath(); | 1507 path = this.directoryModel_.getDefaultDirectory(); |
1511 return; | 1508 } else if (path.indexOf('/') == -1) { |
| 1509 // Path is a file name. |
| 1510 path = this.directoryModel_.getDefaultDirectory() + '/' + path; |
1512 } | 1511 } |
1513 | 1512 |
1514 // In the FULL_PAGE mode if the hash path points to a file we might have | 1513 // In the FULL_PAGE mode if the hash path points to a file we might have |
1515 // to invoke a task after selecting it. | 1514 // to invoke a task after selecting it. |
1516 // If the file path is in params_ we only want to select the file. | 1515 // If the file path is in params_ we only want to select the file. |
1517 var invokeHandlers = pageLoading && !this.params_.selectOnly && | 1516 var invokeHandlers = pageLoading && !this.params_.selectOnly && |
1518 this.dialogType_ == FileManager.DialogType.FULL_PAGE && | 1517 this.dialogType_ == FileManager.DialogType.FULL_PAGE && |
1519 !!location.hash; | 1518 !!location.hash; |
1520 | 1519 |
1521 if (DirectoryModel.getRootType(path) == DirectoryModel.RootType.GDATA) { | 1520 if (DirectoryModel.getRootType(path) == DirectoryModel.RootType.GDATA) { |
(...skipping 3126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4648 this.gdataSpaceInfoBar_.style.width = | 4647 this.gdataSpaceInfoBar_.style.width = |
4649 (100 * usedSpace / result.totalSizeKB) + '%'; | 4648 (100 * usedSpace / result.totalSizeKB) + '%'; |
4650 } else { | 4649 } else { |
4651 this.gdataSpaceInfoBar_.style.display = 'none'; | 4650 this.gdataSpaceInfoBar_.style.display = 'none'; |
4652 this.gdataSpaceInfoLabel_.textContent = | 4651 this.gdataSpaceInfoLabel_.textContent = |
4653 str('GDATA_FAILED_SPACE_INFO'); | 4652 str('GDATA_FAILED_SPACE_INFO'); |
4654 } | 4653 } |
4655 }.bind(this)); | 4654 }.bind(this)); |
4656 } | 4655 } |
4657 })(); | 4656 })(); |
OLD | NEW |