Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(672)

Side by Side Diff: ui/file_manager/file_manager/foreground/js/metadata_box_controller.js

Issue 2313763003: Show a local folder's size in QuickView. (Closed)
Patch Set: Show a local folder's size in QuickView. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/file_manager/file_manager/foreground/elements/files_metadata_entry.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 * Controller of metadata box. 6 * Controller of metadata box.
7 * 7 *
8 * @param{!MetadataModel} metadataModel 8 * @param{!MetadataModel} metadataModel
9 * @param{!FilesMetadataBox} metadataBox 9 * @param{!FilesMetadataBox} metadataBox
10 * @param{!FilesQuickView} quickView 10 * @param{!FilesQuickView} quickView
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 .get( 83 .get(
84 [entry], MetadataBoxController.GENERAL_METADATA_NAME.concat( 84 [entry], MetadataBoxController.GENERAL_METADATA_NAME.concat(
85 ['hosted', 'externalFileUrl'])) 85 ['hosted', 'externalFileUrl']))
86 .then(this.onGeneralMetadataLoaded_.bind(this, entry)); 86 .then(this.onGeneralMetadataLoaded_.bind(this, entry));
87 }; 87 };
88 88
89 /** 89 /**
90 * Update metadata box with general file information. 90 * Update metadata box with general file information.
91 * Then retrieve file specific metadata if any. 91 * Then retrieve file specific metadata if any.
92 * 92 *
93 * @param {!FileEntry} entry 93 * @param {!Entry} entry
94 * @param {!Array<!MetadataItem>} items 94 * @param {!Array<!MetadataItem>} items
95 * 95 *
96 * @private 96 * @private
97 */ 97 */
98 MetadataBoxController.prototype.onGeneralMetadataLoaded_ = function( 98 MetadataBoxController.prototype.onGeneralMetadataLoaded_ = function(
99 entry, items) { 99 entry, items) {
100 var type = FileType.getType(entry).type; 100 var type = FileType.getType(entry).type;
101 var item = items[0]; 101 var item = items[0];
102 102
103 this.metadataBox_.type = type; 103 this.metadataBox_.type = type;
104 if (item.size) { 104 if (item.size) {
105 this.metadataBox_.size = 105 this.metadataBox_.size =
106 this.fileMetadataFormatter_.formatSize(item.size, item.hosted); 106 this.fileMetadataFormatter_.formatSize(item.size, item.hosted);
107 } 107 }
108 if (entry.isDirectory) {
109 this.setDirectorySize_( /** @type {!DirectoryEntry} */ (entry));
110 }
108 if (item.modificationTime) { 111 if (item.modificationTime) {
109 this.metadataBox_.modificationTime = 112 this.metadataBox_.modificationTime =
110 this.fileMetadataFormatter_.formatModDate(item.modificationTime); 113 this.fileMetadataFormatter_.formatModDate(item.modificationTime);
111 } 114 }
112 115
113 if (item.externalFileUrl) { 116 if (item.externalFileUrl) {
114 this.metadataModel_.get([entry], ['contentMimeType']).then(function(items) { 117 this.metadataModel_.get([entry], ['contentMimeType']).then(function(items) {
115 var item = items[0]; 118 var item = items[0];
116 this.metadataBox_.mediaMimeType = item.contentMimeType; 119 this.metadataBox_.mediaMimeType = item.contentMimeType;
117 }.bind(this)); 120 }.bind(this));
(...skipping 22 matching lines...) Expand all
140 .then(function(items) { 143 .then(function(items) {
141 var item = items[0]; 144 var item = items[0];
142 this.metadataBox_.imageHeight = item.imageHeight; 145 this.metadataBox_.imageHeight = item.imageHeight;
143 this.metadataBox_.imageWidth = item.imageWidth; 146 this.metadataBox_.imageWidth = item.imageWidth;
144 this.metadataBox_.mediaArtist = item.mediaArtist; 147 this.metadataBox_.mediaArtist = item.mediaArtist;
145 this.metadataBox_.mediaTitle = item.mediaTitle; 148 this.metadataBox_.mediaTitle = item.mediaTitle;
146 }.bind(this)); 149 }.bind(this));
147 } 150 }
148 } 151 }
149 }; 152 };
153
154 /**
155 * Set a current directory's size in metadata box.
156 *
157 * @param {!DirectoryEntry} entry
158 *
159 * @private
160 */
161 MetadataBoxController.prototype.setDirectorySize_ = function(entry) {
162 if (!entry.isDirectory)
163 return;
164
165 this.metadataBox_.isSizeLoading = true;
166 chrome.fileManagerPrivate.getDirectorySize(entry,
167 function(size) {
168 if(this.quickViewModel_.getSelectedEntry() != entry) {
169 return;
170 }
171 if(chrome.runtime.lastError) {
172 this.metadataBox_.isSizeLoading = false;
173 return;
174 }
175
176 this.metadataBox_.isSizeLoading = false;
177 this.metadataBox_.size =
178 this.fileMetadataFormatter_.formatSize(size, true);
179 }.bind(this));
180 };
OLDNEW
« no previous file with comments | « ui/file_manager/file_manager/foreground/elements/files_metadata_entry.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698