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

Unified Diff: extensions/renderer/resources/printer_provider_custom_bindings.js

Issue 973993003: Instead of ArrayBuffer, pass blob with printerProvider.onPrintRequested (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 5 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
Index: extensions/renderer/resources/printer_provider_custom_bindings.js
diff --git a/extensions/renderer/resources/printer_provider_custom_bindings.js b/extensions/renderer/resources/printer_provider_custom_bindings.js
index 9bf9fa27bf09f7a7c88208051cd20077c2d409bc..8e858bac9f5cdbe2f4d6f424bfaa7157a0367c26 100644
--- a/extensions/renderer/resources/printer_provider_custom_bindings.js
+++ b/extensions/renderer/resources/printer_provider_custom_bindings.js
@@ -6,6 +6,7 @@ var binding = require('binding').Binding.create('printerProvider');
var printerProviderInternal = require('binding').Binding.create(
'printerProviderInternal').generate();
var eventBindings = require('event_bindings');
+var blobNatives = requireNative('blob_natives');
var printerProviderSchema =
requireNative('schema_registry').GetSchema('printerProvider')
@@ -29,9 +30,15 @@ var validate = require('schemaUtils').validate;
// Handles a chrome.printerProvider event as described in the file comment.
// |eventName|: The event name.
+// |prepareArgsForDispatch|: Function called before dispatching the event to
+// the extension. It's called with original event |args| list and callback
+// that should be called when the |args| are ready for dispatch. The
+// callbacks should report whether the argument preparation was successful.
+// The function should not change the first argument, which contains the
+// request id.
// |resultreporter|: The function that should be called to report event result.
-// One of chrome.printerProviderInternal API functions.
-function handleEvent(eventName, resultReporter) {
+// One of chrome.printerProviderInternal API functions.
+function handleEvent(eventName, prepareArgsForDispatch, resultReporter) {
eventBindings.registerArgumentMassager(
'printerProvider.' + eventName,
function(args, dispatch) {
@@ -69,15 +76,43 @@ function handleEvent(eventName, resultReporter) {
}
};
- dispatch(args.slice(1).concat(reportResult));
+ prepareArgsForDispatch(args, function(success) {
+ if (!success) {
+ // Do not throw an exception since the extension should not yet be
+ // aware of the event.
+ resultReporter(args[0], null);
not at google - send to devlin 2015/03/04 21:54:49 document that args[0] is the request ID, like you
tbarzic 2015/03/04 23:24:34 Done.
+ return;
+ }
+ dispatch(args.slice(1).concat(reportResult));
+ });
});
}
-handleEvent('onGetPrintersRequested', printerProviderInternal.reportPrinters);
+// Sets up printJob.document property for a print request. The printJob argument
+// is at |args[1]|.
+function createPrintRequestBlobArguments(args, callback) {
+ printerProviderInternal.getPrintData(args[0], function(blobInfo) {
not at google - send to devlin 2015/03/04 21:54:49 and here
tbarzic 2015/03/04 23:24:34 Done.
+ if (chrome.runtime.lastError) {
+ callback(false);
+ return;
+ }
+
+ args[1].document = blobNatives.TakeBrowserProcessBlob(
not at google - send to devlin 2015/03/04 21:54:49 and document what args[1] is.
tbarzic 2015/03/04 23:24:34 Done.
+ blobInfo.blobUuid, blobInfo.type, blobInfo.size);
+ callback(true);
+ });
+}
+
+handleEvent('onGetPrintersRequested',
+ function(args, callback) { callback(true); },
+ printerProviderInternal.reportPrinters);
handleEvent('onGetCapabilityRequested',
+ function(args, callback) { callback(true); },
printerProviderInternal.reportPrinterCapability);
-handleEvent('onPrintRequested', printerProviderInternal.reportPrintResult);
+handleEvent('onPrintRequested',
+ createPrintRequestBlobArguments,
+ printerProviderInternal.reportPrintResult);
exports.binding = binding.generate();

Powered by Google App Engine
This is Rietveld 408576698