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 dbe483656c626fed221a56f364bce64713813d9f..d2c133ea8fb05a4cb731530a1abe413c9266e6aa 100644 |
--- a/chrome/browser/resources/print_preview/native_layer.js |
+++ b/chrome/browser/resources/print_preview/native_layer.js |
@@ -66,6 +66,25 @@ print_preview.PrivetPrinterCapabilitiesResponse; |
*/ |
print_preview.PrinterSetupResponse; |
+/** |
+ * @typedef {{ |
+ * completed: boolean, |
+ * accessToken: string, |
+ * }} |
+ */ |
+print_preview.AccessTokenResponse; |
+ |
+/** |
+ * @typedef {{ |
+ * extensionId: string, |
+ * extensionName: string, |
+ * id: string, |
+ * name: string, |
+ * description: (string|undefined), |
+ * }} |
+ */ |
+print_preview.ProvisionalDestinationInfo; |
+ |
cr.define('print_preview', function() { |
'use strict'; |
@@ -91,15 +110,10 @@ cr.define('print_preview', function() { |
this.onDidGetPreviewPageCount_.bind(this); |
global.onDidPreviewPage = this.onDidPreviewPage_.bind(this); |
global.updatePrintPreview = this.onUpdatePrintPreview_.bind(this); |
- global.onDidGetAccessToken = this.onDidGetAccessToken_.bind(this); |
global.onEnableManipulateSettingsForTest = |
this.onEnableManipulateSettingsForTest_.bind(this); |
global.printPresetOptionsFromDocument = |
this.onPrintPresetOptionsFromDocument_.bind(this); |
- global.onProvisionalPrinterResolved = |
- this.onProvisionalDestinationResolved_.bind(this); |
- global.failedToResolveProvisionalPrinter = |
- this.failedToResolveProvisionalDestination_.bind(this); |
/** @private {!cr.EventTarget} */ |
this.eventTarget_ = new cr.EventTarget(); |
@@ -132,7 +146,6 @@ cr.define('print_preview', function() { |
* @const |
*/ |
NativeLayer.EventType = { |
- ACCESS_TOKEN_READY: 'print_preview.NativeLayer.ACCESS_TOKEN_READY', |
CLOUD_PRINT_ENABLE: 'print_preview.NativeLayer.CLOUD_PRINT_ENABLE', |
DESTINATIONS_RELOAD: 'print_preview.NativeLayer.DESTINATIONS_RELOAD', |
DISABLE_SCALING: 'print_preview.NativeLayer.DISABLE_SCALING', |
@@ -151,8 +164,6 @@ cr.define('print_preview', function() { |
PRINT_TO_CLOUD: 'print_preview.NativeLayer.PRINT_TO_CLOUD', |
SETTINGS_INVALID: 'print_preview.NativeLayer.SETTINGS_INVALID', |
PRINT_PRESET_OPTIONS: 'print_preview.NativeLayer.PRINT_PRESET_OPTIONS', |
- PROVISIONAL_DESTINATION_RESOLVED: |
- 'print_preview.NativeLayer.PROVISIONAL_DESTINATION_RESOLVED' |
}; |
/** |
@@ -192,9 +203,10 @@ cr.define('print_preview', function() { |
/** |
* Requests access token for cloud print requests. |
* @param {string} authType type of access token. |
+ * @return {!Promise<!print_preview.AccessTokenResponse>} |
*/ |
- startGetAccessToken: function(authType) { |
- chrome.send('getAccessToken', [authType]); |
+ getAccessToken: function(authType) { |
+ return cr.sendWithPromise('getAccessToken', authType); |
}, |
/** |
@@ -296,14 +308,13 @@ 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} |
+ * the provider extension access to the printer. |
* @param {string} provisionalDestinationId |
+ * @return {!Promise<!print_preview.ProvisionalDestinationInfo>} |
*/ |
grantExtensionPrinterAccess: function(provisionalDestinationId) { |
- chrome.send('grantExtensionPrinterAccess', [provisionalDestinationId]); |
+ return cr.sendWithPromise('grantExtensionPrinterAccess', |
+ provisionalDestinationId); |
}, |
/** |
@@ -684,20 +695,6 @@ cr.define('print_preview', function() { |
this.eventTarget_.dispatchEvent(pagePreviewGenEvent); |
}, |
- /** |
- * Notification that access token is ready. |
- * @param {string} authType Type of access token. |
- * @param {string} accessToken Access token. |
- * @private |
- */ |
- onDidGetAccessToken_: function(authType, accessToken) { |
- var getAccessTokenEvent = new Event( |
- NativeLayer.EventType.ACCESS_TOKEN_READY); |
- getAccessTokenEvent.authType = authType; |
- getAccessTokenEvent.accessToken = accessToken; |
- this.eventTarget_.dispatchEvent(getAccessTokenEvent); |
- }, |
- |
/** |
* Update the print preview when new preview data is available. |
* Create the PDF plugin as needed. |
@@ -731,42 +728,6 @@ cr.define('print_preview', function() { |
}, |
/** |
- * 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.eventTarget_.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.eventTarget_.dispatchEvent(evt); |
- }, |
- |
- /** |
* Allows for onManipulateSettings to be called |
* from the native layer. |
* @private |