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

Unified Diff: chrome/browser/resources/print_preview/data/cloud_capabilities.js

Issue 10108001: Refactor print preview web ui (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove new widget Created 8 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/print_preview/data/cloud_capabilities.js
diff --git a/chrome/browser/resources/print_preview/data/cloud_capabilities.js b/chrome/browser/resources/print_preview/data/cloud_capabilities.js
new file mode 100644
index 0000000000000000000000000000000000000000..a4da3a90bed42afc9b66f1ce5174d3b2c350d146
--- /dev/null
+++ b/chrome/browser/resources/print_preview/data/cloud_capabilities.js
@@ -0,0 +1,315 @@
+// Copyright (c) 2012 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';
+
+ /**
+ * Capabilities of a cloud-based print destination.
+ *
+ * @param {print_preview.CollateCapability} collateCapability Print
+ * destination collate capability.
+ * @param {print_preview.ColorCapability} colorCapability Print destination
+ * color capability.
+ * @param {print_preview.CopiesCapability} copiesCapability Print destination
+ * copies capability.
+ * @param {print_preview.DuplexCapability} duplexCapability Print destination
+ * duplexing capability.
+ * @constructor
+ * @extends {print_preview.ChromiumCapabilities}
+ */
+ function CloudCapabilities(
+ collateCapability, colorCapability, copiesCapability, duplexCapability) {
+ print_preview.ChromiumCapabilities.call(this);
+
+ this.hasPageRangeCapability = true;
+ this.hasCopiesCapability = !!copiesCapability;
+ this.hasCollateCapability = !!collateCapability;
+ this.defaultIsCollateEnabled =
+ !!collateCapability && collateCapability.isCollateDefault;
+ this.hasDuplexCapability = !!duplexCapability;
+ this.defaultIsDuplexEnabled =
+ !!duplexCapability && duplexCapability.isDuplexDefault;
+ this.hasOrientationCapability = true;
+ this.hasColorCapability = !!colorCapability;
+ this.defaultIsColorEnabled =
+ !!colorCapability && colorCapability.isColorDefault;
+ this.hasMarginsCapability = true;
+ this.hasHeaderFooterCapability = true;
+ this.defaultIsHeaderFooterEnabled = true;
+
+ /**
+ * Print destination collate capability.
+ * @type {print_preview.CollateCapability}
+ * @private
+ */
+ this.collateCapability_ = collateCapability;
+
+ /**
+ * Print destination color capability.
+ * @type {print_preview.ColorCapability}
+ * @private
+ */
+ this.colorCapability_ = colorCapability;
+
+ /**
+ * Print destination copies capability.
+ * @type {print_preview.CopiesCapability}
+ * @private
+ */
+ this.copiesCapability_ = copiesCapability;
+
+ /**
+ * Print destination duplexing capability.
+ * @type {print_preview.DuplexCapability}
+ * @private
+ */
+ this.duplexCapability_ = duplexCapability;
+ };
+
+ /**
+ * Enumeration of the capability formats of cloud-based print destinations.
+ * @enum {string}
+ */
+ CloudCapabilities.Format = {
+ HP: 'hp',
+ PPD: 'ppd',
+ XPS: 'xps'
+ };
+
+ CloudCapabilities.prototype = {
+ __proto__: print_preview.ChromiumCapabilities.prototype,
+
+ /**
+ * @return {print_preview.CollateCapability} The print destination's collate
+ * capability.
+ */
+ get collateCapability() {
+ return this.collateCapability_;
+ },
+
+ /**
+ * @return {print_preview.CollateCapability} The print destination's color
+ * capability.
+ */
+ get colorCapability() {
+ return this.colorCapability_;
+ },
+
+ /**
+ * @return {print_preview.CollateCapability} The print destination's copies
+ * capability.
+ */
+ get copiesCapability() {
+ return this.copiesCapability_;
+ },
+
+ /**
+ * @return {print_preview.CollateCapability} The print destination's
+ * duplexing capability.
+ */
+ get duplexCapability() {
+ return this.duplexCapability_;
+ }
+ };
+
+ /**
+ * A single print capability of a cloud-based print destination.
+ *
+ * @param {string} id Identifier of the capability.
+ * @param {print_preview.CloudCapability.Type} type Type of the capability.
+ * @constructor
+ */
+ function CloudCapability(id, type) {
+ /**
+ * Identifier of the capability.
+ * @type {string}
+ * @private
+ */
+ this.id_ = id;
+
+ /**
+ * Type of the capability.
+ * @type {print_preview.CloudCapability.Type}
+ * @private
+ */
+ this.type_ = type;
+ };
+
+ /**
+ * Enumeration of the types of cloud-based print capabilities.
+ * @enum {string}
+ */
+ CloudCapability.Type = {
+ FEATURE: 'Feature',
+ PARAMETER_DEF: 'ParameterDef'
+ };
+
+ CloudCapability.prototype = {
+ /** @return {string} Identifier of the capability. */
+ get id() {
+ return this.id_;
+ },
+
+ /** @return {print_preview.CloudCapability.Type} Type of the capability. */
+ get type() {
+ return this.type_;
+ }
+ };
+
+ /**
+ * Cloud-based collate capability.
+ *
+ * @param {string} id Identifier of the collate capability.
+ * @param {string} collateOption Identifier of the option that enables
+ * collation.
+ * @param {string} noCollateOption Identifier of the option that disables
+ * collation.
+ * @param {boolean} isCollateDefault Whether collation is enabled by default.
+ * @constructor
+ * @extends {print_preview.CloudCapability}
+ */
+ function CollateCapability(
+ id, collateOption, noCollateOption, isCollateDefault) {
+ CloudCapability.call(this, id, CloudCapability.Type.FEATURE);
+
+ /**
+ * Identifier of the option that enables collation.
+ * @type {string}
+ * @private
+ */
+ this.collateOption_ = collateOption;
+
+ /**
+ * Identifier of the option that disables collation.
+ * @type {string}
+ * @private
+ */
+ this.noCollateOption_ = noCollateOption;
+
+ /**
+ * Whether collation is enabled by default.
+ * @type {boolean}
+ * @private
+ */
+ this.isCollateDefault_ = isCollateDefault;
+ };
+
+ /**
+ * Mapping of capability formats to an identifier of the collate capability.
+ * @type {object<CloudCapabilities.Format, string>}
+ */
+ CollateCapability.Id = {};
+ CollateCapability.Id[CloudCapabilities.Format.PPD] = 'Collate';
+ CollateCapability.Id[CloudCapabilities.Format.XPS] = 'psk:DocumentCollate';
+
+ /**
+ * @type {RegExp}
+ */
+ CollateCapability.COLLATE_REGEX = /(.*:collated.*|true)/i;
+
+ CollateCapability.NO_COLLATE_REGEX = /(.*:uncollated.*|false)/i;
+
+ CollateCapability.prototype = {
+ __proto__: CloudCapability.prototype,
+
+ get collateOption() {
+ return this.collateOption_;
+ },
+
+ get noCollateOption() {
+ return this.noCollateOption_;
+ },
+
+ get isCollateDefault() {
+ return this.isCollateDefault_;
+ }
+ };
+
+ function ColorCapability(id, colorOption, bwOption, isColorDefault) {
+ CloudCapability.call(this, id, CloudCapability.Type.FEATURE);
+ this.colorOption_ = colorOption;
+ this.bwOption_ = bwOption;
+ this.isColorDefault_ = isColorDefault;
+ };
+
+ ColorCapability.Id = {};
+ ColorCapability.Id[CloudCapabilities.Format.HP] = 'ns1:Colors';
+ ColorCapability.Id[CloudCapabilities.Format.PPD] = 'ColorModel';
+ ColorCapability.Id[CloudCapabilities.Format.XPS] = 'psk:PageOutputColor';
+
+ ColorCapability.COLOR_REGEX = /(.*color.*|.*rgb.*|.*cmy.*|true)/i;
+
+ ColorCapability.BW_REGEX = /(.*gray.*|.*mono.*|.*black.*|false)/i;
+
+ ColorCapability.prototype = {
+ __proto__: CloudCapability.prototype,
+
+ get colorOption() {
+ return this.colorOption_;
+ },
+
+ get bwOption() {
+ return this.bwOption_;
+ },
+
+ get isColorDefault() {
+ return this.isColorDefault_;
+ }
+ };
+
+ function CopiesCapability(id) {
+ CloudCapability.call(this, id, CloudCapability.Type.PARAMETER_DEF);
+ };
+
+ CopiesCapability.prototype = {
+ __proto__: CloudCapability.prototype
+ };
+
+ CopiesCapability.Id = {};
+ CopiesCapability.Id[CloudCapabilities.Format.XPS] =
+ 'psk:JobCopiesAllDocuments';
+
+ function DuplexCapability(
+ id, simplexOption, longEdgeOption, isDuplexDefault) {
+ CloudCapability.call(this, id, CloudCapability.Type.FEATURE);
+ this.simplexOption_ = simplexOption;
+ this.longEdgeOption_ = longEdgeOption;
+ this.isDuplexDefault_ = isDuplexDefault;
+ };
+
+ DuplexCapability.Id = {};
+ DuplexCapability.Id[CloudCapabilities.Format.PPD] = 'Duplex';
+ DuplexCapability.Id[CloudCapabilities.Format.XPS] =
+ 'psk:JobDuplexAllDocumentsContiguously';
+
+ DuplexCapability.SIMPLEX_REGEX = /(.*onesided.*|.*none.*)/i;
+
+ DuplexCapability.LONG_EDGE_REGEX = /(.*longedge.*|duplexNoTumble)/i;
+
+ DuplexCapability.prototype = {
+ __proto__: CloudCapability.prototype,
+
+ get simplexOption() {
+ return this.simplexOption_;
+ },
+
+ get longEdgeOption() {
+ return this.longEdgeOption_;
+ },
+
+ get isDuplexDefault() {
+ return this.isDuplexDefault_;
+ }
+ };
+
+ // Export
+ return {
+ CloudCapabilities: CloudCapabilities,
+ CollateCapability: CollateCapability,
+ ColorCapability: ColorCapability,
+ CopiesCapability: CopiesCapability,
+ DuplexCapability: DuplexCapability
+ };
+});

Powered by Google App Engine
This is Rietveld 408576698