Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1738)

Side by Side Diff: chrome/browser/resources/print_preview/native_layer.js

Issue 335583004: Added a test that currently is able to print to pdf. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed style issues and made the testing functionality optional Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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['onEnableManipulateSettings'] =
ivandavid 2014/06/17 22:59:16 Allows the native layer to send a message to print
50 this.onEnableManipulateSettings_.bind(this);
51 //global['onManipulateSettings'] = this.onManipulateSettings_.bind(this);
49 }; 52 };
50 53
51 /** 54 /**
52 * Event types dispatched from the Chromium native layer. 55 * Event types dispatched from the Chromium native layer.
53 * @enum {string} 56 * @enum {string}
54 * @const 57 * @const
55 */ 58 */
56 NativeLayer.EventType = { 59 NativeLayer.EventType = {
57 ACCESS_TOKEN_READY: 'print_preview.NativeLayer.ACCESS_TOKEN_READY', 60 ACCESS_TOKEN_READY: 'print_preview.NativeLayer.ACCESS_TOKEN_READY',
58 CAPABILITIES_SET: 'print_preview.NativeLayer.CAPABILITIES_SET', 61 CAPABILITIES_SET: 'print_preview.NativeLayer.CAPABILITIES_SET',
(...skipping 11 matching lines...) Expand all
70 PAGE_PREVIEW_READY: 'print_preview.NativeLayer.PAGE_PREVIEW_READY', 73 PAGE_PREVIEW_READY: 'print_preview.NativeLayer.PAGE_PREVIEW_READY',
71 PREVIEW_GENERATION_DONE: 74 PREVIEW_GENERATION_DONE:
72 'print_preview.NativeLayer.PREVIEW_GENERATION_DONE', 75 'print_preview.NativeLayer.PREVIEW_GENERATION_DONE',
73 PREVIEW_GENERATION_FAIL: 76 PREVIEW_GENERATION_FAIL:
74 'print_preview.NativeLayer.PREVIEW_GENERATION_FAIL', 77 'print_preview.NativeLayer.PREVIEW_GENERATION_FAIL',
75 PRINT_TO_CLOUD: 'print_preview.NativeLayer.PRINT_TO_CLOUD', 78 PRINT_TO_CLOUD: 'print_preview.NativeLayer.PRINT_TO_CLOUD',
76 SETTINGS_INVALID: 'print_preview.NativeLayer.SETTINGS_INVALID', 79 SETTINGS_INVALID: 'print_preview.NativeLayer.SETTINGS_INVALID',
77 PRIVET_PRINTER_CHANGED: 'print_preview.NativeLayer.PRIVET_PRINTER_CHANGED', 80 PRIVET_PRINTER_CHANGED: 'print_preview.NativeLayer.PRIVET_PRINTER_CHANGED',
78 PRIVET_CAPABILITIES_SET: 81 PRIVET_CAPABILITIES_SET:
79 'print_preview.NativeLayer.PRIVET_CAPABILITIES_SET', 82 'print_preview.NativeLayer.PRIVET_CAPABILITIES_SET',
80 PRIVET_PRINT_FAILED: 'print_preview.NativeLayer.PRIVET_PRINT_FAILED' 83 PRIVET_PRINT_FAILED: 'print_preview.NativeLayer.PRIVET_PRINT_FAILED',
84 MANIPULATE_SETTINGS: 'print_preview.NativeLayer.MANIPULATE_SETTINGS'
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
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, specifically during testing.
Lei Zhang 2014/06/17 23:22:20 specifically -> only? Maybe onEnableManipulateSett
684 */
685 onEnableManipulateSettings_: function() {
ivandavid 2014/06/17 22:59:16 See comment for line 49.
686 global['onManipulateSettings'] =
687 this.onManipulateSettings_.bind(this);
688 },
689
690 /**
691 * Function call from browsertest to start clicking certain buttons.
692 * @param {string} messageName The setting that is to be manipulated,
693 * such as the layout settings, or page numbers
694 * @param {string, boolean, undefined} Is the value that we want to
695 * set the particular setting to. For layout settings, page numbers,
696 * and margins, its a string. For 'headers and footers' and
697 * 'background colors and images,' its a boolean. For Save as PDF,
698 * its undefined as it isn't needed.
699 */
700 onManipulateSettings_: function(messageName, parameter) {
701 var manipulateSettingsEvent =
702 new Event(NativeLayer.EventType.MANIPULATE_SETTINGS);
703 manipulateSettingsEvent.messageName = messageName;
704 if (messageName == 'SAVE_AS_PDF') {
705 }
706 else if (messageName == 'LAYOUT_SETTINGS') {
707 manipulateSettingsEvent.layoutSettings = parameter;
708 }
709 else if (messageName == 'PAGE_NUMBERS') {
710 manipulateSettingsEvent.pageNumbers = parameter;
711 }
712 else if (messageName == 'HEADERS_AND_FOOTERS') {
713 manipulateSettingsEvent.headersAndFooters = parameter;
714 }
715 else if (messageName == 'BACKGROUND_COLORS_AND_IMAGES') {
716 manipulateSettingsEvent.backgroundColorsAndImages = parameter;
717 }
718 else if (messageName == 'MARGINS') {
719 manipulateSettingsEvent.margins = parameter;
720 }
721 this.dispatchEvent(manipulateSettingsEvent);
675 } 722 }
676 }; 723 };
677 724
678 /** 725 /**
679 * Initial settings retrieved from the native layer. 726 * Initial settings retrieved from the native layer.
680 * @param {boolean} isInKioskAutoPrintMode Whether the print preview should be 727 * @param {boolean} isInKioskAutoPrintMode Whether the print preview should be
681 * in auto-print mode. 728 * in auto-print mode.
682 * @param {string} thousandsDelimeter Character delimeter of thousands digits. 729 * @param {string} thousandsDelimeter Character delimeter of thousands digits.
683 * @param {string} decimalDelimeter Character delimeter of the decimal point. 730 * @param {string} decimalDelimeter Character delimeter of the decimal point.
684 * @param {!print_preview.MeasurementSystem.UnitType} unitType Unit type of 731 * @param {!print_preview.MeasurementSystem.UnitType} unitType Unit type of
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
850 return this.serializedAppStateStr_; 897 return this.serializedAppStateStr_;
851 } 898 }
852 }; 899 };
853 900
854 // Export 901 // Export
855 return { 902 return {
856 NativeInitialSettings: NativeInitialSettings, 903 NativeInitialSettings: NativeInitialSettings,
857 NativeLayer: NativeLayer 904 NativeLayer: NativeLayer
858 }; 905 };
859 }); 906 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698