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

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

Issue 16439016: extfs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 6 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/renderer/extensions/dispatcher.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/extfs_custom_bindings.js
diff --git a/chrome/renderer/resources/extensions/extfs_custom_bindings.js b/chrome/renderer/resources/extensions/extfs_custom_bindings.js
new file mode 100644
index 0000000000000000000000000000000000000000..267cb2e08bb540a16bdca0f01a751f0381ac9b4c
--- /dev/null
+++ b/chrome/renderer/resources/extensions/extfs_custom_bindings.js
@@ -0,0 +1,64 @@
+// 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 bindings for the downloads API.
+
+var binding = require('binding').Binding.create('extfs');
+var eventBindings = require('event_bindings');
+
+eventBindings.registerArgumentMassager(
+ 'extfs.onEntryRequested',
+ function (args, dispatch) {
+ var requestId = args[0];
+ var path = args[1];
+ var callback = function(errorCode, entry) {
+ console.log('@@@@ calling returnEntry');
+ chrome.extfs.returnEntry(requestId, errorCode, entry);
+ };
+ console.log('@@@@ calling the original listener');
+ dispatch([path, callback]);
+ });
+
+eventBindings.registerArgumentMassager(
+ 'extfs.onDirectoryEntriesRequested',
+ function (args, dispatch) {
+ var requestId = args[0];
+ var path = args[1];
+ var callback = function(errorCode, entries) {
+ console.log('@@@@ calling returnEntries');
+ chrome.extfs.returnEntries(requestId, errorCode, entries);
+ };
+ console.log('@@@@ calling the original listener');
+ dispatch([path, callback]);
+ });
+
+eventBindings.registerArgumentMassager(
+ 'extfs.onSnapshotRequested',
+ function (args, dispatch) {
+ var requestId = args[0];
+ var path = args[1];
+ var callback = function(errorCode, blob) {
+ console.log('@@@@ calling returnSnapshot');
+ console.log('@@@@ blob: ' + blob);
+ console.log('@@@@ requestId: ' + requestId);
+ chrome.extfs.returnSnapshot(requestId, errorCode, blob);
+ };
+ console.log('@@@@ calling the original listener');
+ dispatch([path, callback]);
+ });
+
+binding.registerCustomHook(function(bindingsAPI) {
+ var apiFunctions = bindingsAPI.apiFunctions;
+ apiFunctions.setUpdateArgumentsPostValidate(
+ "returnSnapshot", function(requestId, errorCode, blob) {
+ console.log('@@@@ intercepting returnSnapshot');
+ // The blob URL will be revoked in the browser.
+ var blobURL = window.URL.createObjectURL(blob);
+ console.log('@@@@ blobURL: ' + blobURL);
+ console.log('@@@@ requestId: ' + requestId);
+ return [requestId, errorCode, blobURL];
+ });
+});
+
+exports.binding = binding.generate();
« no previous file with comments | « chrome/renderer/extensions/dispatcher.cc ('k') | chrome/renderer/resources/renderer_resources.grd » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698