Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(179)

Side by Side Diff: chrome/browser/resources/print_preview/data/destination.js

Issue 900503002: List printers managed by extensions in print preview (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 * description: (string|undefined)}=} opt_params Optional parameters 58 * description: (string|undefined)}=} opt_params Optional parameters
58 * for the destination. 59 * for the destination.
59 * @constructor 60 * @constructor
60 */ 61 */
61 function Destination(id, type, origin, displayName, isRecent, 62 function Destination(id, type, origin, displayName, isRecent,
62 connectionStatus, opt_params) { 63 connectionStatus, opt_params) {
63 /** 64 /**
64 * ID of the destination. 65 * ID of the destination.
65 * @private {string} 66 * @private {string}
66 */ 67 */
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 * {@code null} if terms-of-service does not apply to the print destination. 147 * {@code null} if terms-of-service does not apply to the print destination.
147 * @private {?boolean} 148 * @private {?boolean}
148 */ 149 */
149 this.isTosAccepted_ = !!(opt_params && opt_params.isTosAccepted); 150 this.isTosAccepted_ = !!(opt_params && opt_params.isTosAccepted);
150 151
151 /** 152 /**
152 * Cloud ID for Privet printers. 153 * Cloud ID for Privet printers.
153 * @private {string} 154 * @private {string}
154 */ 155 */
155 this.cloudID_ = (opt_params && opt_params.cloudID) || ''; 156 this.cloudID_ = (opt_params && opt_params.cloudID) || '';
157
158 /**
159 * Extension ID for extension managed printers.
160 * @private {string}
161 */
162 this.extensionId_ = (opt_params && opt_params.extensionId) || '';
156 }; 163 };
157 164
158 /** 165 /**
159 * Prefix of the location destination tag. 166 * Prefix of the location destination tag.
160 * @type {!Array.<string>} 167 * @type {!Array.<string>}
161 * @const 168 * @const
162 */ 169 */
163 Destination.LOCATION_TAG_PREFIXES = [ 170 Destination.LOCATION_TAG_PREFIXES = [
164 '__cp__location=', 171 '__cp__location=',
165 '__cp__printer-location=' 172 '__cp__printer-location='
(...skipping 22 matching lines...) Expand all
188 195
189 /** 196 /**
190 * Enumeration of the origin types for cloud destinations. 197 * Enumeration of the origin types for cloud destinations.
191 * @enum {string} 198 * @enum {string}
192 */ 199 */
193 Destination.Origin = { 200 Destination.Origin = {
194 LOCAL: 'local', 201 LOCAL: 'local',
195 COOKIES: 'cookies', 202 COOKIES: 'cookies',
196 PROFILE: 'profile', 203 PROFILE: 'profile',
197 DEVICE: 'device', 204 DEVICE: 'device',
198 PRIVET: 'privet' 205 PRIVET: 'privet',
206 EXTENSION: 'extension'
199 }; 207 };
200 208
201 /** 209 /**
202 * Enumeration of the connection statuses of printer destinations. 210 * Enumeration of the connection statuses of printer destinations.
203 * @enum {string} 211 * @enum {string}
204 */ 212 */
205 Destination.ConnectionStatus = { 213 Destination.ConnectionStatus = {
206 DORMANT: 'DORMANT', 214 DORMANT: 'DORMANT',
207 OFFLINE: 'OFFLINE', 215 OFFLINE: 'OFFLINE',
208 ONLINE: 'ONLINE', 216 ONLINE: 'ONLINE',
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 /** 281 /**
274 * @return {string} Account this destination is registered for, if known. 282 * @return {string} Account this destination is registered for, if known.
275 */ 283 */
276 get account() { 284 get account() {
277 return this.account_; 285 return this.account_;
278 }, 286 },
279 287
280 /** @return {boolean} Whether the destination is local or cloud-based. */ 288 /** @return {boolean} Whether the destination is local or cloud-based. */
281 get isLocal() { 289 get isLocal() {
282 return this.origin_ == Destination.Origin.LOCAL || 290 return this.origin_ == Destination.Origin.LOCAL ||
291 this.origin_ == Destination.Origin.EXTENSION ||
283 (this.origin_ == Destination.Origin.PRIVET && 292 (this.origin_ == Destination.Origin.PRIVET &&
284 this.connectionStatus_ != 293 this.connectionStatus_ !=
285 Destination.ConnectionStatus.UNREGISTERED); 294 Destination.ConnectionStatus.UNREGISTERED);
286 }, 295 },
287 296
288 /** @return {boolean} Whether the destination is a Privet local printer */ 297 /** @return {boolean} Whether the destination is a Privet local printer */
289 get isPrivet() { 298 get isPrivet() {
290 return this.origin_ == Destination.Origin.PRIVET; 299 return this.origin_ == Destination.Origin.PRIVET;
291 }, 300 },
292 301
293 /** 302 /**
303 * @return {boolean} Whether the destination is an extension managed
304 * printer.
305 */
306 get isExtension() {
307 return this.origin_ == Destination.Origin.EXTENSION;
308 },
309
310 /**
294 * @return {string} The location of the destination, or an empty string if 311 * @return {string} The location of the destination, or an empty string if
295 * the location is unknown. 312 * the location is unknown.
296 */ 313 */
297 get location() { 314 get location() {
298 if (this.location_ == null) { 315 if (this.location_ == null) {
299 this.location_ = ''; 316 this.location_ = '';
300 this.tags_.some(function(tag) { 317 this.tags_.some(function(tag) {
301 return Destination.LOCATION_TAG_PREFIXES.some(function(prefix) { 318 return Destination.LOCATION_TAG_PREFIXES.some(function(prefix) {
302 if (tag.indexOf(prefix) == 0) { 319 if (tag.indexOf(prefix) == 0) {
303 this.location_ = tag.substring(prefix.length) || ''; 320 this.location_ = tag.substring(prefix.length) || '';
(...skipping 28 matching lines...) Expand all
332 /** @return {!Array.<string>} Tags associated with the destination. */ 349 /** @return {!Array.<string>} Tags associated with the destination. */
333 get tags() { 350 get tags() {
334 return this.tags_.slice(0); 351 return this.tags_.slice(0);
335 }, 352 },
336 353
337 /** @return {string} Cloud ID associated with the destination */ 354 /** @return {string} Cloud ID associated with the destination */
338 get cloudID() { 355 get cloudID() {
339 return this.cloudID_; 356 return this.cloudID_;
340 }, 357 },
341 358
359 /**
360 * @return {string} Extension ID associated with the destination. Set only
361 * for extension managed printers.
Aleksey Shlyapnikov 2015/02/04 18:50:27 Nit: It is always set, it's just set to '' for non
tbarzic 2015/02/04 19:27:41 Done.
362 */
363 get extensionId() {
364 return this.extensionId_;
365 },
366
342 /** @return {?print_preview.Cdd} Print capabilities of the destination. */ 367 /** @return {?print_preview.Cdd} Print capabilities of the destination. */
343 get capabilities() { 368 get capabilities() {
344 return this.capabilities_; 369 return this.capabilities_;
345 }, 370 },
346 371
347 /** 372 /**
348 * @param {!print_preview.Cdd} capabilities Print capabilities of the 373 * @param {!print_preview.Cdd} capabilities Print capabilities of the
349 * destination. 374 * destination.
350 */ 375 */
351 set capabilities(capabilities) { 376 set capabilities(capabilities) {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 }, 428 },
404 429
405 /** @return {string} Relative URL of the destination's icon. */ 430 /** @return {string} Relative URL of the destination's icon. */
406 get iconUrl() { 431 get iconUrl() {
407 if (this.id_ == Destination.GooglePromotedId.DOCS) { 432 if (this.id_ == Destination.GooglePromotedId.DOCS) {
408 return Destination.IconUrl_.DOCS; 433 return Destination.IconUrl_.DOCS;
409 } else if (this.id_ == Destination.GooglePromotedId.FEDEX) { 434 } else if (this.id_ == Destination.GooglePromotedId.FEDEX) {
410 return Destination.IconUrl_.FEDEX; 435 return Destination.IconUrl_.FEDEX;
411 } else if (this.id_ == Destination.GooglePromotedId.SAVE_AS_PDF) { 436 } else if (this.id_ == Destination.GooglePromotedId.SAVE_AS_PDF) {
412 return Destination.IconUrl_.PDF; 437 return Destination.IconUrl_.PDF;
438 } else if (this.isExtension) {
439 // TODO(tbarzic): Update the way extension printers are displayed in the
440 // destination list when the desired UX is defined.
441 return 'chrome://extension-icon/' + this.extensionId + '/48/1';
413 } else if (this.isLocal) { 442 } else if (this.isLocal) {
414 return Destination.IconUrl_.LOCAL; 443 return Destination.IconUrl_.LOCAL;
415 } else if (this.type_ == Destination.Type.MOBILE && this.isOwned_) { 444 } else if (this.type_ == Destination.Type.MOBILE && this.isOwned_) {
416 return Destination.IconUrl_.MOBILE; 445 return Destination.IconUrl_.MOBILE;
417 } else if (this.type_ == Destination.Type.MOBILE) { 446 } else if (this.type_ == Destination.Type.MOBILE) {
418 return Destination.IconUrl_.MOBILE_SHARED; 447 return Destination.IconUrl_.MOBILE_SHARED;
419 } else if (this.isOwned_) { 448 } else if (this.isOwned_) {
420 return Destination.IconUrl_.CLOUD; 449 return Destination.IconUrl_.CLOUD;
421 } else { 450 } else {
422 return Destination.IconUrl_.CLOUD_SHARED; 451 return Destination.IconUrl_.CLOUD_SHARED;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 return property.match(query); 490 return property.match(query);
462 }); 491 });
463 } 492 }
464 }; 493 };
465 494
466 // Export 495 // Export
467 return { 496 return {
468 Destination: Destination, 497 Destination: Destination,
469 }; 498 };
470 }); 499 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698