* @private
*/
this.destinationStore_ = new print_preview.DestinationStore(
- this.nativeLayer_, this.appState_, this.metrics_);
+ this.nativeLayer_, this.userInfo_, this.appState_, this.metrics_);
/**
* Storage of the print ticket used to create the print job.
this.addChild(this.copiesSettings_);
/**
+ * Component that renders the media size settings.
+ * @type {!print_preview.MediaSizeSettings}
+ * @private
+ */
+ this.mediaSizeSettings_ =
+ new print_preview.MediaSizeSettings(this.printTicketStore_.mediaSize);
+ this.addChild(this.mediaSizeSettings_);
+
+ /**
* Component that renders the layout settings.
* @type {!print_preview.LayoutSettings}
* @private
INITIALIZING: 'initializing',
READY: 'ready',
OPENING_PDF_PREVIEW: 'opening-pdf-preview',
+ OPENING_CLOUD_PRINT_DIALOG: 'opening-cloud-print-dialog',
OPENING_NATIVE_PRINT_DIALOG: 'opening-native-print-dialog',
PRINTING: 'printing',
FILE_SELECTION: 'file-selection',
this.onManageLocalDestinationsActivated_.bind(this));
this.tracker.add(
this.destinationSearch_,
+ print_preview.DestinationSearch.EventType.ADD_ACCOUNT,
+ this.onCloudPrintSignInActivated_.bind(this, true /*addAccount*/));
+ this.tracker.add(
+ this.destinationSearch_,
print_preview.DestinationSearch.EventType.SIGN_IN,
- this.onCloudPrintSignInActivated_.bind(this));
+ this.onCloudPrintSignInActivated_.bind(this, false /*addAccount*/));
this.tracker.add(
this.destinationSearch_,
print_preview.DestinationListItem.EventType.REGISTER_PROMO_CLICKED,
this.destinationSettings_.decorate($('destination-settings'));
this.pageSettings_.decorate($('page-settings'));
this.copiesSettings_.decorate($('copies-settings'));
+ this.mediaSizeSettings_.decorate($('media-size-settings'));
this.layoutSettings_.decorate($('layout-settings'));
this.colorSettings_.decorate($('color-settings'));
this.marginSettings_.decorate($('margin-settings'));
this.destinationSettings_.isEnabled = isEnabled;
this.pageSettings_.isEnabled = isEnabled;
this.copiesSettings_.isEnabled = isEnabled;
+ this.mediaSizeSettings_.isEnabled = isEnabled;
this.layoutSettings_.isEnabled = isEnabled;
this.colorSettings_.isEnabled = isEnabled;
this.marginSettings_.isEnabled = isEnabled;
printIfReady_: function() {
var okToPrint =
(this.uiState_ == PrintPreview.UiState_.PRINTING ||
- this.uiState_ == PrintPreview.UiState_.OPENING_PDF_PREVIEW ||
- this.uiState_ == PrintPreview.UiState_.FILE_SELECTION ||
- this.isInKioskAutoPrintMode_) &&
+ this.uiState_ == PrintPreview.UiState_.OPENING_PDF_PREVIEW ||
+ this.uiState_ == PrintPreview.UiState_.FILE_SELECTION ||
+ this.uiState_ == PrintPreview.UiState_.OPENING_CLOUD_PRINT_DIALOG ||
+ this.isInKioskAutoPrintMode_) &&
this.destinationStore_.selectedDestination &&
this.destinationStore_.selectedDestination.capabilities;
if (!okToPrint) {
}
assert(this.printTicketStore_.isTicketValid(),
'Trying to print with invalid ticket');
- this.nativeLayer_.startPrint(
- this.destinationStore_.selectedDestination,
- this.printTicketStore_,
- this.cloudPrintInterface_,
- this.documentInfo_,
- this.uiState_ == PrintPreview.UiState_.OPENING_PDF_PREVIEW);
+ if (this.uiState_ == PrintPreview.UiState_.OPENING_CLOUD_PRINT_DIALOG) {
+ this.nativeLayer_.startShowCloudPrintDialog(
+ this.printTicketStore_.pageRange.getPageNumberSet().size);
+ } else {
+ this.nativeLayer_.startPrint(
+ this.destinationStore_.selectedDestination,
+ this.printTicketStore_,
+ this.cloudPrintInterface_,
+ this.documentInfo_,
+ this.uiState_ == PrintPreview.UiState_.OPENING_PDF_PREVIEW);
+ }
return PrintPreview.PrintAttemptResult_.PRINTED;
},
this.isInKioskAutoPrintMode_ = settings.isInKioskAutoPrintMode;
// The following components must be initialized in this order.
- this.appState_.init(settings.serializedAppStateStr);
+ this.appState_.init(
+ settings.serializedAppStateStr,
+ settings.systemDefaultDestinationId);
this.documentInfo_.init(
settings.isDocumentModifiable,
settings.documentTitle,
settings.decimalDelimeter,
settings.unitType,
settings.selectionOnly);
- this.destinationStore_.init(settings.systemDefaultDestinationId);
+ this.destinationStore_.init();
this.appState_.setInitialized();
$('document-title').innerText = settings.documentTitle;
* @private
*/
onCloudPrintEnable_: function(event) {
- this.cloudPrintInterface_ =
- new cloudprint.CloudPrintInterface(event.baseCloudPrintUrl,
- this.nativeLayer_);
+ this.cloudPrintInterface_ = new cloudprint.CloudPrintInterface(
+ event.baseCloudPrintUrl,
+ this.nativeLayer_,
+ this.userInfo_);
this.tracker.add(
this.cloudPrintInterface_,
cloudprint.CloudPrintInterface.EventType.SUBMIT_DONE,
UPDATE_PRINTER_TOS_ACCEPTANCE_FAILED,
this.onCloudPrintError_.bind(this));
- this.userInfo_.setCloudPrintInterface(this.cloudPrintInterface_);
this.destinationStore_.setCloudPrintInterface(this.cloudPrintInterface_);
if (this.destinationSearch_.getIsVisible()) {
this.destinationStore_.startLoadCloudDestinations();
this.printHeader_.isPrintButtonEnabled = false;
if (this.uiState_ == PrintPreview.UiState_.PRINTING) {
this.nativeLayer_.startCancelPendingPrint();
+ } else if (this.uiState_ ==
+ PrintPreview.UiState_.OPENING_CLOUD_PRINT_DIALOG) {
+ this.uiState_ = PrintPreview.UiState_.READY;
}
},
if (e.keyCode == 13 /*enter*/ &&
!this.destinationSearch_.getIsVisible() &&
+ this.destinationStore_.selectedDestination &&
this.printTicketStore_.isTicketValid()) {
assert(this.uiState_ == PrintPreview.UiState_.READY,
'Trying to print when not in ready state: ' + this.uiState_);
/**
* Called when the user wants to sign in to Google Cloud Print. Calls the
* corresponding native layer event.
+ * @param {boolean} addAccount Whether to open an 'add a new account' or
+ * default sign in page.
* @private
*/
- onCloudPrintSignInActivated_: function() {
- this.nativeLayer_.startCloudPrintSignIn();
+ onCloudPrintSignInActivated_: function(addAccount) {
+ this.nativeLayer_.startCloudPrintSignIn(addAccount);
},
/**
this.uiState_);
setIsVisible($('cloud-print-dialog-throbber'), true);
this.setIsEnabled_(false);
- this.uiState_ = PrintPreview.UiState_.OPENING_NATIVE_PRINT_DIALOG;
- this.nativeLayer_.startShowCloudPrintDialog(
- this.printTicketStore_.pageRange.getPageNumberSet().size);
+ this.uiState_ = PrintPreview.UiState_.OPENING_CLOUD_PRINT_DIALOG;
+ this.printIfReady_();
},
/**
*/
onDestinationSelect_: function() {
var selectedDest = this.destinationStore_.selectedDestination;
- setIsVisible($('cloud-print-dialog-link'),
- !cr.isChromeOS && !selectedDest.isLocal);
- if (this.isInKioskAutoPrintMode_) {
+ setIsVisible(
+ $('cloud-print-dialog-link'),
+ selectedDest && !cr.isChromeOS && !selectedDest.isLocal);
+ if (selectedDest && this.isInKioskAutoPrintMode_) {
this.onPrintButtonClick_();
}
},
onDestinationSearchDone_: function() {
var isPromoVisible = cr.isChromeOS &&
this.cloudPrintInterface_ &&
- this.userInfo_.getUserEmail() &&
+ this.userInfo_.activeUser &&
!this.appState_.isGcpPromoDismissed &&
!this.destinationStore_.isLocalDestinationsSearchInProgress &&
!this.destinationStore_.isCloudDestinationsSearchInProgress &&
print_preview.Metrics.GcpPromoBucket.CLICKED);
this.appState_.persistIsGcpPromoDismissed(true);
window.open(this.cloudPrintInterface_.baseUrl + '?user=' +
- this.userInfo_.getUserEmail() + '#printers');
+ this.userInfo_.activeUser + '#printers');
this.close_();
}
};
<include src="data/ticket_items/copies.js"/>
<include src="data/ticket_items/duplex.js"/>
<include src="data/ticket_items/header_footer.js"/>
+<include src="data/ticket_items/media_size.js"/>
<include src="data/ticket_items/landscape.js"/>
<include src="data/ticket_items/margins_type.js"/>
<include src="data/ticket_items/page_range.js"/>
<include src="settings/page_settings.js"/>
<include src="settings/copies_settings.js"/>
+<include src="settings/media_size_settings.js"/>
<include src="settings/layout_settings.js"/>
<include src="settings/color_settings.js"/>
<include src="settings/margin_settings.js"/>
<include src="previewarea/margin_control.js"/>
<include src="previewarea/margin_control_container.js"/>
+<include src="../pdf/pdf_scripting_api.js" />
<include src="previewarea/preview_area.js"/>
<include src="preview_generator.js"/>