| 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 cr.define('print_preview', function() { | 5 cr.define('print_preview', function() { |
| 6 'use strict'; | 6 'use strict'; |
| 7 | 7 |
| 8 /** | 8 /** |
| 9 * An interface to the native Chromium printing system layer. | 9 * An interface to the native Chromium printing system layer. |
| 10 * @constructor | 10 * @constructor |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 this.onFileSelectionCancelled_.bind(this); | 29 this.onFileSelectionCancelled_.bind(this); |
| 30 global['fileSelectionCompleted'] = | 30 global['fileSelectionCompleted'] = |
| 31 this.onFileSelectionCompleted_.bind(this); | 31 this.onFileSelectionCompleted_.bind(this); |
| 32 global['printPreviewFailed'] = this.onPrintPreviewFailed_.bind(this); | 32 global['printPreviewFailed'] = this.onPrintPreviewFailed_.bind(this); |
| 33 global['invalidPrinterSettings'] = | 33 global['invalidPrinterSettings'] = |
| 34 this.onInvalidPrinterSettings_.bind(this); | 34 this.onInvalidPrinterSettings_.bind(this); |
| 35 global['onDidGetDefaultPageLayout'] = | 35 global['onDidGetDefaultPageLayout'] = |
| 36 this.onDidGetDefaultPageLayout_.bind(this); | 36 this.onDidGetDefaultPageLayout_.bind(this); |
| 37 global['onDidGetPreviewPageCount'] = | 37 global['onDidGetPreviewPageCount'] = |
| 38 this.onDidGetPreviewPageCount_.bind(this); | 38 this.onDidGetPreviewPageCount_.bind(this); |
| 39 global['reloadPreviewPages'] = this.onReloadPreviewPages_.bind(this); | |
| 40 global['onDidPreviewPage'] = this.onDidPreviewPage_.bind(this); | 39 global['onDidPreviewPage'] = this.onDidPreviewPage_.bind(this); |
| 41 global['updatePrintPreview'] = this.onUpdatePrintPreview_.bind(this); | 40 global['updatePrintPreview'] = this.onUpdatePrintPreview_.bind(this); |
| 42 global['printScalingDisabledForSourcePDF'] = | 41 global['printScalingDisabledForSourcePDF'] = |
| 43 this.onPrintScalingDisabledForSourcePDF_.bind(this); | 42 this.onPrintScalingDisabledForSourcePDF_.bind(this); |
| 44 global['onDidGetAccessToken'] = this.onDidGetAccessToken_.bind(this); | 43 global['onDidGetAccessToken'] = this.onDidGetAccessToken_.bind(this); |
| 45 global['autoCancelForTesting'] = this.autoCancelForTesting_.bind(this); | 44 global['autoCancelForTesting'] = this.autoCancelForTesting_.bind(this); |
| 46 global['onPrivetPrinterChanged'] = this.onPrivetPrinterChanged_.bind(this); | 45 global['onPrivetPrinterChanged'] = this.onPrivetPrinterChanged_.bind(this); |
| 47 global['onPrivetPrinterSearchDone'] = | 46 global['onPrivetPrinterSearchDone'] = |
| 48 this.onPrivetPrinterSearchDone_.bind(this); | 47 this.onPrivetPrinterSearchDone_.bind(this); |
| 49 global['onPrivetCapabilitiesSet'] = | 48 global['onPrivetCapabilitiesSet'] = |
| (...skipping 18 matching lines...) Expand all Loading... |
| 68 GET_CAPABILITIES_FAIL: 'print_preview.NativeLayer.GET_CAPABILITIES_FAIL', | 67 GET_CAPABILITIES_FAIL: 'print_preview.NativeLayer.GET_CAPABILITIES_FAIL', |
| 69 INITIAL_SETTINGS_SET: 'print_preview.NativeLayer.INITIAL_SETTINGS_SET', | 68 INITIAL_SETTINGS_SET: 'print_preview.NativeLayer.INITIAL_SETTINGS_SET', |
| 70 LOCAL_DESTINATIONS_SET: 'print_preview.NativeLayer.LOCAL_DESTINATIONS_SET', | 69 LOCAL_DESTINATIONS_SET: 'print_preview.NativeLayer.LOCAL_DESTINATIONS_SET', |
| 71 PAGE_COUNT_READY: 'print_preview.NativeLayer.PAGE_COUNT_READY', | 70 PAGE_COUNT_READY: 'print_preview.NativeLayer.PAGE_COUNT_READY', |
| 72 PAGE_LAYOUT_READY: 'print_preview.NativeLayer.PAGE_LAYOUT_READY', | 71 PAGE_LAYOUT_READY: 'print_preview.NativeLayer.PAGE_LAYOUT_READY', |
| 73 PAGE_PREVIEW_READY: 'print_preview.NativeLayer.PAGE_PREVIEW_READY', | 72 PAGE_PREVIEW_READY: 'print_preview.NativeLayer.PAGE_PREVIEW_READY', |
| 74 PREVIEW_GENERATION_DONE: | 73 PREVIEW_GENERATION_DONE: |
| 75 'print_preview.NativeLayer.PREVIEW_GENERATION_DONE', | 74 'print_preview.NativeLayer.PREVIEW_GENERATION_DONE', |
| 76 PREVIEW_GENERATION_FAIL: | 75 PREVIEW_GENERATION_FAIL: |
| 77 'print_preview.NativeLayer.PREVIEW_GENERATION_FAIL', | 76 'print_preview.NativeLayer.PREVIEW_GENERATION_FAIL', |
| 78 PREVIEW_RELOAD: 'print_preview.NativeLayer.PREVIEW_RELOAD', | |
| 79 PRINT_TO_CLOUD: 'print_preview.NativeLayer.PRINT_TO_CLOUD', | 77 PRINT_TO_CLOUD: 'print_preview.NativeLayer.PRINT_TO_CLOUD', |
| 80 SETTINGS_INVALID: 'print_preview.NativeLayer.SETTINGS_INVALID', | 78 SETTINGS_INVALID: 'print_preview.NativeLayer.SETTINGS_INVALID', |
| 81 PRIVET_PRINTER_CHANGED: 'print_preview.NativeLayer.PRIVET_PRINTER_CHANGED', | 79 PRIVET_PRINTER_CHANGED: 'print_preview.NativeLayer.PRIVET_PRINTER_CHANGED', |
| 82 PRIVET_PRINTER_SEARCH_DONE: | 80 PRIVET_PRINTER_SEARCH_DONE: |
| 83 'print_preview.NativeLayer.PRIVET_PRINTER_SEARCH_DONE', | 81 'print_preview.NativeLayer.PRIVET_PRINTER_SEARCH_DONE', |
| 84 PRIVET_CAPABILITIES_SET: | 82 PRIVET_CAPABILITIES_SET: |
| 85 'print_preview.NativeLayer.PRIVET_CAPABILITIES_SET', | 83 'print_preview.NativeLayer.PRIVET_CAPABILITIES_SET', |
| 86 PRIVET_PRINT_FAILED: 'print_preview.NativeLayer.PRIVET_PRINT_FAILED' | 84 PRIVET_PRINT_FAILED: 'print_preview.NativeLayer.PRIVET_PRINT_FAILED' |
| 87 }; | 85 }; |
| 88 | 86 |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 }, | 164 }, |
| 167 | 165 |
| 168 /** | 166 /** |
| 169 * Requests that a preview be generated. The following events may be | 167 * Requests that a preview be generated. The following events may be |
| 170 * dispatched in response: | 168 * dispatched in response: |
| 171 * - PAGE_COUNT_READY | 169 * - PAGE_COUNT_READY |
| 172 * - PAGE_LAYOUT_READY | 170 * - PAGE_LAYOUT_READY |
| 173 * - PAGE_PREVIEW_READY | 171 * - PAGE_PREVIEW_READY |
| 174 * - PREVIEW_GENERATION_DONE | 172 * - PREVIEW_GENERATION_DONE |
| 175 * - PREVIEW_GENERATION_FAIL | 173 * - PREVIEW_GENERATION_FAIL |
| 176 * - PREVIEW_RELOAD | |
| 177 * @param {print_preview.Destination} destination Destination to print to. | 174 * @param {print_preview.Destination} destination Destination to print to. |
| 178 * @param {!print_preview.PrintTicketStore} printTicketStore Used to get the | 175 * @param {!print_preview.PrintTicketStore} printTicketStore Used to get the |
| 179 * state of the print ticket. | 176 * state of the print ticket. |
| 180 * @param {!print_preview.DocumentInfo} documentInfo Document data model. | 177 * @param {!print_preview.DocumentInfo} documentInfo Document data model. |
| 181 * @param {number} ID of the preview request. | 178 * @param {number} ID of the preview request. |
| 182 */ | 179 */ |
| 183 startGetPreview: function( | 180 startGetPreview: function( |
| 184 destination, printTicketStore, documentInfo, requestId) { | 181 destination, printTicketStore, documentInfo, requestId) { |
| 185 assert(printTicketStore.isTicketValidForPreview(), | 182 assert(printTicketStore.isTicketValidForPreview(), |
| 186 'Trying to generate preview when ticket is not valid'); | 183 'Trying to generate preview when ticket is not valid'); |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 551 */ | 548 */ |
| 552 onDidGetPreviewPageCount_: function(pageCount, previewResponseId) { | 549 onDidGetPreviewPageCount_: function(pageCount, previewResponseId) { |
| 553 var pageCountChangeEvent = new Event( | 550 var pageCountChangeEvent = new Event( |
| 554 NativeLayer.EventType.PAGE_COUNT_READY); | 551 NativeLayer.EventType.PAGE_COUNT_READY); |
| 555 pageCountChangeEvent.pageCount = pageCount; | 552 pageCountChangeEvent.pageCount = pageCount; |
| 556 pageCountChangeEvent.previewResponseId = previewResponseId; | 553 pageCountChangeEvent.previewResponseId = previewResponseId; |
| 557 this.dispatchEvent(pageCountChangeEvent); | 554 this.dispatchEvent(pageCountChangeEvent); |
| 558 }, | 555 }, |
| 559 | 556 |
| 560 /** | 557 /** |
| 561 * Called when no pipelining previewed pages. | |
| 562 * @param {number} previewUid Preview unique identifier. | |
| 563 * @param {number} previewResponseId The preview request id that resulted in | |
| 564 * this response. | |
| 565 * @private | |
| 566 */ | |
| 567 onReloadPreviewPages_: function(previewUid, previewResponseId) { | |
| 568 var previewReloadEvent = new Event( | |
| 569 NativeLayer.EventType.PREVIEW_RELOAD); | |
| 570 previewReloadEvent.previewUid = previewUid; | |
| 571 previewReloadEvent.previewResponseId = previewResponseId; | |
| 572 this.dispatchEvent(previewReloadEvent); | |
| 573 }, | |
| 574 | |
| 575 /** | |
| 576 * Notification that a print preview page has been rendered. | 558 * Notification that a print preview page has been rendered. |
| 577 * Check if the settings have changed and request a regeneration if needed. | 559 * Check if the settings have changed and request a regeneration if needed. |
| 578 * Called from PrintPreviewUI::OnDidPreviewPage(). | 560 * Called from PrintPreviewUI::OnDidPreviewPage(). |
| 579 * @param {number} pageNumber The page number, 0-based. | 561 * @param {number} pageNumber The page number, 0-based. |
| 580 * @param {number} previewUid Preview unique identifier. | 562 * @param {number} previewUid Preview unique identifier. |
| 581 * @param {number} previewResponseId The preview request id that resulted in | 563 * @param {number} previewResponseId The preview request id that resulted in |
| 582 * this response. | 564 * this response. |
| 583 * @private | 565 * @private |
| 584 */ | 566 */ |
| 585 onDidPreviewPage_: function(pageNumber, previewUid, previewResponseId) { | 567 onDidPreviewPage_: function(pageNumber, previewUid, previewResponseId) { |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 868 return this.serializedAppStateStr_; | 850 return this.serializedAppStateStr_; |
| 869 } | 851 } |
| 870 }; | 852 }; |
| 871 | 853 |
| 872 // Export | 854 // Export |
| 873 return { | 855 return { |
| 874 NativeInitialSettings: NativeInitialSettings, | 856 NativeInitialSettings: NativeInitialSettings, |
| 875 NativeLayer: NativeLayer | 857 NativeLayer: NativeLayer |
| 876 }; | 858 }; |
| 877 }); | 859 }); |
| OLD | NEW |