Chromium Code Reviews| 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 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 /** | |
| 186 * Whether the destination is an enterprise policy controlled printer. | |
| 187 * @private {boolean} | |
| 188 */ | |
| 189 this.isEnterprisePrinter_ = | |
| 190 (opt_params && opt_params.tags && | |
| 191 arrayContains(opt_params.tags, Destination.EnterprisePrinterTag_)) || | |
|
skau
2017/01/19 03:30:08
Can we add an out_params.isEnterprise instead? We
xdai1
2017/01/19 19:41:30
Done.
| |
| 192 false; | |
| 193 | |
| 185 assert(this.provisionalType_ != | 194 assert(this.provisionalType_ != |
| 186 Destination.ProvisionalType.NEEDS_USB_PERMISSON || | 195 Destination.ProvisionalType.NEEDS_USB_PERMISSON || |
| 187 this.isExtension, | 196 this.isExtension, |
| 188 'Provisional USB destination only supprted with extension origin.'); | 197 'Provisional USB destination only supprted with extension origin.'); |
| 189 }; | 198 }; |
| 190 | 199 |
| 191 /** | 200 /** |
| 192 * Prefix of the location destination tag. | 201 * Prefix of the location destination tag. |
| 193 * @type {!Array<string>} | 202 * @type {!Array<string>} |
| 194 * @const | 203 * @const |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 254 /** Destination is not provisional. */ | 263 /** Destination is not provisional. */ |
| 255 NONE: 'NONE', | 264 NONE: 'NONE', |
| 256 /** | 265 /** |
| 257 * User has to grant USB access for the destination to its provider. | 266 * User has to grant USB access for the destination to its provider. |
| 258 * Used for destinations with extension origin. | 267 * Used for destinations with extension origin. |
| 259 */ | 268 */ |
| 260 NEEDS_USB_PERMISSION: 'NEEDS_USB_PERMISSION' | 269 NEEDS_USB_PERMISSION: 'NEEDS_USB_PERMISSION' |
| 261 }; | 270 }; |
| 262 | 271 |
| 263 /** | 272 /** |
| 273 * Special tag that denotes whether the destination is an enterprise policy | |
| 274 * controlled printer. | |
| 275 * @type {string} | |
| 276 * @const | |
| 277 * @private | |
| 278 */ | |
| 279 Destination.EnterprisePrinterTag_ = '__cp__cups_enterprise_printer=true'; | |
| 280 | |
| 281 /** | |
| 264 * Enumeration of relative icon URLs for various types of destinations. | 282 * Enumeration of relative icon URLs for various types of destinations. |
| 265 * @enum {string} | 283 * @enum {string} |
| 266 * @private | 284 * @private |
| 267 */ | 285 */ |
| 268 Destination.IconUrl_ = { | 286 Destination.IconUrl_ = { |
| 269 CLOUD: 'images/printer.png', | 287 CLOUD: 'images/printer.png', |
| 270 CLOUD_SHARED: 'images/printer_shared.png', | 288 CLOUD_SHARED: 'images/printer_shared.png', |
| 271 LOCAL: 'images/printer.png', | 289 LOCAL: 'images/printer.png', |
| 272 MOBILE: 'images/mobile.png', | 290 MOBILE: 'images/mobile.png', |
| 273 MOBILE_SHARED: 'images/mobile_shared.png', | 291 MOBILE_SHARED: 'images/mobile_shared.png', |
| 274 THIRD_PARTY: 'images/third_party.png', | 292 THIRD_PARTY: 'images/third_party.png', |
| 275 PDF: 'images/pdf.png', | 293 PDF: 'images/pdf.png', |
| 276 DOCS: 'images/google_doc.png', | 294 DOCS: 'images/google_doc.png', |
| 277 FEDEX: 'images/third_party_fedex.png' | 295 FEDEX: 'images/third_party_fedex.png', |
| 296 ENTERPRISE: 'images/business.svg' | |
| 278 }; | 297 }; |
| 279 | 298 |
| 280 Destination.prototype = { | 299 Destination.prototype = { |
| 281 /** @return {string} ID of the destination. */ | 300 /** @return {string} ID of the destination. */ |
| 282 get id() { | 301 get id() { |
| 283 return this.id_; | 302 return this.id_; |
| 284 }, | 303 }, |
| 285 | 304 |
| 286 /** @return {!print_preview.Destination.Type} Type of the destination. */ | 305 /** @return {!print_preview.Destination.Type} Type of the destination. */ |
| 287 get type() { | 306 get type() { |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 482 get iconUrl() { | 501 get iconUrl() { |
| 483 if (this.id_ == Destination.GooglePromotedId.DOCS) { | 502 if (this.id_ == Destination.GooglePromotedId.DOCS) { |
| 484 return Destination.IconUrl_.DOCS; | 503 return Destination.IconUrl_.DOCS; |
| 485 } | 504 } |
| 486 if (this.id_ == Destination.GooglePromotedId.FEDEX) { | 505 if (this.id_ == Destination.GooglePromotedId.FEDEX) { |
| 487 return Destination.IconUrl_.FEDEX; | 506 return Destination.IconUrl_.FEDEX; |
| 488 } | 507 } |
| 489 if (this.id_ == Destination.GooglePromotedId.SAVE_AS_PDF) { | 508 if (this.id_ == Destination.GooglePromotedId.SAVE_AS_PDF) { |
| 490 return Destination.IconUrl_.PDF; | 509 return Destination.IconUrl_.PDF; |
| 491 } | 510 } |
| 511 if (this.isEnterprisePrinter) { | |
| 512 return Destination.IconUrl_.ENTERPRISE; | |
| 513 } | |
| 492 if (this.isLocal) { | 514 if (this.isLocal) { |
| 493 return Destination.IconUrl_.LOCAL; | 515 return Destination.IconUrl_.LOCAL; |
| 494 } | 516 } |
| 495 if (this.type_ == Destination.Type.MOBILE && this.isOwned_) { | 517 if (this.type_ == Destination.Type.MOBILE && this.isOwned_) { |
| 496 return Destination.IconUrl_.MOBILE; | 518 return Destination.IconUrl_.MOBILE; |
| 497 } | 519 } |
| 498 if (this.type_ == Destination.Type.MOBILE) { | 520 if (this.type_ == Destination.Type.MOBILE) { |
| 499 return Destination.IconUrl_.MOBILE_SHARED; | 521 return Destination.IconUrl_.MOBILE_SHARED; |
| 500 } | 522 } |
| 501 if (this.isOwned_) { | 523 if (this.isOwned_) { |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 551 get provisionalType() { | 573 get provisionalType() { |
| 552 return this.provisionalType_; | 574 return this.provisionalType_; |
| 553 }, | 575 }, |
| 554 | 576 |
| 555 /** | 577 /** |
| 556 * Whether the destinaion is provisional. | 578 * Whether the destinaion is provisional. |
| 557 * @return {boolean} | 579 * @return {boolean} |
| 558 */ | 580 */ |
| 559 get isProvisional() { | 581 get isProvisional() { |
| 560 return this.provisionalType_ != Destination.ProvisionalType.NONE; | 582 return this.provisionalType_ != Destination.ProvisionalType.NONE; |
| 561 } | 583 }, |
| 584 | |
| 585 /** | |
| 586 * Whether the printer is enterprise policy controlled printer. | |
| 587 * @return {boolean} | |
| 588 */ | |
| 589 get isEnterprisePrinter() { | |
| 590 return this.isEnterprisePrinter_; | |
| 591 }, | |
| 562 }; | 592 }; |
| 563 | 593 |
| 564 // Export | 594 // Export |
| 565 return { | 595 return { |
| 566 Destination: Destination, | 596 Destination: Destination, |
| 567 }; | 597 }; |
| 568 }); | 598 }); |
| OLD | NEW |