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

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

Issue 319373004: Revert 275646 "Generalize printer color model handling, get rid ..." (Closed) Base URL: svn://svn.chromium.org/chrome/
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: trunk/src/chrome/browser/resources/print_preview/data/ticket_items/color.js
===================================================================
--- trunk/src/chrome/browser/resources/print_preview/data/ticket_items/color.js (revision 275710)
+++ trunk/src/chrome/browser/resources/print_preview/data/ticket_items/color.js (working copy)
@@ -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,75 +33,59 @@
/** @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() {
- 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);
+ 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) {
- if (dest.id == print_preview.Destination.GooglePromotedId.DOCS ||
- dest.id == print_preview.Destination.GooglePromotedId.FEDEX ||
- dest.type == print_preview.Destination.Type.MOBILE) {
- return true;
- }
+ if (!dest) {
+ return false;
}
- return this.getDefaultValueInternal();
+ 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;
+ },
+
+ /**
* @param options {!Array.<!Object.<{type: string=, is_default: boolean=}>>
* @return {Object.<{type: string=, is_default: boolean=}>} Default color
* option of the given list.

Powered by Google App Engine
This is Rietveld 408576698