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.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 28 matching lines...) Expand all Loading... | |
| 39 global['onDidPreviewPage'] = this.onDidPreviewPage_.bind(this); | 39 global['onDidPreviewPage'] = this.onDidPreviewPage_.bind(this); |
| 40 global['updatePrintPreview'] = this.onUpdatePrintPreview_.bind(this); | 40 global['updatePrintPreview'] = this.onUpdatePrintPreview_.bind(this); |
| 41 global['printScalingDisabledForSourcePDF'] = | 41 global['printScalingDisabledForSourcePDF'] = |
| 42 this.onPrintScalingDisabledForSourcePDF_.bind(this); | 42 this.onPrintScalingDisabledForSourcePDF_.bind(this); |
| 43 global['onDidGetAccessToken'] = this.onDidGetAccessToken_.bind(this); | 43 global['onDidGetAccessToken'] = this.onDidGetAccessToken_.bind(this); |
| 44 global['autoCancelForTesting'] = this.autoCancelForTesting_.bind(this); | 44 global['autoCancelForTesting'] = this.autoCancelForTesting_.bind(this); |
| 45 global['onPrivetPrinterChanged'] = this.onPrivetPrinterChanged_.bind(this); | 45 global['onPrivetPrinterChanged'] = this.onPrivetPrinterChanged_.bind(this); |
| 46 global['onPrivetCapabilitiesSet'] = | 46 global['onPrivetCapabilitiesSet'] = |
| 47 this.onPrivetCapabilitiesSet_.bind(this); | 47 this.onPrivetCapabilitiesSet_.bind(this); |
| 48 global['onPrivetPrintFailed'] = this.onPrivetPrintFailed_.bind(this); | 48 global['onPrivetPrintFailed'] = this.onPrivetPrintFailed_.bind(this); |
| 49 global['onEnableManipulateSettingsForTest'] = | |
| 50 this.onEnableManipulateSettingsForTest_.bind(this); | |
| 49 }; | 51 }; |
| 50 | 52 |
| 51 /** | 53 /** |
| 52 * Event types dispatched from the Chromium native layer. | 54 * Event types dispatched from the Chromium native layer. |
| 53 * @enum {string} | 55 * @enum {string} |
| 54 * @const | 56 * @const |
| 55 */ | 57 */ |
| 56 NativeLayer.EventType = { | 58 NativeLayer.EventType = { |
| 57 ACCESS_TOKEN_READY: 'print_preview.NativeLayer.ACCESS_TOKEN_READY', | 59 ACCESS_TOKEN_READY: 'print_preview.NativeLayer.ACCESS_TOKEN_READY', |
| 58 CAPABILITIES_SET: 'print_preview.NativeLayer.CAPABILITIES_SET', | 60 CAPABILITIES_SET: 'print_preview.NativeLayer.CAPABILITIES_SET', |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 70 PAGE_PREVIEW_READY: 'print_preview.NativeLayer.PAGE_PREVIEW_READY', | 72 PAGE_PREVIEW_READY: 'print_preview.NativeLayer.PAGE_PREVIEW_READY', |
| 71 PREVIEW_GENERATION_DONE: | 73 PREVIEW_GENERATION_DONE: |
| 72 'print_preview.NativeLayer.PREVIEW_GENERATION_DONE', | 74 'print_preview.NativeLayer.PREVIEW_GENERATION_DONE', |
| 73 PREVIEW_GENERATION_FAIL: | 75 PREVIEW_GENERATION_FAIL: |
| 74 'print_preview.NativeLayer.PREVIEW_GENERATION_FAIL', | 76 'print_preview.NativeLayer.PREVIEW_GENERATION_FAIL', |
| 75 PRINT_TO_CLOUD: 'print_preview.NativeLayer.PRINT_TO_CLOUD', | 77 PRINT_TO_CLOUD: 'print_preview.NativeLayer.PRINT_TO_CLOUD', |
| 76 SETTINGS_INVALID: 'print_preview.NativeLayer.SETTINGS_INVALID', | 78 SETTINGS_INVALID: 'print_preview.NativeLayer.SETTINGS_INVALID', |
| 77 PRIVET_PRINTER_CHANGED: 'print_preview.NativeLayer.PRIVET_PRINTER_CHANGED', | 79 PRIVET_PRINTER_CHANGED: 'print_preview.NativeLayer.PRIVET_PRINTER_CHANGED', |
| 78 PRIVET_CAPABILITIES_SET: | 80 PRIVET_CAPABILITIES_SET: |
| 79 'print_preview.NativeLayer.PRIVET_CAPABILITIES_SET', | 81 'print_preview.NativeLayer.PRIVET_CAPABILITIES_SET', |
| 80 PRIVET_PRINT_FAILED: 'print_preview.NativeLayer.PRIVET_PRINT_FAILED' | 82 PRIVET_PRINT_FAILED: 'print_preview.NativeLayer.PRIVET_PRINT_FAILED', |
| 83 MANIPULATE_SETTINGS_FOR_TEST: | |
| 84 'print_preview.NativeLayer.MANIPULATE_SETTINGS_FOR_TEST' | |
| 81 }; | 85 }; |
| 82 | 86 |
| 83 /** | 87 /** |
| 84 * Constant values matching printing::DuplexMode enum. | 88 * Constant values matching printing::DuplexMode enum. |
| 85 * @enum {number} | 89 * @enum {number} |
| 86 */ | 90 */ |
| 87 NativeLayer.DuplexMode = { | 91 NativeLayer.DuplexMode = { |
| 88 SIMPLEX: 0, | 92 SIMPLEX: 0, |
| 89 LONG_EDGE: 1, | 93 LONG_EDGE: 1, |
| 90 UNKNOWN_DUPLEX_MODE: -1 | 94 UNKNOWN_DUPLEX_MODE: -1 |
| (...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 665 /** | 669 /** |
| 666 * @param {string} http_error The HTTP response code or -1 if not an HTTP | 670 * @param {string} http_error The HTTP response code or -1 if not an HTTP |
| 667 * error. | 671 * error. |
| 668 * @private | 672 * @private |
| 669 */ | 673 */ |
| 670 onPrivetPrintFailed_: function(http_error) { | 674 onPrivetPrintFailed_: function(http_error) { |
| 671 var privetPrintFailedEvent = | 675 var privetPrintFailedEvent = |
| 672 new Event(NativeLayer.EventType.PRIVET_PRINT_FAILED); | 676 new Event(NativeLayer.EventType.PRIVET_PRINT_FAILED); |
| 673 privetPrintFailedEvent.httpError = http_error; | 677 privetPrintFailedEvent.httpError = http_error; |
| 674 this.dispatchEvent(privetPrintFailedEvent); | 678 this.dispatchEvent(privetPrintFailedEvent); |
| 679 }, | |
| 680 | |
| 681 /** | |
| 682 * Function that allows for onManipulateSettings to be called | |
| 683 * from the native layer. | |
| 684 */ | |
| 685 onEnableManipulateSettingsForTest_: function() { | |
| 686 global['onManipulateSettingsForTest'] = | |
| 687 this.onManipulateSettingsForTest_.bind(this); | |
| 688 }, | |
| 689 | |
| 690 /** | |
| 691 * Function that dispatches an event to print_preview.js to change | |
| 692 * a particular setting for print preview. | |
| 693 * @param {Dictionary} settings Dictionary containing the value to be | |
| 694 * changed and that value should be set to. | |
| 695 */ | |
| 696 onManipulateSettingsForTest_: function(settings) { | |
| 697 var manipulateSettingsEvent = | |
| 698 new Event(NativeLayer.EventType.MANIPULATE_SETTINGS_FOR_TEST); | |
| 699 manipulateSettingsEvent.settings = settings; | |
| 700 this.dispatchEvent(manipulateSettingsEvent); | |
| 701 }, | |
| 702 | |
| 703 /** | |
| 704 * Function that sends a message to the test, letting it know that an | |
| 705 * option has been set to a particular value and that the change has | |
| 706 * finished modifying the preview area. | |
| 707 */ | |
| 708 previewReady: function() { | |
| 709 if (global['onManipulateSettingsForTest']) { | |
| 710 chrome.send('UILoadedForTest'); | |
| 711 } | |
| 712 }, | |
| 713 | |
| 714 /** | |
| 715 * Function that notifies the test that the option it tried to change | |
| 716 * had not been changed successfully. | |
| 717 */ | |
| 718 previewFailed: function() { | |
|
ivandavid
2014/06/20 01:00:26
Test will assert false when this happens, causing
| |
| 719 chrome.send('UIFailedLoadingForTest'); | |
| 675 } | 720 } |
| 676 }; | 721 }; |
| 677 | 722 |
| 678 /** | 723 /** |
| 679 * Initial settings retrieved from the native layer. | 724 * Initial settings retrieved from the native layer. |
| 680 * @param {boolean} isInKioskAutoPrintMode Whether the print preview should be | 725 * @param {boolean} isInKioskAutoPrintMode Whether the print preview should be |
| 681 * in auto-print mode. | 726 * in auto-print mode. |
| 682 * @param {string} thousandsDelimeter Character delimeter of thousands digits. | 727 * @param {string} thousandsDelimeter Character delimeter of thousands digits. |
| 683 * @param {string} decimalDelimeter Character delimeter of the decimal point. | 728 * @param {string} decimalDelimeter Character delimeter of the decimal point. |
| 684 * @param {!print_preview.MeasurementSystem.UnitType} unitType Unit type of | 729 * @param {!print_preview.MeasurementSystem.UnitType} unitType Unit type of |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 850 return this.serializedAppStateStr_; | 895 return this.serializedAppStateStr_; |
| 851 } | 896 } |
| 852 }; | 897 }; |
| 853 | 898 |
| 854 // Export | 899 // Export |
| 855 return { | 900 return { |
| 856 NativeInitialSettings: NativeInitialSettings, | 901 NativeInitialSettings: NativeInitialSettings, |
| 857 NativeLayer: NativeLayer | 902 NativeLayer: NativeLayer |
| 858 }; | 903 }; |
| 859 }); | 904 }); |
| OLD | NEW |