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 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 }, | 200 }, |
201 | 201 |
202 /** | 202 /** |
203 * Dispatches a PAGE_READY event to signal that a page preview is ready. | 203 * Dispatches a PAGE_READY event to signal that a page preview is ready. |
204 * @param {number} previewIndex Index of the page with respect to the pages | 204 * @param {number} previewIndex Index of the page with respect to the pages |
205 * shown in the preview. E.g an index of 0 is the first displayed page, | 205 * shown in the preview. E.g an index of 0 is the first displayed page, |
206 * but not necessarily the first original document page. | 206 * but not necessarily the first original document page. |
207 * @param {number} pageNumber Number of the page with respect to the | 207 * @param {number} pageNumber Number of the page with respect to the |
208 * document. A value of 3 means it's the third page of the original | 208 * document. A value of 3 means it's the third page of the original |
209 * document. | 209 * document. |
210 * @param {string} previewUid Unique identifier of the preview. | 210 * @param {number} previewUid Unique identifier of the preview. |
211 * @private | 211 * @private |
212 */ | 212 */ |
213 dispatchPageReadyEvent_: function(previewIndex, pageNumber, previewUid) { | 213 dispatchPageReadyEvent_: function(previewIndex, pageNumber, previewUid) { |
214 var pageGenEvent = new cr.Event(PreviewGenerator.EventType.PAGE_READY); | 214 var pageGenEvent = new cr.Event(PreviewGenerator.EventType.PAGE_READY); |
215 pageGenEvent.previewIndex = previewIndex; | 215 pageGenEvent.previewIndex = previewIndex; |
216 pageGenEvent.previewUrl = | 216 pageGenEvent.previewUrl = 'chrome://print/' + previewUid.toString() + |
217 'chrome://print/' + previewUid + '/' + (pageNumber - 1) + | 217 '/' + (pageNumber - 1) + '/print.pdf'; |
218 '/print.pdf'; | |
219 this.dispatchEvent(pageGenEvent); | 218 this.dispatchEvent(pageGenEvent); |
220 }, | 219 }, |
221 | 220 |
222 /** | 221 /** |
223 * Dispatches a PREVIEW_START event. Signals that the preview should be | 222 * Dispatches a PREVIEW_START event. Signals that the preview should be |
224 * reloaded. | 223 * reloaded. |
225 * @param {string} previewUid Unique identifier of the preview. | 224 * @param {number} previewUid Unique identifier of the preview. |
226 * @param {number} index Index of the first page of the preview. | 225 * @param {number} index Index of the first page of the preview. |
227 * @private | 226 * @private |
228 */ | 227 */ |
229 dispatchPreviewStartEvent_: function(previewUid, index) { | 228 dispatchPreviewStartEvent_: function(previewUid, index) { |
230 var previewStartEvent = new cr.Event( | 229 var previewStartEvent = new cr.Event( |
231 PreviewGenerator.EventType.PREVIEW_START); | 230 PreviewGenerator.EventType.PREVIEW_START); |
232 if (!this.printTicketStore_.isDocumentModifiable) { | 231 if (!this.printTicketStore_.isDocumentModifiable) { |
233 index = -1; | 232 index = -1; |
234 } | 233 } |
235 previewStartEvent.previewUrl = | 234 previewStartEvent.previewUrl = 'chrome://print/' + |
236 'chrome://print/' + previewUid + '/' + index + '/print.pdf'; | 235 previewUid.toString() + '/' + index + '/print.pdf'; |
237 this.dispatchEvent(previewStartEvent); | 236 this.dispatchEvent(previewStartEvent); |
238 }, | 237 }, |
239 | 238 |
240 /** | 239 /** |
241 * @return {boolean} Whether the print ticket has changed sufficiently to | 240 * @return {boolean} Whether the print ticket has changed sufficiently to |
242 * determine whether a new preview request should be issued. | 241 * determine whether a new preview request should be issued. |
243 * @private | 242 * @private |
244 */ | 243 */ |
245 hasPreviewChanged_: function() { | 244 hasPreviewChanged_: function() { |
246 var ticketStore = this.printTicketStore_; | 245 var ticketStore = this.printTicketStore_; |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
380 // current one. | 379 // current one. |
381 cr.dispatchSimpleEvent(this, PreviewGenerator.EventType.FAIL); | 380 cr.dispatchSimpleEvent(this, PreviewGenerator.EventType.FAIL); |
382 } | 381 } |
383 }; | 382 }; |
384 | 383 |
385 // Export | 384 // Export |
386 return { | 385 return { |
387 PreviewGenerator: PreviewGenerator | 386 PreviewGenerator: PreviewGenerator |
388 }; | 387 }; |
389 }); | 388 }); |
OLD | NEW |