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

Side by Side Diff: chrome/browser/resources/print_preview/print_preview.js

Issue 480303002: Use document from preview for System Dialog printing on Windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Tue Aug 26 01:11:31 PDT 2014 Created 6 years, 3 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // TODO(rltoscano): Move data/* into print_preview.data namespace 5 // TODO(rltoscano): Move data/* into print_preview.data namespace
6 6
7 var localStrings = new LocalStrings(templateData); 7 var localStrings = new LocalStrings(templateData);
8 8
9 <include src="component.js"/> 9 <include src="component.js"/>
10 <include src="print_preview_focus_manager.js"/> 10 <include src="print_preview_focus_manager.js"/>
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 224
225 /** 225 /**
226 * Whether Print Preview is in App Kiosk mode, basically, use only printers 226 * Whether Print Preview is in App Kiosk mode, basically, use only printers
227 * available for the device. 227 * available for the device.
228 * @type {boolean} 228 * @type {boolean}
229 * @private 229 * @private
230 */ 230 */
231 this.isInAppKioskMode_ = false; 231 this.isInAppKioskMode_ = false;
232 232
233 /** 233 /**
234 * Whether Print with System Dialog option is available.
235 * @type {boolean}
236 * @private
237 */
238 this.isSystemDialogAvailable_ = false;
239
240 /**
234 * State of the print preview UI. 241 * State of the print preview UI.
235 * @type {print_preview.PrintPreview.UiState_} 242 * @type {print_preview.PrintPreview.UiState_}
236 * @private 243 * @private
237 */ 244 */
238 this.uiState_ = PrintPreview.UiState_.INITIALIZING; 245 this.uiState_ = PrintPreview.UiState_.INITIALIZING;
239 246
240 /** 247 /**
241 * Whether document preview generation is in progress. 248 * Whether document preview generation is in progress.
242 * @type {boolean} 249 * @type {boolean}
243 * @private 250 * @private
244 */ 251 */
245 this.isPreviewGenerationInProgress_ = true; 252 this.isPreviewGenerationInProgress_ = true;
253
254 /**
255 * Whether to show system dialog before next printing.
256 * @type {boolean}
257 * @private
258 */
259 this.showSystemDialogBeforeNextPrint_ = false;
246 }; 260 };
247 261
248 /** 262 /**
249 * States of the print preview. 263 * States of the print preview.
250 * @enum {string} 264 * @enum {string}
251 * @private 265 * @private
252 */ 266 */
253 PrintPreview.UiState_ = { 267 PrintPreview.UiState_ = {
254 INITIALIZING: 'initializing', 268 INITIALIZING: 'initializing',
255 READY: 'ready', 269 READY: 'ready',
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 'Trying to print with invalid ticket'); 545 'Trying to print with invalid ticket');
532 if (this.uiState_ == PrintPreview.UiState_.OPENING_CLOUD_PRINT_DIALOG) { 546 if (this.uiState_ == PrintPreview.UiState_.OPENING_CLOUD_PRINT_DIALOG) {
533 this.nativeLayer_.startShowCloudPrintDialog( 547 this.nativeLayer_.startShowCloudPrintDialog(
534 this.printTicketStore_.pageRange.getPageNumberSet().size); 548 this.printTicketStore_.pageRange.getPageNumberSet().size);
535 } else { 549 } else {
536 this.nativeLayer_.startPrint( 550 this.nativeLayer_.startPrint(
537 this.destinationStore_.selectedDestination, 551 this.destinationStore_.selectedDestination,
538 this.printTicketStore_, 552 this.printTicketStore_,
539 this.cloudPrintInterface_, 553 this.cloudPrintInterface_,
540 this.documentInfo_, 554 this.documentInfo_,
541 this.uiState_ == PrintPreview.UiState_.OPENING_PDF_PREVIEW); 555 this.uiState_ == PrintPreview.UiState_.OPENING_PDF_PREVIEW,
556 this.showSystemDialogBeforeNextPrint_);
557 this.showSystemDialogBeforeNextPrint_ = false;
542 } 558 }
543 return PrintPreview.PrintAttemptResult_.PRINTED; 559 return PrintPreview.PrintAttemptResult_.PRINTED;
544 }, 560 },
545 561
546 /** 562 /**
547 * Closes the print preview. 563 * Closes the print preview.
548 * @private 564 * @private
549 */ 565 */
550 close_: function() { 566 close_: function() {
551 this.exitDocument(); 567 this.exitDocument();
552 this.uiState_ = PrintPreview.UiState_.CLOSING; 568 this.uiState_ = PrintPreview.UiState_.CLOSING;
553 this.nativeLayer_.startCloseDialog(); 569 this.nativeLayer_.startCloseDialog();
554 }, 570 },
555 571
556 /** 572 /**
557 * Opens the native system print dialog after disabling all controls. 573 * Opens the native system print dialog after disabling all controls.
558 * @private 574 * @private
559 */ 575 */
560 openSystemPrintDialog_: function() { 576 openSystemPrintDialog_: function() {
577 if (!this.shouldShowSystemDialogLink_())
578 return;
579 if (cr.isWindows) {
580 this.showSystemDialogBeforeNextPrint_ = true;
581 this.printDocumentOrOpenPdfPreview_(false /*isPdfPreview*/);
582 return;
583 }
561 setIsVisible($('system-dialog-throbber'), true); 584 setIsVisible($('system-dialog-throbber'), true);
562 this.setIsEnabled_(false); 585 this.setIsEnabled_(false);
563 this.uiState_ = PrintPreview.UiState_.OPENING_NATIVE_PRINT_DIALOG; 586 this.uiState_ = PrintPreview.UiState_.OPENING_NATIVE_PRINT_DIALOG;
564 this.nativeLayer_.startShowSystemDialog(); 587 this.nativeLayer_.startShowSystemDialog();
565 }, 588 },
566 589
567 /** 590 /**
568 * Called when the native layer has initial settings to set. Sets the 591 * Called when the native layer has initial settings to set. Sets the
569 * initial settings of the print preview and begins fetching print 592 * initial settings of the print preview and begins fetching print
570 * destinations. 593 * destinations.
(...skipping 21 matching lines...) Expand all
592 settings.documentHasSelection); 615 settings.documentHasSelection);
593 this.printTicketStore_.init( 616 this.printTicketStore_.init(
594 settings.thousandsDelimeter, 617 settings.thousandsDelimeter,
595 settings.decimalDelimeter, 618 settings.decimalDelimeter,
596 settings.unitType, 619 settings.unitType,
597 settings.selectionOnly); 620 settings.selectionOnly);
598 this.destinationStore_.init(settings.isInAppKioskMode); 621 this.destinationStore_.init(settings.isInAppKioskMode);
599 this.appState_.setInitialized(); 622 this.appState_.setInitialized();
600 623
601 $('document-title').innerText = settings.documentTitle; 624 $('document-title').innerText = settings.documentTitle;
602 setIsVisible($('system-dialog-link'), 625 this.isSystemDialogAvailable_ = !settings.hidePrintWithSystemDialogLink &&
603 !settings.hidePrintWithSystemDialogLink && 626 !settings.isInAppKioskMode;
604 !settings.isInAppKioskMode); 627 setIsVisible($('system-dialog-link'), this.shouldShowSystemDialogLink_());
605 }, 628 },
606 629
607 /** 630 /**
608 * Calls when the native layer enables Google Cloud Print integration. 631 * Calls when the native layer enables Google Cloud Print integration.
609 * Fetches the user's cloud printers. 632 * Fetches the user's cloud printers.
610 * @param {Event} event Contains the base URL of the Google Cloud Print 633 * @param {Event} event Contains the base URL of the Google Cloud Print
611 * service. 634 * service.
612 * @private 635 * @private
613 */ 636 */
614 onCloudPrintEnable_: function(event) { 637 onCloudPrintEnable_: function(event) {
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
1074 this.nativeLayer_.previewReadyForTest(); 1097 this.nativeLayer_.previewReadyForTest();
1075 } else if (margins >= 0 && margins < combobox.length) { 1098 } else if (margins >= 0 && margins < combobox.length) {
1076 combobox.selectedIndex = margins; 1099 combobox.selectedIndex = margins;
1077 this.marginSettings_.onSelectChange_(); 1100 this.marginSettings_.onSelectChange_();
1078 } else { 1101 } else {
1079 this.nativeLayer_.previewFailedForTest(); 1102 this.nativeLayer_.previewFailedForTest();
1080 } 1103 }
1081 }, 1104 },
1082 1105
1083 /** 1106 /**
1107 * Returns true if "Print using system dialog" link should be shown for
1108 * current destination.
1109 * @return {boolean} Returns true if link should be shown.
1110 */
1111 shouldShowSystemDialogLink_: function() {
1112 if (!this.isSystemDialogAvailable_)
1113 return false;
1114 if (!cr.isWindows)
1115 return true;
1116 var selectedDest = this.destinationStore_.selectedDestination;
1117 return selectedDest &&
1118 selectedDest.origin == print_preview.Destination.Origin.LOCAL &&
1119 selectedDest.id !=
1120 print_preview.Destination.GooglePromotedId.SAVE_AS_PDF;
1121 },
1122
1123 /**
1084 * Called when the open-cloud-print-dialog link is clicked. Opens the Google 1124 * Called when the open-cloud-print-dialog link is clicked. Opens the Google
1085 * Cloud Print web dialog. 1125 * Cloud Print web dialog.
1086 * @private 1126 * @private
1087 */ 1127 */
1088 onCloudPrintDialogLinkClick_: function() { 1128 onCloudPrintDialogLinkClick_: function() {
1089 assert(this.uiState_ == PrintPreview.UiState_.READY, 1129 assert(this.uiState_ == PrintPreview.UiState_.READY,
1090 'Opening Google Cloud Print dialog when not in ready state: ' + 1130 'Opening Google Cloud Print dialog when not in ready state: ' +
1091 this.uiState_); 1131 this.uiState_);
1092 setIsVisible($('cloud-print-dialog-throbber'), true); 1132 setIsVisible($('cloud-print-dialog-throbber'), true);
1093 this.setIsEnabled_(false); 1133 this.setIsEnabled_(false);
1094 this.uiState_ = PrintPreview.UiState_.OPENING_CLOUD_PRINT_DIALOG; 1134 this.uiState_ = PrintPreview.UiState_.OPENING_CLOUD_PRINT_DIALOG;
1095 this.printIfReady_(); 1135 this.printIfReady_();
1096 }, 1136 },
1097 1137
1098 /** 1138 /**
1099 * Called when a print destination is selected. Shows/hides the "Print with 1139 * Called when a print destination is selected. Shows/hides the "Print with
1100 * Cloud Print" link in the navbar. 1140 * Cloud Print" link in the navbar.
1101 * @private 1141 * @private
1102 */ 1142 */
1103 onDestinationSelect_: function() { 1143 onDestinationSelect_: function() {
1104 var selectedDest = this.destinationStore_.selectedDestination; 1144 var selectedDest = this.destinationStore_.selectedDestination;
1105 setIsVisible( 1145 setIsVisible(
1106 $('cloud-print-dialog-link'), 1146 $('cloud-print-dialog-link'),
1107 selectedDest && !cr.isChromeOS && !selectedDest.isLocal); 1147 selectedDest && !cr.isChromeOS && !selectedDest.isLocal);
1148 setIsVisible(
1149 $('system-dialog-link'),
1150 this.shouldShowSystemDialogLink_());
1108 if (selectedDest && this.isInKioskAutoPrintMode_) { 1151 if (selectedDest && this.isInKioskAutoPrintMode_) {
1109 this.onPrintButtonClick_(); 1152 this.onPrintButtonClick_();
1110 } 1153 }
1111 }, 1154 },
1112 1155
1113 /** 1156 /**
1114 * Called when the destination store loads a group of destinations. Shows 1157 * Called when the destination store loads a group of destinations. Shows
1115 * a promo on Chrome OS if the user has no print destinations promoting 1158 * a promo on Chrome OS if the user has no print destinations promoting
1116 * Google Cloud Print. 1159 * Google Cloud Print.
1117 * @private 1160 * @private
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
1232 <include src="search/cloud_destination_list.js"/> 1275 <include src="search/cloud_destination_list.js"/>
1233 <include src="search/recent_destination_list.js"/> 1276 <include src="search/recent_destination_list.js"/>
1234 <include src="search/destination_list_item.js"/> 1277 <include src="search/destination_list_item.js"/>
1235 <include src="search/destination_search.js"/> 1278 <include src="search/destination_search.js"/>
1236 <include src="search/fedex_tos.js"/> 1279 <include src="search/fedex_tos.js"/>
1237 1280
1238 window.addEventListener('DOMContentLoaded', function() { 1281 window.addEventListener('DOMContentLoaded', function() {
1239 printPreview = new print_preview.PrintPreview(); 1282 printPreview = new print_preview.PrintPreview();
1240 printPreview.initialize(); 1283 printPreview.initialize();
1241 }); 1284 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/print_preview/native_layer.js ('k') | chrome/browser/ui/webui/print_preview/print_preview_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698