| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 cr.exportPath('print_preview'); | 5 cr.exportPath('print_preview'); |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * The CDD (Cloud Device Description) describes the capabilities of a print | 8 * The CDD (Cloud Device Description) describes the capabilities of a print |
| 9 * destination. | 9 * destination. |
| 10 * | 10 * |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 * @param {string} displayName Display name of the destination. | 47 * @param {string} displayName Display name of the destination. |
| 48 * @param {boolean} isRecent Whether the destination has been used recently. | 48 * @param {boolean} isRecent Whether the destination has been used recently. |
| 49 * @param {!print_preview.Destination.ConnectionStatus} connectionStatus | 49 * @param {!print_preview.Destination.ConnectionStatus} connectionStatus |
| 50 * Connection status of the print destination. | 50 * Connection status of the print destination. |
| 51 * @param {{tags: (Array<string>|undefined), | 51 * @param {{tags: (Array<string>|undefined), |
| 52 * isOwned: (boolean|undefined), | 52 * isOwned: (boolean|undefined), |
| 53 * account: (string|undefined), | 53 * account: (string|undefined), |
| 54 * lastAccessTime: (number|undefined), | 54 * lastAccessTime: (number|undefined), |
| 55 * isTosAccepted: (boolean|undefined), | 55 * isTosAccepted: (boolean|undefined), |
| 56 * cloudID: (string|undefined), | 56 * cloudID: (string|undefined), |
| 57 * provisionalType: |
| 58 * (print_preview.Destination.ProvisionalType|undefined), |
| 57 * extensionId: (string|undefined), | 59 * extensionId: (string|undefined), |
| 58 * extensionName: (string|undefined), | 60 * extensionName: (string|undefined), |
| 59 * description: (string|undefined)}=} opt_params Optional parameters | 61 * description: (string|undefined)}=} opt_params Optional parameters |
| 60 * for the destination. | 62 * for the destination. |
| 61 * @constructor | 63 * @constructor |
| 62 */ | 64 */ |
| 63 function Destination(id, type, origin, displayName, isRecent, | 65 function Destination(id, type, origin, displayName, isRecent, |
| 64 connectionStatus, opt_params) { | 66 connectionStatus, opt_params) { |
| 65 /** | 67 /** |
| 66 * ID of the destination. | 68 * ID of the destination. |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 * Extension ID for extension managed printers. | 162 * Extension ID for extension managed printers. |
| 161 * @private {string} | 163 * @private {string} |
| 162 */ | 164 */ |
| 163 this.extensionId_ = (opt_params && opt_params.extensionId) || ''; | 165 this.extensionId_ = (opt_params && opt_params.extensionId) || ''; |
| 164 | 166 |
| 165 /** | 167 /** |
| 166 * Extension name for extension managed printers. | 168 * Extension name for extension managed printers. |
| 167 * @private {string} | 169 * @private {string} |
| 168 */ | 170 */ |
| 169 this.extensionName_ = (opt_params && opt_params.extensionName) || ''; | 171 this.extensionName_ = (opt_params && opt_params.extensionName) || ''; |
| 172 |
| 173 /** |
| 174 * Different from {@code Destination.ProvisionalType.NONE} if the |
| 175 * destination is provisional. Provisional destinations cannot be selected |
| 176 * as they are, but have to be resolved first (i.e. extra steps have to be |
| 177 * taken to get actual destination properties, which should replace the |
| 178 * provisional ones). Provisional destination resolvment flow will be |
| 179 * started when the user attempts to select the destination in search UI. |
| 180 * @private {Destination.ProvisionalType} |
| 181 */ |
| 182 this.provisionalType_ = (opt_params && opt_params.provisionalType) || |
| 183 Destination.ProvisionalType.NONE; |
| 184 |
| 185 assert(this.provisionalType_ != |
| 186 Destination.ProvisionalType.NEEDS_USB_PERMISSON || |
| 187 this.isExtension, |
| 188 'Provisional USB destination only supprted with extension origin.'); |
| 170 }; | 189 }; |
| 171 | 190 |
| 172 /** | 191 /** |
| 173 * Prefix of the location destination tag. | 192 * Prefix of the location destination tag. |
| 174 * @type {!Array<string>} | 193 * @type {!Array<string>} |
| 175 * @const | 194 * @const |
| 176 */ | 195 */ |
| 177 Destination.LOCATION_TAG_PREFIXES = [ | 196 Destination.LOCATION_TAG_PREFIXES = [ |
| 178 '__cp__location=', | 197 '__cp__location=', |
| 179 '__cp__printer-location=' | 198 '__cp__printer-location=' |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 */ | 238 */ |
| 220 Destination.ConnectionStatus = { | 239 Destination.ConnectionStatus = { |
| 221 DORMANT: 'DORMANT', | 240 DORMANT: 'DORMANT', |
| 222 OFFLINE: 'OFFLINE', | 241 OFFLINE: 'OFFLINE', |
| 223 ONLINE: 'ONLINE', | 242 ONLINE: 'ONLINE', |
| 224 UNKNOWN: 'UNKNOWN', | 243 UNKNOWN: 'UNKNOWN', |
| 225 UNREGISTERED: 'UNREGISTERED' | 244 UNREGISTERED: 'UNREGISTERED' |
| 226 }; | 245 }; |
| 227 | 246 |
| 228 /** | 247 /** |
| 248 * Enumeration specifying whether a destination is provisional and the reason |
| 249 * the destination is provisional. |
| 250 * @enum {string |
| 251 */ |
| 252 Destination.ProvisionalType = { |
| 253 /** Destination is not provisional. */ |
| 254 NONE: 'NONE', |
| 255 /** |
| 256 * User has to grant USB access for the destination to its provider. |
| 257 * Used for destinations with extension origin. |
| 258 */ |
| 259 NEEDS_USB_PERMISSION: 'NEEDS_USB_PERMISSION' |
| 260 }; |
| 261 |
| 262 /** |
| 229 * Enumeration of relative icon URLs for various types of destinations. | 263 * Enumeration of relative icon URLs for various types of destinations. |
| 230 * @enum {string} | 264 * @enum {string} |
| 231 * @private | 265 * @private |
| 232 */ | 266 */ |
| 233 Destination.IconUrl_ = { | 267 Destination.IconUrl_ = { |
| 234 CLOUD: 'images/printer.png', | 268 CLOUD: 'images/printer.png', |
| 235 CLOUD_SHARED: 'images/printer_shared.png', | 269 CLOUD_SHARED: 'images/printer_shared.png', |
| 236 LOCAL: 'images/printer.png', | 270 LOCAL: 'images/printer.png', |
| 237 MOBILE: 'images/mobile.png', | 271 MOBILE: 'images/mobile.png', |
| 238 MOBILE_SHARED: 'images/mobile_shared.png', | 272 MOBILE_SHARED: 'images/mobile_shared.png', |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 494 * @param {!RegExp} query Query to match against the destination. | 528 * @param {!RegExp} query Query to match against the destination. |
| 495 * @return {boolean} {@code true} if the query matches this destination, | 529 * @return {boolean} {@code true} if the query matches this destination, |
| 496 * {@code false} otherwise. | 530 * {@code false} otherwise. |
| 497 */ | 531 */ |
| 498 matches: function(query) { | 532 matches: function(query) { |
| 499 return !!this.displayName_.match(query) || | 533 return !!this.displayName_.match(query) || |
| 500 !!this.extensionName_.match(query) || | 534 !!this.extensionName_.match(query) || |
| 501 this.extraPropertiesToMatch.some(function(property) { | 535 this.extraPropertiesToMatch.some(function(property) { |
| 502 return property.match(query); | 536 return property.match(query); |
| 503 }); | 537 }); |
| 538 }, |
| 539 |
| 540 /** |
| 541 * Gets the destination's provisional type. |
| 542 * @return {Destination.ProvisionalType} |
| 543 */ |
| 544 get provisionalType() { |
| 545 return this.provisionalType_; |
| 546 }, |
| 547 |
| 548 /** |
| 549 * Whether the destinaion is provisional. |
| 550 * @return {boolean} |
| 551 */ |
| 552 get isProvisional() { |
| 553 return this.provisionalType_ != Destination.ProvisionalType.NONE; |
| 504 } | 554 } |
| 505 }; | 555 }; |
| 506 | 556 |
| 507 // Export | 557 // Export |
| 508 return { | 558 return { |
| 509 Destination: Destination, | 559 Destination: Destination, |
| 510 }; | 560 }; |
| 511 }); | 561 }); |
| OLD | NEW |