summaryrefslogtreecommitdiffstats
path: root/chromium/chrome/browser/resources/print_preview
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/chrome/browser/resources/print_preview')
-rw-r--r--chromium/chrome/browser/resources/print_preview/BUILD.gn3
-rw-r--r--chromium/chrome/browser/resources/print_preview/data/BUILD.gn11
-rw-r--r--chromium/chrome/browser/resources/print_preview/data/destination.js49
-rw-r--r--chromium/chrome/browser/resources/print_preview/data/destination_match.html1
-rw-r--r--chromium/chrome/browser/resources/print_preview/data/destination_match.js33
-rw-r--r--chromium/chrome/browser/resources/print_preview/data/document_info.js9
-rw-r--r--chromium/chrome/browser/resources/print_preview/data/local_parsers.html1
-rw-r--r--chromium/chrome/browser/resources/print_preview/data/margins.js41
-rw-r--r--chromium/chrome/browser/resources/print_preview/data/model.html2
-rw-r--r--chromium/chrome/browser/resources/print_preview/data/model.js185
-rw-r--r--chromium/chrome/browser/resources/print_preview/data/scaling.html3
-rw-r--r--chromium/chrome/browser/resources/print_preview/data/scaling.js24
-rw-r--r--chromium/chrome/browser/resources/print_preview/native_layer.js15
-rw-r--r--chromium/chrome/browser/resources/print_preview/polymer3/demo.js116
-rw-r--r--chromium/chrome/browser/resources/print_preview/print_preview_resources.grd10
-rw-r--r--chromium/chrome/browser/resources/print_preview/print_preview_utils.js2
-rw-r--r--chromium/chrome/browser/resources/print_preview/ui/BUILD.gn7
-rw-r--r--chromium/chrome/browser/resources/print_preview/ui/advanced_options_settings.html1
-rw-r--r--chromium/chrome/browser/resources/print_preview/ui/advanced_settings_item.html8
-rw-r--r--chromium/chrome/browser/resources/print_preview/ui/advanced_settings_item.js35
-rw-r--r--chromium/chrome/browser/resources/print_preview/ui/app.html3
-rw-r--r--chromium/chrome/browser/resources/print_preview/ui/app.js4
-rw-r--r--chromium/chrome/browser/resources/print_preview/ui/destination_dialog.html5
-rw-r--r--chromium/chrome/browser/resources/print_preview/ui/destination_dialog.js6
-rw-r--r--chromium/chrome/browser/resources/print_preview/ui/destination_list_item.html2
-rw-r--r--chromium/chrome/browser/resources/print_preview/ui/destination_select.html2
-rw-r--r--chromium/chrome/browser/resources/print_preview/ui/destination_select.js2
-rw-r--r--chromium/chrome/browser/resources/print_preview/ui/duplex_settings.html2
-rw-r--r--chromium/chrome/browser/resources/print_preview/ui/duplex_settings.js2
-rw-r--r--chromium/chrome/browser/resources/print_preview/ui/header.html2
-rw-r--r--chromium/chrome/browser/resources/print_preview/ui/header_new.html2
-rw-r--r--chromium/chrome/browser/resources/print_preview/ui/icons.html (renamed from chromium/chrome/browser/resources/print_preview/icons.html)13
-rw-r--r--chromium/chrome/browser/resources/print_preview/ui/margin_control.js4
-rw-r--r--chromium/chrome/browser/resources/print_preview/ui/margin_control_container.js61
-rw-r--r--chromium/chrome/browser/resources/print_preview/ui/margins_settings.html15
-rw-r--r--chromium/chrome/browser/resources/print_preview/ui/margins_settings.js7
-rw-r--r--chromium/chrome/browser/resources/print_preview/ui/pages_per_sheet_settings.js3
-rw-r--r--chromium/chrome/browser/resources/print_preview/ui/pin_settings.js2
-rw-r--r--chromium/chrome/browser/resources/print_preview/ui/preview_area.html1
-rw-r--r--chromium/chrome/browser/resources/print_preview/ui/preview_area.js89
-rw-r--r--chromium/chrome/browser/resources/print_preview/ui/scaling_settings.html7
-rw-r--r--chromium/chrome/browser/resources/print_preview/ui/scaling_settings.js126
-rw-r--r--chromium/chrome/browser/resources/print_preview/ui/sidebar.html7
-rw-r--r--chromium/chrome/browser/resources/print_preview/ui/sidebar.js2
44 files changed, 618 insertions, 307 deletions
diff --git a/chromium/chrome/browser/resources/print_preview/BUILD.gn b/chromium/chrome/browser/resources/print_preview/BUILD.gn
index fe72fb197fb..0bb1822b6fe 100644
--- a/chromium/chrome/browser/resources/print_preview/BUILD.gn
+++ b/chromium/chrome/browser/resources/print_preview/BUILD.gn
@@ -77,9 +77,9 @@ js_type_check("print_preview_resources") {
js_library("print_preview_utils") {
deps = [
":dark_mode_behavior",
+ "//third_party/polymer/v1_0/components-chromium/iron-iconset-svg:iron-iconset-svg-extracted",
"//ui/webui/resources/js:util",
]
- externs_list = [ "$externs_path/pending.js" ]
}
js_library("metrics") {
@@ -127,6 +127,7 @@ js_library("cloud_print_interface_native") {
js_library("native_layer") {
deps = [
"data:destination",
+ "data:destination_match",
"data:measurement_system",
"//ui/webui/resources/js:cr",
]
diff --git a/chromium/chrome/browser/resources/print_preview/data/BUILD.gn b/chromium/chrome/browser/resources/print_preview/data/BUILD.gn
index 5ab503b223e..7f04cc61c7b 100644
--- a/chromium/chrome/browser/resources/print_preview/data/BUILD.gn
+++ b/chromium/chrome/browser/resources/print_preview/data/BUILD.gn
@@ -19,6 +19,7 @@ js_type_check("closure_compile") {
":measurement_system",
":model",
":printable_area",
+ ":scaling",
":size",
":state",
]
@@ -50,6 +51,7 @@ js_library("invitation_store") {
js_library("local_parsers") {
deps = [
":destination",
+ ":destination_match",
"..:native_layer",
"//ui/webui/resources/js:cr",
]
@@ -58,7 +60,6 @@ js_library("local_parsers") {
js_library("destination_match") {
deps = [
":destination",
- "..:native_layer",
"//ui/webui/resources/js:cr",
]
}
@@ -111,8 +112,10 @@ js_library("measurement_system") {
js_library("model") {
deps = [
":destination",
+ ":destination_match",
":document_info",
":margins",
+ ":scaling",
"//ui/webui/resources/js:cr",
"//ui/webui/resources/js:promise_resolver",
]
@@ -126,6 +129,12 @@ js_library("printable_area") {
]
}
+js_library("scaling") {
+ deps = [
+ "//ui/webui/resources/js:cr",
+ ]
+}
+
js_library("size") {
deps = [
"//ui/webui/resources/js:cr",
diff --git a/chromium/chrome/browser/resources/print_preview/data/destination.js b/chromium/chrome/browser/resources/print_preview/data/destination.js
index 403becbf6d1..761891d5c01 100644
--- a/chromium/chrome/browser/resources/print_preview/data/destination.js
+++ b/chromium/chrome/browser/resources/print_preview/data/destination.js
@@ -95,6 +95,17 @@ cr.define('print_preview', function() {
let VendorCapabilitySelectOption;
/**
+ * Same as cloud_devices::printer::TypedValueVendorCapability::ValueType.
+ * @enum {string}
+ */
+ const VendorCapabilityValueType = {
+ BOOLEAN: 'BOOLEAN',
+ FLOAT: 'FLOAT',
+ INTEGER: 'INTEGER',
+ STRING: 'STRING',
+ };
+
+ /**
* Specifies a custom vendor capability.
* @typedef {{
* id: (string),
@@ -106,6 +117,7 @@ cr.define('print_preview', function() {
* }|undefined),
* typed_value_cap: ({
* default: (number | string | boolean | undefined),
+ * value_type: (print_preview.VendorCapabilityValueType | undefined),
* }|undefined),
* range_cap: ({
* default: (number),
@@ -219,14 +231,31 @@ cr.define('print_preview', function() {
};
/**
+ * Enumeration of background graphics printing mode restrictions used by
+ * Chromium.
+ * This has to coincide with |printing::BackgroundGraphicsModeRestriction| as
+ * defined in printing/backend/printing_restrictions.h
+ * @enum {number}
+ */
+ const BackgroundGraphicsModeRestriction = {
+ UNSET: 0,
+ ENABLED: 1,
+ DISABLED: 2,
+ };
+
+ /**
* Policies affecting a destination.
* @typedef {{
* allowedColorModes: ?print_preview.ColorModeRestriction,
* allowedDuplexModes: ?print_preview.DuplexModeRestriction,
* allowedPinMode: ?print_preview.PinModeRestriction,
+ * allowedBackgroundGraphicsMode:
+ * ?print_preview.BackgroundGraphicsModeRestriction,
* defaultColorMode: ?print_preview.ColorModeRestriction,
* defaultDuplexMode: ?print_preview.DuplexModeRestriction,
* defaultPinMode: ?print_preview.PinModeRestriction,
+ * defaultBackgroundGraphicsMode:
+ * ?print_preview.BackgroundGraphicsModeRestriction,
* }}
*/
let Policies;
@@ -821,6 +850,16 @@ cr.define('print_preview', function() {
this.policies.allowedPinModes :
null;
}
+
+ /**
+ * @return {?print_preview.BackgroundGraphicsModeRestriction} Background
+ * graphics mode allowed by policy.
+ */
+ get backgroundGraphicsPolicy() {
+ return this.policies && this.policies.allowedBackgroundGraphicsModes ?
+ this.policies.allowedBackgroundGraphicsModes :
+ null;
+ }
// </if>
/**
@@ -867,6 +906,14 @@ cr.define('print_preview', function() {
get defaultPinPolicy() {
return this.policies && this.policies.defaultPinMode;
}
+
+ /**
+ * @return {?print_preview.BackgroundGraphicsModeRestriction} Value of
+ * default background graphics setting given by policy.
+ */
+ get defaultBackgroundGraphicsPolicy() {
+ return this.policies && this.policies.defaultBackgroundGraphicsMode;
+ }
// </if>
/**
@@ -966,9 +1013,11 @@ cr.define('print_preview', function() {
makeRecentDestination: makeRecentDestination,
RecentDestination: RecentDestination,
VendorCapabilitySelectOption: VendorCapabilitySelectOption,
+ VendorCapabilityValueType: VendorCapabilityValueType,
VendorCapability: VendorCapability,
// <if expr="chromeos">
+ BackgroundGraphicsModeRestriction: BackgroundGraphicsModeRestriction,
ColorModeRestriction: ColorModeRestriction,
DuplexModeRestriction: DuplexModeRestriction,
PinModeRestriction: PinModeRestriction,
diff --git a/chromium/chrome/browser/resources/print_preview/data/destination_match.html b/chromium/chrome/browser/resources/print_preview/data/destination_match.html
index 35c9a62fc62..288ce95f4ce 100644
--- a/chromium/chrome/browser/resources/print_preview/data/destination_match.html
+++ b/chromium/chrome/browser/resources/print_preview/data/destination_match.html
@@ -1,5 +1,4 @@
<link rel="import" href="chrome://resources/html/cr.html">
-<link rel="import" href="../native_layer.html">
<link rel="import" href="destination.html">
<script src="destination_match.js"></script>
diff --git a/chromium/chrome/browser/resources/print_preview/data/destination_match.js b/chromium/chrome/browser/resources/print_preview/data/destination_match.js
index 9e3e9307f93..c147e002611 100644
--- a/chromium/chrome/browser/resources/print_preview/data/destination_match.js
+++ b/chromium/chrome/browser/resources/print_preview/data/destination_match.js
@@ -5,6 +5,19 @@
cr.define('print_preview', function() {
'use strict';
/**
+ * Printer types for capabilities and printer list requests.
+ * Must match PrinterType in printing/print_job_constants.h
+ * @enum {number}
+ */
+ const PrinterType = {
+ PRIVET_PRINTER: 0,
+ EXTENSION_PRINTER: 1,
+ PDF_PRINTER: 2,
+ LOCAL_PRINTER: 3,
+ CLOUD_PRINTER: 4
+ };
+
+ /**
* Converts DestinationOrigin to PrinterType.
* @param {!print_preview.DestinationOrigin} origin The printer's
* destination origin.
@@ -25,6 +38,19 @@ cr.define('print_preview', function() {
return print_preview.PrinterType.CLOUD_PRINTER;
};
+ /**
+ * @param {!print_preview.Destination} destination The destination to figure
+ * out the printer type of.
+ * @return {!print_preview.PrinterType} Map the destination to a PrinterType.
+ */
+ function getPrinterTypeForDestination(destination) {
+ if (destination.id ==
+ print_preview.Destination.GooglePromotedId.SAVE_AS_PDF) {
+ return print_preview.PrinterType.PDF_PRINTER;
+ }
+ return print_preview.originToType(destination.origin);
+ }
+
class DestinationMatch {
/**
* A set of key parameters describing a destination used to determine
@@ -116,5 +142,10 @@ cr.define('print_preview', function() {
}
// Export
- return {originToType: originToType, DestinationMatch: DestinationMatch};
+ return {
+ DestinationMatch: DestinationMatch,
+ PrinterType: PrinterType,
+ getPrinterTypeForDestination: getPrinterTypeForDestination,
+ originToType: originToType,
+ };
});
diff --git a/chromium/chrome/browser/resources/print_preview/data/document_info.js b/chromium/chrome/browser/resources/print_preview/data/document_info.js
index 67ce1c952af..d85124d3a13 100644
--- a/chromium/chrome/browser/resources/print_preview/data/document_info.js
+++ b/chromium/chrome/browser/resources/print_preview/data/document_info.js
@@ -9,6 +9,7 @@ cr.exportPath('print_preview');
* hasCssMediaStyles: boolean,
* hasSelection: boolean,
* isModifiable: boolean,
+ * isPdf: boolean,
* isScalingDisabled: boolean,
* fitToPageScaling: number,
* pageCount: number,
@@ -48,6 +49,7 @@ Polymer({
hasCssMediaStyles: false,
hasSelection: false,
isModifiable: true,
+ isPdf: false,
isScalingDisabled: false,
fitToPageScaling: 100,
pageCount: 0,
@@ -113,13 +115,16 @@ Polymer({
/**
* Initializes the state of the data model.
* @param {boolean} isModifiable Whether the document is modifiable.
+ * @param {boolean} isPdf Whether the document is PDF.
* @param {string} title Title of the document.
* @param {boolean} hasSelection Whether the document has user-selected
* content.
*/
- init: function(isModifiable, title, hasSelection) {
+ init: function(isModifiable, isPdf, title, hasSelection) {
this.isInitialized_ = true;
this.set('documentSettings.isModifiable', isModifiable);
+ // TODO(crbug.com/702995): Remove once Flash is deprecated.
+ this.set('documentSettings.isPdf', isPdf);
this.set('documentSettings.title', title);
this.set('documentSettings.hasSelection', hasSelection);
},
@@ -154,7 +159,7 @@ Polymer({
Math.round(pageLayout.marginTop), Math.round(pageLayout.marginRight),
Math.round(pageLayout.marginBottom), Math.round(pageLayout.marginLeft));
- const o = print_preview.ticket_items.CustomMarginsOrientation;
+ const o = print_preview.CustomMarginsOrientation;
const pageSize = new print_preview.Size(
pageLayout.contentWidth + margins.get(o.LEFT) + margins.get(o.RIGHT),
pageLayout.contentHeight + margins.get(o.TOP) + margins.get(o.BOTTOM));
diff --git a/chromium/chrome/browser/resources/print_preview/data/local_parsers.html b/chromium/chrome/browser/resources/print_preview/data/local_parsers.html
index b6fe90e29d7..fed4e851ed9 100644
--- a/chromium/chrome/browser/resources/print_preview/data/local_parsers.html
+++ b/chromium/chrome/browser/resources/print_preview/data/local_parsers.html
@@ -1,5 +1,6 @@
<link rel="import" href="chrome://resources/html/cr.html">
<link rel="import" href="../native_layer.html">
<link rel="import" href="destination.html">
+<link rel="import" href="destination_match.html">
<script src="local_parsers.js"></script>
diff --git a/chromium/chrome/browser/resources/print_preview/data/margins.js b/chromium/chrome/browser/resources/print_preview/data/margins.js
index 3facd5a82cd..ce38eb65947 100644
--- a/chromium/chrome/browser/resources/print_preview/data/margins.js
+++ b/chromium/chrome/browser/resources/print_preview/data/margins.js
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-cr.define('print_preview.ticket_items', function() {
+cr.define('print_preview', function() {
'use strict';
/**
@@ -21,7 +21,7 @@ cr.define('print_preview.ticket_items', function() {
* printing/print_job_constants.h.
* @enum {number}
*/
- const MarginsTypeValue = {
+ const MarginsType = {
DEFAULT: 0,
NO_MARGINS: 1,
MINIMUM: 2,
@@ -30,7 +30,7 @@ cr.define('print_preview.ticket_items', function() {
return {
CustomMarginsOrientation: CustomMarginsOrientation,
- MarginsTypeValue: MarginsTypeValue,
+ MarginsType: MarginsType,
};
});
@@ -61,18 +61,14 @@ cr.define('print_preview', function() {
/**
* Backing store for the margin values in points.
* @type {!Object<
- * !print_preview.ticket_items.CustomMarginsOrientation, number>}
+ * !print_preview.CustomMarginsOrientation, number>}
* @private
*/
this.value_ = {};
- this.value_[print_preview.ticket_items.CustomMarginsOrientation.TOP] =
- top;
- this.value_[print_preview.ticket_items.CustomMarginsOrientation.RIGHT] =
- right;
- this.value_[print_preview.ticket_items.CustomMarginsOrientation.BOTTOM] =
- bottom;
- this.value_[print_preview.ticket_items.CustomMarginsOrientation.LEFT] =
- left;
+ this.value_[print_preview.CustomMarginsOrientation.TOP] = top;
+ this.value_[print_preview.CustomMarginsOrientation.RIGHT] = right;
+ this.value_[print_preview.CustomMarginsOrientation.BOTTOM] = bottom;
+ this.value_[print_preview.CustomMarginsOrientation.LEFT] = left;
}
/**
@@ -83,15 +79,14 @@ cr.define('print_preview', function() {
*/
static parse(state) {
return new print_preview.Margins(
- state[print_preview.ticket_items.CustomMarginsOrientation.TOP] || 0,
- state[print_preview.ticket_items.CustomMarginsOrientation.RIGHT] || 0,
- state[print_preview.ticket_items.CustomMarginsOrientation.BOTTOM] ||
- 0,
- state[print_preview.ticket_items.CustomMarginsOrientation.LEFT] || 0);
+ state[print_preview.CustomMarginsOrientation.TOP] || 0,
+ state[print_preview.CustomMarginsOrientation.RIGHT] || 0,
+ state[print_preview.CustomMarginsOrientation.BOTTOM] || 0,
+ state[print_preview.CustomMarginsOrientation.LEFT] || 0);
}
/**
- * @param {!print_preview.ticket_items.CustomMarginsOrientation}
+ * @param {!print_preview.CustomMarginsOrientation}
* orientation Specifies the margin value to get.
* @return {number} Value of the margin of the given orientation.
*/
@@ -100,7 +95,7 @@ cr.define('print_preview', function() {
}
/**
- * @param {!print_preview.ticket_items.CustomMarginsOrientation}
+ * @param {!print_preview.CustomMarginsOrientation}
* orientation Specifies the margin to set.
* @param {number} value Updated value of the margin in points to modify.
* @return {!print_preview.Margins} A new copy of |this| with the
@@ -110,10 +105,10 @@ cr.define('print_preview', function() {
const newValue = this.clone_();
newValue[orientation] = value;
return new Margins(
- newValue[print_preview.ticket_items.CustomMarginsOrientation.TOP],
- newValue[print_preview.ticket_items.CustomMarginsOrientation.RIGHT],
- newValue[print_preview.ticket_items.CustomMarginsOrientation.BOTTOM],
- newValue[print_preview.ticket_items.CustomMarginsOrientation.LEFT]);
+ newValue[print_preview.CustomMarginsOrientation.TOP],
+ newValue[print_preview.CustomMarginsOrientation.RIGHT],
+ newValue[print_preview.CustomMarginsOrientation.BOTTOM],
+ newValue[print_preview.CustomMarginsOrientation.LEFT]);
}
/**
diff --git a/chromium/chrome/browser/resources/print_preview/data/model.html b/chromium/chrome/browser/resources/print_preview/data/model.html
index c29628bb3fa..1fb0c92a112 100644
--- a/chromium/chrome/browser/resources/print_preview/data/model.html
+++ b/chromium/chrome/browser/resources/print_preview/data/model.html
@@ -3,7 +3,9 @@
<link rel="import" href="chrome://resources/html/cr.html">
<link rel="import" href="chrome://resources/html/promise_resolver.html">
<link rel="import" href="destination.html">
+<link rel="import" href="destination_match.html">
<link rel="import" href="document_info.html">
<link rel="import" href="margins.html">
+<link rel="import" href="scaling.html">
<script src="model.js"></script>
diff --git a/chromium/chrome/browser/resources/print_preview/data/model.js b/chromium/chrome/browser/resources/print_preview/data/model.js
index 4e5182375ae..bcdc1711aa4 100644
--- a/chromium/chrome/browser/resources/print_preview/data/model.js
+++ b/chromium/chrome/browser/resources/print_preview/data/model.js
@@ -30,8 +30,9 @@ cr.define('print_preview', function() {
* mediaSize: !print_preview.Setting,
* margins: !print_preview.Setting,
* dpi: !print_preview.Setting,
- * fitToPage: !print_preview.Setting,
* scaling: !print_preview.Setting,
+ * scalingType: !print_preview.Setting,
+ * scalingTypePdf: !print_preview.Setting,
* duplex: !print_preview.Setting,
* duplexShortEdge: !print_preview.Setting,
* cssBackground: !print_preview.Setting,
@@ -60,16 +61,17 @@ cr.define('print_preview', function() {
* width_microns: number,
* custom_display_name: (string | undefined),
* is_default: (boolean | undefined)} | undefined),
- * marginsType: (print_preview.ticket_items.MarginsTypeValue | undefined),
+ * marginsType: (print_preview.MarginsType | undefined),
* customMargins: (print_preview.MarginsSetting | undefined),
* isColorEnabled: (boolean | undefined),
* isDuplexEnabled: (boolean | undefined),
* isHeaderFooterEnabled: (boolean | undefined),
* isLandscapeEnabled: (boolean | undefined),
* isCollateEnabled: (boolean | undefined),
- * isFitToPageEnabled: (boolean | undefined),
* isCssBackgroundEnabled: (boolean | undefined),
* scaling: (string | undefined),
+ * scalingType: (print_preview.ScalingType | undefined),
+ * scalingTypePdf: (print_preview.ScalingType | undefined),
* vendor_options: (Object | undefined),
* isPinEnabled: (boolean | undefined),
* pinValue: (string | undefined)
@@ -147,8 +149,7 @@ cr.define('print_preview.Model', () => {
'use strict';
/**
- * Sticky setting names. Alphabetical except for fitToPage, which must be set
- * after scaling in updateFromStickySettings().
+ * Sticky setting names in alphabetical order.
* @type {!Array<string>}
*/
const STICKY_SETTING_NAMES = [
@@ -164,9 +165,9 @@ const STICKY_SETTING_NAMES = [
'layout',
'margins',
'mediaSize',
- 'customScaling',
'scaling',
- 'fitToPage',
+ 'scalingType',
+ 'scalingTypePdf',
'vendorItems',
];
// <if expr="chromeos">
@@ -188,9 +189,9 @@ Polymer({
/**
* Object containing current settings of Print Preview, for use by Polymer
* controls.
- * Initialize settings that are only available on some printers to
- * unavailable, and settings that are provided by PDF generation to
- * available.
+ * Initialize all settings to available so that more settings always stays
+ * in a collapsed state during startup, when document information and
+ * printer capabilities may arrive at slightly different times.
* @type {!print_preview.Settings}
*/
settings: {
@@ -242,7 +243,7 @@ Polymer({
value: true, /* color */
unavailableValue: false,
valid: true,
- available: false,
+ available: true,
setByPolicy: false,
setFromUi: false,
key: 'isColorEnabled',
@@ -255,16 +256,15 @@ Polymer({
height_microns: 279400,
},
valid: true,
- available: false,
+ available: true,
setByPolicy: false,
setFromUi: false,
key: 'mediaSize',
updatesPreview: true,
},
margins: {
- value: print_preview.ticket_items.MarginsTypeValue.DEFAULT,
- unavailableValue:
- print_preview.ticket_items.MarginsTypeValue.DEFAULT,
+ value: print_preview.MarginsType.DEFAULT,
+ unavailableValue: print_preview.MarginsType.DEFAULT,
valid: true,
available: true,
setByPolicy: false,
@@ -286,47 +286,47 @@ Polymer({
value: {},
unavailableValue: {},
valid: true,
- available: false,
+ available: true,
setByPolicy: false,
setFromUi: false,
key: 'dpi',
updatesPreview: false,
},
- fitToPage: {
- value: false,
- unavailableValue: false,
+ scaling: {
+ value: '100',
+ unavailableValue: '100',
valid: true,
available: true,
setByPolicy: false,
setFromUi: false,
- key: 'isFitToPageEnabled',
+ key: 'scaling',
updatesPreview: true,
},
- scaling: {
- value: '100',
- unavailableValue: '100',
+ scalingType: {
+ value: print_preview.ScalingType.DEFAULT,
+ unavailableValue: print_preview.ScalingType.DEFAULT,
valid: true,
available: true,
setByPolicy: false,
setFromUi: false,
- key: 'scaling',
+ key: 'scalingType',
updatesPreview: true,
},
- customScaling: {
- value: false,
- unavailableValue: false,
+ scalingTypePdf: {
+ value: print_preview.ScalingType.DEFAULT,
+ unavailableValue: print_preview.ScalingType.DEFAULT,
valid: true,
available: true,
setByPolicy: false,
setFromUi: false,
- key: 'customScaling',
+ key: 'scalingTypePdf',
updatesPreview: true,
},
duplex: {
value: true,
unavailableValue: false,
valid: true,
- available: false,
+ available: true,
setByPolicy: false,
setFromUi: false,
key: 'isDuplexEnabled',
@@ -386,7 +386,7 @@ Polymer({
value: {},
unavailableValue: {},
valid: true,
- available: false,
+ available: true,
setByPolicy: false,
setFromUi: false,
key: 'vendorOptions',
@@ -441,7 +441,7 @@ Polymer({
value: false,
unavailableValue: false,
valid: true,
- available: false,
+ available: true,
setByPolicy: false,
setFromUi: false,
key: 'isPinEnabled',
@@ -451,7 +451,7 @@ Polymer({
value: '',
unavailableValue: '',
valid: true,
- available: false,
+ available: true,
setByPolicy: false,
setFromUi: false,
key: 'pinValue',
@@ -484,8 +484,8 @@ Polymer({
observers: [
'updateSettingsFromDestination_(destination.capabilities)',
'updateSettingsAvailabilityFromDocumentSettings_(' +
- 'documentSettings.isModifiable, documentSettings.hasCssMediaStyles,' +
- 'documentSettings.hasSelection)',
+ 'documentSettings.isModifiable, documentSettings.isPdf,' +
+ 'documentSettings.hasCssMediaStyles, documentSettings.hasSelection)',
'updateHeaderFooterAvailable_(' +
'margins, settings.margins.value, ' +
'settings.customMargins.value, settings.mediaSize.value)',
@@ -706,11 +706,15 @@ Polymer({
const knownSizeToSaveAsPdf = isSaveAsPDF &&
(!this.documentSettings.isModifiable ||
this.documentSettings.hasCssMediaStyles);
- this.setSettingPath_('fitToPage.unavailableValue', !isSaveAsPDF);
+ const scalingAvailable = !knownSizeToSaveAsPdf &&
+ (this.documentSettings.isModifiable || this.documentSettings.isPdf);
+ this.setSettingPath_('scaling.available', scalingAvailable);
this.setSettingPath_(
- 'fitToPage.available',
- !knownSizeToSaveAsPdf && !this.documentSettings.isModifiable);
- this.setSettingPath_('scaling.available', !knownSizeToSaveAsPdf);
+ 'scalingType.available',
+ scalingAvailable && !this.documentSettings.isPdf);
+ this.setSettingPath_(
+ 'scalingTypePdf.available',
+ scalingAvailable && this.documentSettings.isPdf);
const caps = this.destination && this.destination.capabilities ?
this.destination.capabilities.printer :
null;
@@ -727,6 +731,9 @@ Polymer({
}
this.setSettingPath_(
+ 'pagesPerSheet.available',
+ this.documentSettings.isModifiable || this.documentSettings.isPdf);
+ this.setSettingPath_(
'margins.available', this.documentSettings.isModifiable);
this.setSettingPath_(
'customMargins.available', this.documentSettings.isModifiable);
@@ -784,22 +791,20 @@ Polymer({
// Otherwise, availability depends on the margins.
let available = false;
const marginsType =
- /** @type {!print_preview.ticket_items.MarginsTypeValue} */ (
+ /** @type {!print_preview.MarginsType} */ (
this.getSettingValue('margins'));
switch (marginsType) {
- case print_preview.ticket_items.MarginsTypeValue.DEFAULT:
+ case print_preview.MarginsType.DEFAULT:
available = !this.margins ||
- this.margins.get(
- print_preview.ticket_items.CustomMarginsOrientation.TOP) > 0 ||
- this.margins.get(
- print_preview.ticket_items.CustomMarginsOrientation.BOTTOM) > 0;
+ this.margins.get(print_preview.CustomMarginsOrientation.TOP) > 0 ||
+ this.margins.get(print_preview.CustomMarginsOrientation.BOTTOM) > 0;
break;
- case print_preview.ticket_items.MarginsTypeValue.NO_MARGINS:
+ case print_preview.MarginsType.NO_MARGINS:
break;
- case print_preview.ticket_items.MarginsTypeValue.MINIMUM:
+ case print_preview.MarginsType.MINIMUM:
available = true;
break;
- case print_preview.ticket_items.MarginsTypeValue.CUSTOM:
+ case print_preview.MarginsType.CUSTOM:
const margins = this.getSettingValue('customMargins');
available = margins.marginTop > 0 || margins.marginBottom > 0;
break;
@@ -1017,21 +1022,14 @@ Polymer({
},
applyStickySettings: function() {
- const defaultScaling = '100';
if (this.stickySettings_) {
STICKY_SETTING_NAMES.forEach(settingName => {
const setting = this.get(settingName, this.settings);
const value = this.stickySettings_[setting.key];
if (value != undefined) {
this.setSetting(settingName, value);
- } else if (
- settingName === 'customScaling' &&
- !!this.stickySettings_['scaling']) {
- // If users with an old set of sticky settings intentionally set a non
- // default value, set customScaling to true so the value is restored.
- // Otherwise, set to false with noSticky=true.
- const scalingIsDefault = this.stickySettings_['scaling'] === '100';
- this.setSetting(settingName, !scalingIsDefault, scalingIsDefault);
+ } else {
+ this.applyScalingStickySettings_(settingName);
}
});
}
@@ -1052,6 +1050,39 @@ Polymer({
this.fire('sticky-settings-changed', this.getStickySettings_());
},
+ /**
+ * Helper function for applyStickySettings(). Checks if the setting
+ * is a scaling setting and applies by applying the old types
+ * that rely on 'fitToPage' and 'customScaling'.
+ * @param {string} settingName Name of the setting being applied.
+ * @private
+ */
+ applyScalingStickySettings_: function(settingName) {
+ // TODO(dhoss): Remove checks for 'customScaling' and 'fitToPage'
+ if (settingName === 'scalingType' &&
+ 'customScaling' in this.stickySettings_) {
+ const isCustom = this.stickySettings_['customScaling'];
+ const scalingType = isCustom ? print_preview.ScalingType.CUSTOM :
+ print_preview.ScalingType.DEFAULT;
+ this.setSetting(settingName, scalingType);
+ } else if (settingName === 'scalingTypePdf') {
+ if ('isFitToPageEnabled' in this.stickySettings_) {
+ const isFitToPage = this.stickySettings_['isFitToPageEnabled'];
+ const scalingTypePdf = isFitToPage ?
+ print_preview.ScalingType.FIT_TO_PAGE :
+ this.getSetting('scalingType').value;
+ this.setSetting(settingName, scalingTypePdf);
+ } else if (
+ this.getSetting('scalingType').value ===
+ print_preview.ScalingType.CUSTOM) {
+ // In the event that 'isFitToPageEnabled' was not in the sticky
+ // settings, and 'scalingType' has been set to custom, we want
+ // 'scalingTypePdf' to match.
+ this.setSetting(settingName, print_preview.ScalingType.CUSTOM);
+ }
+ }
+ },
+
// <if expr="chromeos">
/**
* Restricts settings and applies defaults as defined by policy applicable to
@@ -1066,7 +1097,7 @@ Polymer({
// We want to set the value nevertheless so we call |this.set| directly.
this.set(
'settings.color.value',
- colorValue == print_preview.ColorModeRestriction.COLOR);
+ colorValue === print_preview.ColorModeRestriction.COLOR);
}
this.set('settings.color.setByPolicy', !!colorPolicy);
@@ -1093,7 +1124,7 @@ Polymer({
!!duplexPolicy && setDuplexTypeByPolicy);
const pinPolicy = this.destination.pinPolicy;
- if (pinPolicy == print_preview.PinModeRestriction.NO_PIN) {
+ if (pinPolicy === print_preview.PinModeRestriction.NO_PIN) {
this.set('settings.pin.available', false);
this.set('settings.pinValue.available', false);
}
@@ -1101,10 +1132,22 @@ Polymer({
if (pinValue) {
this.set(
'settings.pin.value',
- pinValue == print_preview.PinModeRestriction.PIN);
+ pinValue === print_preview.PinModeRestriction.PIN);
}
this.set('settings.pin.setByPolicy', !!pinPolicy);
+ const backgroundGraphicsPolicy = this.destination.backgroundGraphicsPolicy;
+ const backgroundGraphicsValue = backgroundGraphicsPolicy ?
+ backgroundGraphicsPolicy :
+ this.destination.defaultBackgroundGraphicsPolicy;
+ if (backgroundGraphicsValue) {
+ this.set(
+ 'settings.cssBackground.value',
+ backgroundGraphicsValue ===
+ print_preview.BackgroundGraphicsModeRestriction.ENABLED);
+ }
+ this.set('settings.cssBackground.setByPolicy', !!backgroundGraphicsPolicy);
+
this.updateManaged_();
},
// </if>
@@ -1113,8 +1156,8 @@ Polymer({
updateManaged_: function() {
let managedSettings = ['headerFooter'];
// <if expr="chromeos">
- managedSettings =
- managedSettings.concat(['color', 'duplex', 'duplexShortEdge', 'pin']);
+ managedSettings = managedSettings.concat(
+ ['color', 'cssBackground', 'duplex', 'duplexShortEdge', 'pin']);
// </if>
this.controlsManaged = managedSettings.some(settingName => {
const setting = this.getSetting(settingName);
@@ -1191,6 +1234,9 @@ Polymer({
vendor_id: (number | undefined)}}
*/
(this.getSettingValue('dpi'));
+ const scalingSettingKey = this.getSetting('scalingTypePdf').available ?
+ 'scalingTypePdf' :
+ 'scalingType';
const ticket = {
mediaSize: this.getSettingValue('mediaSize'),
pageCount: this.getSettingValue('pages').length,
@@ -1205,23 +1251,20 @@ Polymer({
shouldPrintBackgrounds: this.getSettingValue('cssBackground'),
shouldPrintSelectionOnly: false, // only used in print preview
previewModifiable: this.documentSettings.isModifiable,
- printToPDF: destination.id ==
- print_preview.Destination.GooglePromotedId.SAVE_AS_PDF,
printToGoogleDrive:
destination.id == print_preview.Destination.GooglePromotedId.DOCS,
- printWithCloudPrint: !destination.isLocal,
- printWithPrivet: destination.isPrivet,
- printWithExtension: destination.isExtension,
+ printerType: print_preview.getPrinterTypeForDestination(destination),
rasterizePDF: this.getSettingValue('rasterize'),
- scaleFactor: this.getSettingValue('customScaling') ?
+ scaleFactor: this.getSettingValue(scalingSettingKey) ===
+ print_preview.ScalingType.CUSTOM ?
parseInt(this.getSettingValue('scaling'), 10) :
100,
+ scalingType: this.getSettingValue(scalingSettingKey),
pagesPerSheet: this.getSettingValue('pagesPerSheet'),
dpiHorizontal: (dpi && 'horizontal_dpi' in dpi) ? dpi.horizontal_dpi : 0,
dpiVertical: (dpi && 'vertical_dpi' in dpi) ? dpi.vertical_dpi : 0,
dpiDefault: (dpi && 'is_default' in dpi) ? dpi.is_default : false,
deviceName: destination.id,
- fitToPageEnabled: this.getSettingValue('fitToPage'),
pageWidth: this.pageSize.width,
pageHeight: this.pageSize.height,
showSystemDialog: showSystemDialog,
@@ -1232,8 +1275,7 @@ Polymer({
ticket.cloudPrintID = destination.id;
}
- if (this.getSettingValue('margins') ==
- print_preview.ticket_items.MarginsTypeValue.CUSTOM) {
+ if (this.getSettingValue('margins') == print_preview.MarginsType.CUSTOM) {
ticket.marginsCustom = this.getSettingValue('customMargins');
}
@@ -1252,6 +1294,9 @@ Polymer({
if (this.getSettingValue('pin')) {
ticket.pinValue = this.getSettingValue('pinValue');
}
+ if (destination.origin == print_preview.DestinationOrigin.CROS) {
+ ticket.advancedSettings = this.getSettingValue('vendorItems');
+ }
// </if>
return JSON.stringify(ticket);
diff --git a/chromium/chrome/browser/resources/print_preview/data/scaling.html b/chromium/chrome/browser/resources/print_preview/data/scaling.html
new file mode 100644
index 00000000000..cbaac092c4e
--- /dev/null
+++ b/chromium/chrome/browser/resources/print_preview/data/scaling.html
@@ -0,0 +1,3 @@
+<link rel="import" href="chrome://resources/html/cr.html">
+
+<script src="scaling.js"></script>
diff --git a/chromium/chrome/browser/resources/print_preview/data/scaling.js b/chromium/chrome/browser/resources/print_preview/data/scaling.js
new file mode 100644
index 00000000000..49c8d5b912d
--- /dev/null
+++ b/chromium/chrome/browser/resources/print_preview/data/scaling.js
@@ -0,0 +1,24 @@
+// Copyright (c) 2019 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+cr.define('print_preview', function() {
+ 'use strict';
+
+ /**
+ * Must be kept in sync with the C++ ScalingType enum in
+ * printing/print_job_constants.h.
+ * @enum {number}
+ */
+ const ScalingType = {
+ DEFAULT: 0,
+ FIT_TO_PAGE: 1,
+ FIT_TO_PAPER: 2,
+ CUSTOM: 3,
+ };
+
+ // Export
+ return {
+ ScalingType: ScalingType,
+ };
+});
diff --git a/chromium/chrome/browser/resources/print_preview/native_layer.js b/chromium/chrome/browser/resources/print_preview/native_layer.js
index ddf522abeb6..8a5abc38989 100644
--- a/chromium/chrome/browser/resources/print_preview/native_layer.js
+++ b/chromium/chrome/browser/resources/print_preview/native_layer.js
@@ -37,6 +37,7 @@ cr.define('print_preview', function() {
* decimalDelimiter: string,
* unitType: !print_preview.MeasurementSystemUnitType,
* previewModifiable: boolean,
+ * previewIsPdf: boolean,
* documentTitle: string,
* documentHasSelection: boolean,
* shouldPrintSelectionOnly: boolean,
@@ -98,19 +99,6 @@ cr.define('print_preview', function() {
let ProvisionalDestinationInfo;
/**
- * Printer types for capabilities and printer list requests.
- * Should match PrinterType in print_preview_handler.h
- * @enum {number}
- */
- const PrinterType = {
- PRIVET_PRINTER: 0,
- EXTENSION_PRINTER: 1,
- PDF_PRINTER: 2,
- LOCAL_PRINTER: 3,
- CLOUD_PRINTER: 4
- };
-
- /**
* An interface to the native Chromium printing system layer.
*/
class NativeLayer {
@@ -329,7 +317,6 @@ cr.define('print_preview', function() {
NativeLayer: NativeLayer,
PreviewSettings: PreviewSettings,
PrinterSetupResponse: PrinterSetupResponse,
- PrinterType: PrinterType,
PrivetPrinterDescription: PrivetPrinterDescription,
ProvisionalDestinationInfo: ProvisionalDestinationInfo,
};
diff --git a/chromium/chrome/browser/resources/print_preview/polymer3/demo.js b/chromium/chrome/browser/resources/print_preview/polymer3/demo.js
index 39a1b1bc694..7e062bfa5e7 100644
--- a/chromium/chrome/browser/resources/print_preview/polymer3/demo.js
+++ b/chromium/chrome/browser/resources/print_preview/polymer3/demo.js
@@ -2,33 +2,68 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+import 'chrome://resources/cr_components/managed_footnote/managed_footnote.m.js';
+import 'chrome://resources/cr_elements/action_link_css.m.js';
+import 'chrome://resources/cr_elements/cr_action_menu/cr_action_menu.m.js';
import 'chrome://resources/cr_elements/cr_button/cr_button.m.js';
import 'chrome://resources/cr_elements/cr_checkbox/cr_checkbox.m.js';
import 'chrome://resources/cr_elements/cr_dialog/cr_dialog.m.js';
import 'chrome://resources/cr_elements/cr_drawer/cr_drawer.m.js';
+import 'chrome://resources/cr_elements/cr_expand_button/cr_expand_button.m.js';
import 'chrome://resources/cr_elements/cr_icon_button/cr_icon_button.m.js';
import 'chrome://resources/cr_elements/cr_input/cr_input.m.js';
+import 'chrome://resources/cr_elements/cr_lazy_render/cr_lazy_render.m.js';
+import 'chrome://resources/cr_elements/cr_link_row/cr_link_row.m.js';
import 'chrome://resources/cr_elements/cr_radio_button/cr_radio_button.m.js';
import 'chrome://resources/cr_elements/cr_radio_group/cr_radio_group.m.js';
import 'chrome://resources/cr_elements/cr_search_field/cr_search_field.m.js';
import 'chrome://resources/cr_elements/cr_tabs/cr_tabs.m.js';
import 'chrome://resources/cr_elements/cr_toast/cr_toast.m.js';
import 'chrome://resources/cr_elements/cr_toggle/cr_toggle.m.js';
+import 'chrome://resources/cr_elements/cr_toolbar/cr_toolbar.m.js';
import 'chrome://resources/cr_elements/icons.m.js';
import 'chrome://resources/cr_elements/md_select_css.m.js';
+import 'chrome://resources/cr_elements/policy/cr_tooltip_icon.m.js';
+import 'chrome://resources/js/action_link.js';
import 'chrome://resources/polymer/v3_0/iron-icon/iron-icon.js';
+import '../strings.m.js';
+import * as crToastManager from 'chrome://resources/cr_elements/cr_toast/cr_toast_manager.m.js';
import {html, PolymerElement} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js';
class HelloPolymer3Element extends PolymerElement {
static get template() {
return html`
- <style include="md-select">
+ <style include="md-select action-link">
cr-toggle {
display: inline-block;
}
+
+ cr-icon-button {
+ --cr-icon-button-color: white;
+ }
+
+ .setting {
+ align-items: center;
+ display: flex;
+ }
+
+ div, cr-input, select, cr-checkbox {
+ margin-top: 20px;
+ }
</style>
+ <cr-toolbar id="toolbar" page-name="Polymer 3 Demo"
+ search-prompt="Search">
+ <cr-icon-button iron-icon="cr:more-vert" on-click="showActionMenu_">
+ </cr-icon-button>
+ </cr-toolbar>
+ <cr-action-menu>
+ <button class="dropdown-item">Hello</button>
+ <button class="dropdown-item">Action</button>
+ <button class="dropdown-item">Menu</button>
+ </cr-action-menu>
+
<cr-checkbox checked="{{checkboxChecked_}}">
[[checkboxChecked_]]
</cr-checkbox>
@@ -47,8 +82,6 @@ class HelloPolymer3Element extends PolymerElement {
<cr-input></cr-input>
- <cr-icon-button iron-icon="cr:more-vert"></cr-icon-button>
-
<div>
<cr-button on-click="onClick_">Show toast</cr-button>
<cr-toast><span>I am toasted</span></cr-toast>
@@ -86,14 +119,49 @@ class HelloPolymer3Element extends PolymerElement {
<div>
<cr-button on-click="showDialog_">Click to open dialog</cr-button>
- <cr-dialog id="dialog">
- <div slot="title">I am a dialog</div>
- </cr-dialog>
+ <cr-lazy-render id="dialog">
+ <template>
+ <cr-dialog>
+ <div slot="title">I am a dialog</div>
+ </cr-dialog>
+ </template>
+ </cr-lazy-render>
</div>
<div>
<cr-search-field label="test search field"></cr-search-field>
+ </div>
+
<div>
+ <cr-expand-button on-click="onExpand_">Expand</cr-expand-button>
+ <div hidden$="[[!expanded_]]">Expanded content</div>
+ </div>
+
+ <div class="setting">
+ <span>Some setting</span>
+ <cr-tooltip-icon tooltip-text="This setting is controlled by policy"
+ icon-class="cr20:domain"
+ icon-aria-label="This setting is controlled by policy">
+ </cr-tooltip-icon>
+ <cr-toggle disabled checked></cr-toggle>
+ </div>
+
+ <div>
+ <cr-link-row class="hr" label="Hello Link Row"></cr-link-row>
+ </div>
+
+ <a is="action-link">I am an action link</a>
+
+ <div>
+ <cr-toast-manager></cr-toast-manager>
+ <cr-button on-click="showToastWithManager_">
+ Show toast for 2s
+ </cr-button>
+ </div>
+
+ <div>
+ <managed-footnote></managed-footnote>
+ </div>
`;
}
@@ -106,6 +174,12 @@ class HelloPolymer3Element extends PolymerElement {
checkboxChecked_: Boolean,
/** @private */
+ expanded_: {
+ type: Boolean,
+ value: false,
+ },
+
+ /** @private */
selectedSubpage_: {
type: Number,
value: 0,
@@ -116,6 +190,12 @@ class HelloPolymer3Element extends PolymerElement {
type: Array,
value: () => (['A', 'B']),
},
+
+ /** @private */
+ isFirst_: {
+ type: Boolean,
+ value: true,
+ },
};
}
@@ -131,7 +211,7 @@ class HelloPolymer3Element extends PolymerElement {
/** @private */
showDialog_() {
- this.shadowRoot.querySelector('cr-dialog').showModal();
+ this.shadowRoot.querySelector('#dialog').get().showModal();
}
/**
@@ -149,6 +229,28 @@ class HelloPolymer3Element extends PolymerElement {
isTabBSelected_() {
return this.selectedSubpage_ === 1;
}
+
+ /** @private */
+ onExpand_() {
+ this.expanded_ = !this.expanded_;
+ }
+
+ /**
+ * @param {!Event} e
+ * @private
+ */
+ showActionMenu_(e) {
+ this.shadowRoot.querySelector('cr-action-menu').showAt(e.target);
+ }
+
+ /** @private */
+ showToastWithManager_() {
+ const toastManager = crToastManager.getInstance();
+ toastManager.duration = 2000;
+ toastManager.show(
+ 'I am toasted ' + (this.isFirst_ ? 'first' : 'second'), false);
+ this.isFirst_ = !this.isFirst_;
+ }
} // class HelloPolymer3
customElements.define('hello-polymer3', HelloPolymer3Element);
diff --git a/chromium/chrome/browser/resources/print_preview/print_preview_resources.grd b/chromium/chrome/browser/resources/print_preview/print_preview_resources.grd
index 41d460f7452..25005669658 100644
--- a/chromium/chrome/browser/resources/print_preview/print_preview_resources.grd
+++ b/chromium/chrome/browser/resources/print_preview/print_preview_resources.grd
@@ -145,6 +145,12 @@
<structure name="IDR_PRINT_PREVIEW_DATA_DOCUMENT_INFO_JS"
file="data/document_info.js"
type="chrome_html" />
+ <structure name="IDR_PRINT_PREVIEW_DATA_SCALING_HTML"
+ file="data/scaling.html"
+ type="chrome_html" />
+ <structure name="IDR_PRINT_PREVIEW_DATA_SCALING_JS"
+ file="data/scaling.js"
+ type="chrome_html" />
<structure name="IDR_PRINT_PREVIEW_DATA_SIZE_HTML"
file="data/size.html"
type="chrome_html" />
@@ -432,8 +438,8 @@
<structure name="IDR_PRINT_PREVIEW_UI_STRINGS_HTML"
file="ui/strings.html"
type="chrome_html" />
- <structure name="IDR_PRINT_PREVIEW_ICONS_HTML"
- file="icons.html"
+ <structure name="IDR_PRINT_PREVIEW_UI_ICONS_HTML"
+ file="ui/icons.html"
type="chrome_html" />
<if expr="not optimize_webui">
diff --git a/chromium/chrome/browser/resources/print_preview/print_preview_utils.js b/chromium/chrome/browser/resources/print_preview/print_preview_utils.js
index 009f602c06e..cf7256fbce1 100644
--- a/chromium/chrome/browser/resources/print_preview/print_preview_utils.js
+++ b/chromium/chrome/browser/resources/print_preview/print_preview_utils.js
@@ -59,7 +59,7 @@ function observerDepsDefined(args) {
/**
* Returns background images (icon and dropdown arrow) for use in a md-select.
- * @param {!Polymer.IronIconsetSvg} iconset The iconset the icon is in.
+ * @param {!IronIconsetSvgElement} iconset The iconset the icon is in.
* @param {string} iconName The icon name
* @param {!HTMLElement} el The element that contains the select.
* @return {string} String containing inlined SVG of the icon and
diff --git a/chromium/chrome/browser/resources/print_preview/ui/BUILD.gn b/chromium/chrome/browser/resources/print_preview/ui/BUILD.gn
index 488bf4143ba..5b144bb14df 100644
--- a/chromium/chrome/browser/resources/print_preview/ui/BUILD.gn
+++ b/chromium/chrome/browser/resources/print_preview/ui/BUILD.gn
@@ -151,10 +151,10 @@ js_library("destination_select") {
":select_behavior",
"..:print_preview_utils",
"../data:destination",
+ "//third_party/polymer/v1_0/components-chromium/iron-iconset-svg:iron-iconset-svg-extracted",
"//third_party/polymer/v1_0/components-chromium/iron-meta:iron-meta-extracted",
"//ui/webui/resources/js:i18n_behavior",
]
- externs_list = [ "$externs_path/pending.js" ]
}
if (is_chromeos) {
@@ -232,6 +232,7 @@ js_library("scaling_settings") {
deps = [
":number_settings_section",
":settings_behavior",
+ "../data:scaling",
]
}
@@ -246,8 +247,8 @@ js_library("duplex_settings") {
":select_behavior",
":settings_behavior",
"..:print_preview_utils",
+ "//third_party/polymer/v1_0/components-chromium/iron-iconset-svg:iron-iconset-svg-extracted",
]
- externs_list = [ "$externs_path/pending.js" ]
}
js_library("advanced_options_settings") {
@@ -317,6 +318,7 @@ js_library("preview_area") {
"../../pdf:pdf_scripting_api",
"../data:coordinate2d",
"../data:destination",
+ "../data:destination_match",
"../data:margins",
"../data:model",
"../data:printable_area",
@@ -376,6 +378,7 @@ js_library("destination_dialog") {
"//ui/webui/resources/js:i18n_behavior",
"//ui/webui/resources/js:list_property_update_behavior",
]
+ externs_list = [ "$externs_path/pending_polymer.js" ]
}
js_library("destination_list") {
diff --git a/chromium/chrome/browser/resources/print_preview/ui/advanced_options_settings.html b/chromium/chrome/browser/resources/print_preview/ui/advanced_options_settings.html
index 4cffcd9b8e9..ec2c7ba8213 100644
--- a/chromium/chrome/browser/resources/print_preview/ui/advanced_options_settings.html
+++ b/chromium/chrome/browser/resources/print_preview/ui/advanced_options_settings.html
@@ -10,6 +10,7 @@
<template>
<style include="print-preview-shared">
cr-button {
+ height: fit-content;
min-height: 32px;
text-align: center;
width: calc(100% - 2 * var(--print-preview-sidebar-margin));
diff --git a/chromium/chrome/browser/resources/print_preview/ui/advanced_settings_item.html b/chromium/chrome/browser/resources/print_preview/ui/advanced_settings_item.html
index 2dd7432984d..396e8525c4f 100644
--- a/chromium/chrome/browser/resources/print_preview/ui/advanced_settings_item.html
+++ b/chromium/chrome/browser/resources/print_preview/ui/advanced_settings_item.html
@@ -1,6 +1,7 @@
<link rel="import" href="chrome://resources/html/polymer.html">
<link rel="import" href="chrome://resources/cr_elements/hidden_style_css.html">
+<link rel="import" href="chrome://resources/cr_elements/cr_checkbox/cr_checkbox.html">
<link rel="import" href="chrome://resources/cr_elements/cr_input/cr_input.html">
<link rel="import" href="chrome://resources/cr_elements/search_highlight_style_css.html">
<link rel="import" href="chrome://resources/cr_elements/shared_vars_css.html">
@@ -76,11 +77,16 @@
</select>
</div>
</template>
- <span hidden$="[[isCapabilityTypeSelect_(capability)]]">
+ <span hidden$="[[!isCapabilityTypeInput_(capability)]]">
<cr-input type="text" on-input="onUserInput_" spellcheck="false"
placeholder="[[getCapabilityPlaceholder_(capability)]]">
</cr-input>
</span>
+ <span hidden$="[[!isCapabilityTypeCheckbox_(capability)]]">
+ <cr-checkbox on-change="onCheckboxInput_"
+ checked="[[isChecked_(currentValue_)]]">
+ </cr-checkbox>
+ </span>
</div>
</template>
<script src="advanced_settings_item.js"></script>
diff --git a/chromium/chrome/browser/resources/print_preview/ui/advanced_settings_item.js b/chromium/chrome/browser/resources/print_preview/ui/advanced_settings_item.js
index 4b01e0ef35f..56450e98237 100644
--- a/chromium/chrome/browser/resources/print_preview/ui/advanced_settings_item.js
+++ b/chromium/chrome/browser/resources/print_preview/ui/advanced_settings_item.js
@@ -67,6 +67,33 @@ Polymer({
},
/**
+ * @return {boolean} Whether the capability represented by this item is
+ * of type checkbox.
+ * @private
+ */
+ isCapabilityTypeCheckbox_: function() {
+ return this.capability.type == 'TYPED_VALUE' &&
+ this.capability.typed_value_cap.value_type == 'BOOLEAN';
+ },
+
+ /**
+ * @return {boolean} Whether the capability represented by this item is
+ * of type input.
+ * @private
+ */
+ isCapabilityTypeInput_: function() {
+ return !this.isCapabilityTypeSelect_() && !this.isCapabilityTypeCheckbox_();
+ },
+
+ /**
+ * @return {boolean} Whether the checkbox setting is checked.
+ * @private
+ */
+ isChecked_: function() {
+ return this.currentValue_ == 'true';
+ },
+
+ /**
* @param {!print_preview.VendorCapabilitySelectOption} option The option
* for a select capability.
* @return {boolean} Whether the option is selected.
@@ -137,6 +164,14 @@ Polymer({
},
/**
+ * @param {!Event} e Event containing the new value.
+ * @private
+ */
+ onCheckboxInput_: function(e) {
+ this.currentValue_ = e.target.checked ? 'true' : 'false';
+ },
+
+ /**
* @return {string} The current value of the setting, or the empty string if
* it is not set.
*/
diff --git a/chromium/chrome/browser/resources/print_preview/ui/app.html b/chromium/chrome/browser/resources/print_preview/ui/app.html
index 2e5816ecc93..d5ad5503a1a 100644
--- a/chromium/chrome/browser/resources/print_preview/ui/app.html
+++ b/chromium/chrome/browser/resources/print_preview/ui/app.html
@@ -73,7 +73,8 @@
cloud-print-error-message="[[cloudPrintErrorMessage_]]"
destination-state="{{destinationState_}}"
controls-managed="[[controlsManaged_]]" destination="{{destination_}}"
- error="{{error_}}" new-print-preview-layout="[[newPrintPreviewLayout_]]"
+ error="{{error_}}" is-pdf="[[documentSettings_.isPdf]]"
+ new-print-preview-layout="[[newPrintPreviewLayout_]]"
page-count="[[documentSettings_.pageCount]]"
settings="[[settings]]" state="[[state]]" on-focus="onSidebarFocus_"
<if expr="is_macosx">
diff --git a/chromium/chrome/browser/resources/print_preview/ui/app.js b/chromium/chrome/browser/resources/print_preview/ui/app.js
index 8f30d4e6358..ccd7ca5e5e7 100644
--- a/chromium/chrome/browser/resources/print_preview/ui/app.js
+++ b/chromium/chrome/browser/resources/print_preview/ui/app.js
@@ -266,8 +266,8 @@ Polymer({
settings.uiLocale);
}
this.$.documentInfo.init(
- settings.previewModifiable, settings.documentTitle,
- settings.documentHasSelection);
+ settings.previewModifiable, settings.previewIsPdf,
+ settings.documentTitle, settings.documentHasSelection);
this.$.model.setStickySettings(settings.serializedAppStateStr);
this.$.model.setPolicySettings(
settings.headerFooter, settings.isHeaderFooterManaged);
diff --git a/chromium/chrome/browser/resources/print_preview/ui/destination_dialog.html b/chromium/chrome/browser/resources/print_preview/ui/destination_dialog.html
index a941dae7276..a9f91768268 100644
--- a/chromium/chrome/browser/resources/print_preview/ui/destination_dialog.html
+++ b/chromium/chrome/browser/resources/print_preview/ui/destination_dialog.html
@@ -16,7 +16,7 @@
<link rel="import" href="chrome://resources/html/list_property_update_behavior.html">
<link rel="import" href="chrome://resources/cr_elements/md_select_css.html">
<link rel="import" href="chrome://resources/polymer/v1_0/iron-icon/iron-icon.html">
-<link rel="import" href="../icons.html">
+<link rel="import" href="icons.html">
<link rel="import" href="../metrics.html">
<link rel="import" href="../native_layer.html">
<link rel="import" href="../print_preview_utils.html">
@@ -166,7 +166,8 @@
</select>
</div>
<print-preview-search-box id="searchBox"
- label="$i18n{searchBoxPlaceholder}" search-query="{{searchQuery_}}">
+ label="$i18n{searchBoxPlaceholder}" search-query="{{searchQuery_}}"
+ autofocus>
</print-preview-search-box>
</div>
<div slot="body">
diff --git a/chromium/chrome/browser/resources/print_preview/ui/destination_dialog.js b/chromium/chrome/browser/resources/print_preview/ui/destination_dialog.js
index 5c30560c050..06dabe3874a 100644
--- a/chromium/chrome/browser/resources/print_preview/ui/destination_dialog.js
+++ b/chromium/chrome/browser/resources/print_preview/ui/destination_dialog.js
@@ -287,12 +287,6 @@ Polymer({
show: function() {
this.$.dialog.showModal();
- // Note: Manually focusing here instead of using autofocus, as it is
- // currently not possible to validate refocusing of the search input if
- // autofocus is used. See https://crbug.com/985637 and
- // https://crbug.com/985636. Autofocus can be restored when one or both of
- // these issues are resolved.
- this.$.searchBox.focus();
this.loadingDestinations_ = this.destinationStore === undefined ||
this.destinationStore.isPrintDestinationSearchInProgress;
this.metrics_.record(
diff --git a/chromium/chrome/browser/resources/print_preview/ui/destination_list_item.html b/chromium/chrome/browser/resources/print_preview/ui/destination_list_item.html
index 5e6056eb752..2a98fe8fd59 100644
--- a/chromium/chrome/browser/resources/print_preview/ui/destination_list_item.html
+++ b/chromium/chrome/browser/resources/print_preview/ui/destination_list_item.html
@@ -6,7 +6,7 @@
<link rel="import" href="chrome://resources/html/cr.html">
<link rel="import" href="chrome://resources/html/load_time_data.html">
<link rel="import" href="chrome://resources/polymer/v1_0/iron-icon/iron-icon.html">
-<link rel="import" href="../icons.html">
+<link rel="import" href="icons.html">
<link rel="import" href="../data/destination.html">
<link rel="import" href="highlight_utils.html">
<link rel="import" href="print_preview_vars_css.html">
diff --git a/chromium/chrome/browser/resources/print_preview/ui/destination_select.html b/chromium/chrome/browser/resources/print_preview/ui/destination_select.html
index 2b7cb3cec17..2438ba0e47b 100644
--- a/chromium/chrome/browser/resources/print_preview/ui/destination_select.html
+++ b/chromium/chrome/browser/resources/print_preview/ui/destination_select.html
@@ -7,7 +7,7 @@
<link rel="import" href="chrome://resources/html/util.html">
<link rel="import" href="chrome://resources/polymer/v1_0/iron-iconset-svg/iron-iconset-svg.html">
<link rel="import" href="chrome://resources/polymer/v1_0/iron-meta/iron-meta.html">
-<link rel="import" href="../icons.html">
+<link rel="import" href="icons.html">
<link rel="import" href="../print_preview_utils.html">
<link rel="import" href="../data/destination.html">
<link rel="import" href="print_preview_shared_css.html">
diff --git a/chromium/chrome/browser/resources/print_preview/ui/destination_select.js b/chromium/chrome/browser/resources/print_preview/ui/destination_select.js
index 2c68355bd2a..d725445e819 100644
--- a/chromium/chrome/browser/resources/print_preview/ui/destination_select.js
+++ b/chromium/chrome/browser/resources/print_preview/ui/destination_select.js
@@ -76,7 +76,7 @@ Polymer({
}
// </if>
iconSetAndIcon = iconSetAndIcon || icon.split(':');
- const iconset = /** @type {!Polymer.IronIconsetSvg} */ (
+ const iconset = /** @type {!IronIconsetSvgElement} */ (
this.meta_.byKey(iconSetAndIcon[0]));
return getSelectDropdownBackground(iconset, iconSetAndIcon[1], this);
},
diff --git a/chromium/chrome/browser/resources/print_preview/ui/duplex_settings.html b/chromium/chrome/browser/resources/print_preview/ui/duplex_settings.html
index a1382d8bc8d..c1393ed1e50 100644
--- a/chromium/chrome/browser/resources/print_preview/ui/duplex_settings.html
+++ b/chromium/chrome/browser/resources/print_preview/ui/duplex_settings.html
@@ -6,7 +6,7 @@
<link rel="import" href="chrome://resources/html/util.html">
<link rel="import" href="chrome://resources/polymer/v1_0/iron-iconset-svg/iron-iconset-svg.html">
<link rel="import" href="chrome://resources/polymer/v1_0/iron-meta/iron-meta.html">
-<link rel="import" href="../icons.html">
+<link rel="import" href="icons.html">
<link rel="import" href="../print_preview_utils.html">
<link rel="import" href="print_preview_shared_css.html">
<link rel="import" href="select_behavior.html">
diff --git a/chromium/chrome/browser/resources/print_preview/ui/duplex_settings.js b/chromium/chrome/browser/resources/print_preview/ui/duplex_settings.js
index 167c1fc7342..22b0820adf3 100644
--- a/chromium/chrome/browser/resources/print_preview/ui/duplex_settings.js
+++ b/chromium/chrome/browser/resources/print_preview/ui/duplex_settings.js
@@ -81,7 +81,7 @@ Polymer({
getBackgroundImages_: function() {
const icon =
this.getSettingValue('duplexShortEdge') ? 'short-edge' : 'long-edge';
- const iconset = /** @type {!Polymer.IronIconsetSvg} */ (
+ const iconset = /** @type {!IronIconsetSvgElement} */ (
this.meta_.byKey('print-preview'));
return getSelectDropdownBackground(iconset, icon, this);
},
diff --git a/chromium/chrome/browser/resources/print_preview/ui/header.html b/chromium/chrome/browser/resources/print_preview/ui/header.html
index 8e92fdd887f..0b9152f23a7 100644
--- a/chromium/chrome/browser/resources/print_preview/ui/header.html
+++ b/chromium/chrome/browser/resources/print_preview/ui/header.html
@@ -6,7 +6,7 @@
<link rel="import" href="chrome://resources/polymer/v1_0/iron-icon/iron-icon.html">
<link rel="import" href="../data/destination.html">
<link rel="import" href="../data/state.html">
-<link rel="import" href="../icons.html">
+<link rel="import" href="icons.html">
<link rel="import" href="settings_behavior.html">
<link rel="import" href="print_preview_vars_css.html">
<link rel="import" href="strings.html">
diff --git a/chromium/chrome/browser/resources/print_preview/ui/header_new.html b/chromium/chrome/browser/resources/print_preview/ui/header_new.html
index 9983f9f2b24..6a16578d5b6 100644
--- a/chromium/chrome/browser/resources/print_preview/ui/header_new.html
+++ b/chromium/chrome/browser/resources/print_preview/ui/header_new.html
@@ -5,7 +5,7 @@
<link rel="import" href="chrome://resources/polymer/v1_0/iron-icon/iron-icon.html">
<link rel="import" href="../data/destination.html">
<link rel="import" href="../data/state.html">
-<link rel="import" href="../icons.html">
+<link rel="import" href="icons.html">
<link rel="import" href="settings_behavior.html">
<link rel="import" href="print_preview_vars_css.html">
<link rel="import" href="strings.html">
diff --git a/chromium/chrome/browser/resources/print_preview/icons.html b/chromium/chrome/browser/resources/print_preview/ui/icons.html
index 8cffcf206ad..1f5ce331dc9 100644
--- a/chromium/chrome/browser/resources/print_preview/icons.html
+++ b/chromium/chrome/browser/resources/print_preview/ui/icons.html
@@ -7,20 +7,15 @@
<defs>
<!-- Custom svgs (namratakannan). -->
<g id="printer-shared" viewBox="0 0 106 96">
- <defs>
- <path d="M44 59H32v26h12v11H21.2V74.462H0V42.154C0 33.215 7.102 26 15.9 26h74.2c8.798 0 15.9 7.215 15.9 16.154V59H91.393A15.943 15.943 0 0 0 93 52c0-8.84-7.16-16-16-16s-16 7.16-16 16c0 2.51.578 4.886 1.607 7H44zM84 0H21v22h63V0z" id="a"></path>
- </defs>
- <g fill-rule="nonzero">
- <use xlink:href="#a"></use>
- <path d="M77 68c-9.679 0-29 6.253-29 18.667V96h58v-9.333C106 74.253 86.679 68 77 68zM77 64c6.63 0 12-5.37 12-12s-5.37-12-12-12-12 5.37-12 12 5.37 12 12 12z" fill="#4A93F9"></path>
- </g>
+ <path d="M44 59H32v26h12v11H21.2V74.462H0V42.154C0 33.215 7.102 26 15.9 26h74.2c8.798 0 15.9 7.215 15.9 16.154V59H91.393A15.943 15.943 0 0 0 93 52c0-8.84-7.16-16-16-16s-16 7.16-16 16c0 2.51.578 4.886 1.607 7H44zM84 0H21v22h63V0z"></path>
+ <path d="M77 68c-9.679 0-29 6.253-29 18.667V96h58v-9.333C106 74.253 86.679 68 77 68zM77 64c6.63 0 12-5.37 12-12s-5.37-12-12-12-12 5.37-12 12 5.37 12 12 12z" fill="#4A93F9"></path>
</g>
<g id="short-edge" viewBox="0 0 26 20" fill-rule="evenodd">
- <path d="M2 14v2h2v-2H2zm12 4v2h2v-2h-2zm4 0v2h2v-2h-2zm3.556-18H4.444C3.1 0 2 1.35 2 3v6h2V2h18v7h2V3c0-1.65-1.1-3-2.444-3zM24 18h-2v2c1.1 0 2-.9 2-2zM0 10v2h26v-2H0zm6 8v2h2v-2H6zm16-4v2h2v-2h-2zm-12 4v2h2v-2h-2zm-8 0c0 1.1.9 2 2 2v-2H2z" fill-rule="nonzero">
+ <path d="M2 14v2h2v-2H2zm12 4v2h2v-2h-2zm4 0v2h2v-2h-2zm3.556-18H4.444C3.1 0 2 1.35 2 3v6h2V2h18v7h2V3c0-1.65-1.1-3-2.444-3zM24 18h-2v2c1.1 0 2-.9 2-2zM0 10v2h26v-2H0zm6 8v2h2v-2H6zm16-4v2h2v-2h-2zm-12 4v2h2v-2h-2zm-8 0c0 1.1.9 2 2 2v-2H2z">
<path d="M29-6v32H-3V-6z">
</g>
<g id="long-edge" viewBox="0 0 23 22" fill-rule="evenodd">
- <path d="M17 20h2v-2h-2v2zm4-12h2V6h-2v2zM0 4v14c0 1.1 1.35 2 3 2h6v-2H2V4h7V2H3c-1.65 0-3 .9-3 2zm21-2v2h2c0-1.1-.9-2-2-2zM10 22h2V0h-2v22zm11-6h2v-2h-2v2zM17 4h2V2h-2v2zm-4 16h2v-2h-2v2zm0-16h2V2h-2v2zm8 8h2v-2h-2v2zm0 8c1.1 0 2-.9 2-2h-2v2z" fill-rule="nonzero">
+ <path d="M17 20h2v-2h-2v2zm4-12h2V6h-2v2zM0 4v14c0 1.1 1.35 2 3 2h6v-2H2V4h7V2H3c-1.65 0-3 .9-3 2zm21-2v2h2c0-1.1-.9-2-2-2zM10 22h2V0h-2v22zm11-6h2v-2h-2v2zM17 4h2V2h-2v2zm-4 16h2v-2h-2v2zm0-16h2V2h-2v2zm8 8h2v-2h-2v2zm0 8c1.1 0 2-.9 2-2h-2v2z">
<path d="M-5-5h32v32H-5z">
</g>
diff --git a/chromium/chrome/browser/resources/print_preview/ui/margin_control.js b/chromium/chrome/browser/resources/print_preview/ui/margin_control.js
index 0e9dca3478f..97e8f1bfea2 100644
--- a/chromium/chrome/browser/resources/print_preview/ui/margin_control.js
+++ b/chromium/chrome/browser/resources/print_preview/ui/margin_control.js
@@ -138,7 +138,7 @@ Polymer({
*/
convertPixelsToPts: function(pixels) {
let pts;
- const Orientation = print_preview.ticket_items.CustomMarginsOrientation;
+ const Orientation = print_preview.CustomMarginsOrientation;
if (this.side == Orientation.TOP) {
pts = pixels - this.translateTransform.y + RADIUS_PX;
pts /= this.scaleTransform;
@@ -253,7 +253,7 @@ Polymer({
return;
}
- const Orientation = print_preview.ticket_items.CustomMarginsOrientation;
+ const Orientation = print_preview.CustomMarginsOrientation;
let x = this.translateTransform.x;
let y = this.translateTransform.y;
let width = null;
diff --git a/chromium/chrome/browser/resources/print_preview/ui/margin_control_container.js b/chromium/chrome/browser/resources/print_preview/ui/margin_control_container.js
index b507fc864bb..c675756de45 100644
--- a/chromium/chrome/browser/resources/print_preview/ui/margin_control_container.js
+++ b/chromium/chrome/browser/resources/print_preview/ui/margin_control_container.js
@@ -7,15 +7,13 @@ cr.define('print_preview', function() {
'use strict';
/**
- * @const {!Map<!print_preview.ticket_items.CustomMarginsOrientation, string>}
+ * @const {!Map<!print_preview.CustomMarginsOrientation, string>}
*/
const MARGIN_KEY_MAP = new Map([
- [print_preview.ticket_items.CustomMarginsOrientation.TOP, 'marginTop'],
- [print_preview.ticket_items.CustomMarginsOrientation.RIGHT, 'marginRight'],
- [
- print_preview.ticket_items.CustomMarginsOrientation.BOTTOM, 'marginBottom'
- ],
- [print_preview.ticket_items.CustomMarginsOrientation.LEFT, 'marginLeft']
+ [print_preview.CustomMarginsOrientation.TOP, 'marginTop'],
+ [print_preview.CustomMarginsOrientation.RIGHT, 'marginRight'],
+ [print_preview.CustomMarginsOrientation.BOTTOM, 'marginBottom'],
+ [print_preview.CustomMarginsOrientation.LEFT, 'marginLeft']
]);
/** @const {number} */
@@ -87,16 +85,16 @@ cr.define('print_preview', function() {
},
/**
- * @private {!Array<!print_preview.ticket_items.CustomMarginsOrientation>}
+ * @private {!Array<!print_preview.CustomMarginsOrientation>}
*/
marginSides_: {
type: Array,
notify: true,
value: [
- print_preview.ticket_items.CustomMarginsOrientation.TOP,
- print_preview.ticket_items.CustomMarginsOrientation.RIGHT,
- print_preview.ticket_items.CustomMarginsOrientation.BOTTOM,
- print_preview.ticket_items.CustomMarginsOrientation.LEFT,
+ print_preview.CustomMarginsOrientation.TOP,
+ print_preview.CustomMarginsOrientation.RIGHT,
+ print_preview.CustomMarginsOrientation.BOTTOM,
+ print_preview.CustomMarginsOrientation.LEFT,
],
},
@@ -138,8 +136,7 @@ cr.define('print_preview', function() {
*/
computeAvailable_: function() {
return this.previewLoaded && !!this.clipSize_ &&
- this.getSettingValue('margins') ==
- print_preview.ticket_items.MarginsTypeValue.CUSTOM &&
+ this.getSettingValue('margins') == print_preview.MarginsType.CUSTOM &&
!!this.pageSize;
},
@@ -150,7 +147,7 @@ cr.define('print_preview', function() {
// custom margins were reset.
const newMargins = {};
for (const side of Object.values(
- print_preview.ticket_items.CustomMarginsOrientation)) {
+ print_preview.CustomMarginsOrientation)) {
const key = print_preview.MARGIN_KEY_MAP.get(side);
newMargins[key] = this.documentMargins.get(side);
}
@@ -187,11 +184,9 @@ cr.define('print_preview', function() {
this.resetMargins_ = true;
const marginsSetting = this.getSetting('margins');
- if (marginsSetting.value ==
- print_preview.ticket_items.MarginsTypeValue.CUSTOM) {
+ if (marginsSetting.value == print_preview.MarginsType.CUSTOM) {
// Set the margins value to default first.
- this.setSetting(
- 'margins', print_preview.ticket_items.MarginsTypeValue.DEFAULT);
+ this.setSetting('margins', print_preview.MarginsType.DEFAULT);
}
// Reset custom margins so that the sticky value is not restored for the
// new paper size.
@@ -218,16 +213,14 @@ cr.define('print_preview', function() {
},
/**
- * @param {!print_preview.ticket_items.CustomMarginsOrientation} orientation
+ * @param {!print_preview.CustomMarginsOrientation} orientation
* Orientation value to test.
* @return {boolean} Whether the given orientation is TOP or BOTTOM.
* @private
*/
isTopOrBottom_: function(orientation) {
- return orientation ==
- print_preview.ticket_items.CustomMarginsOrientation.TOP ||
- orientation ==
- print_preview.ticket_items.CustomMarginsOrientation.BOTTOM;
+ return orientation == print_preview.CustomMarginsOrientation.TOP ||
+ orientation == print_preview.CustomMarginsOrientation.BOTTOM;
},
/**
@@ -241,8 +234,7 @@ cr.define('print_preview', function() {
*/
posInPixelsToPts_: function(control, posInPixels) {
const side =
- /** @type {print_preview.ticket_items.CustomMarginsOrientation} */ (
- control.side);
+ /** @type {print_preview.CustomMarginsOrientation} */ (control.side);
return this.clipAndRoundValue_(
side,
control.convertPixelsToPts(
@@ -349,7 +341,7 @@ cr.define('print_preview', function() {
const x = control.offsetLeft;
const y = control.offsetTop;
const isTopOrBottom = this.isTopOrBottom_(
- /** @type {!print_preview.ticket_items.CustomMarginsOrientation} */ (
+ /** @type {!print_preview.CustomMarginsOrientation} */ (
control.side));
const position = {};
// Extra padding, in px, to ensure the full textbox will be visible and
@@ -395,8 +387,7 @@ cr.define('print_preview', function() {
*/
setMargin_: function(side, marginValue) {
const marginSide =
- /** @type {!print_preview.ticket_items.CustomMarginsOrientation} */ (
- side);
+ /** @type {!print_preview.CustomMarginsOrientation} */ (side);
const oldMargins = /** @type {print_preview.MarginsSetting} */ (
this.getSettingValue('customMargins'));
const key = print_preview.MARGIN_KEY_MAP.get(marginSide);
@@ -416,12 +407,11 @@ cr.define('print_preview', function() {
*/
clipAndRoundValue_: function(side, value) {
const marginSide =
- /** @type {!print_preview.ticket_items.CustomMarginsOrientation} */ (
- side);
+ /** @type {!print_preview.CustomMarginsOrientation} */ (side);
if (value < 0) {
return 0;
}
- const Orientation = print_preview.ticket_items.CustomMarginsOrientation;
+ const Orientation = print_preview.CustomMarginsOrientation;
let limit = 0;
const margins = this.getSettingValue('customMargins');
if (marginSide == Orientation.TOP) {
@@ -482,10 +472,9 @@ cr.define('print_preview', function() {
new print_preview.Coordinate2d(e.x, e.y);
this.marginStartPositionInPixels_ =
new print_preview.Coordinate2d(control.offsetLeft, control.offsetTop);
- this.dragging_ =
- this.isTopOrBottom_(
- /** @type {print_preview.ticket_items.CustomMarginsOrientation} */
- (control.side)) ?
+ this.dragging_ = this.isTopOrBottom_(
+ /** @type {print_preview.CustomMarginsOrientation} */
+ (control.side)) ?
'dragging-vertical' :
'dragging-horizontal';
this.listen(control, 'pointercancel', 'onPointerUp_');
diff --git a/chromium/chrome/browser/resources/print_preview/ui/margins_settings.html b/chromium/chrome/browser/resources/print_preview/ui/margins_settings.html
index f02aa28e304..a47ee58145f 100644
--- a/chromium/chrome/browser/resources/print_preview/ui/margins_settings.html
+++ b/chromium/chrome/browser/resources/print_preview/ui/margins_settings.html
@@ -19,16 +19,19 @@
settings.pagesPerSheet.value)]]"
value="{{selectedValue::change}}">
<!-- The order of these options must match the natural order of their
- values, which come from
- print_preview.ticket_items.MarginsTypeValue. -->
- <option value="[[MarginsValue.DEFAULT]]" selected>
+ values, which come from print_preview.MarginsType. -->
+ <option value="[[MarginsTypeEnum.DEFAULT]]" selected>
$i18n{defaultMargins}
</option>
- <option value="[[MarginsValue.NO_MARGINS]]">$i18n{noMargins}</option>
- <option value="[[MarginsValue.MINIMUM]]">
+ <option value="[[MarginsTypeEnum.NO_MARGINS]]">
+ $i18n{noMargins}
+ </option>
+ <option value="[[MarginsTypeEnum.MINIMUM]]">
$i18n{minimumMargins}
</option>
- <option value="[[MarginsValue.CUSTOM]]">$i18n{customMargins}</option>
+ <option value="[[MarginsTypeEnum.CUSTOM]]">
+ $i18n{customMargins}
+ </option>
</select>
</div>
</print-preview-settings-section>
diff --git a/chromium/chrome/browser/resources/print_preview/ui/margins_settings.js b/chromium/chrome/browser/resources/print_preview/ui/margins_settings.js
index 94732b721b3..cd4e0aec72a 100644
--- a/chromium/chrome/browser/resources/print_preview/ui/margins_settings.js
+++ b/chromium/chrome/browser/resources/print_preview/ui/margins_settings.js
@@ -11,14 +11,14 @@ Polymer({
disabled: Boolean,
/** Mirroring the enum so that it can be used from HTML bindings. */
- MarginsValue: Object,
+ MarginsTypeEnum: Object,
},
observers: ['onMarginsSettingChange_(settings.margins.value)'],
/** @override */
ready: function() {
- this.MarginsValue = print_preview.ticket_items.MarginsTypeValue;
+ this.MarginsTypeEnum = print_preview.MarginsType;
},
/**
@@ -27,8 +27,7 @@ Polymer({
*/
onMarginsSettingChange_: function(newValue) {
this.selectedValue =
- /** @type {!print_preview.ticket_items.MarginsTypeValue} */ (newValue)
- .toString();
+ /** @type {!print_preview.MarginsType} */ (newValue).toString();
},
/** @param {string} value The new select value. */
diff --git a/chromium/chrome/browser/resources/print_preview/ui/pages_per_sheet_settings.js b/chromium/chrome/browser/resources/print_preview/ui/pages_per_sheet_settings.js
index d581eeedb72..9753375431a 100644
--- a/chromium/chrome/browser/resources/print_preview/ui/pages_per_sheet_settings.js
+++ b/chromium/chrome/browser/resources/print_preview/ui/pages_per_sheet_settings.js
@@ -19,8 +19,7 @@ Polymer({
*/
onPagesPerSheetSettingChange_: function(newValue) {
this.selectedValue = /** @type {number} */ (newValue).toString();
- this.setSetting(
- 'margins', print_preview.ticket_items.MarginsTypeValue.DEFAULT);
+ this.setSetting('margins', print_preview.MarginsType.DEFAULT);
},
/** @param {string} value The new select value. */
diff --git a/chromium/chrome/browser/resources/print_preview/ui/pin_settings.js b/chromium/chrome/browser/resources/print_preview/ui/pin_settings.js
index e6c1c40346b..8e56e89d2c7 100644
--- a/chromium/chrome/browser/resources/print_preview/ui/pin_settings.js
+++ b/chromium/chrome/browser/resources/print_preview/ui/pin_settings.js
@@ -66,7 +66,7 @@ Polymer({
/** @private */
onCollapseChanged_: function() {
if (this.pinEnabled_) {
- /** @type {!CrInputElement} */ (this.$.pinValue).inputElement.focus();
+ /** @type {!CrInputElement} */ (this.$.pinValue).focusInput();
}
},
diff --git a/chromium/chrome/browser/resources/print_preview/ui/preview_area.html b/chromium/chrome/browser/resources/print_preview/ui/preview_area.html
index ac0d828314d..2696ecfb2a9 100644
--- a/chromium/chrome/browser/resources/print_preview/ui/preview_area.html
+++ b/chromium/chrome/browser/resources/print_preview/ui/preview_area.html
@@ -10,6 +10,7 @@
<link rel="import" href="../dark_mode_behavior.html">
<link rel="import" href="../data/coordinate2d.html">
<link rel="import" href="../data/destination.html">
+<link rel="import" href="../data/destination_match.html">
<link rel="import" href="../data/margins.html">
<link rel="import" href="../data/model.html">
<link rel="import" href="../data/printable_area.html">
diff --git a/chromium/chrome/browser/resources/print_preview/ui/preview_area.js b/chromium/chrome/browser/resources/print_preview/ui/preview_area.js
index 71f038f3955..bee496891ac 100644
--- a/chromium/chrome/browser/resources/print_preview/ui/preview_area.js
+++ b/chromium/chrome/browser/resources/print_preview/ui/preview_area.js
@@ -529,13 +529,12 @@ Polymer({
*/
marginsValid_: function() {
const type = this.getSettingValue('margins');
- if (!Object.values(print_preview.ticket_items.MarginsTypeValue)
- .includes(type)) {
+ if (!Object.values(print_preview.MarginsType).includes(type)) {
// Unrecognized margins type.
return false;
}
- if (type !== print_preview.ticket_items.MarginsTypeValue.CUSTOM) {
+ if (type !== print_preview.MarginsType.CUSTOM) {
return true;
}
@@ -567,11 +566,11 @@ Polymer({
// Margins
const newMarginsType = this.getSettingValue('margins');
if (newMarginsType !== lastTicket.marginsType &&
- newMarginsType !== print_preview.ticket_items.MarginsTypeValue.CUSTOM) {
+ newMarginsType !== print_preview.MarginsType.CUSTOM) {
return true;
}
- if (newMarginsType === print_preview.ticket_items.MarginsTypeValue.CUSTOM) {
+ if (newMarginsType === print_preview.MarginsType.CUSTOM) {
const customMargins =
/** @type {!print_preview.MarginsSetting} */ (
this.getSettingValue('customMargins'));
@@ -595,11 +594,10 @@ Polymer({
}
const customMarginsChanged =
- Object.values(print_preview.ticket_items.CustomMarginsOrientation)
- .some(side => {
- return this.margins.get(side) !==
- customMargins[print_preview.MARGIN_KEY_MAP.get(side)];
- });
+ Object.values(print_preview.CustomMarginsOrientation).some(side => {
+ return this.margins.get(side) !==
+ customMargins[print_preview.MARGIN_KEY_MAP.get(side)];
+ });
if (customMarginsChanged) {
return true;
}
@@ -608,28 +606,25 @@ Polymer({
// Simple settings: ranges, layout, header/footer, pages per sheet, fit to
// page, css background, selection only, rasterize, scaling, dpi
if (!areRangesEqual(
- /** @type {!Array<{from: number, to: number}>} */ (
- this.getSettingValue('ranges')),
- lastTicket.pageRange) ||
+ /** @type {!Array<{from: number, to: number}>} */
+ (this.getSettingValue('ranges')), lastTicket.pageRange) ||
this.getSettingValue('layout') !== lastTicket.landscape ||
this.getColorForTicket_() !== lastTicket.color ||
this.getSettingValue('headerFooter') !==
lastTicket.headerFooterEnabled ||
- this.getSettingValue('fitToPage') !== lastTicket.fitToPageEnabled ||
this.getSettingValue('cssBackground') !==
lastTicket.shouldPrintBackgrounds ||
this.getSettingValue('selectionOnly') !==
lastTicket.shouldPrintSelectionOnly ||
this.getSettingValue('rasterize') !== lastTicket.rasterizePDF ||
- this.getScaleFactorForTicket_() !== lastTicket.scaleFactor) {
+ this.isScalingChanged_(lastTicket)) {
return true;
}
// Pages per sheet. If margins are non-default, wait for the return to
// default margins to trigger a request.
if (this.getSettingValue('pagesPerSheet') !== lastTicket.pagesPerSheet &&
- this.getSettingValue('margins') ===
- print_preview.ticket_items.MarginsTypeValue.DEFAULT) {
+ this.getSettingValue('margins') === print_preview.MarginsType.DEFAULT) {
return true;
}
@@ -641,17 +636,13 @@ Polymer({
newValue.width_microns != lastTicket.mediaSize.width_microns ||
(this.destination.id !== lastTicket.deviceName &&
this.getSettingValue('margins') ===
- print_preview.ticket_items.MarginsTypeValue.MINIMUM)) {
+ print_preview.MarginsType.MINIMUM)) {
return true;
}
// Destination
- if (this.destination.isPrivet !== lastTicket.printWithPrivet ||
- this.destination.isExtension !== lastTicket.printWithExtension ||
- !this.destination.isLocal !== lastTicket.printWithCloudPrint ||
- (lastTicket.printToPDF &&
- this.destination.id !==
- print_preview.Destination.GooglePromotedId.SAVE_AS_PDF)) {
+ if (print_preview.getPrinterTypeForDestination(this.destination) !==
+ lastTicket.printerType) {
return true;
}
@@ -664,13 +655,48 @@ Polymer({
/** @type {boolean} */ (this.getSettingValue('color')));
},
- /** @return {number} Scale factor. */
+ /** @return {number} Scale factor for print ticket. */
getScaleFactorForTicket_: function() {
- return this.getSettingValue('customScaling') ?
+ return this.getSettingValue(this.getScalingSettingKey_()) ===
+ print_preview.ScalingType.CUSTOM ?
parseInt(this.getSettingValue('scaling'), 10) :
100;
},
+ /** @return {string} Appropriate key for the scaling type setting. */
+ getScalingSettingKey_: function() {
+ return this.getSetting('scalingTypePdf').available ? 'scalingTypePdf' :
+ 'scalingType';
+ },
+
+ /**
+ * @param {Object} lastTicket Last print ticket.
+ * @return {boolean} Whether new scaling settings update the previewed
+ * document.
+ */
+ isScalingChanged_: function(lastTicket) {
+ // Preview always updates if the scale factor is changed.
+ if (this.getScaleFactorForTicket_() !== lastTicket.scaleFactor) {
+ return true;
+ }
+
+ // If both scale factors and type match, no scaling change happened.
+ const scalingType = this.getSettingValue(this.getScalingSettingKey_());
+ if (scalingType === lastTicket.scalingType) {
+ return false;
+ }
+
+ // Scaling doesn't always change because of a scalingType change. Changing
+ // between custom scaling with a scale factor of 100 and default scaling
+ // makes no difference.
+ const defaultToCustom = scalingType === print_preview.ScalingType.DEFAULT &&
+ lastTicket.scalingType === print_preview.ScalingType.CUSTOM;
+ const customToDefault = scalingType === print_preview.ScalingType.CUSTOM &&
+ lastTicket.scalingType === print_preview.ScalingType.DEFAULT;
+
+ return !defaultToCustom && !customToDefault;
+ },
+
/**
* @param {string} dpiField The field in dpi to retrieve.
* @return {number} Field value.
@@ -705,8 +731,8 @@ Polymer({
isFirstRequest: this.inFlightRequestId_ == 0,
requestID: this.inFlightRequestId_,
previewModifiable: this.documentModifiable,
- fitToPageEnabled: this.getSettingValue('fitToPage'),
scaleFactor: this.getScaleFactorForTicket_(),
+ scalingType: this.getSettingValue(this.getScalingSettingKey_()),
shouldPrintBackgrounds: this.getSettingValue('cssBackground'),
shouldPrintSelectionOnly: this.getSettingValue('selectionOnly'),
// NOTE: Even though the remaining fields don't directly relate to the
@@ -720,11 +746,7 @@ Polymer({
duplex: this.getSettingValue('duplex') ?
print_preview.DuplexMode.LONG_EDGE :
print_preview.DuplexMode.SIMPLEX,
- printToPDF: this.destination.id ==
- print_preview.Destination.GooglePromotedId.SAVE_AS_PDF,
- printWithCloudPrint: !this.destination.isLocal,
- printWithPrivet: this.destination.isPrivet,
- printWithExtension: this.destination.isExtension,
+ printerType: print_preview.getPrinterTypeForDestination(this.destination),
rasterizePDF: this.getSettingValue('rasterize'),
};
@@ -733,8 +755,7 @@ Polymer({
ticket.cloudPrintID = this.destination.id;
}
- if (this.getSettingValue('margins') ==
- print_preview.ticket_items.MarginsTypeValue.CUSTOM) {
+ if (this.getSettingValue('margins') == print_preview.MarginsType.CUSTOM) {
ticket.marginsCustom = this.getSettingValue('customMargins');
}
this.lastTicket_ = ticket;
diff --git a/chromium/chrome/browser/resources/print_preview/ui/scaling_settings.html b/chromium/chrome/browser/resources/print_preview/ui/scaling_settings.html
index d4cd7a36b99..8da1200544a 100644
--- a/chromium/chrome/browser/resources/print_preview/ui/scaling_settings.html
+++ b/chromium/chrome/browser/resources/print_preview/ui/scaling_settings.html
@@ -2,6 +2,7 @@
<link rel="import" href="chrome://resources/cr_elements/md_select_css.html">
<link rel="import" href="chrome://resources/polymer/v1_0/iron-collapse/iron-collapse.html">
+<link rel="import" href="../data/scaling.html">
<link rel="import" href="number_settings_section.html">
<link rel="import" href="print_preview_shared_css.html">
<link rel="import" href="select_behavior.html">
@@ -20,10 +21,12 @@
<option value="[[ScalingValue.DEFAULT]]">
$i18n{optionDefaultScaling}
</option>
- <option value="[[ScalingValue.FIT_TO_PAGE]]"
- hidden$="[[!settings.fitToPage.available]]">
+ <option value="[[ScalingValue.FIT_TO_PAGE]]" hidden$="[[!isPdf]]">
$i18n{optionFitToPage}
</option>
+ <option value="[[ScalingValue.FIT_TO_PAPER]]" hidden$="[[!isPdf]]">
+ $i18n{optionFitToPaper}
+ </option>
<option value="[[ScalingValue.CUSTOM]]">
$i18n{optionCustomScaling}
</option>
diff --git a/chromium/chrome/browser/resources/print_preview/ui/scaling_settings.js b/chromium/chrome/browser/resources/print_preview/ui/scaling_settings.js
index 909562b33d3..500637a9ab2 100644
--- a/chromium/chrome/browser/resources/print_preview/ui/scaling_settings.js
+++ b/chromium/chrome/browser/resources/print_preview/ui/scaling_settings.js
@@ -4,20 +4,10 @@
cr.exportPath('print_preview');
-/** @enum {number} */
-const ScalingValue = {
- DEFAULT: 0,
- FIT_TO_PAGE: 1,
- CUSTOM: 2,
-};
-
/*
- * When fit to page is available, the checkbox and input interact as follows:
- * 1. When checkbox is checked, the fit to page scaling value is displayed in
- * the input. The error message is cleared if it was present.
- * 2. When checkbox is unchecked, the most recent valid scale value is restored.
- * 3. If the input is modified while the checkbox is checked, the checkbox will
- * be unchecked automatically, regardless of the validity of the new value.
+ * Fit to page and fit to paper options will only be displayed for PDF
+ * documents. If the custom option is selected, an additional input field will
+ * appear to enter the custom scale factor.
*/
Polymer({
is: 'print-preview-scaling-settings',
@@ -30,6 +20,8 @@ Polymer({
observer: 'onDisabledChanged_',
},
+ isPdf: Boolean,
+
/** @private {string} */
currentValue_: {
type: String,
@@ -39,8 +31,8 @@ Polymer({
/** @private {boolean} */
customSelected_: {
type: Boolean,
- computed: 'computeCustomSelected_(settings.customScaling.*, ' +
- 'settings.fitToPage.*)',
+ computed: 'computeCustomSelected_(settingKey_, ' +
+ 'settings.scalingType.*, settings.scalingTypePdf.*)',
},
/** @private {boolean} */
@@ -52,14 +44,23 @@ Polymer({
value: false,
},
+ /** @private {string} */
+ settingKey_: {
+ type: String,
+ computed: 'computeSettingKey_(isPdf)',
+ },
+
/** Mirroring the enum so that it can be used from HTML bindings. */
- ScalingValue: Object,
+ ScalingValue: {
+ type: Object,
+ value: print_preview.ScalingType,
+ },
},
observers: [
- 'onFitToPageSettingChange_(settings.fitToPage.value)',
+ 'onScalingTypeSettingChanged_(settingKey_, settings.scalingType.value, ' +
+ 'settings.scalingTypePdf.value)',
'onScalingSettingChanged_(settings.scaling.value)',
- 'onCustomScalingSettingChanged_(settings.customScaling.value)',
],
/** @private {string} */
@@ -81,28 +82,26 @@ Polymer({
*/
userSelectedCustomScaling_: false,
- /** @override */
- ready: function() {
- this.ScalingValue = ScalingValue;
- },
-
onProcessSelectChange: function(value) {
- if (value === ScalingValue.FIT_TO_PAGE.toString()) {
- this.setSetting('fitToPage', true);
- return;
- }
-
- const fitToPageAvailable = this.getSetting('fitToPage').available;
- if (fitToPageAvailable) {
- this.setSetting('fitToPage', false);
- }
- const isCustom = value === ScalingValue.CUSTOM.toString();
+ const isCustom = value === print_preview.ScalingType.CUSTOM.toString();
if (isCustom && !this.customScalingSettingSet_) {
this.userSelectedCustomScaling_ = true;
} else {
this.customScalingSettingSet_ = false;
}
- this.setSetting('customScaling', isCustom);
+
+ const valueAsNumber = parseInt(value, 10);
+ if (isCustom || value === print_preview.ScalingType.DEFAULT.toString()) {
+ this.setSetting('scalingType', valueAsNumber);
+ }
+ if (this.isPdf ||
+ this.getSetting('scalingTypePdf').value ===
+ print_preview.ScalingType.DEFAULT ||
+ this.getSetting('scalingTypePdf').value ===
+ print_preview.ScalingType.CUSTOM) {
+ this.setSetting('scalingTypePdf', valueAsNumber);
+ }
+
if (isCustom) {
this.setSetting('scaling', this.currentValue_);
}
@@ -117,48 +116,35 @@ Polymer({
}
},
- /** @private */
- onFitToPageSettingChange_: function() {
- if (!this.getSettingValue('fitToPage') ||
- !this.getSetting('fitToPage').available) {
- return;
- }
-
- this.updateScalingToValid_();
- this.selectedValue = ScalingValue.FIT_TO_PAGE.toString();
+ /**
+ * Updates the input string when scaling setting is set.
+ * @private
+ */
+ onScalingSettingChanged_: function() {
+ const value = /** @type {string} */ (this.getSetting('scaling').value);
+ this.lastValidScaling_ = value;
+ this.currentValue_ = value;
},
/** @private */
- onCustomScalingSettingChanged_: function() {
- if (this.getSettingValue('fitToPage') &&
- this.getSetting('fitToPage').available) {
+ onScalingTypeSettingChanged_: function() {
+ if (!this.settingKey_) {
return;
}
- const isCustom =
- /** @type {boolean} */ (this.getSetting('customScaling').value);
- if (!isCustom) {
+ const value = /** @type {!print_preview.ScalingType} */
+ (this.getSettingValue(this.settingKey_));
+ if (value !== print_preview.ScalingType.CUSTOM) {
this.updateScalingToValid_();
} else {
this.customScalingSettingSet_ = true;
}
- this.selectedValue = isCustom ? ScalingValue.CUSTOM.toString() :
- ScalingValue.DEFAULT.toString();
- },
-
- /**
- * Updates the input string when scaling setting is set.
- * @private
- */
- onScalingSettingChanged_: function() {
- const value = /** @type {string} */ (this.getSetting('scaling').value);
- this.lastValidScaling_ = value;
- this.currentValue_ = value;
+ this.selectedValue = value.toString();
},
/**
- * Updates scaling and fit to page settings based on the validity and current
- * value of the scaling input.
+ * Updates scaling settings based on the validity and current value of the
+ * scaling input.
* @private
*/
onInputChanged_: function() {
@@ -188,9 +174,17 @@ Polymer({
* @private
*/
computeCustomSelected_: function() {
- return /** @type {boolean} */ (this.getSettingValue('customScaling')) &&
- (!this.getSetting('fitToPage').available ||
- !(/** @type {boolean} */ (this.getSettingValue('fitToPage'))));
+ return !!this.settingKey_ &&
+ this.getSettingValue(this.settingKey_) ===
+ print_preview.ScalingType.CUSTOM;
+ },
+
+ /**
+ * @return {string} The key of the appropriate scaling setting.
+ * @private
+ */
+ computeSettingKey_: function() {
+ return this.isPdf ? 'scalingTypePdf' : 'scalingType';
},
/** @private */
diff --git a/chromium/chrome/browser/resources/print_preview/ui/sidebar.html b/chromium/chrome/browser/resources/print_preview/ui/sidebar.html
index 7e5739246aa..7fffd00a38c 100644
--- a/chromium/chrome/browser/resources/print_preview/ui/sidebar.html
+++ b/chromium/chrome/browser/resources/print_preview/ui/sidebar.html
@@ -48,6 +48,11 @@
flex-direction: column;
}
+ :host([new-print-preview-layout]) {
+ border-inline-end: none;
+ border-inline-start: var(--print-preview-settings-border);
+ }
+
@media (prefers-color-scheme: dark) {
:host {
background-color: rgba(255, 255, 255, .04);
@@ -163,7 +168,7 @@
hidden$="[[!settings.dpi.available]]" class="settings-section">
</print-preview-dpi-settings>
<print-preview-scaling-settings settings="[[settings]]"
- disabled="[[controlsDisabled_]]"
+ disabled="[[controlsDisabled_]]" is-pdf="[[isPdf]]"
hidden$="[[!settings.scaling.available]]"
class="settings-section">
</print-preview-scaling-settings>
diff --git a/chromium/chrome/browser/resources/print_preview/ui/sidebar.js b/chromium/chrome/browser/resources/print_preview/ui/sidebar.js
index 687539f8323..fe77e9d7c44 100644
--- a/chromium/chrome/browser/resources/print_preview/ui/sidebar.js
+++ b/chromium/chrome/browser/resources/print_preview/ui/sidebar.js
@@ -47,6 +47,8 @@ Polymer({
notify: true,
},
+ isPdf: Boolean,
+
newPrintPreviewLayout: {
type: Boolean,
reflectToAttribute: true,