| 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 * isTosAccepted: (boolean|undefined), | 55 * isTosAccepted: (boolean|undefined), |
| 56 * cloudID: (string|undefined), | 56 * cloudID: (string|undefined), |
| 57 * provisionalType: | 57 * provisionalType: |
| 58 * (print_preview.Destination.ProvisionalType|undefined), | 58 * (print_preview.Destination.ProvisionalType|undefined), |
| 59 * extensionId: (string|undefined), | 59 * extensionId: (string|undefined), |
| 60 * extensionName: (string|undefined), | 60 * extensionName: (string|undefined), |
| 61 * description: (string|undefined)}=} opt_params Optional parameters | 61 * description: (string|undefined)}=} opt_params Optional parameters |
| 62 * for the destination. | 62 * for the destination. |
| 63 * @constructor | 63 * @constructor |
| 64 */ | 64 */ |
| 65 function Destination(id, type, origin, displayName, isRecent, | 65 function Destination( |
| 66 connectionStatus, opt_params) { | 66 id, type, origin, displayName, isRecent, connectionStatus, opt_params) { |
| 67 /** | 67 /** |
| 68 * ID of the destination. | 68 * ID of the destination. |
| 69 * @private {string} | 69 * @private {string} |
| 70 */ | 70 */ |
| 71 this.id_ = id; | 71 this.id_ = id; |
| 72 | 72 |
| 73 /** | 73 /** |
| 74 * Type of the destination. | 74 * Type of the destination. |
| 75 * @private {!print_preview.Destination.Type} | 75 * @private {!print_preview.Destination.Type} |
| 76 */ | 76 */ |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 * Connection status of the destination. | 134 * Connection status of the destination. |
| 135 * @private {!print_preview.Destination.ConnectionStatus} | 135 * @private {!print_preview.Destination.ConnectionStatus} |
| 136 */ | 136 */ |
| 137 this.connectionStatus_ = connectionStatus; | 137 this.connectionStatus_ = connectionStatus; |
| 138 | 138 |
| 139 /** | 139 /** |
| 140 * Number of milliseconds since the epoch when the printer was last | 140 * Number of milliseconds since the epoch when the printer was last |
| 141 * accessed. | 141 * accessed. |
| 142 * @private {number} | 142 * @private {number} |
| 143 */ | 143 */ |
| 144 this.lastAccessTime_ = (opt_params && opt_params.lastAccessTime) || | 144 this.lastAccessTime_ = |
| 145 Date.now(); | 145 (opt_params && opt_params.lastAccessTime) || Date.now(); |
| 146 | 146 |
| 147 /** | 147 /** |
| 148 * Whether the user has accepted the terms-of-service for the print | 148 * Whether the user has accepted the terms-of-service for the print |
| 149 * destination. Only applies to the FedEx Office cloud-based printer. | 149 * destination. Only applies to the FedEx Office cloud-based printer. |
| 150 * {@code null} if terms-of-service does not apply to the print destination. | 150 * {@code null} if terms-of-service does not apply to the print destination. |
| 151 * @private {?boolean} | 151 * @private {?boolean} |
| 152 */ | 152 */ |
| 153 this.isTosAccepted_ = !!(opt_params && opt_params.isTosAccepted); | 153 this.isTosAccepted_ = !!(opt_params && opt_params.isTosAccepted); |
| 154 | 154 |
| 155 /** | 155 /** |
| (...skipping 17 matching lines...) Expand all Loading... |
| 173 /** | 173 /** |
| 174 * Different from {@code Destination.ProvisionalType.NONE} if the | 174 * Different from {@code Destination.ProvisionalType.NONE} if the |
| 175 * destination is provisional. Provisional destinations cannot be selected | 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 | 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 | 177 * taken to get actual destination properties, which should replace the |
| 178 * provisional ones). Provisional destination resolvment flow will be | 178 * provisional ones). Provisional destination resolvment flow will be |
| 179 * started when the user attempts to select the destination in search UI. | 179 * started when the user attempts to select the destination in search UI. |
| 180 * @private {Destination.ProvisionalType} | 180 * @private {Destination.ProvisionalType} |
| 181 */ | 181 */ |
| 182 this.provisionalType_ = (opt_params && opt_params.provisionalType) || | 182 this.provisionalType_ = (opt_params && opt_params.provisionalType) || |
| 183 Destination.ProvisionalType.NONE; | 183 Destination.ProvisionalType.NONE; |
| 184 | 184 |
| 185 assert(this.provisionalType_ != | 185 assert( |
| 186 Destination.ProvisionalType.NEEDS_USB_PERMISSON || | 186 this.provisionalType_ != |
| 187 this.isExtension, | 187 Destination.ProvisionalType.NEEDS_USB_PERMISSON || |
| 188 'Provisional USB destination only supprted with extension origin.'); | 188 this.isExtension, |
| 189 'Provisional USB destination only supprted with extension origin.'); |
| 189 }; | 190 }; |
| 190 | 191 |
| 191 /** | 192 /** |
| 192 * Prefix of the location destination tag. | 193 * Prefix of the location destination tag. |
| 193 * @type {!Array<string>} | 194 * @type {!Array<string>} |
| 194 * @const | 195 * @const |
| 195 */ | 196 */ |
| 196 Destination.LOCATION_TAG_PREFIXES = [ | 197 Destination.LOCATION_TAG_PREFIXES = |
| 197 '__cp__location=', | 198 ['__cp__location=', '__cp__printer-location=']; |
| 198 '__cp__printer-location=' | |
| 199 ]; | |
| 200 | 199 |
| 201 /** | 200 /** |
| 202 * Enumeration of Google-promoted destination IDs. | 201 * Enumeration of Google-promoted destination IDs. |
| 203 * @enum {string} | 202 * @enum {string} |
| 204 */ | 203 */ |
| 205 Destination.GooglePromotedId = { | 204 Destination.GooglePromotedId = { |
| 206 DOCS: '__google__docs', | 205 DOCS: '__google__docs', |
| 207 FEDEX: '__google__fedex', | 206 FEDEX: '__google__fedex', |
| 208 SAVE_AS_PDF: 'Save as PDF' | 207 SAVE_AS_PDF: 'Save as PDF' |
| 209 }; | 208 }; |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 /** | 321 /** |
| 323 * @return {string} Account this destination is registered for, if known. | 322 * @return {string} Account this destination is registered for, if known. |
| 324 */ | 323 */ |
| 325 get account() { | 324 get account() { |
| 326 return this.account_; | 325 return this.account_; |
| 327 }, | 326 }, |
| 328 | 327 |
| 329 /** @return {boolean} Whether the destination is local or cloud-based. */ | 328 /** @return {boolean} Whether the destination is local or cloud-based. */ |
| 330 get isLocal() { | 329 get isLocal() { |
| 331 return this.origin_ == Destination.Origin.LOCAL || | 330 return this.origin_ == Destination.Origin.LOCAL || |
| 332 this.origin_ == Destination.Origin.EXTENSION || | 331 this.origin_ == Destination.Origin.EXTENSION || |
| 333 (this.origin_ == Destination.Origin.PRIVET && | 332 (this.origin_ == Destination.Origin.PRIVET && |
| 334 this.connectionStatus_ != | 333 this.connectionStatus_ != Destination.ConnectionStatus.UNREGISTERED); |
| 335 Destination.ConnectionStatus.UNREGISTERED); | |
| 336 }, | 334 }, |
| 337 | 335 |
| 338 /** @return {boolean} Whether the destination is a Privet local printer */ | 336 /** @return {boolean} Whether the destination is a Privet local printer */ |
| 339 get isPrivet() { | 337 get isPrivet() { |
| 340 return this.origin_ == Destination.Origin.PRIVET; | 338 return this.origin_ == Destination.Origin.PRIVET; |
| 341 }, | 339 }, |
| 342 | 340 |
| 343 /** | 341 /** |
| 344 * @return {boolean} Whether the destination is an extension managed | 342 * @return {boolean} Whether the destination is an extension managed |
| 345 * printer. | 343 * printer. |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 437 /** | 435 /** |
| 438 * @param {!print_preview.Destination.ConnectionStatus} status Connection | 436 * @param {!print_preview.Destination.ConnectionStatus} status Connection |
| 439 * status of the print destination. | 437 * status of the print destination. |
| 440 */ | 438 */ |
| 441 set connectionStatus(status) { | 439 set connectionStatus(status) { |
| 442 this.connectionStatus_ = status; | 440 this.connectionStatus_ = status; |
| 443 }, | 441 }, |
| 444 | 442 |
| 445 /** @return {boolean} Whether the destination is considered offline. */ | 443 /** @return {boolean} Whether the destination is considered offline. */ |
| 446 get isOffline() { | 444 get isOffline() { |
| 447 return arrayContains([print_preview.Destination.ConnectionStatus.OFFLINE, | 445 return arrayContains( |
| 448 print_preview.Destination.ConnectionStatus.DORMANT], | 446 [ |
| 449 this.connectionStatus_); | 447 print_preview.Destination.ConnectionStatus.OFFLINE, |
| 448 print_preview.Destination.ConnectionStatus.DORMANT |
| 449 ], |
| 450 this.connectionStatus_); |
| 450 }, | 451 }, |
| 451 | 452 |
| 452 /** @return {string} Human readable status for offline destination. */ | 453 /** @return {string} Human readable status for offline destination. */ |
| 453 get offlineStatusText() { | 454 get offlineStatusText() { |
| 454 if (!this.isOffline) { | 455 if (!this.isOffline) { |
| 455 return ''; | 456 return ''; |
| 456 } | 457 } |
| 457 var offlineDurationMs = Date.now() - this.lastAccessTime_; | 458 var offlineDurationMs = Date.now() - this.lastAccessTime_; |
| 458 var offlineMessageId; | 459 var offlineMessageId; |
| 459 if (offlineDurationMs > 31622400000.0) { // One year. | 460 if (offlineDurationMs > 31622400000.0) { // One year. |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 557 get isProvisional() { | 558 get isProvisional() { |
| 558 return this.provisionalType_ != Destination.ProvisionalType.NONE; | 559 return this.provisionalType_ != Destination.ProvisionalType.NONE; |
| 559 } | 560 } |
| 560 }; | 561 }; |
| 561 | 562 |
| 562 // Export | 563 // Export |
| 563 return { | 564 return { |
| 564 Destination: Destination, | 565 Destination: Destination, |
| 565 }; | 566 }; |
| 566 }); | 567 }); |
| OLD | NEW |