OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 cr.define('print_preview.ticket_items', function() { | 5 cr.define('print_preview.ticket_items', function() { |
6 'use strict'; | 6 'use strict'; |
7 | 7 |
8 /** | 8 /** |
9 * Ticket item whose value is a {@code boolean} that represents whether to | 9 * Ticket item whose value is a {@code boolean} that represents whether to |
10 * print selection only. | 10 * distill the page before printing. |
11 * @param {!print_preview.DocumentInfo} documentInfo Information about the | 11 * @param {!print_preview.DocumentInfo} documentInfo Information about the |
12 * document to print. | 12 * document to print. |
13 * @constructor | 13 * @constructor |
14 * @extends {print_preview.ticket_items.TicketItem} | 14 * @extends {print_preview.ticket_items.TicketItem} |
15 */ | 15 */ |
16 function SelectionOnly(documentInfo) { | 16 function DistillPage(documentInfo) { |
17 print_preview.ticket_items.TicketItem.call( | 17 print_preview.ticket_items.TicketItem.call( |
18 this, | 18 this, |
19 null /*appState*/, | 19 null /*appState*/, |
20 null /*field*/, | 20 null /*field*/, |
21 null /*destinationStore*/, | 21 null /*destinationStore*/, |
22 documentInfo); | 22 documentInfo); |
| 23 |
| 24 this.isAvailable_ = false; |
23 }; | 25 }; |
24 | 26 |
25 SelectionOnly.prototype = { | 27 DistillPage.prototype = { |
26 __proto__: print_preview.ticket_items.TicketItem.prototype, | 28 __proto__: print_preview.ticket_items.TicketItem.prototype, |
27 | 29 |
28 /** @override */ | 30 /** @override */ |
29 wouldValueBeValid: function(value) { | 31 wouldValueBeValid: function(value) { |
30 return true; | 32 return true; |
31 }, | 33 }, |
32 | 34 |
33 /** @override */ | 35 /** @override */ |
34 isCapabilityAvailable: function() { | 36 isCapabilityAvailable: function() { |
35 return this.getDocumentInfoInternal().isModifiable && | 37 return this.isAvailable_; |
36 this.getDocumentInfoInternal().hasSelection; | |
37 }, | 38 }, |
38 | 39 |
39 /** @override */ | 40 /** @override */ |
40 getDefaultValueInternal: function() { | 41 getDefaultValueInternal: function() { |
41 return false; | 42 return false; |
42 }, | 43 }, |
43 | 44 |
44 /** @override */ | 45 /** @override */ |
45 getCapabilityNotAvailableValueInternal: function() { | 46 getCapabilityNotAvailableValueInternal: function() { |
46 return false; | 47 return false; |
| 48 }, |
| 49 |
| 50 setIsCapabilityAvailable: function(isAvailable) { |
| 51 if (this.isAvailable_ == isAvailable) |
| 52 return; |
| 53 |
| 54 this.isAvailable_ = isAvailable; |
| 55 this.dispatchChangeEventInternal(); |
47 } | 56 } |
48 }; | 57 }; |
49 | 58 |
50 // Export | 59 // Export |
51 return { | 60 return { |
52 SelectionOnly: SelectionOnly | 61 DistillPage: DistillPage |
53 }; | 62 }; |
54 }); | 63 }); |
OLD | NEW |