Chromium Code Reviews| 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) | |
|
dgozman
2012/07/02 12:38:47
Sometimes save-as dialog is called with 'drive/fol
| |
| 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 1032 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1067 FileManager.prototype.canExecute_ = function(commandId) { | 1064 FileManager.prototype.canExecute_ = function(commandId) { |
| 1068 var readonly = this.isOnReadonlyDirectory(); | 1065 var readonly = this.isOnReadonlyDirectory(); |
| 1069 switch (commandId) { | 1066 switch (commandId) { |
| 1070 case 'copy': | 1067 case 'copy': |
| 1071 case 'cut': | 1068 case 'cut': |
| 1072 return this.document_.queryCommandEnabled(commandId); | 1069 return this.document_.queryCommandEnabled(commandId); |
| 1073 | 1070 |
| 1074 // Hack goes below, since we don't receive beforepaste event, but receive | 1071 // Hack goes below, since we don't receive beforepaste event, but receive |
| 1075 // beforecut and beforecopy events. | 1072 // beforecut and beforecopy events. |
| 1076 case 'paste': | 1073 case 'paste': |
| 1077 return this.isRenamingInProgress() | 1074 return this.isRenamingInProgress() ? |
| 1078 ? this.document_.queryCommandEnabled(commandId) | 1075 this.document_.queryCommandEnabled(commandId) : |
| 1079 : (!!this.fileTransferController_ && | 1076 (!!this.fileTransferController_ && |
| 1080 this.fileTransferController_.queryPasteCommandEnabled()); | 1077 this.fileTransferController_.queryPasteCommandEnabled()); |
| 1081 | 1078 |
| 1082 case 'rename': | 1079 case 'rename': |
| 1083 return (// Initialized to the point where we have a current directory | 1080 return (// Initialized to the point where we have a current directory |
| 1084 !readonly && | 1081 !readonly && |
| 1085 // Rename not in progress. | 1082 // Rename not in progress. |
| 1086 !this.isRenamingInProgress() && | 1083 !this.isRenamingInProgress() && |
| 1087 // Only one file selected. | 1084 // Only one file selected. |
| 1088 this.selection && | 1085 this.selection && |
| 1089 this.selection.totalCount == 1); | 1086 this.selection.totalCount == 1); |
| 1090 | 1087 |
| 1091 case 'delete': | 1088 case 'delete': |
| 1092 return (this.isRenamingInProgress() | 1089 return (this.isRenamingInProgress() ? |
| 1093 ? this.document_.queryCommandEnabled(commandId) | 1090 this.document_.queryCommandEnabled(commandId) : |
| 1094 : !readonly && | 1091 !readonly && |
| 1095 this.selection && | 1092 this.selection && |
| 1096 this.selection.totalCount > 0); | 1093 this.selection.totalCount > 0); |
| 1097 | 1094 |
| 1098 case 'newfolder': | 1095 case 'newfolder': |
| 1099 return !readonly && | 1096 return !readonly && |
| 1100 !this.directoryModel_.isSearching() && | 1097 !this.directoryModel_.isSearching() && |
| 1101 (this.dialogType_ == FileManager.DialogType.SELECT_SAVEAS_FILE || | 1098 (this.dialogType_ == FileManager.DialogType.SELECT_SAVEAS_FILE || |
| 1102 this.dialogType_ == FileManager.DialogType.FULL_PAGE); | 1099 this.dialogType_ == FileManager.DialogType.FULL_PAGE); |
| 1103 | 1100 |
| 1104 case 'unmount': | 1101 case 'unmount': |
| 1105 return true; | 1102 return true; |
| 1106 | 1103 |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1477 */ | 1474 */ |
| 1478 FileManager.prototype.setupCurrentDirectory_ = function(pageLoading) { | 1475 FileManager.prototype.setupCurrentDirectory_ = function(pageLoading) { |
| 1479 var path = location.hash ? // Location hash has the highest priority. | 1476 var path = location.hash ? // Location hash has the highest priority. |
| 1480 decodeURI(location.hash.substr(1)) : | 1477 decodeURI(location.hash.substr(1)) : |
| 1481 this.params_.defaultPath; | 1478 this.params_.defaultPath; |
| 1482 | 1479 |
| 1483 if (!pageLoading && path == this.directoryModel_.getCurrentDirPath()) | 1480 if (!pageLoading && path == this.directoryModel_.getCurrentDirPath()) |
| 1484 return; | 1481 return; |
| 1485 | 1482 |
| 1486 if (!path) { | 1483 if (!path) { |
| 1487 this.directoryModel_.setupDefaultPath(); | 1484 path = this.directoryModel_.getDefaultDirectory(); |
| 1488 return; | 1485 } else if (path.indexOf('/') == -1) { |
| 1486 // Path is a file name. | |
| 1487 path = this.directoryModel_.getDefaultDirectory() + '/' + path; | |
| 1489 } | 1488 } |
| 1490 | 1489 |
| 1491 // In the FULL_PAGE mode if the hash path points to a file we might have | 1490 // In the FULL_PAGE mode if the hash path points to a file we might have |
| 1492 // to invoke a task after selecting it. | 1491 // to invoke a task after selecting it. |
| 1493 // If the file path is in params_ we only want to select the file. | 1492 // If the file path is in params_ we only want to select the file. |
| 1494 var invokeHandlers = pageLoading && !this.params_.selectOnly && | 1493 var invokeHandlers = pageLoading && !this.params_.selectOnly && |
| 1495 this.dialogType_ == FileManager.DialogType.FULL_PAGE && | 1494 this.dialogType_ == FileManager.DialogType.FULL_PAGE && |
| 1496 !!location.hash; | 1495 !!location.hash; |
| 1497 | 1496 |
| 1498 if (DirectoryModel.getRootType(path) == DirectoryModel.RootType.GDATA) { | 1497 if (DirectoryModel.getRootType(path) == DirectoryModel.RootType.GDATA) { |
| (...skipping 3084 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4583 function closeBanner() { | 4582 function closeBanner() { |
| 4584 self.cleanupGDataWelcome_(); | 4583 self.cleanupGDataWelcome_(); |
| 4585 // Stop showing the welcome banner. | 4584 // Stop showing the welcome banner. |
| 4586 localStorage[WELCOME_HEADER_COUNTER_KEY] = WELCOME_HEADER_COUNTER_LIMIT; | 4585 localStorage[WELCOME_HEADER_COUNTER_KEY] = WELCOME_HEADER_COUNTER_LIMIT; |
| 4587 } | 4586 } |
| 4588 | 4587 |
| 4589 return maybeShowBanner; | 4588 return maybeShowBanner; |
| 4590 }; | 4589 }; |
| 4591 })(); | 4590 })(); |
| 4592 | 4591 |
| OLD | NEW |