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

Unified Diff: chrome/browser/resources/print_preview/native_layer.js

Issue 900503002: List printers managed by extensions in print preview (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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: chrome/browser/resources/print_preview/native_layer.js
diff --git a/chrome/browser/resources/print_preview/native_layer.js b/chrome/browser/resources/print_preview/native_layer.js
index d4beb8926afb27fd2400ba4f8f52f222d76fc2be..57b73bfd32479953afff2728d6356b4700df8b0b 100644
--- a/chrome/browser/resources/print_preview/native_layer.js
+++ b/chrome/browser/resources/print_preview/native_layer.js
@@ -57,6 +57,10 @@ cr.define('print_preview', function() {
global.onPrivetCapabilitiesSet =
this.onPrivetCapabilitiesSet_.bind(this);
global.onPrivetPrintFailed = this.onPrivetPrintFailed_.bind(this);
+ global.onExtensionPrintersAdded =
+ this.onExtensionPrintersAdded_.bind(this);
+ global.onExtensionCapabilitiesSet =
+ this.onExtensionCapabilitiesSet_.bind(this);
global.onEnableManipulateSettingsForTest =
this.onEnableManipulateSettingsForTest_.bind(this);
global.printPresetOptionsFromDocument =
@@ -95,6 +99,10 @@ cr.define('print_preview', function() {
PRIVET_CAPABILITIES_SET:
'print_preview.NativeLayer.PRIVET_CAPABILITIES_SET',
PRIVET_PRINT_FAILED: 'print_preview.NativeLayer.PRIVET_PRINT_FAILED',
+ EXTENSION_PRINTERS_ADDED:
+ 'print_preview.NativeLayer.EXTENSION_PRINTERS_ADDED',
+ EXTENSION_CAPABILITIES_SET:
+ 'print_preview.NativeLayer.EXTENSION_CAPABILITIES_SET',
PRINT_PRESET_OPTIONS: 'print_preview.NativeLayer.PRINT_PRESET_OPTIONS',
};
@@ -177,6 +185,26 @@ cr.define('print_preview', function() {
},
/**
+ * Requests that extension system dispatches an event requesting the list of
+ * extension managed printers.
+ */
+ startGetExtensionDestinations: function() {
+ chrome.send('getExtensionPrinters');
+ },
+
+ /**
+ * Requests an extension destination's printing capabilities. A
+ * EXTENSION_CAPABILITIES_SET event will be dispatched in response.
+ * @param {string} extensionId The ID of the extension from which the
+ * capabilities should be requested.
+ * @param {string} printerId The ID of the printer whose capabilities are
+ * requested.
+ */
+ startGetExtensionDestinationCapabilities: function(extensionId, printerId) {
+ chrome.send('getExtensionPrinterCapabilities', [extensionId, printerId]);
+ },
+
+ /**
* Requests the destination's printing capabilities. A CAPABILITIES_SET
* event will be dispatched in response.
* @param {string} destinationId ID of the destination.
@@ -299,6 +327,10 @@ cr.define('print_preview', function() {
assert(!opt_showSystemDialog || (cr.isWindows && destination.isLocal),
'Implemented for Windows only');
+ // TODO(tbarzic): Implement this.
+ assert(!destination.isExtension,
+ 'Printing to extension printers not yet implemented.');
+
var ticket = {
'pageRange': printTicketStore.pageRange.getDocumentPageRanges(),
'mediaSize': printTicketStore.mediaSize.getValue(),
@@ -720,6 +752,40 @@ cr.define('print_preview', function() {
},
/**
+ * @param {Array.<{extensionId: string,
+ * id: string,
+ * name: string,
+ * description: (string|undefined)}>} printers The list
+ * containing information about printers added by an extension.
+ * @param {boolean} done Whether this is the final list of extension
+ * managed printers.
+ */
+ onExtensionPrintersAdded_: function(printers, done) {
+ var event = new Event(NativeLayer.EventType.EXTENSION_PRINTERS_ADDED);
+ event.printers = printers;
+ event.done = done;
+ this.dispatchEvent(event);
+ },
+
+ /**
+ * Called when an extension responds to a request for an extension printer
+ * capabilities.
+ * @param {string} extensionId The ID of extension that manages the printer.
+ * @param {string} printerId The printer's ID (within the extension's
+ * space).
+ * @param {Object} capabilities The reported printer capabilities.
+ */
+ onExtensionCapabilitiesSet_: function(extensionId,
+ printerId,
+ capabilities) {
+ var event = new Event(NativeLayer.EventType.EXTENSION_CAPABILITIES_SET);
+ event.extensionID = extensionId;
+ event.printerID = printerId;
+ event.capabilities = capabilities;
+ this.dispatchEvent(event);
+ },
+
+ /**
* Allows for onManipulateSettings to be called
* from the native layer.
* @private

Powered by Google App Engine
This is Rietveld 408576698