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

Unified Diff: chrome/renderer/resources/extensions/file_system_provider_custom_bindings.js

Issue 513683002: [fsp] Add support for providing thumbnails. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed a bug. Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
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);

Powered by Google App Engine
This is Rietveld 408576698