Chromium Code Reviews| 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 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 324 | 324 |
| 325 PrintPreview.prototype = { | 325 PrintPreview.prototype = { |
| 326 __proto__: print_preview.Component.prototype, | 326 __proto__: print_preview.Component.prototype, |
| 327 | 327 |
| 328 /** Sets up the page and print preview by getting the printer list. */ | 328 /** Sets up the page and print preview by getting the printer list. */ |
| 329 initialize: function() { | 329 initialize: function() { |
| 330 this.decorate($('print-preview')); | 330 this.decorate($('print-preview')); |
| 331 if (!this.previewArea_.hasCompatiblePlugin) { | 331 if (!this.previewArea_.hasCompatiblePlugin) { |
| 332 this.setIsEnabled_(false); | 332 this.setIsEnabled_(false); |
| 333 } | 333 } |
| 334 this.nativeLayer_.startGetInitialSettings(); | 334 this.nativeLayer_.getInitialSettings().then( |
| 335 this.onInitialSettingsSet_.bind(this)); | |
| 335 print_preview.PrintPreviewFocusManager.getInstance().initialize(); | 336 print_preview.PrintPreviewFocusManager.getInstance().initialize(); |
| 336 cr.ui.FocusOutlineManager.forDocument(document); | 337 cr.ui.FocusOutlineManager.forDocument(document); |
| 337 }, | 338 }, |
| 338 | 339 |
| 339 /** @override */ | 340 /** @override */ |
| 340 enterDocument: function() { | 341 enterDocument: function() { |
| 341 // Native layer events. | 342 // Native layer events. |
| 343 var nativeLayerEventTarget = this.nativeLayer_.getEventTarget(); | |
| 342 this.tracker.add( | 344 this.tracker.add( |
| 343 this.nativeLayer_, | 345 nativeLayerEventTarget, |
| 344 print_preview.NativeLayer.EventType.INITIAL_SETTINGS_SET, | |
| 345 this.onInitialSettingsSet_.bind(this)); | |
| 346 this.tracker.add( | |
| 347 this.nativeLayer_, | |
| 348 print_preview.NativeLayer.EventType.CLOUD_PRINT_ENABLE, | 346 print_preview.NativeLayer.EventType.CLOUD_PRINT_ENABLE, |
| 349 this.onCloudPrintEnable_.bind(this)); | 347 this.onCloudPrintEnable_.bind(this)); |
| 350 this.tracker.add( | 348 this.tracker.add( |
| 351 this.nativeLayer_, | 349 nativeLayerEventTarget, |
| 352 print_preview.NativeLayer.EventType.PRINT_TO_CLOUD, | 350 print_preview.NativeLayer.EventType.PRINT_TO_CLOUD, |
| 353 this.onPrintToCloud_.bind(this)); | 351 this.onPrintToCloud_.bind(this)); |
| 354 this.tracker.add( | 352 this.tracker.add( |
| 355 this.nativeLayer_, | 353 nativeLayerEventTarget, |
| 356 print_preview.NativeLayer.EventType.FILE_SELECTION_CANCEL, | 354 print_preview.NativeLayer.EventType.FILE_SELECTION_CANCEL, |
| 357 this.onFileSelectionCancel_.bind(this)); | 355 this.onFileSelectionCancel_.bind(this)); |
| 358 this.tracker.add( | 356 this.tracker.add( |
| 359 this.nativeLayer_, | 357 nativeLayerEventTarget, |
| 360 print_preview.NativeLayer.EventType.FILE_SELECTION_COMPLETE, | 358 print_preview.NativeLayer.EventType.FILE_SELECTION_COMPLETE, |
| 361 this.onFileSelectionComplete_.bind(this)); | 359 this.onFileSelectionComplete_.bind(this)); |
| 362 this.tracker.add( | 360 this.tracker.add( |
| 363 this.nativeLayer_, | 361 nativeLayerEventTarget, |
| 364 print_preview.NativeLayer.EventType.SETTINGS_INVALID, | 362 print_preview.NativeLayer.EventType.SETTINGS_INVALID, |
| 365 this.onSettingsInvalid_.bind(this)); | 363 this.onSettingsInvalid_.bind(this)); |
| 366 this.tracker.add( | 364 this.tracker.add( |
| 367 this.nativeLayer_, | 365 nativeLayerEventTarget, |
| 368 print_preview.NativeLayer.EventType.PRINT_PRESET_OPTIONS, | 366 print_preview.NativeLayer.EventType.PRINT_PRESET_OPTIONS, |
| 369 this.onPrintPresetOptionsFromDocument_.bind(this)); | 367 this.onPrintPresetOptionsFromDocument_.bind(this)); |
| 370 this.tracker.add( | 368 this.tracker.add( |
| 371 this.nativeLayer_, | 369 nativeLayerEventTarget, |
| 372 print_preview.NativeLayer.EventType.PAGE_COUNT_READY, | 370 print_preview.NativeLayer.EventType.PAGE_COUNT_READY, |
| 373 this.onPageCountReady_.bind(this)); | 371 this.onPageCountReady_.bind(this)); |
| 374 this.tracker.add( | 372 this.tracker.add( |
| 375 this.nativeLayer_, | 373 nativeLayerEventTarget, |
| 376 print_preview.NativeLayer.EventType.PRIVET_PRINT_FAILED, | 374 print_preview.NativeLayer.EventType.PRIVET_PRINT_FAILED, |
| 377 this.onPrivetPrintFailed_.bind(this)); | 375 this.onPrivetPrintFailed_.bind(this)); |
| 378 this.tracker.add( | 376 this.tracker.add( |
| 379 this.nativeLayer_, | 377 nativeLayerEventTarget, |
| 380 print_preview.NativeLayer.EventType.MANIPULATE_SETTINGS_FOR_TEST, | 378 print_preview.NativeLayer.EventType.MANIPULATE_SETTINGS_FOR_TEST, |
| 381 this.onManipulateSettingsForTest_.bind(this)); | 379 this.onManipulateSettingsForTest_.bind(this)); |
| 382 | 380 |
| 383 if ($('system-dialog-link')) { | 381 if ($('system-dialog-link')) { |
| 384 this.tracker.add( | 382 this.tracker.add( |
| 385 getRequiredElement('system-dialog-link'), | 383 getRequiredElement('system-dialog-link'), |
| 386 'click', | 384 'click', |
| 387 this.openSystemPrintDialog_.bind(this)); | 385 this.openSystemPrintDialog_.bind(this)); |
| 388 } | 386 } |
| 389 if ($('open-pdf-in-preview-link')) { | 387 if ($('open-pdf-in-preview-link')) { |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 631 setIsVisible(getRequiredElement('system-dialog-throbber'), true); | 629 setIsVisible(getRequiredElement('system-dialog-throbber'), true); |
| 632 this.setIsEnabled_(false); | 630 this.setIsEnabled_(false); |
| 633 this.uiState_ = PrintPreviewUiState_.OPENING_NATIVE_PRINT_DIALOG; | 631 this.uiState_ = PrintPreviewUiState_.OPENING_NATIVE_PRINT_DIALOG; |
| 634 this.nativeLayer_.startShowSystemDialog(); | 632 this.nativeLayer_.startShowSystemDialog(); |
| 635 }, | 633 }, |
| 636 | 634 |
| 637 /** | 635 /** |
| 638 * Called when the native layer has initial settings to set. Sets the | 636 * Called when the native layer has initial settings to set. Sets the |
| 639 * initial settings of the print preview and begins fetching print | 637 * initial settings of the print preview and begins fetching print |
| 640 * destinations. | 638 * destinations. |
| 641 * @param {Event} event Contains the initial print preview settings | 639 * @param {!print_preview.NativeInitialSettings} settings The initial print |
| 642 * persisted through the session. | 640 * preview settings persisted through the session. |
| 643 * @private | 641 * @private |
| 644 */ | 642 */ |
| 645 onInitialSettingsSet_: function(event) { | 643 onInitialSettingsSet_: function(settings) { |
| 646 assert(this.uiState_ == PrintPreviewUiState_.INITIALIZING, | 644 assert(this.uiState_ == PrintPreviewUiState_.INITIALIZING, |
| 647 'Updating initial settings when not in initializing state: ' + | 645 'Updating initial settings when not in initializing ' + |
| 648 this.uiState_); | 646 'state: ' + this.uiState_); |
|
dpapad
2017/05/19 02:07:06
Can you revert this line completely? It seems that
rbpotter
2017/05/19 02:25:38
Done.
| |
| 649 this.uiState_ = PrintPreviewUiState_.READY; | 647 this.uiState_ = PrintPreviewUiState_.READY; |
| 650 | 648 |
| 651 var settings = event.initialSettings; | |
| 652 this.isInKioskAutoPrintMode_ = settings.isInKioskAutoPrintMode; | 649 this.isInKioskAutoPrintMode_ = settings.isInKioskAutoPrintMode; |
| 653 this.isInAppKioskMode_ = settings.isInAppKioskMode; | 650 this.isInAppKioskMode_ = settings.isInAppKioskMode; |
| 654 | 651 |
| 655 // The following components must be initialized in this order. | 652 // The following components must be initialized in this order. |
| 656 this.appState_.init(settings.serializedAppStateStr); | 653 this.appState_.init(settings.serializedAppStateStr); |
| 657 this.documentInfo_.init( | 654 this.documentInfo_.init( |
| 658 settings.isDocumentModifiable, | 655 settings.isDocumentModifiable, |
| 659 settings.documentTitle, | 656 settings.documentTitle, |
| 660 settings.documentHasSelection); | 657 settings.documentHasSelection); |
| 661 this.printTicketStore_.init( | 658 this.printTicketStore_.init( |
| (...skipping 682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1344 // <include src="previewarea/preview_area.js"> | 1341 // <include src="previewarea/preview_area.js"> |
| 1345 // <include src="preview_generator.js"> | 1342 // <include src="preview_generator.js"> |
| 1346 | 1343 |
| 1347 // <include src="search/destination_list.js"> | 1344 // <include src="search/destination_list.js"> |
| 1348 // <include src="search/cloud_destination_list.js"> | 1345 // <include src="search/cloud_destination_list.js"> |
| 1349 // <include src="search/recent_destination_list.js"> | 1346 // <include src="search/recent_destination_list.js"> |
| 1350 // <include src="search/destination_list_item.js"> | 1347 // <include src="search/destination_list_item.js"> |
| 1351 // <include src="search/destination_search.js"> | 1348 // <include src="search/destination_search.js"> |
| 1352 // <include src="search/provisional_destination_resolver.js"> | 1349 // <include src="search/provisional_destination_resolver.js"> |
| 1353 | 1350 |
| 1354 /** | |
| 1355 * Global instance of PrintPreview, used by browser tests. | |
| 1356 * @type {print_preview.PrintPreview} | |
| 1357 */ | |
| 1358 var printPreview; | |
| 1359 window.addEventListener('DOMContentLoaded', function() { | 1351 window.addEventListener('DOMContentLoaded', function() { |
| 1360 printPreview = new print_preview.PrintPreview(); | 1352 var previewWindow = /** @type {{isTest: boolean}} */ (window); |
| 1361 printPreview.initialize(); | 1353 if (!previewWindow.isTest) { |
| 1354 var printPreview = new print_preview.PrintPreview(); | |
| 1355 printPreview.initialize(); | |
| 1356 } | |
| 1362 }); | 1357 }); |
| OLD | NEW |