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

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

Issue 50703013: fileSystemProvider: First cut at implementing fileSystemProvider API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address comments Created 7 years, 1 month 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/renderer/extensions/file_system_natives.cc ('k') | chrome/renderer/resources/renderer_resources.grd » ('j') | 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
new file mode 100644
index 0000000000000000000000000000000000000000..b7e2ea8548b001aa2dc990fa4c4d51137ad5ba61
--- /dev/null
+++ b/chrome/renderer/resources/extensions/file_system_provider_custom_bindings.js
@@ -0,0 +1,49 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Custom binding for the fileSystemProvider API.
+
+var binding = require('binding').Binding.create('fileSystemProvider');
+var fileSystemNatives = requireNative('file_system_natives');
+var GetDOMError = fileSystemNatives.GetDOMError;
+
+binding.registerCustomHook(function(bindingsAPI) {
+ var apiFunctions = bindingsAPI.apiFunctions;
+
+ apiFunctions.setUpdateArgumentsPostValidate(
+ 'mount',
+ function(displayName, successCallback, errorCallback) {
+ // Piggyback the error callback onto the success callback,
+ // so we can use the error callback later.
+ successCallback.errorCallback_ = errorCallback;
+ return [displayName, successCallback];
+ });
+
+ apiFunctions.setCustomCallback(
+ 'mount',
+ function(name, request, response) {
+ var fileSystemId = null;
+ var domError = null;
+ if (request.callback && response) {
+ fileSystemId = response[0];
+ // DOMError is present only if mount() failed.
+ if (response[1]) {
+ // Convert a Dictionary to a DOMError.
+ domError = GetDOMError(response[1].name, response[1].message);
+ response.length = 1;
+ }
+
+ var successCallback = request.callback;
+ var errorCallback = request.callback.errorCallback_;
+ delete request.callback;
+
+ if (domError)
+ errorCallback(domError);
+ else
+ successCallback(fileSystemId);
+ }
+ });
+});
+
+exports.binding = binding.generate();
« no previous file with comments | « chrome/renderer/extensions/file_system_natives.cc ('k') | chrome/renderer/resources/renderer_resources.grd » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698