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

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

Issue 2919693002: Print Preview: Change getPrinters to cr.sendWithPromise (Closed)
Patch Set: Address comments Created 3 years, 7 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 d3a12f024adc6aeba9e64778c5ca921f472717ea..4ad76dea1179c79c459e089a01e900fc107a49e3 100644
--- a/chrome/browser/resources/print_preview/native_layer.js
+++ b/chrome/browser/resources/print_preview/native_layer.js
@@ -17,6 +17,17 @@ print_preview.PreviewSettings;
/**
* @typedef {{
+ * deviceName: string,
+ * printerName: string,
+ * printerDescription: (string | undefined),
+ * cupsEnterprisePrinter: (boolean | undefined),
+ * printerOptions: (Object | undefined),
+ * }}
+ */
+print_preview.LocalDestinationInfo;
+
+/**
+ * @typedef {{
* printerId: string,
* success: boolean,
* capabilities: Object,
@@ -34,7 +45,6 @@ cr.define('print_preview', function() {
function NativeLayer() {
// Bind global handlers
global.setUseCloudPrint = this.onSetUseCloudPrint_.bind(this);
- global.setPrinters = this.onSetPrinters_.bind(this);
global.updateWithPrinterCapabilities =
this.onUpdateWithPrinterCapabilities_.bind(this);
global.failedToGetPrinterCapabilities =
@@ -220,9 +230,10 @@ cr.define('print_preview', function() {
/**
* Requests the system's local print destinations. A LOCAL_DESTINATIONS_SET
* event will be dispatched in response.
+ * @return {!Promise<!Array<print_preview.LocalDestinationInfo>>}
*/
- startGetLocalDestinations: function() {
- chrome.send('getPrinters');
+ getPrinters: function() {
+ return cr.sendWithPromise('getPrinters');
},
/**
@@ -550,19 +561,6 @@ cr.define('print_preview', function() {
},
/**
- * Updates the print preview with local printers.
- * Called from PrintPreviewHandler::SetupPrinterList().
- * @param {Array} printers Array of printer info objects.
- * @private
- */
- onSetPrinters_: function(printers) {
- var localDestsSetEvent = new Event(
- NativeLayer.EventType.LOCAL_DESTINATIONS_SET);
- localDestsSetEvent.destinationInfos = printers;
- this.eventTarget_.dispatchEvent(localDestsSetEvent);
- },
-
- /**
* Called when native layer gets settings information for a requested local
* destination.
* @param {Object} settingsInfo printer setting information.

Powered by Google App Engine
This is Rietveld 408576698