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 * |
11 * @typedef {{ | 11 * @typedef {{ |
12 * version: string, | 12 * version: string, |
13 * printer: { | 13 * printer: { |
14 * vendor_capability: !Array.<{Object}>, | 14 * vendor_capability: !Array<{Object}>, |
15 * collate: ({default: (boolean|undefined)}|undefined), | 15 * collate: ({default: (boolean|undefined)}|undefined), |
16 * color: ({ | 16 * color: ({ |
17 * option: !Array.<{ | 17 * option: !Array<{ |
18 * type: (string|undefined), | 18 * type: (string|undefined), |
19 * vendor_id: (string|undefined), | 19 * vendor_id: (string|undefined), |
20 * custom_display_name: (string|undefined), | 20 * custom_display_name: (string|undefined), |
21 * is_default: (boolean|undefined) | 21 * is_default: (boolean|undefined) |
22 * }> | 22 * }> |
23 * }|undefined), | 23 * }|undefined), |
24 * copies: ({default: (number|undefined), | 24 * copies: ({default: (number|undefined), |
25 * max: (number|undefined)}|undefined), | 25 * max: (number|undefined)}|undefined), |
26 * duplex: ({option: !Array.<{type: (string|undefined), | 26 * duplex: ({option: !Array<{type: (string|undefined), |
27 * is_default: (boolean|undefined)}>}|undefined), | 27 * is_default: (boolean|undefined)}>}|undefined), |
28 * page_orientation: ({ | 28 * page_orientation: ({ |
29 * option: !Array.<{type: (string|undefined), | 29 * option: !Array<{type: (string|undefined), |
30 * is_default: (boolean|undefined)}> | 30 * is_default: (boolean|undefined)}> |
31 * }|undefined) | 31 * }|undefined) |
32 * } | 32 * } |
33 * }} | 33 * }} |
34 */ | 34 */ |
35 print_preview.Cdd; | 35 print_preview.Cdd; |
36 | 36 |
37 cr.define('print_preview', function() { | 37 cr.define('print_preview', function() { |
38 'use strict'; | 38 'use strict'; |
39 | 39 |
40 /** | 40 /** |
41 * Print destination data object that holds data for both local and cloud | 41 * Print destination data object that holds data for both local and cloud |
42 * destinations. | 42 * destinations. |
43 * @param {string} id ID of the destination. | 43 * @param {string} id ID of the destination. |
44 * @param {!print_preview.Destination.Type} type Type of the destination. | 44 * @param {!print_preview.Destination.Type} type Type of the destination. |
45 * @param {!print_preview.Destination.Origin} origin Origin of the | 45 * @param {!print_preview.Destination.Origin} origin Origin of the |
46 * destination. | 46 * destination. |
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 * extensionId: (string|undefined), | 57 * extensionId: (string|undefined), |
58 * description: (string|undefined)}=} opt_params Optional parameters | 58 * description: (string|undefined)}=} opt_params Optional parameters |
59 * for the destination. | 59 * for the destination. |
60 * @constructor | 60 * @constructor |
61 */ | 61 */ |
(...skipping 24 matching lines...) Expand all Loading... |
86 this.displayName_ = displayName || ''; | 86 this.displayName_ = displayName || ''; |
87 | 87 |
88 /** | 88 /** |
89 * Whether the destination has been used recently. | 89 * Whether the destination has been used recently. |
90 * @private {boolean} | 90 * @private {boolean} |
91 */ | 91 */ |
92 this.isRecent_ = isRecent; | 92 this.isRecent_ = isRecent; |
93 | 93 |
94 /** | 94 /** |
95 * Tags associated with the destination. | 95 * Tags associated with the destination. |
96 * @private {!Array.<string>} | 96 * @private {!Array<string>} |
97 */ | 97 */ |
98 this.tags_ = (opt_params && opt_params.tags) || []; | 98 this.tags_ = (opt_params && opt_params.tags) || []; |
99 | 99 |
100 /** | 100 /** |
101 * Print capabilities of the destination. | 101 * Print capabilities of the destination. |
102 * @private {?print_preview.Cdd} | 102 * @private {?print_preview.Cdd} |
103 */ | 103 */ |
104 this.capabilities_ = null; | 104 this.capabilities_ = null; |
105 | 105 |
106 /** | 106 /** |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 | 157 |
158 /** | 158 /** |
159 * Extension ID for extension managed printers. | 159 * Extension ID for extension managed printers. |
160 * @private {string} | 160 * @private {string} |
161 */ | 161 */ |
162 this.extensionId_ = (opt_params && opt_params.extensionId) || ''; | 162 this.extensionId_ = (opt_params && opt_params.extensionId) || ''; |
163 }; | 163 }; |
164 | 164 |
165 /** | 165 /** |
166 * Prefix of the location destination tag. | 166 * Prefix of the location destination tag. |
167 * @type {!Array.<string>} | 167 * @type {!Array<string>} |
168 * @const | 168 * @const |
169 */ | 169 */ |
170 Destination.LOCATION_TAG_PREFIXES = [ | 170 Destination.LOCATION_TAG_PREFIXES = [ |
171 '__cp__location=', | 171 '__cp__location=', |
172 '__cp__printer-location=' | 172 '__cp__printer-location=' |
173 ]; | 173 ]; |
174 | 174 |
175 /** | 175 /** |
176 * Enumeration of Google-promoted destination IDs. | 176 * Enumeration of Google-promoted destination IDs. |
177 * @enum {string} | 177 * @enum {string} |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 * destination. | 339 * destination. |
340 */ | 340 */ |
341 get hint() { | 341 get hint() { |
342 if (this.id_ == Destination.GooglePromotedId.DOCS || | 342 if (this.id_ == Destination.GooglePromotedId.DOCS || |
343 this.id_ == Destination.GooglePromotedId.FEDEX) { | 343 this.id_ == Destination.GooglePromotedId.FEDEX) { |
344 return this.account_; | 344 return this.account_; |
345 } | 345 } |
346 return this.location || this.description; | 346 return this.location || this.description; |
347 }, | 347 }, |
348 | 348 |
349 /** @return {!Array.<string>} Tags associated with the destination. */ | 349 /** @return {!Array<string>} Tags associated with the destination. */ |
350 get tags() { | 350 get tags() { |
351 return this.tags_.slice(0); | 351 return this.tags_.slice(0); |
352 }, | 352 }, |
353 | 353 |
354 /** @return {string} Cloud ID associated with the destination */ | 354 /** @return {string} Cloud ID associated with the destination */ |
355 get cloudID() { | 355 get cloudID() { |
356 return this.cloudID_; | 356 return this.cloudID_; |
357 }, | 357 }, |
358 | 358 |
359 /** | 359 /** |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 /** | 464 /** |
465 * @param {?boolean} isTosAccepted Whether the user has accepted the | 465 * @param {?boolean} isTosAccepted Whether the user has accepted the |
466 * terms-of-service of the print destination or {@code null} if | 466 * terms-of-service of the print destination or {@code null} if |
467 * a terms-of-service does not apply. | 467 * a terms-of-service does not apply. |
468 */ | 468 */ |
469 set isTosAccepted(isTosAccepted) { | 469 set isTosAccepted(isTosAccepted) { |
470 this.isTosAccepted_ = isTosAccepted; | 470 this.isTosAccepted_ = isTosAccepted; |
471 }, | 471 }, |
472 | 472 |
473 /** | 473 /** |
474 * @return {!Array.<string>} Properties (besides display name) to match | 474 * @return {!Array<string>} Properties (besides display name) to match |
475 * search queries against. | 475 * search queries against. |
476 */ | 476 */ |
477 get extraPropertiesToMatch() { | 477 get extraPropertiesToMatch() { |
478 return [this.location, this.description]; | 478 return [this.location, this.description]; |
479 }, | 479 }, |
480 | 480 |
481 /** | 481 /** |
482 * Matches a query against the destination. | 482 * Matches a query against the destination. |
483 * @param {!RegExp} query Query to match against the destination. | 483 * @param {!RegExp} query Query to match against the destination. |
484 * @return {boolean} {@code true} if the query matches this destination, | 484 * @return {boolean} {@code true} if the query matches this destination, |
485 * {@code false} otherwise. | 485 * {@code false} otherwise. |
486 */ | 486 */ |
487 matches: function(query) { | 487 matches: function(query) { |
488 return !!this.displayName_.match(query) || | 488 return !!this.displayName_.match(query) || |
489 this.extraPropertiesToMatch.some(function(property) { | 489 this.extraPropertiesToMatch.some(function(property) { |
490 return property.match(query); | 490 return property.match(query); |
491 }); | 491 }); |
492 } | 492 } |
493 }; | 493 }; |
494 | 494 |
495 // Export | 495 // Export |
496 return { | 496 return { |
497 Destination: Destination, | 497 Destination: Destination, |
498 }; | 498 }; |
499 }); | 499 }); |
OLD | NEW |