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

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

Issue 1144983002: Introduce concept of provisional destinations to print preview (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 5 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
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 8c72a538284ac3e98bdaeda005022f06bf5b9754..d9289ffc33c028a4c40d6d1d446d10871dcc0759 100644
--- a/chrome/browser/resources/print_preview/native_layer.js
+++ b/chrome/browser/resources/print_preview/native_layer.js
@@ -67,6 +67,10 @@ cr.define('print_preview', function() {
this.onEnableManipulateSettingsForTest_.bind(this);
global.printPresetOptionsFromDocument =
this.onPrintPresetOptionsFromDocument_.bind(this);
+ global.onProvisionalPrinterResolved =
+ this.onProvisionalDestinationResolved_.bind(this);
+ global.failedToResolveProvisionalPrinter =
+ this.failedToResolveProvisionalDestination_.bind(this);
};
/**
@@ -106,6 +110,8 @@ cr.define('print_preview', function() {
EXTENSION_CAPABILITIES_SET:
'print_preview.NativeLayer.EXTENSION_CAPABILITIES_SET',
PRINT_PRESET_OPTIONS: 'print_preview.NativeLayer.PRINT_PRESET_OPTIONS',
+ PROVISIONAL_DESTINATION_RESOLVED:
+ 'print_preview.NativeLayer.PROVISIONAL_DESTINATION_RESOLVED'
};
/**
@@ -214,6 +220,18 @@ cr.define('print_preview', function() {
},
/**
+ * Requests Chrome to resolve provisional extension destination by granting
+ * the provider extension access to the printer. Chrome will respond with
+ * the resolved destination properties by calling
+ * {@code onProvisionalPrinterResolved}, or in case of an error
+ * {@code failedToResolveProvisionalPrinter}
+ * @param {string} provisionalDestinationId
+ */
+ grantExtensionPrinterAccess: function(provisionalDestinationId) {
+ chrome.send('grantExtensionPrinterAccess', [provisionalDestinationId]);
+ },
+
+ /**
* @param {!print_preview.Destination} destination Destination to print to.
* @param {!print_preview.ticket_items.Color} color Color ticket item.
* @return {number} Native layer color model.
@@ -770,7 +788,8 @@ cr.define('print_preview', function() {
* extensionName: string,
* id: string,
* name: string,
- * description: (string|undefined)}>} printers The list
+ * description: (string|undefined),
+ * provisional: (boolean|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.
@@ -796,6 +815,42 @@ cr.define('print_preview', function() {
this.dispatchEvent(event);
},
+ /**
+ * Called when Chrome reports that attempt to resolve a provisional
+ * destination failed.
+ * @param {string} destinationId The provisional destination ID.
+ * @private
+ */
+ failedToResolveProvisionalDestination_: function(destinationId) {
+ var evt = new Event(
+ NativeLayer.EventType.PROVISIONAL_DESTINATION_RESOLVED);
+ evt.provisionalId = destinationId;
+ evt.destination = null;
+ this.dispatchEvent(evt);
+ },
+
+ /**
+ * Called when Chrome reports that a provisional destination has been
+ * successfully resolved.
+ * Currently used only for extension provided destinations.
+ * @param {string} provisionalDestinationId The provisional destination id.
+ * @param {!{extensionId: string,
+ * extensionName: string,
+ * id: string,
+ * name: string,
+ * description: (string|undefined)}} destinationInfo The resolved
+ * destination info.
+ * @private
+ */
+ onProvisionalDestinationResolved_: function(provisionalDestinationId,
+ destinationInfo) {
+ var evt = new Event(
+ NativeLayer.EventType.PROVISIONAL_DESTINATION_RESOLVED);
+ evt.provisionalId = provisionalDestinationId;
+ evt.destination = destinationInfo;
+ this.dispatchEvent(evt);
+ },
+
/**
* Allows for onManipulateSettings to be called
* from the native layer.

Powered by Google App Engine
This is Rietveld 408576698