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

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, 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: 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..d61da749dd9ed820019ba61474f7042017f6cbc4 100644
--- a/chrome/browser/resources/print_preview/native_layer.js
+++ b/chrome/browser/resources/print_preview/native_layer.js
@@ -36,6 +36,8 @@ cr.define('print_preview', function() {
this.onFailedToGetPrinterCapabilities_.bind(this);
global.failedToGetPrivetPrinterCapabilities =
this.onFailedToGetPrivetPrinterCapabilities_.bind(this);
+ global.failedToGetExtensionPrinterCapabilities =
+ this.onFailedToGetExtensionPrinterCapabilities_.bind(this);
global.reloadPrintersList = this.onReloadPrintersList_.bind(this);
global.printToCloud = this.onPrintToCloud_.bind(this);
global.fileSelectionCancelled =
@@ -57,6 +59,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 +101,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 +187,24 @@ 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} destinationId The ID of the destination whose
+ * capabilities are requested.
+ */
+ startGetExtensionDestinationCapabilities: function(destinationId) {
+ chrome.send('getExtensionPrinterCapabilities', [destinationId]);
+ },
+
+ /**
* 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(),
@@ -514,6 +546,21 @@ cr.define('print_preview', function() {
this.dispatchEvent(getCapsFailEvent);
},
+ /**
+ * Called when native layer fails to get settings information for a
+ * requested extension destination.
+ * @param {string} destinationId Printer affected by error.
+ * @private
+ */
+ onFailedToGetExtensionPrinterCapabilities_: function(destinationId) {
+ var getCapsFailEvent = new Event(
+ NativeLayer.EventType.GET_CAPABILITIES_FAIL);
+ getCapsFailEvent.destinationId = destinationId;
+ getCapsFailEvent.destinationOrigin =
+ print_preview.Destination.Origin.EXTENSION;
+ this.dispatchEvent(getCapsFailEvent);
+ },
+
/** Reloads the printer list. */
onReloadPrintersList_: function() {
cr.dispatchSimpleEvent(this, NativeLayer.EventType.DESTINATIONS_RELOAD);
@@ -720,6 +767,36 @@ 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} printerId The printer's ID.
+ * @param {!Object} capabilities The reported printer capabilities.
+ */
+ onExtensionCapabilitiesSet_: function(printerId,
+ capabilities) {
+ var event = new Event(NativeLayer.EventType.EXTENSION_CAPABILITIES_SET);
+ event.printerId = printerId;
+ event.capabilities = capabilities;
+ this.dispatchEvent(event);
+ },
+
+ /**
* Allows for onManipulateSettings to be called
* from the native layer.
* @private
« no previous file with comments | « chrome/browser/resources/print_preview/data/local_parsers.js ('k') | chrome/browser/resources/print_preview/print_header.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698