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

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

Issue 2865633004: Fix all remaining print preview closure compiler errors (Closed)
Patch Set: Fix onkeydown function Created 3 years, 7 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
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 // <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 10
11 cr.exportPath('print_preview'); 11 cr.exportPath('print_preview');
12 12
13 /** 13 /**
14 * States of the print preview. 14 * States of the print preview.
15 * @enum {string} 15 * @enum {string}
16 * @private 16 * @private
17 */ 17 */
18 print_preview.PrintPreviewUiState_ = { 18 print_preview.PrintPreviewUiState_ = {
19 INITIALIZING: 'initializing', 19 INITIALIZING: 'initializing',
20 READY: 'ready', 20 READY: 'ready',
21 OPENING_PDF_PREVIEW: 'opening-pdf-preview', 21 OPENING_PDF_PREVIEW: 'opening-pdf-preview',
22 OPENING_NATIVE_PRINT_DIALOG: 'opening-native-print-dialog', 22 OPENING_NATIVE_PRINT_DIALOG: 'opening-native-print-dialog',
23 PRINTING: 'printing', 23 PRINTING: 'printing',
24 FILE_SELECTION: 'file-selection', 24 FILE_SELECTION: 'file-selection',
25 CLOSING: 'closing', 25 CLOSING: 'closing',
26 ERROR: 'error' 26 ERROR: 'error'
27 }; 27 };
28 28
29 /**
30 * What can happen when print preview tries to print.
31 * @enum {string}
32 * @private
33 */
34 print_preview.PrintAttemptResult_ = {
35 NOT_READY: 'not-ready',
36 PRINTED: 'printed',
37 READY_WAITING_FOR_PREVIEW: 'ready-waiting-for-preview'
38 };
29 39
30 cr.define('print_preview', function() { 40 cr.define('print_preview', function() {
31 'use strict'; 41 'use strict';
32 42
33 var PrintPreviewUiState_ = print_preview.PrintPreviewUiState_; 43 var PrintPreviewUiState_ = print_preview.PrintPreviewUiState_;
34 44
35 /** 45 /**
36 * Container class for Chromium's print preview. 46 * Container class for Chromium's print preview.
37 * @constructor 47 * @constructor
38 * @extends {print_preview.Component} 48 * @extends {print_preview.Component}
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 this.isPreviewGenerationInProgress_ = true; 315 this.isPreviewGenerationInProgress_ = true;
306 316
307 /** 317 /**
308 * Whether to show system dialog before next printing. 318 * Whether to show system dialog before next printing.
309 * @type {boolean} 319 * @type {boolean}
310 * @private 320 * @private
311 */ 321 */
312 this.showSystemDialogBeforeNextPrint_ = false; 322 this.showSystemDialogBeforeNextPrint_ = false;
313 } 323 }
314 324
315 /**
316 * What can happen when print preview tries to print.
317 * @enum {string}
318 * @private
319 */
320 PrintPreview.PrintAttemptResult_ = {
321 NOT_READY: 'not-ready',
322 PRINTED: 'printed',
323 READY_WAITING_FOR_PREVIEW: 'ready-waiting-for-preview'
324 };
325
326 PrintPreview.prototype = { 325 PrintPreview.prototype = {
327 __proto__: print_preview.Component.prototype, 326 __proto__: print_preview.Component.prototype,
328 327
329 /** Sets up the page and print preview by getting the printer list. */ 328 /** Sets up the page and print preview by getting the printer list. */
330 initialize: function() { 329 initialize: function() {
331 this.decorate($('print-preview')); 330 this.decorate($('print-preview'));
332 if (!this.previewArea_.hasCompatiblePlugin) { 331 if (!this.previewArea_.hasCompatiblePlugin) {
333 this.setIsEnabled_(false); 332 this.setIsEnabled_(false);
334 } 333 }
335 this.nativeLayer_.startGetInitialSettings(); 334 this.nativeLayer_.startGetInitialSettings();
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 this.uiState_ = PrintPreviewUiState_.OPENING_PDF_PREVIEW; 541 this.uiState_ = PrintPreviewUiState_.OPENING_PDF_PREVIEW;
543 } else if (this.destinationStore_.selectedDestination.id == 542 } else if (this.destinationStore_.selectedDestination.id ==
544 print_preview.Destination.GooglePromotedId.SAVE_AS_PDF) { 543 print_preview.Destination.GooglePromotedId.SAVE_AS_PDF) {
545 this.uiState_ = PrintPreviewUiState_.FILE_SELECTION; 544 this.uiState_ = PrintPreviewUiState_.FILE_SELECTION;
546 } else { 545 } else {
547 this.uiState_ = PrintPreviewUiState_.PRINTING; 546 this.uiState_ = PrintPreviewUiState_.PRINTING;
548 } 547 }
549 this.setIsEnabled_(false); 548 this.setIsEnabled_(false);
550 this.printHeader_.isCancelButtonEnabled = true; 549 this.printHeader_.isCancelButtonEnabled = true;
551 var printAttemptResult = this.printIfReady_(); 550 var printAttemptResult = this.printIfReady_();
552 if (printAttemptResult == PrintPreview.PrintAttemptResult_.PRINTED || 551 if (printAttemptResult == print_preview.PrintAttemptResult_.PRINTED ||
553 printAttemptResult == 552 printAttemptResult ==
554 PrintPreview.PrintAttemptResult_.READY_WAITING_FOR_PREVIEW) { 553 print_preview.PrintAttemptResult_.READY_WAITING_FOR_PREVIEW) {
555 if ((this.destinationStore_.selectedDestination.isLocal && 554 if ((this.destinationStore_.selectedDestination.isLocal &&
556 !this.destinationStore_.selectedDestination.isPrivet && 555 !this.destinationStore_.selectedDestination.isPrivet &&
557 !this.destinationStore_.selectedDestination.isExtension && 556 !this.destinationStore_.selectedDestination.isExtension &&
558 this.destinationStore_.selectedDestination.id != 557 this.destinationStore_.selectedDestination.id !=
559 print_preview.Destination.GooglePromotedId.SAVE_AS_PDF) || 558 print_preview.Destination.GooglePromotedId.SAVE_AS_PDF) ||
560 this.uiState_ == PrintPreviewUiState_.OPENING_PDF_PREVIEW) { 559 this.uiState_ == PrintPreviewUiState_.OPENING_PDF_PREVIEW) {
561 // Hide the dialog for now. The actual print command will be issued 560 // Hide the dialog for now. The actual print command will be issued
562 // when the preview generation is done. 561 // when the preview generation is done.
563 this.nativeLayer_.startHideDialog(); 562 this.nativeLayer_.startHideDialog();
564 } 563 }
565 } 564 }
566 }, 565 },
567 566
568 /** 567 /**
569 * Attempts to print if needed and if ready. 568 * Attempts to print if needed and if ready.
570 * @return {PrintPreview.PrintAttemptResult_} Attempt result. 569 * @return {print_preview.PrintAttemptResult_} Attempt result.
571 * @private 570 * @private
572 */ 571 */
573 printIfReady_: function() { 572 printIfReady_: function() {
574 var okToPrint = 573 var okToPrint =
575 (this.uiState_ == PrintPreviewUiState_.PRINTING || 574 (this.uiState_ == PrintPreviewUiState_.PRINTING ||
576 this.uiState_ == PrintPreviewUiState_.OPENING_PDF_PREVIEW || 575 this.uiState_ == PrintPreviewUiState_.OPENING_PDF_PREVIEW ||
577 this.uiState_ == PrintPreviewUiState_.FILE_SELECTION || 576 this.uiState_ == PrintPreviewUiState_.FILE_SELECTION ||
578 this.isInKioskAutoPrintMode_) && 577 this.isInKioskAutoPrintMode_) &&
579 this.destinationStore_.selectedDestination && 578 this.destinationStore_.selectedDestination &&
580 this.destinationStore_.selectedDestination.capabilities; 579 this.destinationStore_.selectedDestination.capabilities;
581 if (!okToPrint) { 580 if (!okToPrint) {
582 return PrintPreview.PrintAttemptResult_.NOT_READY; 581 return print_preview.PrintAttemptResult_.NOT_READY;
583 } 582 }
584 if (this.isPreviewGenerationInProgress_) { 583 if (this.isPreviewGenerationInProgress_) {
585 return PrintPreview.PrintAttemptResult_.READY_WAITING_FOR_PREVIEW; 584 return print_preview.PrintAttemptResult_.READY_WAITING_FOR_PREVIEW;
586 } 585 }
587 assert(this.printTicketStore_.isTicketValid(), 586 assert(this.printTicketStore_.isTicketValid(),
588 'Trying to print with invalid ticket'); 587 'Trying to print with invalid ticket');
589 if (getIsVisible(this.moreSettings_.getElement())) { 588 if (getIsVisible(this.moreSettings_.getElement())) {
590 new print_preview.PrintSettingsUiMetricsContext().record( 589 new print_preview.PrintSettingsUiMetricsContext().record(
591 this.moreSettings_.isExpanded ? 590 this.moreSettings_.isExpanded ?
592 print_preview.Metrics.PrintSettingsUiBucket. 591 print_preview.Metrics.PrintSettingsUiBucket.
593 PRINT_WITH_SETTINGS_EXPANDED : 592 PRINT_WITH_SETTINGS_EXPANDED :
594 print_preview.Metrics.PrintSettingsUiBucket. 593 print_preview.Metrics.PrintSettingsUiBucket.
595 PRINT_WITH_SETTINGS_COLLAPSED); 594 PRINT_WITH_SETTINGS_COLLAPSED);
596 } 595 }
597 this.nativeLayer_.startPrint( 596 this.nativeLayer_.startPrint(
598 assert(this.destinationStore_.selectedDestination), 597 assert(this.destinationStore_.selectedDestination),
599 this.printTicketStore_, 598 this.printTicketStore_,
600 this.cloudPrintInterface_, 599 this.cloudPrintInterface_,
601 this.documentInfo_, 600 this.documentInfo_,
602 this.uiState_ == PrintPreviewUiState_.OPENING_PDF_PREVIEW, 601 this.uiState_ == PrintPreviewUiState_.OPENING_PDF_PREVIEW,
603 this.showSystemDialogBeforeNextPrint_); 602 this.showSystemDialogBeforeNextPrint_);
604 this.showSystemDialogBeforeNextPrint_ = false; 603 this.showSystemDialogBeforeNextPrint_ = false;
605 return PrintPreview.PrintAttemptResult_.PRINTED; 604 return print_preview.PrintAttemptResult_.PRINTED;
606 }, 605 },
607 606
608 /** 607 /**
609 * Closes the print preview. 608 * Closes the print preview.
610 * @private 609 * @private
611 */ 610 */
612 close_: function() { 611 close_: function() {
613 this.exitDocument(); 612 this.exitDocument();
614 this.uiState_ = PrintPreviewUiState_.CLOSING; 613 this.uiState_ = PrintPreviewUiState_.CLOSING;
615 this.nativeLayer_.startCloseDialog(); 614 this.nativeLayer_.startCloseDialog();
(...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after
1345 // <include src="previewarea/preview_area.js"> 1344 // <include src="previewarea/preview_area.js">
1346 // <include src="preview_generator.js"> 1345 // <include src="preview_generator.js">
1347 1346
1348 // <include src="search/destination_list.js"> 1347 // <include src="search/destination_list.js">
1349 // <include src="search/cloud_destination_list.js"> 1348 // <include src="search/cloud_destination_list.js">
1350 // <include src="search/recent_destination_list.js"> 1349 // <include src="search/recent_destination_list.js">
1351 // <include src="search/destination_list_item.js"> 1350 // <include src="search/destination_list_item.js">
1352 // <include src="search/destination_search.js"> 1351 // <include src="search/destination_search.js">
1353 // <include src="search/provisional_destination_resolver.js"> 1352 // <include src="search/provisional_destination_resolver.js">
1354 1353
1354 /**
1355 * Global instance of PrintPreview, used by browser tests.
1356 * @type {print_preview.PrintPreview}
1357 */
1358 var printPreview;
1355 window.addEventListener('DOMContentLoaded', function() { 1359 window.addEventListener('DOMContentLoaded', function() {
1356 printPreview = new print_preview.PrintPreview(); 1360 printPreview = new print_preview.PrintPreview();
1357 printPreview.initialize(); 1361 printPreview.initialize();
1358 }); 1362 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698