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 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 print_preview.NativeLayer.EventType.FILE_SELECTION_COMPLETE, | 253 print_preview.NativeLayer.EventType.FILE_SELECTION_COMPLETE, |
254 this.onFileSelectionComplete_.bind(this)); | 254 this.onFileSelectionComplete_.bind(this)); |
255 this.tracker.add( | 255 this.tracker.add( |
256 this.nativeLayer_, | 256 this.nativeLayer_, |
257 print_preview.NativeLayer.EventType.SETTINGS_INVALID, | 257 print_preview.NativeLayer.EventType.SETTINGS_INVALID, |
258 this.onSettingsInvalid_.bind(this)); | 258 this.onSettingsInvalid_.bind(this)); |
259 this.tracker.add( | 259 this.tracker.add( |
260 this.nativeLayer_, | 260 this.nativeLayer_, |
261 print_preview.NativeLayer.EventType.DISABLE_SCALING, | 261 print_preview.NativeLayer.EventType.DISABLE_SCALING, |
262 this.onDisableScaling_.bind(this)); | 262 this.onDisableScaling_.bind(this)); |
| 263 this.tracker.add( |
| 264 this.nativeLayer_, |
| 265 print_preview.NativeLayer.EventType.PRIVET_PRINT_FAILED, |
| 266 this.onPrivetPrintFailed_.bind(this)); |
| 267 |
263 | 268 |
264 this.tracker.add( | 269 this.tracker.add( |
265 $('system-dialog-link'), | 270 $('system-dialog-link'), |
266 'click', | 271 'click', |
267 this.openSystemPrintDialog_.bind(this)); | 272 this.openSystemPrintDialog_.bind(this)); |
268 this.tracker.add( | 273 this.tracker.add( |
269 $('cloud-print-dialog-link'), | 274 $('cloud-print-dialog-link'), |
270 'click', | 275 'click', |
271 this.onCloudPrintDialogLinkClick_.bind(this)); | 276 this.onCloudPrintDialogLinkClick_.bind(this)); |
272 this.tracker.add( | 277 this.tracker.add( |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 this.uiState_ = PrintPreview.UiState_.OPENING_PDF_PREVIEW; | 404 this.uiState_ = PrintPreview.UiState_.OPENING_PDF_PREVIEW; |
400 } else if (this.destinationStore_.selectedDestination.id == | 405 } else if (this.destinationStore_.selectedDestination.id == |
401 print_preview.Destination.GooglePromotedId.SAVE_AS_PDF) { | 406 print_preview.Destination.GooglePromotedId.SAVE_AS_PDF) { |
402 this.uiState_ = PrintPreview.UiState_.FILE_SELECTION; | 407 this.uiState_ = PrintPreview.UiState_.FILE_SELECTION; |
403 } else { | 408 } else { |
404 this.uiState_ = PrintPreview.UiState_.PRINTING; | 409 this.uiState_ = PrintPreview.UiState_.PRINTING; |
405 } | 410 } |
406 this.setIsEnabled_(false); | 411 this.setIsEnabled_(false); |
407 if (this.printIfReady_() && | 412 if (this.printIfReady_() && |
408 ((this.destinationStore_.selectedDestination.isLocal && | 413 ((this.destinationStore_.selectedDestination.isLocal && |
| 414 !this.destinationStore_.selectedDestination.isPrivet && |
409 this.destinationStore_.selectedDestination.id != | 415 this.destinationStore_.selectedDestination.id != |
410 print_preview.Destination.GooglePromotedId.SAVE_AS_PDF) || | 416 print_preview.Destination.GooglePromotedId.SAVE_AS_PDF) || |
411 this.uiState_ == PrintPreview.UiState_.OPENING_PDF_PREVIEW)) { | 417 this.uiState_ == PrintPreview.UiState_.OPENING_PDF_PREVIEW)) { |
412 // Hide the dialog for now. The actual print command will be issued when | 418 // Hide the dialog for now. The actual print command will be issued when |
413 // the preview generation is done. | 419 // the preview generation is done. |
414 this.nativeLayer_.startHideDialog(); | 420 this.nativeLayer_.startHideDialog(); |
415 } | 421 } |
416 }, | 422 }, |
417 | 423 |
418 /** | 424 /** |
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
796 * Called when the native layer dispatches a DISABLE_SCALING event. Resets | 802 * Called when the native layer dispatches a DISABLE_SCALING event. Resets |
797 * fit-to-page selection and updates document info. | 803 * fit-to-page selection and updates document info. |
798 * @private | 804 * @private |
799 */ | 805 */ |
800 onDisableScaling_: function() { | 806 onDisableScaling_: function() { |
801 this.printTicketStore_.fitToPage.updateValue(null); | 807 this.printTicketStore_.fitToPage.updateValue(null); |
802 this.documentInfo_.updateIsScalingDisabled(true); | 808 this.documentInfo_.updateIsScalingDisabled(true); |
803 }, | 809 }, |
804 | 810 |
805 /** | 811 /** |
| 812 * Called when privet printing fails. |
| 813 * @param {Event} event Event object representing the failure. |
| 814 * @private |
| 815 */ |
| 816 onPrivetPrintFailed_: function(event) { |
| 817 console.error('Privet printing failed with error code ' + |
| 818 event.httpError); |
| 819 this.printHeader_.setErrorMessage( |
| 820 localStrings.getString('couldNotPrint')); |
| 821 }, |
| 822 |
| 823 /** |
806 * Called when the open-cloud-print-dialog link is clicked. Opens the Google | 824 * Called when the open-cloud-print-dialog link is clicked. Opens the Google |
807 * Cloud Print web dialog. | 825 * Cloud Print web dialog. |
808 * @private | 826 * @private |
809 */ | 827 */ |
810 onCloudPrintDialogLinkClick_: function() { | 828 onCloudPrintDialogLinkClick_: function() { |
811 assert(this.uiState_ == PrintPreview.UiState_.READY, | 829 assert(this.uiState_ == PrintPreview.UiState_.READY, |
812 'Opening Google Cloud Print dialog when not in ready state: ' + | 830 'Opening Google Cloud Print dialog when not in ready state: ' + |
813 this.uiState_); | 831 this.uiState_); |
814 setIsVisible($('cloud-print-dialog-throbber'), true); | 832 setIsVisible($('cloud-print-dialog-throbber'), true); |
815 this.setIsEnabled_(false); | 833 this.setIsEnabled_(false); |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
941 <include src="search/recent_destination_list.js"/> | 959 <include src="search/recent_destination_list.js"/> |
942 <include src="search/destination_list_item.js"/> | 960 <include src="search/destination_list_item.js"/> |
943 <include src="search/destination_search.js"/> | 961 <include src="search/destination_search.js"/> |
944 <include src="search/search_box.js"/> | 962 <include src="search/search_box.js"/> |
945 <include src="search/fedex_tos.js"/> | 963 <include src="search/fedex_tos.js"/> |
946 | 964 |
947 window.addEventListener('DOMContentLoaded', function() { | 965 window.addEventListener('DOMContentLoaded', function() { |
948 printPreview = new print_preview.PrintPreview(); | 966 printPreview = new print_preview.PrintPreview(); |
949 printPreview.initialize(); | 967 printPreview.initialize(); |
950 }); | 968 }); |
OLD | NEW |