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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 * - PREVIEW_RELOAD | 133 * - PREVIEW_RELOAD |
134 * @param {print_preview.Destination} destination Destination to print to. | 134 * @param {print_preview.Destination} destination Destination to print to. |
135 * @param {!print_preview.PrintTicketStore} printTicketStore Used to get the | 135 * @param {!print_preview.PrintTicketStore} printTicketStore Used to get the |
136 * state of the print ticket. | 136 * state of the print ticket. |
137 * @param {number} ID of the preview request. | 137 * @param {number} ID of the preview request. |
138 */ | 138 */ |
139 startGetPreview: function(destination, printTicketStore, requestId) { | 139 startGetPreview: function(destination, printTicketStore, requestId) { |
140 assert(printTicketStore.isTicketValidForPreview(), | 140 assert(printTicketStore.isTicketValidForPreview(), |
141 'Trying to generate preview when ticket is not valid'); | 141 'Trying to generate preview when ticket is not valid'); |
142 | 142 |
143 var pageRanges = | |
144 (requestId > 0 && printTicketStore.hasPageRangeCapability()) ? | |
145 printTicketStore.getPageNumberSet().getPageRanges() : []; | |
146 | |
147 var ticket = { | 143 var ticket = { |
148 'pageRange': pageRanges, | 144 'pageRange': printTicketStore.getPageRange().getPageRanges(), |
149 'landscape': printTicketStore.isLandscapeEnabled(), | 145 'landscape': printTicketStore.isLandscapeEnabled(), |
150 'color': printTicketStore.isColorEnabled() ? | 146 'color': printTicketStore.isColorEnabled() ? |
151 NativeLayer.ColorMode_.COLOR : NativeLayer.ColorMode_.GRAY, | 147 NativeLayer.ColorMode_.COLOR : NativeLayer.ColorMode_.GRAY, |
152 'headerFooterEnabled': printTicketStore.isHeaderFooterEnabled(), | 148 'headerFooterEnabled': printTicketStore.isHeaderFooterEnabled(), |
153 'marginsType': printTicketStore.getMarginsType(), | 149 'marginsType': printTicketStore.getMarginsType(), |
154 'isFirstRequest': requestId == 0, | 150 'isFirstRequest': requestId == 0, |
155 'requestID': requestId, | 151 'requestID': requestId, |
156 'previewModifiable': printTicketStore.isDocumentModifiable, | 152 'previewModifiable': printTicketStore.isDocumentModifiable, |
157 'printToPDF': | 153 'printToPDF': |
158 destination != null && | 154 destination != null && |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 * to Google Cloud Print. | 204 * to Google Cloud Print. |
209 * @param {boolean=} opt_isOpenPdfInPreview Whether to open the PDF in the | 205 * @param {boolean=} opt_isOpenPdfInPreview Whether to open the PDF in the |
210 * system's preview application. | 206 * system's preview application. |
211 */ | 207 */ |
212 startPrint: function(destination, printTicketStore, cloudPrintInterface, | 208 startPrint: function(destination, printTicketStore, cloudPrintInterface, |
213 opt_isOpenPdfInPreview) { | 209 opt_isOpenPdfInPreview) { |
214 assert(printTicketStore.isTicketValid(), | 210 assert(printTicketStore.isTicketValid(), |
215 'Trying to print when ticket is not valid'); | 211 'Trying to print when ticket is not valid'); |
216 | 212 |
217 var ticket = { | 213 var ticket = { |
218 'pageRange': printTicketStore.hasPageRangeCapability() ? | 214 'pageRange': printTicketStore.getPageRange().getPageRanges(), |
219 printTicketStore.getPageNumberSet().getPageRanges() : [], | |
220 'pageCount': printTicketStore.getPageNumberSet().size, | 215 'pageCount': printTicketStore.getPageNumberSet().size, |
221 'landscape': printTicketStore.isLandscapeEnabled(), | 216 'landscape': printTicketStore.isLandscapeEnabled(), |
222 'color': printTicketStore.isColorEnabled() ? | 217 'color': printTicketStore.isColorEnabled() ? |
223 NativeLayer.ColorMode_.COLOR : NativeLayer.ColorMode_.GRAY, | 218 NativeLayer.ColorMode_.COLOR : NativeLayer.ColorMode_.GRAY, |
224 'headerFooterEnabled': printTicketStore.isHeaderFooterEnabled(), | 219 'headerFooterEnabled': printTicketStore.isHeaderFooterEnabled(), |
225 'marginsType': printTicketStore.getMarginsType(), | 220 'marginsType': printTicketStore.getMarginsType(), |
226 'generateDraftData': true, // TODO(rltoscano): What should this be? | 221 'generateDraftData': true, // TODO(rltoscano): What should this be? |
227 'duplex': printTicketStore.isDuplexEnabled() ? | 222 'duplex': printTicketStore.isDuplexEnabled() ? |
228 NativeLayer.DuplexMode.LONG_EDGE : NativeLayer.DuplexMode.SIMPLEX, | 223 NativeLayer.DuplexMode.LONG_EDGE : NativeLayer.DuplexMode.SIMPLEX, |
229 'copies': printTicketStore.getCopies(), | 224 'copies': printTicketStore.getCopies(), |
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
713 return this.serializedAppStateStr_; | 708 return this.serializedAppStateStr_; |
714 } | 709 } |
715 }; | 710 }; |
716 | 711 |
717 // Export | 712 // Export |
718 return { | 713 return { |
719 NativeInitialSettings: NativeInitialSettings, | 714 NativeInitialSettings: NativeInitialSettings, |
720 NativeLayer: NativeLayer | 715 NativeLayer: NativeLayer |
721 }; | 716 }; |
722 }); | 717 }); |
OLD | NEW |