| 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 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 /** Removes all event listeners that the preview generator has attached. */ | 217 /** Removes all event listeners that the preview generator has attached. */ |
| 218 removeEventListeners: function() { | 218 removeEventListeners: function() { |
| 219 this.tracker_.removeAll(); | 219 this.tracker_.removeAll(); |
| 220 }, | 220 }, |
| 221 | 221 |
| 222 /** | 222 /** |
| 223 * Adds event listeners to the relevant native layer events. | 223 * Adds event listeners to the relevant native layer events. |
| 224 * @private | 224 * @private |
| 225 */ | 225 */ |
| 226 addEventListeners_: function() { | 226 addEventListeners_: function() { |
| 227 var nativeLayerEventTarget = this.nativeLayer_.getEventTarget(); |
| 227 this.tracker_.add( | 228 this.tracker_.add( |
| 228 this.nativeLayer_, | 229 nativeLayerEventTarget, |
| 229 print_preview.NativeLayer.EventType.PAGE_LAYOUT_READY, | 230 print_preview.NativeLayer.EventType.PAGE_LAYOUT_READY, |
| 230 this.onPageLayoutReady_.bind(this)); | 231 this.onPageLayoutReady_.bind(this)); |
| 231 this.tracker_.add( | 232 this.tracker_.add( |
| 232 this.nativeLayer_, | 233 nativeLayerEventTarget, |
| 233 print_preview.NativeLayer.EventType.PAGE_COUNT_READY, | 234 print_preview.NativeLayer.EventType.PAGE_COUNT_READY, |
| 234 this.onPageCountReady_.bind(this)); | 235 this.onPageCountReady_.bind(this)); |
| 235 this.tracker_.add( | 236 this.tracker_.add( |
| 236 this.nativeLayer_, | 237 nativeLayerEventTarget, |
| 237 print_preview.NativeLayer.EventType.PAGE_PREVIEW_READY, | 238 print_preview.NativeLayer.EventType.PAGE_PREVIEW_READY, |
| 238 this.onPagePreviewReady_.bind(this)); | 239 this.onPagePreviewReady_.bind(this)); |
| 239 this.tracker_.add( | 240 this.tracker_.add( |
| 240 this.nativeLayer_, | 241 nativeLayerEventTarget, |
| 241 print_preview.NativeLayer.EventType.PREVIEW_GENERATION_DONE, | 242 print_preview.NativeLayer.EventType.PREVIEW_GENERATION_DONE, |
| 242 this.onPreviewGenerationDone_.bind(this)); | 243 this.onPreviewGenerationDone_.bind(this)); |
| 243 this.tracker_.add( | 244 this.tracker_.add( |
| 244 this.nativeLayer_, | 245 nativeLayerEventTarget, |
| 245 print_preview.NativeLayer.EventType.PREVIEW_GENERATION_FAIL, | 246 print_preview.NativeLayer.EventType.PREVIEW_GENERATION_FAIL, |
| 246 this.onPreviewGenerationFail_.bind(this)); | 247 this.onPreviewGenerationFail_.bind(this)); |
| 247 }, | 248 }, |
| 248 | 249 |
| 249 /** | 250 /** |
| 250 * Dispatches a PAGE_READY event to signal that a page preview is ready. | 251 * Dispatches a PAGE_READY event to signal that a page preview is ready. |
| 251 * @param {number} previewIndex Index of the page with respect to the pages | 252 * @param {number} previewIndex Index of the page with respect to the pages |
| 252 * shown in the preview. E.g an index of 0 is the first displayed page, | 253 * shown in the preview. E.g an index of 0 is the first displayed page, |
| 253 * but not necessarily the first original document page. | 254 * but not necessarily the first original document page. |
| 254 * @param {number} pageNumber Number of the page with respect to the | 255 * @param {number} pageNumber Number of the page with respect to the |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 425 // current one. | 426 // current one. |
| 426 cr.dispatchSimpleEvent(this, PreviewGenerator.EventType.FAIL); | 427 cr.dispatchSimpleEvent(this, PreviewGenerator.EventType.FAIL); |
| 427 } | 428 } |
| 428 }; | 429 }; |
| 429 | 430 |
| 430 // Export | 431 // Export |
| 431 return { | 432 return { |
| 432 PreviewGenerator: PreviewGenerator | 433 PreviewGenerator: PreviewGenerator |
| 433 }; | 434 }; |
| 434 }); | 435 }); |
| OLD | NEW |