OLD | NEW |
---|---|
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 Loading... | |
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 Loading... | |
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)); | |
fukino
2016/09/06 11:30:58
indent level should be same as function(size)
| |
180 }; | |
OLD | NEW |