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 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 // Set 'cloudPrintID' only if the destination is not local. | 322 // Set 'cloudPrintID' only if the destination is not local. |
323 if (destination && !destination.isLocal) { | 323 if (destination && !destination.isLocal) { |
324 ticket['cloudPrintID'] = destination.id; | 324 ticket['cloudPrintID'] = destination.id; |
325 } | 325 } |
326 | 326 |
327 if (printTicketStore.marginsType.isCapabilityAvailable() && | 327 if (printTicketStore.marginsType.isCapabilityAvailable() && |
328 printTicketStore.marginsType.getValue() == | 328 printTicketStore.marginsType.getValue() == |
329 print_preview.ticket_items.MarginsTypeValue.CUSTOM) { | 329 print_preview.ticket_items.MarginsTypeValue.CUSTOM) { |
330 var customMargins = printTicketStore.customMargins.getValue(); | 330 var customMargins = printTicketStore.customMargins.getValue(); |
331 var orientationEnum = | 331 var orientationEnum = |
332 print_preview.ticket_items.CustomMargins.Orientation; | 332 print_preview.ticket_items.CustomMarginsOrientation; |
333 ticket['marginsCustom'] = { | 333 ticket['marginsCustom'] = { |
334 'marginTop': customMargins.get(orientationEnum.TOP), | 334 'marginTop': customMargins.get(orientationEnum.TOP), |
335 'marginRight': customMargins.get(orientationEnum.RIGHT), | 335 'marginRight': customMargins.get(orientationEnum.RIGHT), |
336 'marginBottom': customMargins.get(orientationEnum.BOTTOM), | 336 'marginBottom': customMargins.get(orientationEnum.BOTTOM), |
337 'marginLeft': customMargins.get(orientationEnum.LEFT) | 337 'marginLeft': customMargins.get(orientationEnum.LEFT) |
338 }; | 338 }; |
339 } | 339 } |
340 | 340 |
341 chrome.send( | 341 chrome.send( |
342 'getPreview', | 342 'getPreview', |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 // Print" because the native system will try to print to Google Cloud | 404 // Print" because the native system will try to print to Google Cloud |
405 // Print with this ID instead of opening a Google Cloud Print dialog. | 405 // Print with this ID instead of opening a Google Cloud Print dialog. |
406 ticket['cloudPrintID'] = destination.id; | 406 ticket['cloudPrintID'] = destination.id; |
407 } | 407 } |
408 | 408 |
409 if (printTicketStore.marginsType.isCapabilityAvailable() && | 409 if (printTicketStore.marginsType.isCapabilityAvailable() && |
410 printTicketStore.marginsType.isValueEqual( | 410 printTicketStore.marginsType.isValueEqual( |
411 print_preview.ticket_items.MarginsTypeValue.CUSTOM)) { | 411 print_preview.ticket_items.MarginsTypeValue.CUSTOM)) { |
412 var customMargins = printTicketStore.customMargins.getValue(); | 412 var customMargins = printTicketStore.customMargins.getValue(); |
413 var orientationEnum = | 413 var orientationEnum = |
414 print_preview.ticket_items.CustomMargins.Orientation; | 414 print_preview.ticket_items.CustomMarginsOrientation; |
415 ticket['marginsCustom'] = { | 415 ticket['marginsCustom'] = { |
416 'marginTop': customMargins.get(orientationEnum.TOP), | 416 'marginTop': customMargins.get(orientationEnum.TOP), |
417 'marginRight': customMargins.get(orientationEnum.RIGHT), | 417 'marginRight': customMargins.get(orientationEnum.RIGHT), |
418 'marginBottom': customMargins.get(orientationEnum.BOTTOM), | 418 'marginBottom': customMargins.get(orientationEnum.BOTTOM), |
419 'marginLeft': customMargins.get(orientationEnum.LEFT) | 419 'marginLeft': customMargins.get(orientationEnum.LEFT) |
420 }; | 420 }; |
421 } | 421 } |
422 | 422 |
423 if (destination.isPrivet || destination.isExtension) { | 423 if (destination.isPrivet || destination.isExtension) { |
424 ticket['ticket'] = printTicketStore.createPrintTicket(destination); | 424 ticket['ticket'] = printTicketStore.createPrintTicket(destination); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
484 chrome.send('forceOpenNewTab', [url]); | 484 chrome.send('forceOpenNewTab', [url]); |
485 }, | 485 }, |
486 | 486 |
487 /** | 487 /** |
488 * @param {!Object} initialSettings Object containing all initial settings. | 488 * @param {!Object} initialSettings Object containing all initial settings. |
489 */ | 489 */ |
490 onSetInitialSettings_: function(initialSettings) { | 490 onSetInitialSettings_: function(initialSettings) { |
491 var numberFormatSymbols = | 491 var numberFormatSymbols = |
492 print_preview.MeasurementSystem.parseNumberFormat( | 492 print_preview.MeasurementSystem.parseNumberFormat( |
493 initialSettings['numberFormat']); | 493 initialSettings['numberFormat']); |
494 var unitType = print_preview.MeasurementSystem.UnitType.IMPERIAL; | 494 var unitType = print_preview.MeasurementSystemUnitType.IMPERIAL; |
495 if (initialSettings['measurementSystem'] != null) { | 495 if (initialSettings['measurementSystem'] != null) { |
496 unitType = initialSettings['measurementSystem']; | 496 unitType = initialSettings['measurementSystem']; |
497 } | 497 } |
498 | 498 |
499 var nativeInitialSettings = new print_preview.NativeInitialSettings( | 499 var nativeInitialSettings = new print_preview.NativeInitialSettings( |
500 initialSettings['printAutomaticallyInKioskMode'] || false, | 500 initialSettings['printAutomaticallyInKioskMode'] || false, |
501 initialSettings['appKioskMode'] || false, | 501 initialSettings['appKioskMode'] || false, |
502 numberFormatSymbols[0] || ',', | 502 numberFormatSymbols[0] || ',', |
503 numberFormatSymbols[1] || '.', | 503 numberFormatSymbols[1] || '.', |
504 unitType, | 504 unitType, |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
561 * Called when native layer gets settings information for a requested local | 561 * Called when native layer gets settings information for a requested local |
562 * destination. | 562 * destination. |
563 * @param {string} destinationId Printer affected by error. | 563 * @param {string} destinationId Printer affected by error. |
564 * @private | 564 * @private |
565 */ | 565 */ |
566 onFailedToGetPrinterCapabilities_: function(destinationId) { | 566 onFailedToGetPrinterCapabilities_: function(destinationId) { |
567 var getCapsFailEvent = new Event( | 567 var getCapsFailEvent = new Event( |
568 NativeLayer.EventType.GET_CAPABILITIES_FAIL); | 568 NativeLayer.EventType.GET_CAPABILITIES_FAIL); |
569 getCapsFailEvent.destinationId = destinationId; | 569 getCapsFailEvent.destinationId = destinationId; |
570 getCapsFailEvent.destinationOrigin = | 570 getCapsFailEvent.destinationOrigin = |
571 print_preview.Destination.Origin.LOCAL; | 571 print_preview.DestinationOrigin.LOCAL; |
572 this.dispatchEvent(getCapsFailEvent); | 572 this.dispatchEvent(getCapsFailEvent); |
573 }, | 573 }, |
574 | 574 |
575 /** | 575 /** |
576 * Called when native layer gets settings information for a requested privet | 576 * Called when native layer gets settings information for a requested privet |
577 * destination. | 577 * destination. |
578 * @param {string} destinationId Printer affected by error. | 578 * @param {string} destinationId Printer affected by error. |
579 * @private | 579 * @private |
580 */ | 580 */ |
581 onFailedToGetPrivetPrinterCapabilities_: function(destinationId) { | 581 onFailedToGetPrivetPrinterCapabilities_: function(destinationId) { |
582 var getCapsFailEvent = new Event( | 582 var getCapsFailEvent = new Event( |
583 NativeLayer.EventType.GET_CAPABILITIES_FAIL); | 583 NativeLayer.EventType.GET_CAPABILITIES_FAIL); |
584 getCapsFailEvent.destinationId = destinationId; | 584 getCapsFailEvent.destinationId = destinationId; |
585 getCapsFailEvent.destinationOrigin = | 585 getCapsFailEvent.destinationOrigin = |
586 print_preview.Destination.Origin.PRIVET; | 586 print_preview.DestinationOrigin.PRIVET; |
587 this.dispatchEvent(getCapsFailEvent); | 587 this.dispatchEvent(getCapsFailEvent); |
588 }, | 588 }, |
589 | 589 |
590 /** | 590 /** |
591 * Called when native layer fails to get settings information for a | 591 * Called when native layer fails to get settings information for a |
592 * requested extension destination. | 592 * requested extension destination. |
593 * @param {string} destinationId Printer affected by error. | 593 * @param {string} destinationId Printer affected by error. |
594 * @private | 594 * @private |
595 */ | 595 */ |
596 onFailedToGetExtensionPrinterCapabilities_: function(destinationId) { | 596 onFailedToGetExtensionPrinterCapabilities_: function(destinationId) { |
597 var getCapsFailEvent = new Event( | 597 var getCapsFailEvent = new Event( |
598 NativeLayer.EventType.GET_CAPABILITIES_FAIL); | 598 NativeLayer.EventType.GET_CAPABILITIES_FAIL); |
599 getCapsFailEvent.destinationId = destinationId; | 599 getCapsFailEvent.destinationId = destinationId; |
600 getCapsFailEvent.destinationOrigin = | 600 getCapsFailEvent.destinationOrigin = |
601 print_preview.Destination.Origin.EXTENSION; | 601 print_preview.DestinationOrigin.EXTENSION; |
602 this.dispatchEvent(getCapsFailEvent); | 602 this.dispatchEvent(getCapsFailEvent); |
603 }, | 603 }, |
604 | 604 |
605 /** Reloads the printer list. */ | 605 /** Reloads the printer list. */ |
606 onReloadPrintersList_: function() { | 606 onReloadPrintersList_: function() { |
607 cr.dispatchSimpleEvent(this, NativeLayer.EventType.DESTINATIONS_RELOAD); | 607 cr.dispatchSimpleEvent(this, NativeLayer.EventType.DESTINATIONS_RELOAD); |
608 }, | 608 }, |
609 | 609 |
610 /** | 610 /** |
611 * Called from the C++ layer. | 611 * Called from the C++ layer. |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
914 }; | 914 }; |
915 | 915 |
916 /** | 916 /** |
917 * Initial settings retrieved from the native layer. | 917 * Initial settings retrieved from the native layer. |
918 * @param {boolean} isInKioskAutoPrintMode Whether the print preview should be | 918 * @param {boolean} isInKioskAutoPrintMode Whether the print preview should be |
919 * in auto-print mode. | 919 * in auto-print mode. |
920 * @param {boolean} isInAppKioskMode Whether the print preview is in App Kiosk | 920 * @param {boolean} isInAppKioskMode Whether the print preview is in App Kiosk |
921 * mode. | 921 * mode. |
922 * @param {string} thousandsDelimeter Character delimeter of thousands digits. | 922 * @param {string} thousandsDelimeter Character delimeter of thousands digits. |
923 * @param {string} decimalDelimeter Character delimeter of the decimal point. | 923 * @param {string} decimalDelimeter Character delimeter of the decimal point. |
924 * @param {!print_preview.MeasurementSystem.UnitType} unitType Unit type of | 924 * @param {!print_preview.MeasurementSystemUnitType} unitType Unit type of |
925 * local machine's measurement system. | 925 * local machine's measurement system. |
926 * @param {boolean} isDocumentModifiable Whether the document to print is | 926 * @param {boolean} isDocumentModifiable Whether the document to print is |
927 * modifiable. | 927 * modifiable. |
928 * @param {string} documentTitle Title of the document. | 928 * @param {string} documentTitle Title of the document. |
929 * @param {boolean} documentHasSelection Whether the document has selected | 929 * @param {boolean} documentHasSelection Whether the document has selected |
930 * content. | 930 * content. |
931 * @param {boolean} selectionOnly Whether only selected content should be | 931 * @param {boolean} selectionOnly Whether only selected content should be |
932 * printed. | 932 * printed. |
933 * @param {?string} systemDefaultDestinationId ID of the system default | 933 * @param {?string} systemDefaultDestinationId ID of the system default |
934 * destination. | 934 * destination. |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
974 | 974 |
975 /** | 975 /** |
976 * Character delimeter of the decimal point. | 976 * Character delimeter of the decimal point. |
977 * @type {string} | 977 * @type {string} |
978 * @private | 978 * @private |
979 */ | 979 */ |
980 this.decimalDelimeter_ = decimalDelimeter; | 980 this.decimalDelimeter_ = decimalDelimeter; |
981 | 981 |
982 /** | 982 /** |
983 * Unit type of local machine's measurement system. | 983 * Unit type of local machine's measurement system. |
984 * @type {string} | 984 * @type {print_preview.MeasurementSystemUnitType} |
985 * @private | 985 * @private |
986 */ | 986 */ |
987 this.unitType_ = unitType; | 987 this.unitType_ = unitType; |
988 | 988 |
989 /** | 989 /** |
990 * Whether the document to print is modifiable. | 990 * Whether the document to print is modifiable. |
991 * @type {boolean} | 991 * @type {boolean} |
992 * @private | 992 * @private |
993 */ | 993 */ |
994 this.isDocumentModifiable_ = isDocumentModifiable; | 994 this.isDocumentModifiable_ = isDocumentModifiable; |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1057 get thousandsDelimeter() { | 1057 get thousandsDelimeter() { |
1058 return this.thousandsDelimeter_; | 1058 return this.thousandsDelimeter_; |
1059 }, | 1059 }, |
1060 | 1060 |
1061 /** @return {string} Character delimeter of the decimal point. */ | 1061 /** @return {string} Character delimeter of the decimal point. */ |
1062 get decimalDelimeter() { | 1062 get decimalDelimeter() { |
1063 return this.decimalDelimeter_; | 1063 return this.decimalDelimeter_; |
1064 }, | 1064 }, |
1065 | 1065 |
1066 /** | 1066 /** |
1067 * @return {!print_preview.MeasurementSystem.UnitType} Unit type of local | 1067 * @return {!print_preview.MeasurementSystemUnitType} Unit type of local |
1068 * machine's measurement system. | 1068 * machine's measurement system. |
1069 */ | 1069 */ |
1070 get unitType() { | 1070 get unitType() { |
1071 return this.unitType_; | 1071 return this.unitType_; |
1072 }, | 1072 }, |
1073 | 1073 |
1074 /** @return {boolean} Whether the document to print is modifiable. */ | 1074 /** @return {boolean} Whether the document to print is modifiable. */ |
1075 get isDocumentModifiable() { | 1075 get isDocumentModifiable() { |
1076 return this.isDocumentModifiable_; | 1076 return this.isDocumentModifiable_; |
1077 }, | 1077 }, |
(...skipping 28 matching lines...) Expand all 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 |