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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 PreviewGenerator.prototype = { | 147 PreviewGenerator.prototype = { |
148 __proto__: cr.EventTarget.prototype, | 148 __proto__: cr.EventTarget.prototype, |
149 | 149 |
150 /** | 150 /** |
151 * Request that new preview be generated. A preview request will not be | 151 * Request that new preview be generated. A preview request will not be |
152 * generated if the print ticket has not changed sufficiently. | 152 * generated if the print ticket has not changed sufficiently. |
153 * @return {boolean} Whether a new preview was actually requested. | 153 * @return {boolean} Whether a new preview was actually requested. |
154 */ | 154 */ |
155 requestPreview: function() { | 155 requestPreview: function() { |
156 if (!this.printTicketStore_.isTicketValidForPreview() || | 156 if (!this.printTicketStore_.isTicketValidForPreview() || |
157 !this.destinationStore_.selectedDestination || | |
158 !this.printTicketStore_.isInitialized) { | 157 !this.printTicketStore_.isInitialized) { |
159 return false; | 158 return false; |
160 } | 159 } |
161 if (!this.hasPreviewChanged_()) { | 160 if (!this.hasPreviewChanged_()) { |
162 // Changes to these ticket items might not trigger a new preview, but | 161 // Changes to these ticket items might not trigger a new preview, but |
163 // they still need to be recorded. | 162 // they still need to be recorded. |
164 this.marginsType_ = this.printTicketStore_.getMarginsType(); | 163 this.marginsType_ = this.printTicketStore_.getMarginsType(); |
165 return false; | 164 return false; |
166 } | 165 } |
167 this.isLandscapeEnabled_ = this.printTicketStore_.isLandscapeEnabled(); | 166 this.isLandscapeEnabled_ = this.printTicketStore_.isLandscapeEnabled(); |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 // current one. | 406 // current one. |
408 cr.dispatchSimpleEvent(this, PreviewGenerator.EventType.FAIL); | 407 cr.dispatchSimpleEvent(this, PreviewGenerator.EventType.FAIL); |
409 } | 408 } |
410 }; | 409 }; |
411 | 410 |
412 // Export | 411 // Export |
413 return { | 412 return { |
414 PreviewGenerator: PreviewGenerator | 413 PreviewGenerator: PreviewGenerator |
415 }; | 414 }; |
416 }); | 415 }); |
OLD | NEW |