| 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 23 matching lines...) Expand all Loading... |
| 34 this.userInfo_ = new print_preview.UserInfo(); | 34 this.userInfo_ = new print_preview.UserInfo(); |
| 35 | 35 |
| 36 /** | 36 /** |
| 37 * Metrics object used to report usage statistics. | 37 * Metrics object used to report usage statistics. |
| 38 * @type {!print_preview.Metrics} | 38 * @type {!print_preview.Metrics} |
| 39 * @private | 39 * @private |
| 40 */ | 40 */ |
| 41 this.metrics_ = new print_preview.Metrics(); | 41 this.metrics_ = new print_preview.Metrics(); |
| 42 | 42 |
| 43 /** | 43 /** |
| 44 * Application state. |
| 45 * @type {!print_preview.AppState} |
| 46 * @private |
| 47 */ |
| 48 this.appState_ = new print_preview.AppState(); |
| 49 |
| 50 /** |
| 44 * Data store which holds print destinations. | 51 * Data store which holds print destinations. |
| 45 * @type {!print_preview.DestinationStore} | 52 * @type {!print_preview.DestinationStore} |
| 46 * @private | 53 * @private |
| 47 */ | 54 */ |
| 48 this.destinationStore_ = new print_preview.DestinationStore( | 55 this.destinationStore_ = new print_preview.DestinationStore( |
| 49 this.nativeLayer_); | 56 this.nativeLayer_, this.appState_); |
| 50 | 57 |
| 51 /** | 58 /** |
| 52 * Storage of the print ticket used to create the print job. | 59 * Storage of the print ticket used to create the print job. |
| 53 * @type {!print_preview.PrintTicketStore} | 60 * @type {!print_preview.PrintTicketStore} |
| 54 * @private | 61 * @private |
| 55 */ | 62 */ |
| 56 this.printTicketStore_ = new print_preview.PrintTicketStore( | 63 this.printTicketStore_ = new print_preview.PrintTicketStore( |
| 57 this.destinationStore_); | 64 this.destinationStore_, this.appState_); |
| 58 | 65 |
| 59 /** | 66 /** |
| 60 * Holds the print and cancel buttons and renders some document statistics. | 67 * Holds the print and cancel buttons and renders some document statistics. |
| 61 * @type {!print_preview.PrintHeader} | 68 * @type {!print_preview.PrintHeader} |
| 62 * @private | 69 * @private |
| 63 */ | 70 */ |
| 64 this.printHeader_ = new print_preview.PrintHeader( | 71 this.printHeader_ = new print_preview.PrintHeader( |
| 65 this.printTicketStore_, this.destinationStore_); | 72 this.printTicketStore_, this.destinationStore_); |
| 66 this.addChild(this.printHeader_); | 73 this.addChild(this.printHeader_); |
| 67 | 74 |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 printIfReady_: function() { | 390 printIfReady_: function() { |
| 384 if ((this.uiState_ == PrintPreview.UiState_.PRINTING || | 391 if ((this.uiState_ == PrintPreview.UiState_.PRINTING || |
| 385 this.uiState_ == PrintPreview.UiState_.OPENING_PDF_PREVIEW || | 392 this.uiState_ == PrintPreview.UiState_.OPENING_PDF_PREVIEW || |
| 386 this.uiState_ == PrintPreview.UiState_.FILE_SELECTION || | 393 this.uiState_ == PrintPreview.UiState_.FILE_SELECTION || |
| 387 this.isInKioskAutoPrintMode_) && | 394 this.isInKioskAutoPrintMode_) && |
| 388 !this.isPreviewGenerationInProgress_ && | 395 !this.isPreviewGenerationInProgress_ && |
| 389 this.destinationStore_.selectedDestination && | 396 this.destinationStore_.selectedDestination && |
| 390 this.destinationStore_.selectedDestination.capabilities) { | 397 this.destinationStore_.selectedDestination.capabilities) { |
| 391 assert(this.printTicketStore_.isTicketValid(), | 398 assert(this.printTicketStore_.isTicketValid(), |
| 392 'Trying to print with invalid ticket'); | 399 'Trying to print with invalid ticket'); |
| 393 this.nativeLayer_.startSaveDestinationAndTicket( | |
| 394 this.destinationStore_.selectedDestination, | |
| 395 this.printTicketStore_); | |
| 396 this.nativeLayer_.startPrint( | 400 this.nativeLayer_.startPrint( |
| 397 this.destinationStore_.selectedDestination, | 401 this.destinationStore_.selectedDestination, |
| 398 this.printTicketStore_, | 402 this.printTicketStore_, |
| 399 this.cloudPrintInterface_, | 403 this.cloudPrintInterface_, |
| 400 this.uiState_ == PrintPreview.UiState_.OPENING_PDF_PREVIEW); | 404 this.uiState_ == PrintPreview.UiState_.OPENING_PDF_PREVIEW); |
| 401 return true; | 405 return true; |
| 402 } else { | 406 } else { |
| 403 return false; | 407 return false; |
| 404 } | 408 } |
| 405 }, | 409 }, |
| (...skipping 26 matching lines...) Expand all Loading... |
| 432 * @param {cr.Event} event Contains the initial print preview settings | 436 * @param {cr.Event} event Contains the initial print preview settings |
| 433 * persisted through the session. | 437 * persisted through the session. |
| 434 * @private | 438 * @private |
| 435 */ | 439 */ |
| 436 onInitialSettingsSet_: function(event) { | 440 onInitialSettingsSet_: function(event) { |
| 437 assert(this.uiState_ == PrintPreview.UiState_.INITIALIZING, | 441 assert(this.uiState_ == PrintPreview.UiState_.INITIALIZING, |
| 438 'Updating initial settings when not in initializing state: ' + | 442 'Updating initial settings when not in initializing state: ' + |
| 439 this.uiState_); | 443 this.uiState_); |
| 440 this.uiState_ = PrintPreview.UiState_.READY; | 444 this.uiState_ = PrintPreview.UiState_.READY; |
| 441 | 445 |
| 442 this.isInKioskAutoPrintMode_ = | 446 var settings = event.initialSettings; |
| 443 event.initialSettings.isInKioskAutoPrintMode; | 447 this.isInKioskAutoPrintMode_ = settings.isInKioskAutoPrintMode; |
| 444 this.destinationStore_.setInitialDestinationId( | 448 document.title = settings.documentTitle; |
| 445 event.initialSettings.initialDestinationId, | 449 |
| 446 event.initialSettings.isLocalDestination); | 450 // The following components must be initialized in this order. |
| 447 document.title = event.initialSettings.documentTitle; | 451 this.appState_.init(settings.serializedAppStateStr); |
| 448 this.printTicketStore_.initialize( | 452 this.printTicketStore_.init( |
| 449 event.initialSettings.isDocumentModifiable, | 453 settings.isDocumentModifiable, |
| 450 event.initialSettings.documentTitle, | 454 settings.documentTitle, |
| 451 event.initialSettings.isDuplexEnabled, | 455 settings.thousandsDelimeter, |
| 452 event.initialSettings.isHeaderFooterEnabled, | 456 settings.decimalDelimeter, |
| 453 event.initialSettings.marginsType, | 457 settings.unitType); |
| 454 event.initialSettings.customMargins, | 458 this.destinationStore_.init(settings.systemDefaultDestinationId); |
| 455 event.initialSettings.thousandsDelimeter, | |
| 456 event.initialSettings.decimalDelimeter, | |
| 457 event.initialSettings.unitType); | |
| 458 }, | 459 }, |
| 459 | 460 |
| 460 /** | 461 /** |
| 461 * Calls when the native layer enables Google Cloud Print integration. | 462 * Calls when the native layer enables Google Cloud Print integration. |
| 462 * Fetches the user's cloud printers. | 463 * Fetches the user's cloud printers. |
| 463 * @param {cr.Event} event Contains the base URL of the Google Cloud Print | 464 * @param {cr.Event} event Contains the base URL of the Google Cloud Print |
| 464 * service. | 465 * service. |
| 465 * @private | 466 * @private |
| 466 */ | 467 */ |
| 467 onCloudPrintEnable_: function(event) { | 468 onCloudPrintEnable_: function(event) { |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 791 <include src="data/destination_store.js"/> | 792 <include src="data/destination_store.js"/> |
| 792 <include src="data/margins.js"/> | 793 <include src="data/margins.js"/> |
| 793 <include src="data/document_info.js"/> | 794 <include src="data/document_info.js"/> |
| 794 <include src="data/printable_area.js"/> | 795 <include src="data/printable_area.js"/> |
| 795 <include src="data/measurement_system.js"/> | 796 <include src="data/measurement_system.js"/> |
| 796 <include src="data/print_ticket_store.js"/> | 797 <include src="data/print_ticket_store.js"/> |
| 797 <include src="data/coordinate2d.js"/> | 798 <include src="data/coordinate2d.js"/> |
| 798 <include src="data/size.js"/> | 799 <include src="data/size.js"/> |
| 799 <include src="data/capabilities_holder.js"/> | 800 <include src="data/capabilities_holder.js"/> |
| 800 <include src="data/user_info.js"/> | 801 <include src="data/user_info.js"/> |
| 802 <include src="data/app_state.js"/> |
| 801 | 803 |
| 802 <include src="data/ticket_items/ticket_item.js"/> | 804 <include src="data/ticket_items/ticket_item.js"/> |
| 803 | 805 |
| 804 <include src="data/ticket_items/custom_margins.js"/> | 806 <include src="data/ticket_items/custom_margins.js"/> |
| 805 <include src="data/ticket_items/collate.js"/> | 807 <include src="data/ticket_items/collate.js"/> |
| 806 <include src="data/ticket_items/color.js"/> | 808 <include src="data/ticket_items/color.js"/> |
| 807 <include src="data/ticket_items/copies.js"/> | 809 <include src="data/ticket_items/copies.js"/> |
| 808 <include src="data/ticket_items/duplex.js"/> | 810 <include src="data/ticket_items/duplex.js"/> |
| 809 <include src="data/ticket_items/header_footer.js"/> | 811 <include src="data/ticket_items/header_footer.js"/> |
| 810 <include src="data/ticket_items/landscape.js"/> | 812 <include src="data/ticket_items/landscape.js"/> |
| (...skipping 26 matching lines...) Expand all Loading... |
| 837 <include src="search/recent_destination_list.js"/> | 839 <include src="search/recent_destination_list.js"/> |
| 838 <include src="search/destination_list_item.js"/> | 840 <include src="search/destination_list_item.js"/> |
| 839 <include src="search/destination_search.js"/> | 841 <include src="search/destination_search.js"/> |
| 840 <include src="search/search_box.js"/> | 842 <include src="search/search_box.js"/> |
| 841 <include src="search/fedex_tos.js"/> | 843 <include src="search/fedex_tos.js"/> |
| 842 | 844 |
| 843 window.addEventListener('DOMContentLoaded', function() { | 845 window.addEventListener('DOMContentLoaded', function() { |
| 844 printPreview = new print_preview.PrintPreview(); | 846 printPreview = new print_preview.PrintPreview(); |
| 845 printPreview.initialize(); | 847 printPreview.initialize(); |
| 846 }); | 848 }); |
| OLD | NEW |