| 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 * extensionId: (string|undefined), | 57 * extensionId: (string|undefined), |
| 58 * extensionName: (string|undefined), | 58 * extensionName: (string|undefined), |
| 59 * usbId: (number | undefined), |
| 59 * description: (string|undefined)}=} opt_params Optional parameters | 60 * description: (string|undefined)}=} opt_params Optional parameters |
| 60 * for the destination. | 61 * for the destination. |
| 61 * @constructor | 62 * @constructor |
| 62 */ | 63 */ |
| 63 function Destination(id, type, origin, displayName, isRecent, | 64 function Destination(id, type, origin, displayName, isRecent, |
| 64 connectionStatus, opt_params) { | 65 connectionStatus, opt_params) { |
| 65 /** | 66 /** |
| 66 * ID of the destination. | 67 * ID of the destination. |
| 67 * @private {string} | 68 * @private {string} |
| 68 */ | 69 */ |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 * Extension ID for extension managed printers. | 161 * Extension ID for extension managed printers. |
| 161 * @private {string} | 162 * @private {string} |
| 162 */ | 163 */ |
| 163 this.extensionId_ = (opt_params && opt_params.extensionId) || ''; | 164 this.extensionId_ = (opt_params && opt_params.extensionId) || ''; |
| 164 | 165 |
| 165 /** | 166 /** |
| 166 * Extension name for extension managed printers. | 167 * Extension name for extension managed printers. |
| 167 * @private {string} | 168 * @private {string} |
| 168 */ | 169 */ |
| 169 this.extensionName_ = (opt_params && opt_params.extensionName) || ''; | 170 this.extensionName_ = (opt_params && opt_params.extensionName) || ''; |
| 171 |
| 172 /** @private {Destination.ProvisionalType} */ |
| 173 this.provisionalType_ = Destination.ProvisionalType.NONE; |
| 174 |
| 175 /** @private {?number} */ |
| 176 this.usbId_ = (opt_params && opt_params.usbId) || null; |
| 170 }; | 177 }; |
| 171 | 178 |
| 172 /** | 179 /** |
| 173 * Prefix of the location destination tag. | 180 * Prefix of the location destination tag. |
| 174 * @type {!Array<string>} | 181 * @type {!Array<string>} |
| 175 * @const | 182 * @const |
| 176 */ | 183 */ |
| 177 Destination.LOCATION_TAG_PREFIXES = [ | 184 Destination.LOCATION_TAG_PREFIXES = [ |
| 178 '__cp__location=', | 185 '__cp__location=', |
| 179 '__cp__printer-location=' | 186 '__cp__printer-location=' |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 * @enum {string} | 225 * @enum {string} |
| 219 */ | 226 */ |
| 220 Destination.ConnectionStatus = { | 227 Destination.ConnectionStatus = { |
| 221 DORMANT: 'DORMANT', | 228 DORMANT: 'DORMANT', |
| 222 OFFLINE: 'OFFLINE', | 229 OFFLINE: 'OFFLINE', |
| 223 ONLINE: 'ONLINE', | 230 ONLINE: 'ONLINE', |
| 224 UNKNOWN: 'UNKNOWN', | 231 UNKNOWN: 'UNKNOWN', |
| 225 UNREGISTERED: 'UNREGISTERED' | 232 UNREGISTERED: 'UNREGISTERED' |
| 226 }; | 233 }; |
| 227 | 234 |
| 235 Destination.ProvisionalType = { |
| 236 NONE: 'NONE', |
| 237 NEEDS_USB_PERMISSION: 'NEEDS_USB_PERMISSION' |
| 238 }; |
| 239 |
| 228 /** | 240 /** |
| 229 * Enumeration of relative icon URLs for various types of destinations. | 241 * Enumeration of relative icon URLs for various types of destinations. |
| 230 * @enum {string} | 242 * @enum {string} |
| 231 * @private | 243 * @private |
| 232 */ | 244 */ |
| 233 Destination.IconUrl_ = { | 245 Destination.IconUrl_ = { |
| 234 CLOUD: 'images/printer.png', | 246 CLOUD: 'images/printer.png', |
| 235 CLOUD_SHARED: 'images/printer_shared.png', | 247 CLOUD_SHARED: 'images/printer_shared.png', |
| 236 LOCAL: 'images/printer.png', | 248 LOCAL: 'images/printer.png', |
| 237 MOBILE: 'images/mobile.png', | 249 MOBILE: 'images/mobile.png', |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 494 * @param {!RegExp} query Query to match against the destination. | 506 * @param {!RegExp} query Query to match against the destination. |
| 495 * @return {boolean} {@code true} if the query matches this destination, | 507 * @return {boolean} {@code true} if the query matches this destination, |
| 496 * {@code false} otherwise. | 508 * {@code false} otherwise. |
| 497 */ | 509 */ |
| 498 matches: function(query) { | 510 matches: function(query) { |
| 499 return !!this.displayName_.match(query) || | 511 return !!this.displayName_.match(query) || |
| 500 !!this.extensionName_.match(query) || | 512 !!this.extensionName_.match(query) || |
| 501 this.extraPropertiesToMatch.some(function(property) { | 513 this.extraPropertiesToMatch.some(function(property) { |
| 502 return property.match(query); | 514 return property.match(query); |
| 503 }); | 515 }); |
| 516 }, |
| 517 |
| 518 /** @return {Destination.ProvisionalType} */ |
| 519 get provisionalType() { |
| 520 return this.provisionalType_; |
| 521 }, |
| 522 |
| 523 /** @param {Destination.ProvisionalType} type */ |
| 524 set provisionalType(type) { |
| 525 if (type == Destination.ProvisionalType.NEDS_USB_PERMISSION) { |
| 526 assert(this.extensionId != null, |
| 527 'Provisional USB destination with no extension ID set.'); |
| 528 assert(this.usbId != null, |
| 529 'Provisional USB destination with no USB ID set.'); |
| 530 } |
| 531 this.provisionalType_ = type; |
| 532 }, |
| 533 |
| 534 /** @return {boolean} */ |
| 535 get isProvisional() { |
| 536 return this.provisionalType_ != Destination.ProvisionalType.NONE; |
| 537 }, |
| 538 |
| 539 /** @return {?number} */ |
| 540 get usbId() { |
| 541 return this.usbId_; |
| 504 } | 542 } |
| 505 }; | 543 }; |
| 506 | 544 |
| 507 // Export | 545 // Export |
| 508 return { | 546 return { |
| 509 Destination: Destination, | 547 Destination: Destination, |
| 510 }; | 548 }; |
| 511 }); | 549 }); |
| OLD | NEW |