| 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 var localStrings = new LocalStrings(templateData); | 7 var localStrings = new LocalStrings(templateData); |
| 8 | 8 |
| 9 <include src="component.js"/> | 9 <include src="component.js"/> |
| 10 | 10 |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 * Whether in kiosk mode where print preview can print automatically without | 187 * Whether in kiosk mode where print preview can print automatically without |
| 188 * user intervention. See http://crbug.com/31395. Print will start when | 188 * user intervention. See http://crbug.com/31395. Print will start when |
| 189 * both the print ticket has been initialized, and an initial printer has | 189 * both the print ticket has been initialized, and an initial printer has |
| 190 * been selected. | 190 * been selected. |
| 191 * @type {boolean} | 191 * @type {boolean} |
| 192 * @private | 192 * @private |
| 193 */ | 193 */ |
| 194 this.isInKioskAutoPrintMode_ = false; | 194 this.isInKioskAutoPrintMode_ = false; |
| 195 | 195 |
| 196 /** | 196 /** |
| 197 * Whether Print Preview is in App Kiosk mode, basically, use only printers |
| 198 * available for the device. |
| 199 * @type {boolean} |
| 200 * @private |
| 201 */ |
| 202 this.isInAppKioskMode_ = false; |
| 203 |
| 204 /** |
| 197 * State of the print preview UI. | 205 * State of the print preview UI. |
| 198 * @type {print_preview.PrintPreview.UiState_} | 206 * @type {print_preview.PrintPreview.UiState_} |
| 199 * @private | 207 * @private |
| 200 */ | 208 */ |
| 201 this.uiState_ = PrintPreview.UiState_.INITIALIZING; | 209 this.uiState_ = PrintPreview.UiState_.INITIALIZING; |
| 202 | 210 |
| 203 /** | 211 /** |
| 204 * Whether document preview generation is in progress. | 212 * Whether document preview generation is in progress. |
| 205 * @type {boolean} | 213 * @type {boolean} |
| 206 * @private | 214 * @private |
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 523 * @private | 531 * @private |
| 524 */ | 532 */ |
| 525 onInitialSettingsSet_: function(event) { | 533 onInitialSettingsSet_: function(event) { |
| 526 assert(this.uiState_ == PrintPreview.UiState_.INITIALIZING, | 534 assert(this.uiState_ == PrintPreview.UiState_.INITIALIZING, |
| 527 'Updating initial settings when not in initializing state: ' + | 535 'Updating initial settings when not in initializing state: ' + |
| 528 this.uiState_); | 536 this.uiState_); |
| 529 this.uiState_ = PrintPreview.UiState_.READY; | 537 this.uiState_ = PrintPreview.UiState_.READY; |
| 530 | 538 |
| 531 var settings = event.initialSettings; | 539 var settings = event.initialSettings; |
| 532 this.isInKioskAutoPrintMode_ = settings.isInKioskAutoPrintMode; | 540 this.isInKioskAutoPrintMode_ = settings.isInKioskAutoPrintMode; |
| 541 this.isInAppKioskMode_ = settings.isInAppKioskMode; |
| 533 | 542 |
| 534 // The following components must be initialized in this order. | 543 // The following components must be initialized in this order. |
| 535 this.appState_.init( | 544 this.appState_.init( |
| 536 settings.serializedAppStateStr, | 545 settings.serializedAppStateStr, |
| 537 settings.systemDefaultDestinationId); | 546 settings.systemDefaultDestinationId); |
| 538 this.documentInfo_.init( | 547 this.documentInfo_.init( |
| 539 settings.isDocumentModifiable, | 548 settings.isDocumentModifiable, |
| 540 settings.documentTitle, | 549 settings.documentTitle, |
| 541 settings.documentHasSelection); | 550 settings.documentHasSelection); |
| 542 this.printTicketStore_.init( | 551 this.printTicketStore_.init( |
| 543 settings.thousandsDelimeter, | 552 settings.thousandsDelimeter, |
| 544 settings.decimalDelimeter, | 553 settings.decimalDelimeter, |
| 545 settings.unitType, | 554 settings.unitType, |
| 546 settings.selectionOnly); | 555 settings.selectionOnly); |
| 547 this.destinationStore_.init(); | 556 this.destinationStore_.init(settings.isInAppKioskMode); |
| 548 this.appState_.setInitialized(); | 557 this.appState_.setInitialized(); |
| 549 | 558 |
| 550 $('document-title').innerText = settings.documentTitle; | 559 $('document-title').innerText = settings.documentTitle; |
| 551 setIsVisible($('system-dialog-link'), | 560 setIsVisible($('system-dialog-link'), |
| 552 !settings.hidePrintWithSystemDialogLink); | 561 !settings.hidePrintWithSystemDialogLink); |
| 562 setIsVisible($('cloud-print-dialog-link'), !settings.isInAppKioskMode); |
| 553 }, | 563 }, |
| 554 | 564 |
| 555 /** | 565 /** |
| 556 * Calls when the native layer enables Google Cloud Print integration. | 566 * Calls when the native layer enables Google Cloud Print integration. |
| 557 * Fetches the user's cloud printers. | 567 * Fetches the user's cloud printers. |
| 558 * @param {Event} event Contains the base URL of the Google Cloud Print | 568 * @param {Event} event Contains the base URL of the Google Cloud Print |
| 559 * service. | 569 * service. |
| 560 * @private | 570 * @private |
| 561 */ | 571 */ |
| 562 onCloudPrintEnable_: function(event) { | 572 onCloudPrintEnable_: function(event) { |
| 563 this.cloudPrintInterface_ = new cloudprint.CloudPrintInterface( | 573 this.cloudPrintInterface_ = new cloudprint.CloudPrintInterface( |
| 564 event.baseCloudPrintUrl, | 574 event.baseCloudPrintUrl, |
| 565 this.nativeLayer_, | 575 this.nativeLayer_, |
| 566 this.userInfo_); | 576 this.userInfo_, |
| 577 event.appKioskMode); |
| 567 this.tracker.add( | 578 this.tracker.add( |
| 568 this.cloudPrintInterface_, | 579 this.cloudPrintInterface_, |
| 569 cloudprint.CloudPrintInterface.EventType.SUBMIT_DONE, | 580 cloudprint.CloudPrintInterface.EventType.SUBMIT_DONE, |
| 570 this.onCloudPrintSubmitDone_.bind(this)); | 581 this.onCloudPrintSubmitDone_.bind(this)); |
| 571 this.tracker.add( | 582 this.tracker.add( |
| 572 this.cloudPrintInterface_, | 583 this.cloudPrintInterface_, |
| 573 cloudprint.CloudPrintInterface.EventType.SEARCH_FAILED, | 584 cloudprint.CloudPrintInterface.EventType.SEARCH_FAILED, |
| 574 this.onCloudPrintError_.bind(this)); | 585 this.onCloudPrintError_.bind(this)); |
| 575 this.tracker.add( | 586 this.tracker.add( |
| 576 this.cloudPrintInterface_, | 587 this.cloudPrintInterface_, |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 655 }, | 666 }, |
| 656 | 667 |
| 657 /** | 668 /** |
| 658 * Called when there was an error communicating with Google Cloud print. | 669 * Called when there was an error communicating with Google Cloud print. |
| 659 * Displays an error message in the print header. | 670 * Displays an error message in the print header. |
| 660 * @param {!Event} event Contains the error message. | 671 * @param {!Event} event Contains the error message. |
| 661 * @private | 672 * @private |
| 662 */ | 673 */ |
| 663 onCloudPrintError_: function(event) { | 674 onCloudPrintError_: function(event) { |
| 664 if (event.status == 403) { | 675 if (event.status == 403) { |
| 665 this.destinationSearch_.showCloudPrintPromo(); | 676 if (!this.isInAppKioskMode_) { |
| 677 this.destinationSearch_.showCloudPrintPromo(); |
| 678 } |
| 666 } else if (event.status == 0) { | 679 } else if (event.status == 0) { |
| 667 return; // Ignore, the system does not have internet connectivity. | 680 return; // Ignore, the system does not have internet connectivity. |
| 668 } else { | 681 } else { |
| 669 this.printHeader_.setErrorMessage(event.message); | 682 this.printHeader_.setErrorMessage(event.message); |
| 670 } | 683 } |
| 671 if (event.status == 200) { | 684 if (event.status == 200) { |
| 672 console.error('Google Cloud Print Error: (' + event.errorCode + ') ' + | 685 console.error('Google Cloud Print Error: (' + event.errorCode + ') ' + |
| 673 event.message); | 686 event.message); |
| 674 } else { | 687 } else { |
| 675 console.error('Google Cloud Print Error: HTTP status ' + event.status); | 688 console.error('Google Cloud Print Error: HTTP status ' + event.status); |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1034 <include src="search/recent_destination_list.js"/> | 1047 <include src="search/recent_destination_list.js"/> |
| 1035 <include src="search/destination_list_item.js"/> | 1048 <include src="search/destination_list_item.js"/> |
| 1036 <include src="search/destination_search.js"/> | 1049 <include src="search/destination_search.js"/> |
| 1037 <include src="search/search_box.js"/> | 1050 <include src="search/search_box.js"/> |
| 1038 <include src="search/fedex_tos.js"/> | 1051 <include src="search/fedex_tos.js"/> |
| 1039 | 1052 |
| 1040 window.addEventListener('DOMContentLoaded', function() { | 1053 window.addEventListener('DOMContentLoaded', function() { |
| 1041 printPreview = new print_preview.PrintPreview(); | 1054 printPreview = new print_preview.PrintPreview(); |
| 1042 printPreview.initialize(); | 1055 printPreview.initialize(); |
| 1043 }); | 1056 }); |
| OLD | NEW |