| 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();
|
|
|