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

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

Issue 2643013002: Don't crash browser process when OK passed as error code in FSP API. (Closed)
Patch Set: Don't crash browser process when OK passed as error code in FSP API. Created 3 years, 10 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
« no previous file with comments | « chrome/common/extensions/api/file_system_provider.idl ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 91a271876da952bcdd39f7c0fc4dbf99db29c44d..c4bdfa0c5444308d1a4c1a5335e47a906c230236 100644
--- a/chrome/renderer/resources/extensions/file_system_provider_custom_bindings.js
+++ b/chrome/renderer/resources/extensions/file_system_provider_custom_bindings.js
@@ -120,6 +120,20 @@ function verifyMetadata(options, metadata) {
}
/**
+ * Verifies if the passed error code is valid when used to indicate
+ * a failure.
+ * @param {!string} error
+ * @return {boolean} True if valid, false if invalid.
+ */
+function verifyErrorForFailure(error) {
+ if (error === 'OK') {
+ console.error('Error code cannot be OK in case of failures.');
+ return false;
+ }
+ return true;
+}
+
+/**
* Annotates an entry metadata by serializing its modifiedTime value.
* @param {EntryMetadata} metadata Input metadata.
* @return {EntryMetadata} metadata Annotated metadata, which can be passed
@@ -156,6 +170,8 @@ function massageArgumentsDefault(args, dispatch) {
options.fileSystemId, options.requestId, Date.now() - executionStart);
};
var onErrorCallback = function(error) {
+ if (!verifyErrorForFailure(error))
+ return;
fileSystemProviderInternal.operationRequestedError(
options.fileSystemId, options.requestId, error,
Date.now() - executionStart);
@@ -188,6 +204,8 @@ eventBindings.registerArgumentMassager(
};
var onErrorCallback = function(error) {
+ if (!verifyErrorForFailure(error))
+ return;
fileSystemProviderInternal.operationRequestedError(
options.fileSystemId, options.requestId, error,
Date.now() - executionStart);
@@ -210,6 +228,8 @@ eventBindings.registerArgumentMassager(
};
var onErrorCallback = function(error) {
+ if (!verifyErrorForFailure(error))
+ return;
fileSystemProviderInternal.operationRequestedError(
options.fileSystemId, options.requestId, error,
Date.now() - executionStart);
@@ -246,6 +266,8 @@ eventBindings.registerArgumentMassager(
};
var onErrorCallback = function(error) {
+ if (!verifyErrorForFailure(error))
+ return;
fileSystemProviderInternal.operationRequestedError(
options.fileSystemId, options.requestId, error,
Date.now() - executionStart);
@@ -272,6 +294,8 @@ eventBindings.registerArgumentMassager(
Date.now() - executionStart);
};
var onErrorCallback = function(error) {
+ if (!verifyErrorForFailure(error))
+ return;
fileSystemProviderInternal.operationRequestedError(
options.fileSystemId, options.requestId, error,
Date.now() - executionStart);
@@ -339,10 +363,16 @@ eventBindings.registerArgumentMassager(
'fileSystemProvider.onMountRequested',
function(args, dispatch) {
var onSuccessCallback = function() {
- // TODO(mtomasz): To be implemented.
+ // chrome.fileManagerPrivate.addProvidedFileSystem doesn't accept
+ // any callbacks, so ignore the callback calls here.
+ // The callbacks exist for consistency with other on*Requested events.
};
var onErrorCallback = function(error) {
- // TODO(mtomasz): To be implemented.
+ if (!verifyErrorForFailure(error))
+ return;
+ // chrome.fileManagerPrivate.addProvidedFileSystem doesn't accept
+ // any callbacks, so ignore the callback calls here.
+ // The callbacks exist for consistency with other on*Requested events.
}
dispatch([onSuccessCallback, onErrorCallback]);
});
« no previous file with comments | « chrome/common/extensions/api/file_system_provider.idl ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698