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

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

Issue 538873002: [fsp] Wire FSP to chrome.fileBrowserPrivate.getEntryProperties(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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 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 86a07b6324f31e86a6c89d46fd52a9c0baab11a8..584d4022f0182d715a2a6d23d97e7b292701755d 100644
--- a/chrome/renderer/resources/extensions/file_system_provider_custom_bindings.js
+++ b/chrome/renderer/resources/extensions/file_system_provider_custom_bindings.js
@@ -172,23 +172,29 @@ eventBindings.registerArgumentMassager(
var executionStart = Date.now();
var options = args[0];
var onSuccessCallback = function(metadata) {
+ var error;
// 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) {
- fileSystemProviderInternal.operationRequestedError(
- options.fileSystemId, options.requestId, 'FAILED',
- Date.now() - executionStart);
- throw new Error('Thumbnail data provided, but not requested.');
- }
+ if (!options.thumbnail && metadata.thumbnail)
+ error = 'Thumbnail data provided, but not requested.';
// Check the format and size. Note, that in the C++ layer, there is
// another sanity check to avoid passing any evil URL.
if ('thumbnail' in metadata && !verifyImageURI(metadata.thumbnail))
- throw new Error('Thumbnail format invalid.');
+ error = 'Thumbnail format invalid.';
+
if ('thumbnail' in metadata &&
metadata.thumbnail.length > METADATA_THUMBNAIL_SIZE_LIMIT) {
- throw new Error('Thumbnail data too large.');
+ error = 'Thumbnail data too large.';
+ }
+
+ if (error) {
+ console.error(error);
+ fileSystemProviderInternal.operationRequestedError(
+ options.fileSystemId, options.requestId, 'FAILED',
+ Date.now() - executionStart);
+ return;
}
fileSystemProviderInternal.getMetadataRequestedSuccess(
@@ -197,11 +203,13 @@ eventBindings.registerArgumentMassager(
annotateMetadata(metadata),
Date.now() - executionStart);
};
+
var onErrorCallback = function(error) {
fileSystemProviderInternal.operationRequestedError(
options.fileSystemId, options.requestId, error,
Date.now() - executionStart);
}
+
dispatch([options, onSuccessCallback, onErrorCallback]);
});
@@ -213,19 +221,28 @@ eventBindings.registerArgumentMassager(
var onSuccessCallback = function(entries, hasNext) {
var annotatedEntries = entries.map(annotateMetadata);
// It is invalid to return a thumbnail when it's not requested.
+ var error;
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.');
+ var error =
+ 'Thumbnails must not be provided when reading a directory.';
+ return;
}
});
+
+ if (error) {
+ console.error(error);
+ fileSystemProviderInternal.operationRequestedError(
+ options.fileSystemId, options.requestId, 'FAILED',
+ Date.now() - executionStart);
+ return;
+ }
+
fileSystemProviderInternal.readDirectoryRequestedSuccess(
options.fileSystemId, options.requestId, annotatedEntries, hasNext,
Date.now() - executionStart);
};
+
var onErrorCallback = function(error) {
fileSystemProviderInternal.operationRequestedError(
options.fileSystemId, options.requestId, error,

Powered by Google App Engine
This is Rietveld 408576698