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

Unified Diff: chrome/browser/resources/print_preview/data/ticket_items/color.js

Issue 321703002: Revert of Generalize printer color model handling, get rid of CUPS specific case. Enable supported paper szes… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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/ticket_items/color.js
diff --git a/chrome/browser/resources/print_preview/data/ticket_items/color.js b/chrome/browser/resources/print_preview/data/ticket_items/color.js
index e3d52381b838ddf188866fb867db48e3b8c8c1b1..fefe5388a927ff9fa4fcbc41538155b1c26db74e 100644
--- a/chrome/browser/resources/print_preview/data/ticket_items/color.js
+++ b/chrome/browser/resources/print_preview/data/ticket_items/color.js
@@ -23,18 +23,6 @@
destinationStore);
};
- /*
- * @private {!Array.<string>} List of capability types considered color.
- * @const
- */
- Color.COLOR_TYPES_ = ['STANDARD_COLOR', 'CUSTOM_COLOR'];
-
- /*
- * @private {!Array.<string>} List of capability types considered monochrome.
- * @const
- */
- Color.MONOCHROME_TYPES_ = ['STANDARD_MONOCHROME', 'CUSTOM_MONOCHROME'];
-
Color.prototype = {
__proto__: print_preview.ticket_items.TicketItem.prototype,
@@ -45,72 +33,56 @@
/** @override */
isCapabilityAvailable: function() {
- var capability = this.capability;
- if (!capability) {
+ var colorCap = this.getColorCapability_();
+ if (!colorCap) {
return false;
}
var hasColor = false;
var hasMonochrome = false;
- capability.option.forEach(function(option) {
- hasColor = hasColor || (Color.COLOR_TYPES_.indexOf(option.type) >= 0);
- hasMonochrome = hasMonochrome ||
- (Color.MONOCHROME_TYPES_.indexOf(option.type) >= 0);
+ colorCap.option.forEach(function(option) {
+ hasColor = hasColor || option.type == 'STANDARD_COLOR';
+ hasMonochrome = hasMonochrome || option.type == 'STANDARD_MONOCHROME';
});
return hasColor && hasMonochrome;
},
- /** @return {Object} Color capability of the selected destination. */
- get capability() {
+ /** @override */
+ getDefaultValueInternal: function() {
+ var colorCap = this.getColorCapability_();
+ var defaultOption = this.getDefaultColorOption_(colorCap.option);
+ return defaultOption && defaultOption.type == 'STANDARD_COLOR';
+ },
+
+ /** @override */
+ getCapabilityNotAvailableValueInternal: function() {
+ var colorCap = this.getColorCapability_();
+ var defaultOption = colorCap ?
+ this.getDefaultColorOption_(colorCap.option) : null;
+
+ // TODO(rltoscano): Get rid of this check based on destination ID. These
+ // destinations should really update their CDDs to have only one color
+ // option that has type 'STANDARD_COLOR'.
+ var dest = this.getSelectedDestInternal();
+ if (!dest) {
+ return false;
+ }
+ return dest.id == print_preview.Destination.GooglePromotedId.DOCS ||
+ dest.id == print_preview.Destination.GooglePromotedId.FEDEX ||
+ dest.type == print_preview.Destination.Type.MOBILE ||
+ defaultOption && defaultOption.type == 'STANDARD_COLOR';
+ },
+
+ /**
+ * @return {Object} Color capability of the selected destination.
+ * @private
+ */
+ getColorCapability_: function() {
var dest = this.getSelectedDestInternal();
return (dest &&
dest.capabilities &&
dest.capabilities.printer &&
dest.capabilities.printer.color) ||
null;
- },
-
- /** @return {Object} Color option corresponding to the current value. */
- getSelectedOption: function() {
- var capability = this.capability;
- var options = capability ? capability.option : null;
- if (options) {
- var typesToLookFor =
- this.getValue() ? Color.COLOR_TYPES_ : Color.MONOCHROME_TYPES_;
- for (var i = 0; i < typesToLookFor.length; i++) {
- var matchingOptions = options.filter(function(option) {
- return option.type == typesToLookFor[i];
- });
- if (matchingOptions.length > 0) {
- return matchingOptions[0];
- }
- }
- }
- return null;
- },
-
- /** @override */
- getDefaultValueInternal: function() {
- var capability = this.capability;
- var defaultOption = capability ?
- this.getDefaultColorOption_(capability.option) : null;
- return defaultOption &&
- (Color.COLOR_TYPES_.indexOf(defaultOption.type) >= 0);
- },
-
- /** @override */
- getCapabilityNotAvailableValueInternal: function() {
- // TODO(rltoscano): Get rid of this check based on destination ID. These
- // destinations should really update their CDDs to have only one color
- // option that has type 'STANDARD_COLOR'.
- var dest = this.getSelectedDestInternal();
- if (dest) {
- if (dest.id == print_preview.Destination.GooglePromotedId.DOCS ||
- dest.id == print_preview.Destination.GooglePromotedId.FEDEX ||
- dest.type == print_preview.Destination.Type.MOBILE) {
- return true;
- }
- }
- return this.getDefaultValueInternal();
},
/**

Powered by Google App Engine
This is Rietveld 408576698