Index: chrome/renderer/resources/extensions/file_system_provider_custom_bindings.js |
diff --git a/chrome/renderer/resources/extensions/file_system_provider_custom_bindings.js b/chrome/renderer/resources/extensions/file_system_provider_custom_bindings.js |
index 020c772c849df1e94f07bcba46aad5888b11fd50..cbf3397e70d5cf93ecb004d4d64f63e81aabeb20 100644 |
--- a/chrome/renderer/resources/extensions/file_system_provider_custom_bindings.js |
+++ b/chrome/renderer/resources/extensions/file_system_provider_custom_bindings.js |
@@ -38,6 +38,8 @@ function annotateMetadata(metadata) { |
}; |
if ('mimeType' in metadata) |
result.mimeType = metadata.mimeType; |
+ if ('thumbnail' in metadata) |
+ result.thumbnail = metadata.thumbnail; |
return result; |
} |
@@ -141,6 +143,16 @@ eventBindings.registerArgumentMassager( |
var executionStart = Date.now(); |
var options = args[0]; |
var onSuccessCallback = function(metadata) { |
+ // It is invalid to return a thumbnail when it's not requested. The |
+ // restriction is added in order to avoid fetching the thumbnail while |
+ // it's not needed. |
+ if (!options.thumbnail && metadata.thumbnail) { |
hirono
2014/08/27 09:20:08
How about checking format of thumbnail?
The string
mtomasz
2014/08/28 04:57:55
Good idea. If users passed something invalid (like
|
+ fileSystemProviderInternal.operationRequestedError( |
+ options.fileSystemId, options.requestId, 'FAILED', |
+ Date.now() - executionStart); |
+ throw new Error('Thumbnail data is provided, but not requested.'); |
+ } |
+ |
fileSystemProviderInternal.getMetadataRequestedSuccess( |
options.fileSystemId, |
options.requestId, |
@@ -162,6 +174,16 @@ eventBindings.registerArgumentMassager( |
var options = args[0]; |
var onSuccessCallback = function(entries, hasNext) { |
var annotatedEntries = entries.map(annotateMetadata); |
+ // It is invalid to return a thumbnail when it's not requested. |
+ annotatedEntries.forEach(function(metadata) { |
+ if (metadata.thumbnail) { |
+ fileSystemProviderInternal.operationRequestedError( |
+ options.fileSystemId, options.requestId, 'FAILED', |
+ Date.now() - executionStart); |
+ throw new Error( |
+ 'Thumbnails must not be provided when reading a directory.'); |
+ } |
+ }); |
fileSystemProviderInternal.readDirectoryRequestedSuccess( |
options.fileSystemId, options.requestId, annotatedEntries, hasNext, |
Date.now() - executionStart); |