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.exportPath('print_preview'); | 5 cr.exportPath('print_preview'); |
6 | 6 |
7 /** | 7 /** |
8 * @typedef {{selectSaveAsPdfDestination: boolean, | 8 * @typedef {{selectSaveAsPdfDestination: boolean, |
9 * layoutSettings.portrait: boolean, | 9 * layoutSettings.portrait: boolean, |
10 * pageRange: string, | 10 * pageRange: string, |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 * dispatched in response: | 270 * dispatched in response: |
271 * - PAGE_COUNT_READY | 271 * - PAGE_COUNT_READY |
272 * - PAGE_LAYOUT_READY | 272 * - PAGE_LAYOUT_READY |
273 * - PAGE_PREVIEW_READY | 273 * - PAGE_PREVIEW_READY |
274 * - PREVIEW_GENERATION_DONE | 274 * - PREVIEW_GENERATION_DONE |
275 * - PREVIEW_GENERATION_FAIL | 275 * - PREVIEW_GENERATION_FAIL |
276 * @param {!print_preview.Destination} destination Destination to print to. | 276 * @param {!print_preview.Destination} destination Destination to print to. |
277 * @param {!print_preview.PrintTicketStore} printTicketStore Used to get the | 277 * @param {!print_preview.PrintTicketStore} printTicketStore Used to get the |
278 * state of the print ticket. | 278 * state of the print ticket. |
279 * @param {!print_preview.DocumentInfo} documentInfo Document data model. | 279 * @param {!print_preview.DocumentInfo} documentInfo Document data model. |
| 280 * @param {boolean} generateDraft Tell the renderer to re-render. |
280 * @param {number} requestId ID of the preview request. | 281 * @param {number} requestId ID of the preview request. |
281 */ | 282 */ |
282 startGetPreview: function( | 283 startGetPreview: function( |
283 destination, printTicketStore, documentInfo, requestId) { | 284 destination, printTicketStore, documentInfo, generateDraft, requestId) { |
284 assert(printTicketStore.isTicketValidForPreview(), | 285 assert(printTicketStore.isTicketValidForPreview(), |
285 'Trying to generate preview when ticket is not valid'); | 286 'Trying to generate preview when ticket is not valid'); |
286 | 287 |
287 var ticket = { | 288 var ticket = { |
288 'pageRange': printTicketStore.pageRange.getDocumentPageRanges(), | 289 'pageRange': printTicketStore.pageRange.getDocumentPageRanges(), |
289 'mediaSize': printTicketStore.mediaSize.getValue(), | 290 'mediaSize': printTicketStore.mediaSize.getValue(), |
290 'landscape': printTicketStore.landscape.getValue(), | 291 'landscape': printTicketStore.landscape.getValue(), |
291 'color': this.getNativeColorModel_(destination, printTicketStore.color), | 292 'color': this.getNativeColorModel_(destination, printTicketStore.color), |
292 'headerFooterEnabled': printTicketStore.headerFooter.getValue(), | 293 'headerFooterEnabled': printTicketStore.headerFooter.getValue(), |
293 'marginsType': printTicketStore.marginsType.getValue(), | 294 'marginsType': printTicketStore.marginsType.getValue(), |
294 'isFirstRequest': requestId == 0, | 295 'isFirstRequest': requestId == 0, |
295 'requestID': requestId, | 296 'requestID': requestId, |
296 'previewModifiable': documentInfo.isModifiable, | 297 'previewModifiable': documentInfo.isModifiable, |
297 'generateDraftData': documentInfo.isModifiable, | 298 'generateDraftData': generateDraft, |
298 'fitToPageEnabled': printTicketStore.fitToPage.getValue(), | 299 'fitToPageEnabled': printTicketStore.fitToPage.getValue(), |
299 'scaleFactor': printTicketStore.scaling.getValueAsNumber(), | 300 'scaleFactor': printTicketStore.scaling.getValueAsNumber(), |
300 // NOTE: Even though the following fields don't directly relate to the | 301 // NOTE: Even though the following fields don't directly relate to the |
301 // preview, they still need to be included. | 302 // preview, they still need to be included. |
302 // e.g. printing::PrintSettingsFromJobSettings() still checks for them. | 303 // e.g. printing::PrintSettingsFromJobSettings() still checks for them. |
303 'collate': true, | 304 'collate': true, |
304 'copies': 1, | 305 'copies': 1, |
305 'deviceName': destination.id, | 306 'deviceName': destination.id, |
306 'dpiHorizontal': "horizontal_dpi" in printTicketStore.dpi.getValue() ? | 307 'dpiHorizontal': "horizontal_dpi" in printTicketStore.dpi.getValue() ? |
307 printTicketStore.dpi.getValue().horizontal_dpi : 0, | 308 printTicketStore.dpi.getValue().horizontal_dpi : 0, |
(...skipping 26 matching lines...) Expand all Loading... |
334 'marginTop': customMargins.get(orientationEnum.TOP), | 335 'marginTop': customMargins.get(orientationEnum.TOP), |
335 'marginRight': customMargins.get(orientationEnum.RIGHT), | 336 'marginRight': customMargins.get(orientationEnum.RIGHT), |
336 'marginBottom': customMargins.get(orientationEnum.BOTTOM), | 337 'marginBottom': customMargins.get(orientationEnum.BOTTOM), |
337 'marginLeft': customMargins.get(orientationEnum.LEFT) | 338 'marginLeft': customMargins.get(orientationEnum.LEFT) |
338 }; | 339 }; |
339 } | 340 } |
340 | 341 |
341 chrome.send( | 342 chrome.send( |
342 'getPreview', | 343 'getPreview', |
343 [JSON.stringify(ticket), | 344 [JSON.stringify(ticket), |
344 requestId > 0 ? documentInfo.pageCount : -1, | 345 requestId > 0 ? documentInfo.pageCount : -1]); |
345 documentInfo.isModifiable]); | |
346 }, | 346 }, |
347 | 347 |
348 /** | 348 /** |
349 * Requests that the document be printed. | 349 * Requests that the document be printed. |
350 * @param {!print_preview.Destination} destination Destination to print to. | 350 * @param {!print_preview.Destination} destination Destination to print to. |
351 * @param {!print_preview.PrintTicketStore} printTicketStore Used to get the | 351 * @param {!print_preview.PrintTicketStore} printTicketStore Used to get the |
352 * state of the print ticket. | 352 * state of the print ticket. |
353 * @param {cloudprint.CloudPrintInterface} cloudPrintInterface Interface | 353 * @param {cloudprint.CloudPrintInterface} cloudPrintInterface Interface |
354 * to Google Cloud Print. | 354 * to Google Cloud Print. |
355 * @param {!print_preview.DocumentInfo} documentInfo Document data model. | 355 * @param {!print_preview.DocumentInfo} documentInfo Document data model. |
(...skipping 750 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1106 return this.serializedDefaultDestinationSelectionRulesStr_; | 1106 return this.serializedDefaultDestinationSelectionRulesStr_; |
1107 } | 1107 } |
1108 }; | 1108 }; |
1109 | 1109 |
1110 // Export | 1110 // Export |
1111 return { | 1111 return { |
1112 NativeInitialSettings: NativeInitialSettings, | 1112 NativeInitialSettings: NativeInitialSettings, |
1113 NativeLayer: NativeLayer | 1113 NativeLayer: NativeLayer |
1114 }; | 1114 }; |
1115 }); | 1115 }); |
OLD | NEW |