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 |
new file mode 100644 |
index 0000000000000000000000000000000000000000..b03d4072f4ec23406ae2b73479dc1eebd2298425 |
--- /dev/null |
+++ b/chrome/browser/resources/print_preview/data/ticket_items/color.js |
@@ -0,0 +1,71 @@ |
+// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+cr.define('print_preview.ticket_items', function() { |
+ 'use strict'; |
+ |
+ /** |
+ * Color ticket item whose value is a {@code boolean} that indicates whether |
+ * the document should be printed in color. |
+ * @param {!print_preview.CapabilitiesHolder} capabilitiesHolder Capabilities |
+ * holder used to determine the default color value and if the color |
+ * capability is available. |
+ * @param {!print_preview.DestinationStore} destinationStore Used to determine |
+ * whether color printing should be available. |
+ * @constructor |
+ * @extends {print_preview.ticket_items.TicketItem} |
+ */ |
+ function Color(capabilitiesHolder, destinationStore) { |
+ print_preview.ticket_items.TicketItem.call(this); |
+ |
+ /** |
+ * Capabilities holder used to determine the default color value and if the |
+ * color capability is available. |
+ * @type {!print_preview.CapabilitiesHolder} |
+ * @private |
+ */ |
+ this.capabilitiesHolder_ = capabilitiesHolder; |
+ |
+ /** |
+ * Used to determine whether color printing should be available. |
+ * @type {!print_preview.DestinationStore} |
+ * @private |
+ */ |
+ this.destinationStore_ = destinationStore; |
+ }; |
+ |
+ Color.prototype = { |
+ __proto__: print_preview.ticket_items.TicketItem.prototype, |
+ |
+ /** @override */ |
+ wouldValueBeValid: function(value) { |
+ return true; |
+ }, |
+ |
+ /** @override */ |
+ isCapabilityAvailable: function() { |
+ return this.capabilitiesHolder_.get().hasColorCapability && |
+ (!this.destinationStore_.selectedDestination || |
+ this.destinationStore_.selectedDestination.id != |
+ print_preview.Destination.GooglePromotedId.SAVE_AS_PDF); |
+ }, |
+ |
+ /** @override */ |
+ getDefaultValueInternal: function() { |
+ return this.capabilitiesHolder_.get().defaultIsColorEnabled; |
+ }, |
+ |
+ /** @override */ |
+ getCapabilityNotAvailableValueInternal: function() { |
+ return this.destinationStore_.selectedDestination && |
+ this.destinationStore_.selectedDestination.id == |
+ print_preview.Destination.GooglePromotedId.SAVE_AS_PDF; |
+ } |
+ }; |
+ |
+ // Export |
+ return { |
+ Color: Color |
+ }; |
+}); |