Chromium Code Reviews| Index: ui/file_manager/file_manager/foreground/js/metadata_box_controller.js |
| diff --git a/ui/file_manager/file_manager/foreground/js/metadata_box_controller.js b/ui/file_manager/file_manager/foreground/js/metadata_box_controller.js |
| index 94d8bc8b21446b735103a799aa671dc65d4788bd..afd063bdf25bc71d88cdfd57dbccc9ab0bb1b894 100644 |
| --- a/ui/file_manager/file_manager/foreground/js/metadata_box_controller.js |
| +++ b/ui/file_manager/file_manager/foreground/js/metadata_box_controller.js |
| @@ -40,6 +40,12 @@ function MetadataBoxController( |
| */ |
| this.fileMetadataFormatter_ = fileMetadataFormatter; |
| + /** |
| + * @type {Promise.<number>} |
|
fukino
2016/09/06 09:12:45
We don't need '.'. Use Promise<number>
harukam
2016/09/06 11:25:24
Acknowledged.
|
| + * @private |
| + */ |
| + this.directorySizePromise_ = null; |
| + |
| // TODO(oka): Add storage to persist the value of |
| // quickViewModel_.metadataBoxActive. |
| /** |
| @@ -90,7 +96,7 @@ MetadataBoxController.prototype.updateView_ = function() { |
| * Update metadata box with general file information. |
| * Then retrieve file specific metadata if any. |
| * |
| - * @param {!FileEntry} entry |
| + * @param {!Entry} entry |
| * @param {!Array<!MetadataItem>} items |
| * |
| * @private |
| @@ -105,6 +111,18 @@ MetadataBoxController.prototype.onGeneralMetadataLoaded_ = function( |
| this.metadataBox_.size = |
| this.fileMetadataFormatter_.formatSize(item.size, item.hosted); |
| } |
| + if (entry.isDirectory) { |
| + this.setDirectorySize_(new Promise(function(resolve, reject) { |
|
fukino
2016/09/06 09:12:45
I think it is better to simply call this.setDirect
harukam
2016/09/06 11:25:24
OK. Thanks.
|
| + chrome.fileManagerPrivate.getDirectorySize( |
| + /** @type {!DirectoryEntry} */ (entry), |
| + function(size) { |
| + if(chrome.runtime.lastError) |
| + reject(); |
| + else |
| + resolve(size); |
| + }); |
| + })); |
| + } |
| if (item.modificationTime) { |
| this.metadataBox_.modificationTime = |
| this.fileMetadataFormatter_.formatModDate(item.modificationTime); |
| @@ -147,3 +165,30 @@ MetadataBoxController.prototype.onGeneralMetadataLoaded_ = function( |
| } |
| } |
| }; |
| + |
| +/** |
| + * Set a directory size in metadata box. |
| + * |
| + * @param {Promise.<number>} directorySizePromise |
| + * |
| + * @private |
| + */ |
| +MetadataBoxController.prototype.setDirectorySize_ = function( |
| + directorySizePromise) { |
| + this.directorySizePromise_ = directorySizePromise; |
|
fukino
2016/09/06 09:12:45
If you avoid showing the size of the wrong entry,
harukam
2016/09/06 11:25:24
Acknowledged.
|
| + if (!directorySizePromise) |
| + return; |
| + |
| + this.metadataBox_.setLoading(true); |
| + directorySizePromise.then(function(size) { |
| + if(this.directorySizePromise_ != directorySizePromise) |
| + return; |
| + this.metadataBox_.setLoading(false); |
| + this.metadataBox_.size = |
| + this.fileMetadataFormatter_.formatSize(size, true); |
| + }.bind(this)).catch(function(error) { |
| + if(this.directorySizePromise_ != directorySizePromise) |
| + return; |
| + this.metadataBox_.setLoading(false); |
| + }.bind(this)); |
| +}; |