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

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: Added ability to set any print preview setting within a test. 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['onManipulateSettings'] = this.onManipulateSettings_.bind(this);
49 }; 50 };
50 51
51 /** 52 /**
52 * Event types dispatched from the Chromium native layer. 53 * Event types dispatched from the Chromium native layer.
53 * @enum {string} 54 * @enum {string}
54 * @const 55 * @const
55 */ 56 */
56 NativeLayer.EventType = { 57 NativeLayer.EventType = {
57 ACCESS_TOKEN_READY: 'print_preview.NativeLayer.ACCESS_TOKEN_READY', 58 ACCESS_TOKEN_READY: 'print_preview.NativeLayer.ACCESS_TOKEN_READY',
58 CAPABILITIES_SET: 'print_preview.NativeLayer.CAPABILITIES_SET', 59 CAPABILITIES_SET: 'print_preview.NativeLayer.CAPABILITIES_SET',
(...skipping 11 matching lines...) Expand all
70 PAGE_PREVIEW_READY: 'print_preview.NativeLayer.PAGE_PREVIEW_READY', 71 PAGE_PREVIEW_READY: 'print_preview.NativeLayer.PAGE_PREVIEW_READY',
71 PREVIEW_GENERATION_DONE: 72 PREVIEW_GENERATION_DONE:
72 'print_preview.NativeLayer.PREVIEW_GENERATION_DONE', 73 'print_preview.NativeLayer.PREVIEW_GENERATION_DONE',
73 PREVIEW_GENERATION_FAIL: 74 PREVIEW_GENERATION_FAIL:
74 'print_preview.NativeLayer.PREVIEW_GENERATION_FAIL', 75 'print_preview.NativeLayer.PREVIEW_GENERATION_FAIL',
75 PRINT_TO_CLOUD: 'print_preview.NativeLayer.PRINT_TO_CLOUD', 76 PRINT_TO_CLOUD: 'print_preview.NativeLayer.PRINT_TO_CLOUD',
76 SETTINGS_INVALID: 'print_preview.NativeLayer.SETTINGS_INVALID', 77 SETTINGS_INVALID: 'print_preview.NativeLayer.SETTINGS_INVALID',
77 PRIVET_PRINTER_CHANGED: 'print_preview.NativeLayer.PRIVET_PRINTER_CHANGED', 78 PRIVET_PRINTER_CHANGED: 'print_preview.NativeLayer.PRIVET_PRINTER_CHANGED',
78 PRIVET_CAPABILITIES_SET: 79 PRIVET_CAPABILITIES_SET:
79 'print_preview.NativeLayer.PRIVET_CAPABILITIES_SET', 80 'print_preview.NativeLayer.PRIVET_CAPABILITIES_SET',
80 PRIVET_PRINT_FAILED: 'print_preview.NativeLayer.PRIVET_PRINT_FAILED' 81 PRIVET_PRINT_FAILED: 'print_preview.NativeLayer.PRIVET_PRINT_FAILED',
82 MANIPULATE_SETTINGS: 'print_preview.NativeLayer.MANIPULATE_SETTINGS'
81 }; 83 };
82 84
83 /** 85 /**
84 * Constant values matching printing::DuplexMode enum. 86 * Constant values matching printing::DuplexMode enum.
85 * @enum {number} 87 * @enum {number}
86 */ 88 */
87 NativeLayer.DuplexMode = { 89 NativeLayer.DuplexMode = {
88 SIMPLEX: 0, 90 SIMPLEX: 0,
89 LONG_EDGE: 1, 91 LONG_EDGE: 1,
90 UNKNOWN_DUPLEX_MODE: -1 92 UNKNOWN_DUPLEX_MODE: -1
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after
665 /** 667 /**
666 * @param {string} http_error The HTTP response code or -1 if not an HTTP 668 * @param {string} http_error The HTTP response code or -1 if not an HTTP
667 * error. 669 * error.
668 * @private 670 * @private
669 */ 671 */
670 onPrivetPrintFailed_: function(http_error) { 672 onPrivetPrintFailed_: function(http_error) {
671 var privetPrintFailedEvent = 673 var privetPrintFailedEvent =
672 new Event(NativeLayer.EventType.PRIVET_PRINT_FAILED); 674 new Event(NativeLayer.EventType.PRIVET_PRINT_FAILED);
673 privetPrintFailedEvent.httpError = http_error; 675 privetPrintFailedEvent.httpError = http_error;
674 this.dispatchEvent(privetPrintFailedEvent); 676 this.dispatchEvent(privetPrintFailedEvent);
677 },
678
679 /**
680 * Function call from browsertest to start clicking certain buttons
681 */
682 onManipulateSettings_: function(messageName, parameter) {
ivandavid 2014/06/17 21:38:18 'messageName' is the property of print preview tha
Lei Zhang 2014/06/17 21:57:33 You should update the JS doc, rather than mentioni
ivandavid 2014/06/17 22:59:16 Done. I think I correctly followed the @param sect
683 var manipulateSettingsEvent =
684 new Event(NativeLayer.EventType.MANIPULATE_SETTINGS);
685 manipulateSettingsEvent.messageName = messageName;
686 if (messageName == 'SAVE_AS_PDF') {
687 }
688 else if (messageName == 'LAYOUT_SETTINGS') {
689 manipulateSettingsEvent.layoutSettings = parameter;
690 }
691 else if (messageName == 'PAGE_NUMBERS') {
692 manipulateSettingsEvent.pageNumbers = parameter;
693 }
694 else if (messageName == 'HEADERS_AND_FOOTERS') {
695 manipulateSettingsEvent.headersAndFooters = parameter;
696 }
697 else if (messageName == 'BACKGROUND_COLORS_AND_IMAGES') {
698 manipulateSettingsEvent.backgroundColorsAndImages = parameter;
699 }
700 else if (messageName == 'MARGINS') {
701 manipulateSettingsEvent.margins = parameter;
702 }
703 this.dispatchEvent(manipulateSettingsEvent);
675 } 704 }
676 }; 705 };
677 706
678 /** 707 /**
679 * Initial settings retrieved from the native layer. 708 * Initial settings retrieved from the native layer.
680 * @param {boolean} isInKioskAutoPrintMode Whether the print preview should be 709 * @param {boolean} isInKioskAutoPrintMode Whether the print preview should be
681 * in auto-print mode. 710 * in auto-print mode.
682 * @param {string} thousandsDelimeter Character delimeter of thousands digits. 711 * @param {string} thousandsDelimeter Character delimeter of thousands digits.
683 * @param {string} decimalDelimeter Character delimeter of the decimal point. 712 * @param {string} decimalDelimeter Character delimeter of the decimal point.
684 * @param {!print_preview.MeasurementSystem.UnitType} unitType Unit type of 713 * @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_; 879 return this.serializedAppStateStr_;
851 } 880 }
852 }; 881 };
853 882
854 // Export 883 // Export
855 return { 884 return {
856 NativeInitialSettings: NativeInitialSettings, 885 NativeInitialSettings: NativeInitialSettings,
857 NativeLayer: NativeLayer 886 NativeLayer: NativeLayer
858 }; 887 };
859 }); 888 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698