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