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 // TODO(rltoscano): Move data/* into print_preview.data namespace | 5 // TODO(rltoscano): Move data/* into print_preview.data namespace |
6 | 6 |
7 // <include src="component.js"> | 7 // <include src="component.js"> |
8 // <include src="print_preview_focus_manager.js"> | 8 // <include src="print_preview_focus_manager.js"> |
9 // | 9 // |
10 | 10 |
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 /** Sets up the page and print preview by getting the printer list. */ | 334 /** Sets up the page and print preview by getting the printer list. */ |
335 initialize: function() { | 335 initialize: function() { |
336 this.decorate($('print-preview')); | 336 this.decorate($('print-preview')); |
337 if (!this.previewArea_.hasCompatiblePlugin) { | 337 if (!this.previewArea_.hasCompatiblePlugin) { |
338 this.setIsEnabled_(false); | 338 this.setIsEnabled_(false); |
339 } | 339 } |
340 this.nativeLayer_.getInitialSettings().then( | 340 this.nativeLayer_.getInitialSettings().then( |
341 this.onInitialSettingsSet_.bind(this)); | 341 this.onInitialSettingsSet_.bind(this)); |
342 print_preview.PrintPreviewFocusManager.getInstance().initialize(); | 342 print_preview.PrintPreviewFocusManager.getInstance().initialize(); |
343 cr.ui.FocusOutlineManager.forDocument(document); | 343 cr.ui.FocusOutlineManager.forDocument(document); |
| 344 this.listenerTracker.add('print-failed', |
| 345 this.onPrintFailed_.bind(this)); |
| 346 this.listenerTracker.add('privet-printer-added', |
| 347 this.destinationStore_.onPrivetPrinterAdded_.bind( |
| 348 this.destinationStore_)); |
| 349 this.listenerTracker.add('extension-printers-added', |
| 350 this.destinationStore_.onExtensionPrintersAdded_.bind( |
| 351 this.destinationStore_)); |
344 }, | 352 }, |
345 | 353 |
346 /** @override */ | 354 /** @override */ |
347 enterDocument: function() { | 355 enterDocument: function() { |
348 // Native layer events. | 356 // Native layer events. |
349 var nativeLayerEventTarget = this.nativeLayer_.getEventTarget(); | 357 var nativeLayerEventTarget = this.nativeLayer_.getEventTarget(); |
350 this.tracker.add( | 358 this.tracker.add( |
351 nativeLayerEventTarget, | 359 nativeLayerEventTarget, |
352 print_preview.NativeLayer.EventType.CLOUD_PRINT_ENABLE, | 360 print_preview.NativeLayer.EventType.CLOUD_PRINT_ENABLE, |
353 this.onCloudPrintEnable_.bind(this)); | 361 this.onCloudPrintEnable_.bind(this)); |
(...skipping 16 matching lines...) Expand all Loading... |
370 this.tracker.add( | 378 this.tracker.add( |
371 nativeLayerEventTarget, | 379 nativeLayerEventTarget, |
372 print_preview.NativeLayer.EventType.PRINT_PRESET_OPTIONS, | 380 print_preview.NativeLayer.EventType.PRINT_PRESET_OPTIONS, |
373 this.onPrintPresetOptionsFromDocument_.bind(this)); | 381 this.onPrintPresetOptionsFromDocument_.bind(this)); |
374 this.tracker.add( | 382 this.tracker.add( |
375 nativeLayerEventTarget, | 383 nativeLayerEventTarget, |
376 print_preview.NativeLayer.EventType.PAGE_COUNT_READY, | 384 print_preview.NativeLayer.EventType.PAGE_COUNT_READY, |
377 this.onPageCountReady_.bind(this)); | 385 this.onPageCountReady_.bind(this)); |
378 this.tracker.add( | 386 this.tracker.add( |
379 nativeLayerEventTarget, | 387 nativeLayerEventTarget, |
380 print_preview.NativeLayer.EventType.PRIVET_PRINT_FAILED, | |
381 this.onPrivetPrintFailed_.bind(this)); | |
382 this.tracker.add( | |
383 nativeLayerEventTarget, | |
384 print_preview.NativeLayer.EventType.MANIPULATE_SETTINGS_FOR_TEST, | 388 print_preview.NativeLayer.EventType.MANIPULATE_SETTINGS_FOR_TEST, |
385 this.onManipulateSettingsForTest_.bind(this)); | 389 this.onManipulateSettingsForTest_.bind(this)); |
386 | 390 |
387 if ($('system-dialog-link')) { | 391 if ($('system-dialog-link')) { |
388 this.tracker.add( | 392 this.tracker.add( |
389 getRequiredElement('system-dialog-link'), | 393 getRequiredElement('system-dialog-link'), |
390 'click', | 394 'click', |
391 this.openSystemPrintDialog_.bind(this)); | 395 this.openSystemPrintDialog_.bind(this)); |
392 } | 396 } |
393 if ($('open-pdf-in-preview-link')) { | 397 if ($('open-pdf-in-preview-link')) { |
(...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1026 * @private | 1030 * @private |
1027 */ | 1031 */ |
1028 onPageCountReady_: function(event) { | 1032 onPageCountReady_: function(event) { |
1029 if (event.fitToPageScaling >= 0) { | 1033 if (event.fitToPageScaling >= 0) { |
1030 this.scalingSettings_.updateFitToPageScaling( | 1034 this.scalingSettings_.updateFitToPageScaling( |
1031 event.fitToPageScaling); | 1035 event.fitToPageScaling); |
1032 } | 1036 } |
1033 }, | 1037 }, |
1034 | 1038 |
1035 /** | 1039 /** |
1036 * Called when privet printing fails. | 1040 * Called when printing to a privet or extension printer fails. |
1037 * @param {Event} event Event object representing the failure. | 1041 * @param {number | string} httpError The HTTP error code, or -1 if not an |
| 1042 * HTTP error. |
1038 * @private | 1043 * @private |
1039 */ | 1044 */ |
1040 onPrivetPrintFailed_: function(event) { | 1045 onPrintFailed_: function(httpError) { |
1041 console.error('Privet printing failed with error code ' + | 1046 console.error('Privet printing failed with error code ' + httpError); |
1042 event.httpError); | |
1043 this.printHeader_.setErrorMessage( | 1047 this.printHeader_.setErrorMessage( |
1044 loadTimeData.getString('couldNotPrint')); | 1048 loadTimeData.getString('couldNotPrint')); |
1045 }, | 1049 }, |
1046 | 1050 |
1047 /** | 1051 /** |
1048 * Called when the print preview settings need to be changed for testing. | 1052 * Called when the print preview settings need to be changed for testing. |
1049 * @param {Event} event Event object that contains the option that is to | 1053 * @param {Event} event Event object that contains the option that is to |
1050 * be changed and what to set that option. | 1054 * be changed and what to set that option. |
1051 * @private | 1055 * @private |
1052 */ | 1056 */ |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1354 // <include src="search/destination_search.js"> | 1358 // <include src="search/destination_search.js"> |
1355 // <include src="search/provisional_destination_resolver.js"> | 1359 // <include src="search/provisional_destination_resolver.js"> |
1356 | 1360 |
1357 window.addEventListener('DOMContentLoaded', function() { | 1361 window.addEventListener('DOMContentLoaded', function() { |
1358 var previewWindow = /** @type {{isTest: boolean}} */ (window); | 1362 var previewWindow = /** @type {{isTest: boolean}} */ (window); |
1359 if (!previewWindow.isTest) { | 1363 if (!previewWindow.isTest) { |
1360 var printPreview = new print_preview.PrintPreview(); | 1364 var printPreview = new print_preview.PrintPreview(); |
1361 printPreview.initialize(); | 1365 printPreview.initialize(); |
1362 } | 1366 } |
1363 }); | 1367 }); |
OLD | NEW |