| 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 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 var numberFormatSymbols = | 396 var numberFormatSymbols = |
| 397 print_preview.MeasurementSystem.parseNumberFormat( | 397 print_preview.MeasurementSystem.parseNumberFormat( |
| 398 initialSettings['numberFormat']); | 398 initialSettings['numberFormat']); |
| 399 var unitType = print_preview.MeasurementSystem.UnitType.IMPERIAL; | 399 var unitType = print_preview.MeasurementSystem.UnitType.IMPERIAL; |
| 400 if (initialSettings['measurementSystem'] != null) { | 400 if (initialSettings['measurementSystem'] != null) { |
| 401 unitType = initialSettings['measurementSystem']; | 401 unitType = initialSettings['measurementSystem']; |
| 402 } | 402 } |
| 403 | 403 |
| 404 var nativeInitialSettings = new print_preview.NativeInitialSettings( | 404 var nativeInitialSettings = new print_preview.NativeInitialSettings( |
| 405 initialSettings['printAutomaticallyInKioskMode'] || false, | 405 initialSettings['printAutomaticallyInKioskMode'] || false, |
| 406 initialSettings['appKioskMode'] || false, |
| 406 initialSettings['hidePrintWithSystemDialogLink'] || false, | 407 initialSettings['hidePrintWithSystemDialogLink'] || false, |
| 407 numberFormatSymbols[0] || ',', | 408 numberFormatSymbols[0] || ',', |
| 408 numberFormatSymbols[1] || '.', | 409 numberFormatSymbols[1] || '.', |
| 409 unitType, | 410 unitType, |
| 410 initialSettings['previewModifiable'] || false, | 411 initialSettings['previewModifiable'] || false, |
| 411 initialSettings['initiatorTitle'] || '', | 412 initialSettings['initiatorTitle'] || '', |
| 412 initialSettings['documentHasSelection'] || false, | 413 initialSettings['documentHasSelection'] || false, |
| 413 initialSettings['shouldPrintSelectionOnly'] || false, | 414 initialSettings['shouldPrintSelectionOnly'] || false, |
| 414 initialSettings['printerName'] || null, | 415 initialSettings['printerName'] || null, |
| 415 initialSettings['appState'] || null); | 416 initialSettings['appState'] || null); |
| 416 | 417 |
| 417 var initialSettingsSetEvent = new Event( | 418 var initialSettingsSetEvent = new Event( |
| 418 NativeLayer.EventType.INITIAL_SETTINGS_SET); | 419 NativeLayer.EventType.INITIAL_SETTINGS_SET); |
| 419 initialSettingsSetEvent.initialSettings = nativeInitialSettings; | 420 initialSettingsSetEvent.initialSettings = nativeInitialSettings; |
| 420 this.dispatchEvent(initialSettingsSetEvent); | 421 this.dispatchEvent(initialSettingsSetEvent); |
| 421 }, | 422 }, |
| 422 | 423 |
| 423 /** | 424 /** |
| 424 * Turn on the integration of Cloud Print. | 425 * Turn on the integration of Cloud Print. |
| 425 * @param {string} cloudPrintURL The URL to use for cloud print servers. | 426 * @param {string} cloudPrintURL The URL to use for cloud print servers. |
| 426 * @private | 427 * @private |
| 427 */ | 428 */ |
| 428 onSetUseCloudPrint_: function(cloudPrintURL) { | 429 onSetUseCloudPrint_: function(settings) { |
| 429 var cloudPrintEnableEvent = new Event( | 430 var cloudPrintEnableEvent = new Event( |
| 430 NativeLayer.EventType.CLOUD_PRINT_ENABLE); | 431 NativeLayer.EventType.CLOUD_PRINT_ENABLE); |
| 431 cloudPrintEnableEvent.baseCloudPrintUrl = cloudPrintURL; | 432 cloudPrintEnableEvent.baseCloudPrintUrl = settings['cloudPrintUrl'] || ''; |
| 433 cloudPrintEnableEvent.appKioskMode = settings['appKioskMode'] || false; |
| 432 this.dispatchEvent(cloudPrintEnableEvent); | 434 this.dispatchEvent(cloudPrintEnableEvent); |
| 433 }, | 435 }, |
| 434 | 436 |
| 435 /** | 437 /** |
| 436 * Updates the print preview with local printers. | 438 * Updates the print preview with local printers. |
| 437 * Called from PrintPreviewHandler::SetupPrinterList(). | 439 * Called from PrintPreviewHandler::SetupPrinterList(). |
| 438 * @param {Array} printers Array of printer info objects. | 440 * @param {Array} printers Array of printer info objects. |
| 439 * @private | 441 * @private |
| 440 */ | 442 */ |
| 441 onSetPrinters_: function(printers) { | 443 onSetPrinters_: function(printers) { |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 688 new Event(NativeLayer.EventType.PRIVET_PRINT_FAILED); | 690 new Event(NativeLayer.EventType.PRIVET_PRINT_FAILED); |
| 689 privetPrintFailedEvent.httpError = http_error; | 691 privetPrintFailedEvent.httpError = http_error; |
| 690 this.dispatchEvent(privetPrintFailedEvent); | 692 this.dispatchEvent(privetPrintFailedEvent); |
| 691 } | 693 } |
| 692 }; | 694 }; |
| 693 | 695 |
| 694 /** | 696 /** |
| 695 * Initial settings retrieved from the native layer. | 697 * Initial settings retrieved from the native layer. |
| 696 * @param {boolean} isInKioskAutoPrintMode Whether the print preview should be | 698 * @param {boolean} isInKioskAutoPrintMode Whether the print preview should be |
| 697 * in auto-print mode. | 699 * in auto-print mode. |
| 700 * @param {boolean} isInAppKioskMode Whether the print preview is in App Kiosk |
| 701 * mode. |
| 698 * @param {string} thousandsDelimeter Character delimeter of thousands digits. | 702 * @param {string} thousandsDelimeter Character delimeter of thousands digits. |
| 699 * @param {string} decimalDelimeter Character delimeter of the decimal point. | 703 * @param {string} decimalDelimeter Character delimeter of the decimal point. |
| 700 * @param {!print_preview.MeasurementSystem.UnitType} unitType Unit type of | 704 * @param {!print_preview.MeasurementSystem.UnitType} unitType Unit type of |
| 701 * local machine's measurement system. | 705 * local machine's measurement system. |
| 702 * @param {boolean} isDocumentModifiable Whether the document to print is | 706 * @param {boolean} isDocumentModifiable Whether the document to print is |
| 703 * modifiable. | 707 * modifiable. |
| 704 * @param {string} documentTitle Title of the document. | 708 * @param {string} documentTitle Title of the document. |
| 705 * @param {boolean} documentHasSelection Whether the document has selected | 709 * @param {boolean} documentHasSelection Whether the document has selected |
| 706 * content. | 710 * content. |
| 707 * @param {boolean} selectionOnly Whether only selected content should be | 711 * @param {boolean} selectionOnly Whether only selected content should be |
| 708 * printed. | 712 * printed. |
| 709 * @param {?string} systemDefaultDestinationId ID of the system default | 713 * @param {?string} systemDefaultDestinationId ID of the system default |
| 710 * destination. | 714 * destination. |
| 711 * @param {?string} serializedAppStateStr Serialized app state. | 715 * @param {?string} serializedAppStateStr Serialized app state. |
| 712 * @constructor | 716 * @constructor |
| 713 */ | 717 */ |
| 714 function NativeInitialSettings( | 718 function NativeInitialSettings( |
| 715 isInKioskAutoPrintMode, | 719 isInKioskAutoPrintMode, |
| 720 isInAppKioskMode, |
| 716 hidePrintWithSystemDialogLink, | 721 hidePrintWithSystemDialogLink, |
| 717 thousandsDelimeter, | 722 thousandsDelimeter, |
| 718 decimalDelimeter, | 723 decimalDelimeter, |
| 719 unitType, | 724 unitType, |
| 720 isDocumentModifiable, | 725 isDocumentModifiable, |
| 721 documentTitle, | 726 documentTitle, |
| 722 documentHasSelection, | 727 documentHasSelection, |
| 723 selectionOnly, | 728 selectionOnly, |
| 724 systemDefaultDestinationId, | 729 systemDefaultDestinationId, |
| 725 serializedAppStateStr) { | 730 serializedAppStateStr) { |
| 726 | 731 |
| 727 /** | 732 /** |
| 728 * Whether the print preview should be in auto-print mode. | 733 * Whether the print preview should be in auto-print mode. |
| 729 * @type {boolean} | 734 * @type {boolean} |
| 730 * @private | 735 * @private |
| 731 */ | 736 */ |
| 732 this.isInKioskAutoPrintMode_ = isInKioskAutoPrintMode; | 737 this.isInKioskAutoPrintMode_ = isInKioskAutoPrintMode; |
| 733 | 738 |
| 734 /** | 739 /** |
| 740 * Whether the print preview should switch to App Kiosk mode. |
| 741 * @type {boolean} |
| 742 * @private |
| 743 */ |
| 744 this.isInAppKioskMode_ = isInAppKioskMode; |
| 745 |
| 746 /** |
| 735 * Whether we should hide the link which shows the system print dialog. | 747 * Whether we should hide the link which shows the system print dialog. |
| 736 * @type {boolean} | 748 * @type {boolean} |
| 737 * @private | 749 * @private |
| 738 */ | 750 */ |
| 739 this.hidePrintWithSystemDialogLink_ = hidePrintWithSystemDialogLink; | 751 this.hidePrintWithSystemDialogLink_ = hidePrintWithSystemDialogLink; |
| 740 | 752 |
| 741 /** | 753 /** |
| 742 * Character delimeter of thousands digits. | 754 * Character delimeter of thousands digits. |
| 743 * @type {string} | 755 * @type {string} |
| 744 * @private | 756 * @private |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 804 | 816 |
| 805 NativeInitialSettings.prototype = { | 817 NativeInitialSettings.prototype = { |
| 806 /** | 818 /** |
| 807 * @return {boolean} Whether the print preview should be in auto-print mode. | 819 * @return {boolean} Whether the print preview should be in auto-print mode. |
| 808 */ | 820 */ |
| 809 get isInKioskAutoPrintMode() { | 821 get isInKioskAutoPrintMode() { |
| 810 return this.isInKioskAutoPrintMode_; | 822 return this.isInKioskAutoPrintMode_; |
| 811 }, | 823 }, |
| 812 | 824 |
| 813 /** | 825 /** |
| 826 * @return {boolean} Whether the print preview should switch to App Kiosk |
| 827 * mode. |
| 828 */ |
| 829 get isInAppKioskMode() { |
| 830 return this.isInAppKioskMode_; |
| 831 }, |
| 832 |
| 833 /** |
| 814 * @return {boolean} Whether we should hide the link which shows the | 834 * @return {boolean} Whether we should hide the link which shows the |
| 815 system print dialog. | 835 system print dialog. |
| 816 */ | 836 */ |
| 817 get hidePrintWithSystemDialogLink() { | 837 get hidePrintWithSystemDialogLink() { |
| 818 return this.hidePrintWithSystemDialogLink_; | 838 return this.hidePrintWithSystemDialogLink_; |
| 819 }, | 839 }, |
| 820 | 840 |
| 821 /** @return {string} Character delimeter of thousands digits. */ | 841 /** @return {string} Character delimeter of thousands digits. */ |
| 822 get thousandsDelimeter() { | 842 get thousandsDelimeter() { |
| 823 return this.thousandsDelimeter_; | 843 return this.thousandsDelimeter_; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 866 return this.serializedAppStateStr_; | 886 return this.serializedAppStateStr_; |
| 867 } | 887 } |
| 868 }; | 888 }; |
| 869 | 889 |
| 870 // Export | 890 // Export |
| 871 return { | 891 return { |
| 872 NativeInitialSettings: NativeInitialSettings, | 892 NativeInitialSettings: NativeInitialSettings, |
| 873 NativeLayer: NativeLayer | 893 NativeLayer: NativeLayer |
| 874 }; | 894 }; |
| 875 }); | 895 }); |
| OLD | NEW |