Chromium Code Reviews| 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 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 320 */ | 320 */ |
| 321 startPrint: function(destination, printTicketStore, cloudPrintInterface, | 321 startPrint: function(destination, printTicketStore, cloudPrintInterface, |
| 322 documentInfo, opt_isOpenPdfInPreview, | 322 documentInfo, opt_isOpenPdfInPreview, |
| 323 opt_showSystemDialog) { | 323 opt_showSystemDialog) { |
| 324 assert(printTicketStore.isTicketValid(), | 324 assert(printTicketStore.isTicketValid(), |
| 325 'Trying to print when ticket is not valid'); | 325 'Trying to print when ticket is not valid'); |
| 326 | 326 |
| 327 assert(!opt_showSystemDialog || (cr.isWindows && destination.isLocal), | 327 assert(!opt_showSystemDialog || (cr.isWindows && destination.isLocal), |
| 328 'Implemented for Windows only'); | 328 'Implemented for Windows only'); |
| 329 | 329 |
| 330 // TODO(tbarzic): Implement this. | |
| 331 assert(!destination.isExtension, | |
| 332 'Printing to extension printers not yet implemented.'); | |
| 333 | |
| 334 var ticket = { | 330 var ticket = { |
| 335 'pageRange': printTicketStore.pageRange.getDocumentPageRanges(), | 331 'pageRange': printTicketStore.pageRange.getDocumentPageRanges(), |
| 336 'mediaSize': printTicketStore.mediaSize.getValue(), | 332 'mediaSize': printTicketStore.mediaSize.getValue(), |
| 337 'pageCount': printTicketStore.pageRange.getPageNumberSet().size, | 333 'pageCount': printTicketStore.pageRange.getPageNumberSet().size, |
| 338 'landscape': printTicketStore.landscape.getValue(), | 334 'landscape': printTicketStore.landscape.getValue(), |
| 339 'color': this.getNativeColorModel_(destination, printTicketStore.color), | 335 'color': this.getNativeColorModel_(destination, printTicketStore.color), |
| 340 'headerFooterEnabled': printTicketStore.headerFooter.getValue(), | 336 'headerFooterEnabled': printTicketStore.headerFooter.getValue(), |
| 341 'marginsType': printTicketStore.marginsType.getValue(), | 337 'marginsType': printTicketStore.marginsType.getValue(), |
| 342 'generateDraftData': true, // TODO(rltoscano): What should this be? | 338 'generateDraftData': true, // TODO(rltoscano): What should this be? |
| 343 'duplex': printTicketStore.duplex.getValue() ? | 339 'duplex': printTicketStore.duplex.getValue() ? |
| 344 NativeLayer.DuplexMode.LONG_EDGE : NativeLayer.DuplexMode.SIMPLEX, | 340 NativeLayer.DuplexMode.LONG_EDGE : NativeLayer.DuplexMode.SIMPLEX, |
| 345 'copies': printTicketStore.copies.getValueAsNumber(), | 341 'copies': printTicketStore.copies.getValueAsNumber(), |
| 346 'collate': printTicketStore.collate.getValue(), | 342 'collate': printTicketStore.collate.getValue(), |
| 347 'shouldPrintBackgrounds': printTicketStore.cssBackground.getValue(), | 343 'shouldPrintBackgrounds': printTicketStore.cssBackground.getValue(), |
| 348 'shouldPrintSelectionOnly': printTicketStore.selectionOnly.getValue(), | 344 'shouldPrintSelectionOnly': printTicketStore.selectionOnly.getValue(), |
| 349 'previewModifiable': documentInfo.isModifiable, | 345 'previewModifiable': documentInfo.isModifiable, |
| 350 'printToPDF': destination.id == | 346 'printToPDF': destination.id == |
| 351 print_preview.Destination.GooglePromotedId.SAVE_AS_PDF, | 347 print_preview.Destination.GooglePromotedId.SAVE_AS_PDF, |
| 352 'printWithCloudPrint': !destination.isLocal, | 348 'printWithCloudPrint': !destination.isLocal, |
| 353 'printWithPrivet': destination.isPrivet, | 349 'printWithPrivet': destination.isPrivet, |
| 350 'printWithExtension': destination.isExtension, | |
|
Aleksey Shlyapnikov
2015/02/12 02:23:17
It feels like printWith... are mutually exclusive
tbarzic
2015/02/12 02:42:22
Yep, I agree.
| |
| 354 'deviceName': destination.id, | 351 'deviceName': destination.id, |
| 355 'isFirstRequest': false, | 352 'isFirstRequest': false, |
| 356 'requestID': -1, | 353 'requestID': -1, |
| 357 'fitToPageEnabled': printTicketStore.fitToPage.getValue(), | 354 'fitToPageEnabled': printTicketStore.fitToPage.getValue(), |
| 358 'pageWidth': documentInfo.pageSize.width, | 355 'pageWidth': documentInfo.pageSize.width, |
| 359 'pageHeight': documentInfo.pageSize.height, | 356 'pageHeight': documentInfo.pageSize.height, |
| 360 'showSystemDialog': opt_showSystemDialog | 357 'showSystemDialog': opt_showSystemDialog |
| 361 }; | 358 }; |
| 362 | 359 |
| 363 if (!destination.isLocal) { | 360 if (!destination.isLocal) { |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 374 var orientationEnum = | 371 var orientationEnum = |
| 375 print_preview.ticket_items.CustomMargins.Orientation; | 372 print_preview.ticket_items.CustomMargins.Orientation; |
| 376 ticket['marginsCustom'] = { | 373 ticket['marginsCustom'] = { |
| 377 'marginTop': customMargins.get(orientationEnum.TOP), | 374 'marginTop': customMargins.get(orientationEnum.TOP), |
| 378 'marginRight': customMargins.get(orientationEnum.RIGHT), | 375 'marginRight': customMargins.get(orientationEnum.RIGHT), |
| 379 'marginBottom': customMargins.get(orientationEnum.BOTTOM), | 376 'marginBottom': customMargins.get(orientationEnum.BOTTOM), |
| 380 'marginLeft': customMargins.get(orientationEnum.LEFT) | 377 'marginLeft': customMargins.get(orientationEnum.LEFT) |
| 381 }; | 378 }; |
| 382 } | 379 } |
| 383 | 380 |
| 384 if (destination.isPrivet) { | 381 if (destination.isPrivet || destination.isExtension) { |
| 385 ticket['ticket'] = printTicketStore.createPrintTicket(destination); | 382 ticket['ticket'] = printTicketStore.createPrintTicket(destination); |
| 386 ticket['capabilities'] = JSON.stringify(destination.capabilities); | 383 ticket['capabilities'] = JSON.stringify(destination.capabilities); |
| 387 } | 384 } |
| 388 | 385 |
| 389 if (opt_isOpenPdfInPreview) { | 386 if (opt_isOpenPdfInPreview) { |
| 390 ticket['OpenPDFInPreview'] = true; | 387 ticket['OpenPDFInPreview'] = true; |
| 391 } | 388 } |
| 392 | 389 |
| 393 chrome.send('print', [JSON.stringify(ticket)]); | 390 chrome.send('print', [JSON.stringify(ticket)]); |
| 394 }, | 391 }, |
| (...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1033 return this.serializedAppStateStr_; | 1030 return this.serializedAppStateStr_; |
| 1034 } | 1031 } |
| 1035 }; | 1032 }; |
| 1036 | 1033 |
| 1037 // Export | 1034 // Export |
| 1038 return { | 1035 return { |
| 1039 NativeInitialSettings: NativeInitialSettings, | 1036 NativeInitialSettings: NativeInitialSettings, |
| 1040 NativeLayer: NativeLayer | 1037 NativeLayer: NativeLayer |
| 1041 }; | 1038 }; |
| 1042 }); | 1039 }); |
| OLD | NEW |