| OLD | NEW |
| 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 <include src="component.js"> | 7 <include src="component.js"> |
| 8 <include src="print_preview_focus_manager.js"> | 8 <include src="print_preview_focus_manager.js"> |
| 9 | 9 |
| 10 cr.define('print_preview', function() { | 10 cr.define('print_preview', function() { |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 this.tracker.add( | 351 this.tracker.add( |
| 352 getRequiredElement('system-dialog-link'), | 352 getRequiredElement('system-dialog-link'), |
| 353 'click', | 353 'click', |
| 354 this.openSystemPrintDialog_.bind(this)); | 354 this.openSystemPrintDialog_.bind(this)); |
| 355 this.tracker.add( | 355 this.tracker.add( |
| 356 getRequiredElement('cloud-print-dialog-link'), | 356 getRequiredElement('cloud-print-dialog-link'), |
| 357 'click', | 357 'click', |
| 358 this.onCloudPrintDialogLinkClick_.bind(this)); | 358 this.onCloudPrintDialogLinkClick_.bind(this)); |
| 359 if ($('open-pdf-in-preview-link')) { | 359 if ($('open-pdf-in-preview-link')) { |
| 360 this.tracker.add( | 360 this.tracker.add( |
| 361 $('open-pdf-in-preview-link'), | 361 getRequiredElement('open-pdf-in-preview-link'), |
| 362 'click', | 362 'click', |
| 363 this.onOpenPdfInPreviewLinkClick_.bind(this)); | 363 this.onOpenPdfInPreviewLinkClick_.bind(this)); |
| 364 } | 364 } |
| 365 | 365 |
| 366 this.tracker.add( | 366 this.tracker.add( |
| 367 this.previewArea_, | 367 this.previewArea_, |
| 368 print_preview.PreviewArea.EventType.PREVIEW_GENERATION_IN_PROGRESS, | 368 print_preview.PreviewArea.EventType.PREVIEW_GENERATION_IN_PROGRESS, |
| 369 this.onPreviewGenerationInProgress_.bind(this)); | 369 this.onPreviewGenerationInProgress_.bind(this)); |
| 370 this.tracker.add( | 370 this.tracker.add( |
| 371 this.previewArea_, | 371 this.previewArea_, |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 524 this.uiState_ == PrintPreview.UiState_.OPENING_PDF_PREVIEW) { | 524 this.uiState_ == PrintPreview.UiState_.OPENING_PDF_PREVIEW) { |
| 525 // Hide the dialog for now. The actual print command will be issued | 525 // Hide the dialog for now. The actual print command will be issued |
| 526 // when the preview generation is done. | 526 // when the preview generation is done. |
| 527 this.nativeLayer_.startHideDialog(); | 527 this.nativeLayer_.startHideDialog(); |
| 528 } | 528 } |
| 529 } | 529 } |
| 530 }, | 530 }, |
| 531 | 531 |
| 532 /** | 532 /** |
| 533 * Attempts to print if needed and if ready. | 533 * Attempts to print if needed and if ready. |
| 534 * @return {PrintPreview.PrintAttemptResult_} Attempt result. | 534 * @return {print_preview.PrintPreview.PrintAttemptResult_} Attempt result. |
| 535 * @private | 535 * @private |
| 536 */ | 536 */ |
| 537 printIfReady_: function() { | 537 printIfReady_: function() { |
| 538 var okToPrint = | 538 var okToPrint = |
| 539 (this.uiState_ == PrintPreview.UiState_.PRINTING || | 539 (this.uiState_ == PrintPreview.UiState_.PRINTING || |
| 540 this.uiState_ == PrintPreview.UiState_.OPENING_PDF_PREVIEW || | 540 this.uiState_ == PrintPreview.UiState_.OPENING_PDF_PREVIEW || |
| 541 this.uiState_ == PrintPreview.UiState_.FILE_SELECTION || | 541 this.uiState_ == PrintPreview.UiState_.FILE_SELECTION || |
| 542 this.uiState_ == PrintPreview.UiState_.OPENING_CLOUD_PRINT_DIALOG || | 542 this.uiState_ == PrintPreview.UiState_.OPENING_CLOUD_PRINT_DIALOG || |
| 543 this.isInKioskAutoPrintMode_) && | 543 this.isInKioskAutoPrintMode_) && |
| 544 this.destinationStore_.selectedDestination && | 544 this.destinationStore_.selectedDestination && |
| (...skipping 12 matching lines...) Expand all Loading... |
| 557 } else { | 557 } else { |
| 558 if (getIsVisible(this.moreSettings_.getElement())) { | 558 if (getIsVisible(this.moreSettings_.getElement())) { |
| 559 new print_preview.PrintSettingsUiMetricsContext().record( | 559 new print_preview.PrintSettingsUiMetricsContext().record( |
| 560 this.moreSettings_.isExpanded ? | 560 this.moreSettings_.isExpanded ? |
| 561 print_preview.Metrics.PrintSettingsUiBucket. | 561 print_preview.Metrics.PrintSettingsUiBucket. |
| 562 PRINT_WITH_SETTINGS_EXPANDED : | 562 PRINT_WITH_SETTINGS_EXPANDED : |
| 563 print_preview.Metrics.PrintSettingsUiBucket. | 563 print_preview.Metrics.PrintSettingsUiBucket. |
| 564 PRINT_WITH_SETTINGS_COLLAPSED); | 564 PRINT_WITH_SETTINGS_COLLAPSED); |
| 565 } | 565 } |
| 566 this.nativeLayer_.startPrint( | 566 this.nativeLayer_.startPrint( |
| 567 this.destinationStore_.selectedDestination, | 567 assert(this.destinationStore_.selectedDestination), |
| 568 this.printTicketStore_, | 568 this.printTicketStore_, |
| 569 this.cloudPrintInterface_, | 569 this.cloudPrintInterface_, |
| 570 this.documentInfo_, | 570 this.documentInfo_, |
| 571 this.uiState_ == PrintPreview.UiState_.OPENING_PDF_PREVIEW, | 571 this.uiState_ == PrintPreview.UiState_.OPENING_PDF_PREVIEW, |
| 572 this.showSystemDialogBeforeNextPrint_); | 572 this.showSystemDialogBeforeNextPrint_); |
| 573 this.showSystemDialogBeforeNextPrint_ = false; | 573 this.showSystemDialogBeforeNextPrint_ = false; |
| 574 } | 574 } |
| 575 return PrintPreview.PrintAttemptResult_.PRINTED; | 575 return PrintPreview.PrintAttemptResult_.PRINTED; |
| 576 }, | 576 }, |
| 577 | 577 |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 692 * @param {Event} event Contains the body to send in the HTTP request. | 692 * @param {Event} event Contains the body to send in the HTTP request. |
| 693 * @private | 693 * @private |
| 694 */ | 694 */ |
| 695 onPrintToCloud_: function(event) { | 695 onPrintToCloud_: function(event) { |
| 696 assert(this.uiState_ == PrintPreview.UiState_.PRINTING, | 696 assert(this.uiState_ == PrintPreview.UiState_.PRINTING, |
| 697 'Document ready to be sent to the cloud when not in printing ' + | 697 'Document ready to be sent to the cloud when not in printing ' + |
| 698 'state: ' + this.uiState_); | 698 'state: ' + this.uiState_); |
| 699 assert(this.cloudPrintInterface_ != null, | 699 assert(this.cloudPrintInterface_ != null, |
| 700 'Google Cloud Print is not enabled'); | 700 'Google Cloud Print is not enabled'); |
| 701 this.cloudPrintInterface_.submit( | 701 this.cloudPrintInterface_.submit( |
| 702 this.destinationStore_.selectedDestination, | 702 assert(this.destinationStore_.selectedDestination), |
| 703 this.printTicketStore_, | 703 this.printTicketStore_, |
| 704 this.documentInfo_, | 704 this.documentInfo_, |
| 705 event.data); | 705 event.data); |
| 706 }, | 706 }, |
| 707 | 707 |
| 708 /** | 708 /** |
| 709 * Called from the native layer when the user cancels the save-to-pdf file | 709 * Called from the native layer when the user cancels the save-to-pdf file |
| 710 * selection dialog. | 710 * selection dialog. |
| 711 * @private | 711 * @private |
| 712 */ | 712 */ |
| (...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1307 <include src="search/cloud_destination_list.js"> | 1307 <include src="search/cloud_destination_list.js"> |
| 1308 <include src="search/recent_destination_list.js"> | 1308 <include src="search/recent_destination_list.js"> |
| 1309 <include src="search/destination_list_item.js"> | 1309 <include src="search/destination_list_item.js"> |
| 1310 <include src="search/destination_search.js"> | 1310 <include src="search/destination_search.js"> |
| 1311 <include src="search/fedex_tos.js"> | 1311 <include src="search/fedex_tos.js"> |
| 1312 | 1312 |
| 1313 window.addEventListener('DOMContentLoaded', function() { | 1313 window.addEventListener('DOMContentLoaded', function() { |
| 1314 printPreview = new print_preview.PrintPreview(); | 1314 printPreview = new print_preview.PrintPreview(); |
| 1315 printPreview.initialize(); | 1315 printPreview.initialize(); |
| 1316 }); | 1316 }); |
| OLD | NEW |