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

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

Issue 2956033002: Print Preview: Make useCloudPrint a WebUI event (Closed)
Patch Set: Created 3 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/print_preview.js
diff --git a/chrome/browser/resources/print_preview/print_preview.js b/chrome/browser/resources/print_preview/print_preview.js
index 741a50e1d1d08eb1df0cd7cd992dc8f4a83254f7..5a339cc610d69f7547d801655e093e00bf228330 100644
--- a/chrome/browser/resources/print_preview/print_preview.js
+++ b/chrome/browser/resources/print_preview/print_preview.js
@@ -340,16 +340,14 @@ cr.define('print_preview', function() {
'extension-printers-added',
this.destinationStore_.onExtensionPrintersAdded_.bind(
this.destinationStore_));
+ this.listenerTracker.add(
+ 'use-cloud-print', this.onCloudPrintEnable_.bind(this));
},
/** @override */
enterDocument: function() {
// Native layer events.
var nativeLayerEventTarget = this.nativeLayer_.getEventTarget();
- this.tracker.add(
- nativeLayerEventTarget,
- print_preview.NativeLayer.EventType.CLOUD_PRINT_ENABLE,
- this.onCloudPrintEnable_.bind(this));
this.tracker.add(
nativeLayerEventTarget,
print_preview.NativeLayer.EventType.SETTINGS_INVALID,
@@ -688,16 +686,18 @@ cr.define('print_preview', function() {
},
/**
- * Calls when the native layer enables Google Cloud Print integration.
+ * Called when Google Cloud Print integration is enabled by the
+ * PrintPreviewHandler.
* Fetches the user's cloud printers.
- * @param {Event} event Contains the base URL of the Google Cloud Print
- * service.
+ * @param {{cloudPrintUrl: string, appKioskMode: boolean}} settings
+ * cloudPrintUrl: The URL to use for cloud print servers.
+ * appKioskMode: Whether to print automatically for kiosk mode.
* @private
*/
- onCloudPrintEnable_: function(event) {
+ onCloudPrintEnable_: function(settings) {
this.cloudPrintInterface_ = new cloudprint.CloudPrintInterface(
- event.baseCloudPrintUrl, this.nativeLayer_, this.userInfo_,
- event.appKioskMode);
+ settings.cloudPrintUrl || '', this.nativeLayer_, this.userInfo_,
+ settings.appKioskMode || false);
this.tracker.add(
this.cloudPrintInterface_,
cloudprint.CloudPrintInterfaceEventType.SUBMIT_DONE,

Powered by Google App Engine
This is Rietveld 408576698