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

Unified Diff: chrome/browser/resources/print_preview/data/destination.js

Issue 10450022: Print Preview Print Destination Search Widget (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Set --bary flag Created 8 years, 7 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 side-by-side diff with in-line comments
Download patch
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 01a9491069556b724effcaefc591b07c69dd429f..b62d818685af0a568149bfe79faece6009ce56bf 100644
--- a/chrome/browser/resources/print_preview/data/destination.js
+++ b/chrome/browser/resources/print_preview/data/destination.js
@@ -9,13 +9,15 @@ cr.define('print_preview', function() {
* Print destination data object that holds data for both local and cloud
* destinations.
* @param {string} id ID of the destination.
+ * @param {!print_preview.Destination.Type} type Type of the destination.
* @param {string} displayName Display name of the destination.
* @param {boolean} isRecent Whether the destination has been used recently.
- * @param {boolean} isLocal Whether the destination is local or cloud-based.
* @param {Array.<string>=} opt_tags Tags associated with the destination.
+ * @param {boolean=} opt_isOwned Whether the destination is owned by the user.
+ * Only applies to cloud-based destinations.
* @constructor
*/
- function Destination(id, displayName, isRecent, isLocal, opt_tags) {
+ function Destination(id, type, displayName, isRecent, opt_tags, opt_isOwned) {
/**
* ID of the destination.
* @type {string}
@@ -24,6 +26,13 @@ cr.define('print_preview', function() {
this.id_ = id;
/**
+ * Type of the destination.
+ * @type {!print_preview.Destination.Type}
+ * @private
+ */
+ this.type_ = type;
+
+ /**
* Display name of the destination.
* @type {string}
* @private
@@ -38,13 +47,6 @@ cr.define('print_preview', function() {
this.isRecent_ = isRecent;
/**
- * Whether the destination is local or cloud-based.
- * @type {boolean}
- * @private
- */
- this.isLocal_ = isLocal;
-
- /**
* Tags associated with the destination.
* @type {!Array.<string>}
* @private
@@ -59,8 +61,15 @@ cr.define('print_preview', function() {
this.capabilities_ = null;
/**
+ * Whether the destination is owned by the user.
+ * @type {boolean}
+ * @private
+ */
+ this.isOwned_ = opt_isOwned || false;
+
+ /**
* Cache of destination location fetched from tags.
- * @type {string}
+ * @type {?string}
* @private
*/
this.location_ = null;
@@ -79,8 +88,18 @@ cr.define('print_preview', function() {
*/
Destination.GooglePromotedId = {
DOCS: '__google__docs',
- SAVE_AS_PDF: 'Save as PDF',
- PRINT_WITH_CLOUD_PRINT: 'printWithCloudPrint'
+ FEDEX: '__google__fedex',
+ SAVE_AS_PDF: 'Save as PDF'
+ };
+
+ /**
+ * Enumeration of the types of destinations.
+ * @enum {string}
+ */
+ Destination.Type = {
+ GOOGLE: 'google',
+ LOCAL: 'local',
+ MOBILE: 'mobile'
};
Destination.prototype = {
@@ -89,6 +108,11 @@ cr.define('print_preview', function() {
return this.id_;
},
+ /** @return {!print_preview.Destination.Type} Type of the destination. */
+ get type() {
+ return this.type_;
+ },
+
/** @return {string} Display name of the destination. */
get displayName() {
return this.displayName_;
@@ -106,9 +130,17 @@ cr.define('print_preview', function() {
this.isRecent_ = isRecent;
},
+ /**
+ * @return {boolean} Whether the user owns the destination. Only applies to
+ * cloud-based destinations.
+ */
+ get isOwned() {
+ return this.isOwned_;
+ },
+
/** @return {boolean} Whether the destination is local or cloud-based. */
get isLocal() {
- return this.isLocal_;
+ return this.type_ == Destination.Type.LOCAL;
},
/** @return {boolean} Whether the destination is promoted by Google. */
@@ -122,14 +154,6 @@ cr.define('print_preview', function() {
},
/**
- * @return {boolean} Whether the destination is the "Print with Cloud Print"
- * destination.
- */
- get isPrintWithCloudPrint() {
- return this.id_ == Destination.GooglePromotedId.PRINT_WITH_CLOUD_PRINT;
- },
-
- /**
* @return {string} The location of the destination, or an empty string if
* the location is unknown.
*/
@@ -138,12 +162,10 @@ cr.define('print_preview', function() {
for (var tag, i = 0; tag = this.tags_[i]; i++) {
if (tag.indexOf(Destination.LOCATION_TAG_PREFIX) == 0) {
this.location_ = tag.substring(
- Destination.LOCATION_TAG_PREFIX.length);
+ Destination.LOCATION_TAG_PREFIX.length) || '';
+ break;
}
}
- if (this.location_ == null) {
- this.location_ = '';
- }
}
return this.location_;
},

Powered by Google App Engine
This is Rietveld 408576698