Index: chrome/browser/resources/print_preview/data/destination.js |
diff --git a/chrome/browser/resources/print_preview/data/destination.js b/chrome/browser/resources/print_preview/data/destination.js |
index 6daad812b68dbaf74bddacd9fe1a641eda29b78b..553c70a88142e53e7fa2a80cd2a190b120ac0fc4 100644 |
--- a/chrome/browser/resources/print_preview/data/destination.js |
+++ b/chrome/browser/resources/print_preview/data/destination.js |
@@ -55,6 +55,7 @@ cr.define('print_preview', function() { |
* isTosAccepted: (boolean|undefined), |
* cloudID: (string|undefined), |
* extensionId: (string|undefined), |
+ * extensionName: (string|undefined), |
* description: (string|undefined)}=} opt_params Optional parameters |
* for the destination. |
* @constructor |
@@ -160,6 +161,12 @@ cr.define('print_preview', function() { |
* @private {string} |
*/ |
this.extensionId_ = (opt_params && opt_params.extensionId) || ''; |
+ |
+ /** |
+ * Extension name for extension managed printers. |
+ * @private {string} |
+ */ |
+ this.extensionName_ = (opt_params && opt_params.extensionName) || ''; |
}; |
/** |
@@ -343,7 +350,7 @@ cr.define('print_preview', function() { |
this.id_ == Destination.GooglePromotedId.FEDEX) { |
return this.account_; |
} |
- return this.location || this.description; |
+ return this.location || this.extensionName || this.description; |
}, |
/** @return {!Array<string>} Tags associated with the destination. */ |
@@ -364,6 +371,14 @@ cr.define('print_preview', function() { |
return this.extensionId_; |
}, |
+ /** |
+ * @return {string} Extension name associated with the destination. |
+ * Non-empty only for extension managed printers. |
+ */ |
+ get extensionName() { |
+ return this.extensionName_; |
+ }, |
+ |
/** @return {?print_preview.Cdd} Print capabilities of the destination. */ |
get capabilities() { |
return this.capabilities_; |
@@ -435,10 +450,6 @@ cr.define('print_preview', function() { |
return Destination.IconUrl_.FEDEX; |
} else if (this.id_ == Destination.GooglePromotedId.SAVE_AS_PDF) { |
return Destination.IconUrl_.PDF; |
- } else if (this.isExtension) { |
- // TODO(tbarzic): Update the way extension printers are displayed in the |
- // destination list when the desired UX is defined. |
- return 'chrome://extension-icon/' + this.extensionId + '/48/1'; |
} else if (this.isLocal) { |
return Destination.IconUrl_.LOCAL; |
} else if (this.type_ == Destination.Type.MOBILE && this.isOwned_) { |
@@ -453,6 +464,20 @@ cr.define('print_preview', function() { |
}, |
/** |
+ * @return {string} For extension destinations returns the backgournd-image |
+ * style property of extension icon associated with the destination. The |
+ * icon should be used to attribute the destination to an extension. |
+ * For non extension destination, returns empty string. |
+ */ |
+ get extensionIconImageStyle() { |
+ if (!this.extensionId_) |
+ return ''; |
+ return '-webkit-image-set(' + |
+ 'url(chrome://extension-icon/' + this.extensionId_ + '/24/1) 1x,' + |
+ 'url(chrome://extension-icon/' + this.extensionId_ + '/48/1) 2x)'; |
+ }, |
Aleksey Shlyapnikov
2015/03/06 00:27:39
If it's not part of the generic iconUrl logic, can
tbarzic
2015/03/06 03:16:11
Done.
|
+ |
+ /** |
* @return {?boolean} Whether the user has accepted the terms-of-service of |
* the print destination or {@code null} if a terms-of-service does not |
* apply. |
@@ -486,6 +511,7 @@ cr.define('print_preview', function() { |
*/ |
matches: function(query) { |
return !!this.displayName_.match(query) || |
+ !!this.extensionName_.match(query) || |
this.extraPropertiesToMatch.some(function(property) { |
return property.match(query); |
}); |