OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 cr.define('print_preview', function() { |
| 6 'use strict'; |
| 7 |
| 8 /** |
| 9 * Capabilities of a print destination not including the capabilities of the |
| 10 * document renderer. |
| 11 * @param {boolean} hasCopiesCapability Whether the print destination has a |
| 12 * copies capability. |
| 13 * @param {string} defaultCopiesStr Default string representation of the |
| 14 * copies value. |
| 15 * @param {boolean} hasCollateCapability Whether the print destination has |
| 16 * collation capability. |
| 17 * @param {boolean} defaultIsCollateEnabled Whether collate is enabled by |
| 18 * default. |
| 19 * @param {boolean} hasDuplexCapability Whether the print destination has |
| 20 * duplexing capability. |
| 21 * @param {boolean} defaultIsDuplexEnabled Whether duplexing is enabled by |
| 22 * default. |
| 23 * @param {boolean} hasOrientationCapability Whether the print destination has |
| 24 * orientation capability. |
| 25 * @param {boolean} defaultIsLandscapeEnabled Whether the document should be |
| 26 * printed in landscape by default. |
| 27 * @param {boolean} hasColorCapability Whether the print destination has |
| 28 * color printing capability. |
| 29 * @param {boolean} defaultIsColorEnabled Whether the document should be |
| 30 * printed in color by default. |
| 31 * @constructor |
| 32 */ |
| 33 function ChromiumCapabilities( |
| 34 hasCopiesCapability, |
| 35 defaultCopiesStr, |
| 36 hasCollateCapability, |
| 37 defaultIsCollateEnabled, |
| 38 hasDuplexCapability, |
| 39 defaultIsDuplexEnabled, |
| 40 hasOrientationCapability, |
| 41 defaultIsLandscapeEnabled, |
| 42 hasColorCapability, |
| 43 defaultIsColorEnabled) { |
| 44 /** |
| 45 * Whether the print destination has a copies capability. |
| 46 * @type {boolean} |
| 47 * @private |
| 48 */ |
| 49 this.hasCopiesCapability_ = hasCopiesCapability; |
| 50 |
| 51 /** |
| 52 * Default string representation of the copies value. |
| 53 * @type {string} |
| 54 * @private |
| 55 */ |
| 56 this.defaultCopiesStr_ = defaultCopiesStr; |
| 57 |
| 58 /** |
| 59 * Whether the print destination has collation capability. |
| 60 * @type {boolean} |
| 61 * @private |
| 62 */ |
| 63 this.hasCollateCapability_ = hasCollateCapability; |
| 64 |
| 65 /** |
| 66 * Whether collate is enabled by default. |
| 67 * @type {boolean} |
| 68 * @private |
| 69 */ |
| 70 this.defaultIsCollateEnabled_ = defaultIsCollateEnabled; |
| 71 |
| 72 /** |
| 73 * Whether the print destination has duplexing capability. |
| 74 * @type {boolean} |
| 75 * @private |
| 76 */ |
| 77 this.hasDuplexCapability_ = hasDuplexCapability; |
| 78 |
| 79 /** |
| 80 * Whether duplex is enabled by default. |
| 81 * @type {boolean} |
| 82 * @private |
| 83 */ |
| 84 this.defaultIsDuplexEnabled_ = defaultIsDuplexEnabled; |
| 85 |
| 86 /** |
| 87 * Whether the print destination has orientation capability. |
| 88 * @type {boolean} |
| 89 * @private |
| 90 */ |
| 91 this.hasOrientationCapability_ = hasOrientationCapability; |
| 92 |
| 93 /** |
| 94 * Whether the document should be printed in landscape by default. |
| 95 * @type {boolean} |
| 96 * @private |
| 97 */ |
| 98 this.defaultIsLandscapeEnabled_ = defaultIsLandscapeEnabled; |
| 99 |
| 100 /** |
| 101 * Whether the print destination has color printing capability. |
| 102 * @type {boolean} |
| 103 * @private |
| 104 */ |
| 105 this.hasColorCapability_ = hasColorCapability; |
| 106 |
| 107 /** |
| 108 * Whether the document should be printed in color. |
| 109 * @type {boolean} |
| 110 * @private |
| 111 */ |
| 112 this.defaultIsColorEnabled_ = defaultIsColorEnabled; |
| 113 }; |
| 114 |
| 115 ChromiumCapabilities.prototype = { |
| 116 /** @return {boolean} Whether the destination has the copies capability. */ |
| 117 get hasCopiesCapability() { |
| 118 return this.hasCopiesCapability_; |
| 119 }, |
| 120 |
| 121 /** @return {string} Default number of copies in string format. */ |
| 122 get defaultCopiesStr() { |
| 123 return this.defaultCopiesStr_; |
| 124 }, |
| 125 |
| 126 /** @return {boolean} Whether the destination has collation capability. */ |
| 127 get hasCollateCapability() { |
| 128 return this.hasCollateCapability_; |
| 129 }, |
| 130 |
| 131 /** @return {boolean} Whether collation is enabled by default. */ |
| 132 get defaultIsCollateEnabled() { |
| 133 return this.defaultIsCollateEnabled_; |
| 134 }, |
| 135 |
| 136 /** @return {boolean} Whether the destination has the duplex capability. */ |
| 137 get hasDuplexCapability() { |
| 138 return this.hasDuplexCapability_; |
| 139 }, |
| 140 |
| 141 /** @return {boolean} Whether duplexing is enabled by default. */ |
| 142 get defaultIsDuplexEnabled() { |
| 143 return this.defaultIsDuplexEnabled_; |
| 144 }, |
| 145 |
| 146 /** |
| 147 * @return {boolean} Whether the destination has the orientation capability. |
| 148 */ |
| 149 get hasOrientationCapability() { |
| 150 return this.hasOrientationCapability_; |
| 151 }, |
| 152 |
| 153 /** |
| 154 * @return {boolean} Whether document should be printed in landscape by |
| 155 * default. |
| 156 */ |
| 157 get defaultIsLandscapeEnabled() { |
| 158 return this.defaultIsLandscapeEnabled_; |
| 159 }, |
| 160 |
| 161 /** |
| 162 * @return {boolean} Whether the destination has color printing capability. |
| 163 */ |
| 164 get hasColorCapability() { |
| 165 return this.hasColorCapability_; |
| 166 }, |
| 167 |
| 168 /** |
| 169 * @return {boolean} Whether document should be printed in color by default. |
| 170 */ |
| 171 get defaultIsColorEnabled() { |
| 172 return this.defaultIsColorEnabled_; |
| 173 }, |
| 174 |
| 175 /** @return {string} Serialized representation of the capabilities. */ |
| 176 serialize: function() { |
| 177 var state = { |
| 178 'hasCopiesCapability': this.hasCopiesCapability_, |
| 179 'defaultCopiesStr': this.defaultCopiesStr_, |
| 180 'hasCollateCapability': this.hasCollateCapability_, |
| 181 'defaultIsCollateEnabled': this.defaultIsCollateEnabled_, |
| 182 'hasDuplexCapability': this.hasDuplexCapability_, |
| 183 'defaultIsDuplexEnabled': this.defaultIsDuplexEnabled_, |
| 184 'hasOrientationCapability': this.hasOrientationCapability_, |
| 185 'defaultIsLandscapeEnabled': this.defaultIsLandscapeEnabled_, |
| 186 'hasColorCapability': this.hasColorCapability_, |
| 187 'defaultIsColorEnabled': this.defaultIsColorEnabled_ |
| 188 }; |
| 189 return JSON.stringify(state); |
| 190 } |
| 191 }; |
| 192 |
| 193 // Export |
| 194 return { |
| 195 ChromiumCapabilities: ChromiumCapabilities |
| 196 }; |
| 197 }); |
OLD | NEW |