| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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', function() { | 5 cr.define('print_preview', function() { |
| 6 'use strict'; | 6 'use strict'; |
| 7 | 7 |
| 8 /** | 8 /** |
| 9 * Interface to the Chromium print preview generator. | 9 * Interface to the Chromium print preview generator. |
| 10 * @param {!print_preview.DestinationStore} destinationStore Used to get the | 10 * @param {!print_preview.DestinationStore} destinationStore Used to get the |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 this.pageNumberSet_ = null; | 84 this.pageNumberSet_ = null; |
| 85 | 85 |
| 86 /** | 86 /** |
| 87 * Margins type used to generate the last preview. | 87 * Margins type used to generate the last preview. |
| 88 * @type {!print_preview.ticket_items.MarginsType.Value} | 88 * @type {!print_preview.ticket_items.MarginsType.Value} |
| 89 * @private | 89 * @private |
| 90 */ | 90 */ |
| 91 this.marginsType_ = print_preview.ticket_items.MarginsType.Value.DEFAULT; | 91 this.marginsType_ = print_preview.ticket_items.MarginsType.Value.DEFAULT; |
| 92 | 92 |
| 93 /** | 93 /** |
| 94 * Whether the document should have element CSS backgrounds printed. |
| 95 * @type {boolean} |
| 96 * @private |
| 97 */ |
| 98 this.isCssBackgroundEnabled_ = false; |
| 99 |
| 100 /** |
| 94 * Destination that was selected for the last preview. | 101 * Destination that was selected for the last preview. |
| 95 * @type {print_preview.Destination} | 102 * @type {print_preview.Destination} |
| 96 * @private | 103 * @private |
| 97 */ | 104 */ |
| 98 this.selectedDestination_ = null; | 105 this.selectedDestination_ = null; |
| 99 | 106 |
| 100 /** | 107 /** |
| 101 * Event tracker used to keep track of native layer events. | 108 * Event tracker used to keep track of native layer events. |
| 102 * @type {!EventTracker} | 109 * @type {!EventTracker} |
| 103 * @private | 110 * @private |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 this.marginsType_ = this.printTicketStore_.getMarginsType(); | 153 this.marginsType_ = this.printTicketStore_.getMarginsType(); |
| 147 return false; | 154 return false; |
| 148 } | 155 } |
| 149 this.isLandscapeEnabled_ = this.printTicketStore_.isLandscapeEnabled(); | 156 this.isLandscapeEnabled_ = this.printTicketStore_.isLandscapeEnabled(); |
| 150 this.isHeaderFooterEnabled_ = | 157 this.isHeaderFooterEnabled_ = |
| 151 this.printTicketStore_.isHeaderFooterEnabled(); | 158 this.printTicketStore_.isHeaderFooterEnabled(); |
| 152 this.isColorEnabled_ = this.printTicketStore_.isColorEnabled(); | 159 this.isColorEnabled_ = this.printTicketStore_.isColorEnabled(); |
| 153 this.isFitToPageEnabled_ = this.printTicketStore_.isFitToPageEnabled(); | 160 this.isFitToPageEnabled_ = this.printTicketStore_.isFitToPageEnabled(); |
| 154 this.pageNumberSet_ = this.printTicketStore_.getPageNumberSet(); | 161 this.pageNumberSet_ = this.printTicketStore_.getPageNumberSet(); |
| 155 this.marginsType_ = this.printTicketStore_.getMarginsType(); | 162 this.marginsType_ = this.printTicketStore_.getMarginsType(); |
| 163 this.isCssBackgroundEnabled_ = |
| 164 this.printTicketStore_.isCssBackgroundEnabled(); |
| 156 this.selectedDestination_ = this.destinationStore_.selectedDestination; | 165 this.selectedDestination_ = this.destinationStore_.selectedDestination; |
| 157 | 166 |
| 158 this.inFlightRequestId_++; | 167 this.inFlightRequestId_++; |
| 159 this.nativeLayer_.startGetPreview( | 168 this.nativeLayer_.startGetPreview( |
| 160 this.destinationStore_.selectedDestination, | 169 this.destinationStore_.selectedDestination, |
| 161 this.printTicketStore_, | 170 this.printTicketStore_, |
| 162 this.inFlightRequestId_); | 171 this.inFlightRequestId_); |
| 163 return true; | 172 return true; |
| 164 }, | 173 }, |
| 165 | 174 |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 ticketStore.isColorEnabled() != this.isColorEnabled_ || | 258 ticketStore.isColorEnabled() != this.isColorEnabled_ || |
| 250 ticketStore.isFitToPageEnabled() != this.isFitToPageEnabled_ || | 259 ticketStore.isFitToPageEnabled() != this.isFitToPageEnabled_ || |
| 251 !ticketStore.getPageNumberSet().equals(this.pageNumberSet_) || | 260 !ticketStore.getPageNumberSet().equals(this.pageNumberSet_) || |
| 252 (ticketStore.getMarginsType() != this.marginsType_ && | 261 (ticketStore.getMarginsType() != this.marginsType_ && |
| 253 ticketStore.getMarginsType() != | 262 ticketStore.getMarginsType() != |
| 254 print_preview.ticket_items.MarginsType.Value.CUSTOM) || | 263 print_preview.ticket_items.MarginsType.Value.CUSTOM) || |
| 255 (ticketStore.getMarginsType() == | 264 (ticketStore.getMarginsType() == |
| 256 print_preview.ticket_items.MarginsType.Value.CUSTOM && | 265 print_preview.ticket_items.MarginsType.Value.CUSTOM && |
| 257 !ticketStore.getCustomMargins().equals( | 266 !ticketStore.getCustomMargins().equals( |
| 258 ticketStore.getDocumentMargins())) || | 267 ticketStore.getDocumentMargins())) || |
| 268 (ticketStore.isCssBackgroundEnabled() != |
| 269 this.isCssBackgroundEnabled_) || |
| 259 (this.selectedDestination_ != | 270 (this.selectedDestination_ != |
| 260 this.destinationStore_.selectedDestination); | 271 this.destinationStore_.selectedDestination); |
| 261 }, | 272 }, |
| 262 | 273 |
| 263 /** | 274 /** |
| 264 * Called when the page layout of the document is ready. Always occurs | 275 * Called when the page layout of the document is ready. Always occurs |
| 265 * as a result of a preview request. | 276 * as a result of a preview request. |
| 266 * @param {cr.Event} event Contains layout info about the document. | 277 * @param {cr.Event} event Contains layout info about the document. |
| 267 * @private | 278 * @private |
| 268 */ | 279 */ |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 // current one. | 390 // current one. |
| 380 cr.dispatchSimpleEvent(this, PreviewGenerator.EventType.FAIL); | 391 cr.dispatchSimpleEvent(this, PreviewGenerator.EventType.FAIL); |
| 381 } | 392 } |
| 382 }; | 393 }; |
| 383 | 394 |
| 384 // Export | 395 // Export |
| 385 return { | 396 return { |
| 386 PreviewGenerator: PreviewGenerator | 397 PreviewGenerator: PreviewGenerator |
| 387 }; | 398 }; |
| 388 }); | 399 }); |
| OLD | NEW |