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 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 254 /** Destination is not provisional. */ | 254 /** Destination is not provisional. */ |
| 255 NONE: 'NONE', | 255 NONE: 'NONE', |
| 256 /** | 256 /** |
| 257 * User has to grant USB access for the destination to its provider. | 257 * User has to grant USB access for the destination to its provider. |
| 258 * Used for destinations with extension origin. | 258 * Used for destinations with extension origin. |
| 259 */ | 259 */ |
| 260 NEEDS_USB_PERMISSION: 'NEEDS_USB_PERMISSION' | 260 NEEDS_USB_PERMISSION: 'NEEDS_USB_PERMISSION' |
| 261 }; | 261 }; |
| 262 | 262 |
| 263 /** | 263 /** |
| 264 * Special tag that denotes whether the destination is an enterprise policy | |
| 265 * controlled printer. | |
| 266 * @type {string} | |
| 267 * @const | |
| 268 * @private | |
| 269 */ | |
| 270 Destination.EnterprisePrinterTag_ = '__cp__cups_enterprise_printer=true'; | |
| 271 | |
| 272 /** | |
| 264 * Enumeration of relative icon URLs for various types of destinations. | 273 * Enumeration of relative icon URLs for various types of destinations. |
| 265 * @enum {string} | 274 * @enum {string} |
| 266 * @private | 275 * @private |
| 267 */ | 276 */ |
| 268 Destination.IconUrl_ = { | 277 Destination.IconUrl_ = { |
| 269 CLOUD: 'images/printer.png', | 278 CLOUD: 'images/printer.png', |
| 270 CLOUD_SHARED: 'images/printer_shared.png', | 279 CLOUD_SHARED: 'images/printer_shared.png', |
| 271 LOCAL: 'images/printer.png', | 280 LOCAL: 'images/printer.png', |
| 272 MOBILE: 'images/mobile.png', | 281 MOBILE: 'images/mobile.png', |
| 273 MOBILE_SHARED: 'images/mobile_shared.png', | 282 MOBILE_SHARED: 'images/mobile_shared.png', |
| 274 THIRD_PARTY: 'images/third_party.png', | 283 THIRD_PARTY: 'images/third_party.png', |
| 275 PDF: 'images/pdf.png', | 284 PDF: 'images/pdf.png', |
| 276 DOCS: 'images/google_doc.png', | 285 DOCS: 'images/google_doc.png', |
| 277 FEDEX: 'images/third_party_fedex.png' | 286 FEDEX: 'images/third_party_fedex.png', |
| 287 ENTERPRISE: 'images/business.svg' | |
| 278 }; | 288 }; |
| 279 | 289 |
| 280 Destination.prototype = { | 290 Destination.prototype = { |
| 281 /** @return {string} ID of the destination. */ | 291 /** @return {string} ID of the destination. */ |
| 282 get id() { | 292 get id() { |
| 283 return this.id_; | 293 return this.id_; |
| 284 }, | 294 }, |
| 285 | 295 |
| 286 /** @return {!print_preview.Destination.Type} Type of the destination. */ | 296 /** @return {!print_preview.Destination.Type} Type of the destination. */ |
| 287 get type() { | 297 get type() { |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 482 get iconUrl() { | 492 get iconUrl() { |
| 483 if (this.id_ == Destination.GooglePromotedId.DOCS) { | 493 if (this.id_ == Destination.GooglePromotedId.DOCS) { |
| 484 return Destination.IconUrl_.DOCS; | 494 return Destination.IconUrl_.DOCS; |
| 485 } | 495 } |
| 486 if (this.id_ == Destination.GooglePromotedId.FEDEX) { | 496 if (this.id_ == Destination.GooglePromotedId.FEDEX) { |
| 487 return Destination.IconUrl_.FEDEX; | 497 return Destination.IconUrl_.FEDEX; |
| 488 } | 498 } |
| 489 if (this.id_ == Destination.GooglePromotedId.SAVE_AS_PDF) { | 499 if (this.id_ == Destination.GooglePromotedId.SAVE_AS_PDF) { |
| 490 return Destination.IconUrl_.PDF; | 500 return Destination.IconUrl_.PDF; |
| 491 } | 501 } |
| 502 if (this.isEnterprisePrinter) { | |
| 503 return Destination.IconUrl_.ENTERPRISE; | |
| 504 } | |
| 492 if (this.isLocal) { | 505 if (this.isLocal) { |
| 493 return Destination.IconUrl_.LOCAL; | 506 return Destination.IconUrl_.LOCAL; |
| 494 } | 507 } |
| 495 if (this.type_ == Destination.Type.MOBILE && this.isOwned_) { | 508 if (this.type_ == Destination.Type.MOBILE && this.isOwned_) { |
| 496 return Destination.IconUrl_.MOBILE; | 509 return Destination.IconUrl_.MOBILE; |
| 497 } | 510 } |
| 498 if (this.type_ == Destination.Type.MOBILE) { | 511 if (this.type_ == Destination.Type.MOBILE) { |
| 499 return Destination.IconUrl_.MOBILE_SHARED; | 512 return Destination.IconUrl_.MOBILE_SHARED; |
| 500 } | 513 } |
| 501 if (this.isOwned_) { | 514 if (this.isOwned_) { |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 551 get provisionalType() { | 564 get provisionalType() { |
| 552 return this.provisionalType_; | 565 return this.provisionalType_; |
| 553 }, | 566 }, |
| 554 | 567 |
| 555 /** | 568 /** |
| 556 * Whether the destinaion is provisional. | 569 * Whether the destinaion is provisional. |
| 557 * @return {boolean} | 570 * @return {boolean} |
| 558 */ | 571 */ |
| 559 get isProvisional() { | 572 get isProvisional() { |
| 560 return this.provisionalType_ != Destination.ProvisionalType.NONE; | 573 return this.provisionalType_ != Destination.ProvisionalType.NONE; |
| 561 } | 574 }, |
| 575 | |
| 576 /** | |
| 577 * Whether the printer is enterprise policy controlled printer. | |
| 578 * @return {boolean} | |
| 579 */ | |
| 580 get isEnterprisePrinter() { | |
| 581 return arrayContains(this.tags_, Destination.EnterprisePrinterTag_); | |
|
dpapad
2017/01/18 02:56:04
Is this linear search going to be costly? What is
xdai1
2017/01/18 18:45:42
For a single printer, the size of |tags_| equals t
skau
2017/01/18 20:59:06
FYI: We expect around 20 printer properties for an
dpapad
2017/01/18 21:09:57
So if I have hundreds of printers (like in a Googl
skau
2017/01/18 22:05:40
xdai@ We should probably make isEnterprise a separ
xdai1
2017/01/19 01:10:17
I made isEnterprise_ a separate field on the desti
xdai1
2017/01/19 01:10:17
the format of|this.tags_| (https://cs.chromium.org
| |
| 582 }, | |
| 562 }; | 583 }; |
| 563 | 584 |
| 564 // Export | 585 // Export |
| 565 return { | 586 return { |
| 566 Destination: Destination, | 587 Destination: Destination, |
| 567 }; | 588 }; |
| 568 }); | 589 }); |
| OLD | NEW |