Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(57)

Side by Side Diff: chrome/browser/resources/print_preview/print_preview.js

Issue 2935303003: Print Preview: Remove global onPrivetPrintFailed (Closed)
Patch Set: Fix Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 cr.addWebUIListener('print-failed',
dpapad 2017/06/14 20:52:45 I think that we need to remove this listener in ex
rbpotter 2017/06/14 22:52:55 Done.
345 this.onPrintFailed_.bind(this));
344 }, 346 },
345 347
346 /** @override */ 348 /** @override */
347 enterDocument: function() { 349 enterDocument: function() {
348 // Native layer events. 350 // Native layer events.
349 var nativeLayerEventTarget = this.nativeLayer_.getEventTarget(); 351 var nativeLayerEventTarget = this.nativeLayer_.getEventTarget();
350 this.tracker.add( 352 this.tracker.add(
351 nativeLayerEventTarget, 353 nativeLayerEventTarget,
352 print_preview.NativeLayer.EventType.CLOUD_PRINT_ENABLE, 354 print_preview.NativeLayer.EventType.CLOUD_PRINT_ENABLE,
353 this.onCloudPrintEnable_.bind(this)); 355 this.onCloudPrintEnable_.bind(this));
(...skipping 16 matching lines...) Expand all
370 this.tracker.add( 372 this.tracker.add(
371 nativeLayerEventTarget, 373 nativeLayerEventTarget,
372 print_preview.NativeLayer.EventType.PRINT_PRESET_OPTIONS, 374 print_preview.NativeLayer.EventType.PRINT_PRESET_OPTIONS,
373 this.onPrintPresetOptionsFromDocument_.bind(this)); 375 this.onPrintPresetOptionsFromDocument_.bind(this));
374 this.tracker.add( 376 this.tracker.add(
375 nativeLayerEventTarget, 377 nativeLayerEventTarget,
376 print_preview.NativeLayer.EventType.PAGE_COUNT_READY, 378 print_preview.NativeLayer.EventType.PAGE_COUNT_READY,
377 this.onPageCountReady_.bind(this)); 379 this.onPageCountReady_.bind(this));
378 this.tracker.add( 380 this.tracker.add(
379 nativeLayerEventTarget, 381 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, 382 print_preview.NativeLayer.EventType.MANIPULATE_SETTINGS_FOR_TEST,
385 this.onManipulateSettingsForTest_.bind(this)); 383 this.onManipulateSettingsForTest_.bind(this));
386 384
387 if ($('system-dialog-link')) { 385 if ($('system-dialog-link')) {
388 this.tracker.add( 386 this.tracker.add(
389 getRequiredElement('system-dialog-link'), 387 getRequiredElement('system-dialog-link'),
390 'click', 388 'click',
391 this.openSystemPrintDialog_.bind(this)); 389 this.openSystemPrintDialog_.bind(this));
392 } 390 }
393 if ($('open-pdf-in-preview-link')) { 391 if ($('open-pdf-in-preview-link')) {
(...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after
1026 * @private 1024 * @private
1027 */ 1025 */
1028 onPageCountReady_: function(event) { 1026 onPageCountReady_: function(event) {
1029 if (event.fitToPageScaling >= 0) { 1027 if (event.fitToPageScaling >= 0) {
1030 this.scalingSettings_.updateFitToPageScaling( 1028 this.scalingSettings_.updateFitToPageScaling(
1031 event.fitToPageScaling); 1029 event.fitToPageScaling);
1032 } 1030 }
1033 }, 1031 },
1034 1032
1035 /** 1033 /**
1036 * Called when privet printing fails. 1034 * Called when printing to a privet or extension printer fails.
1037 * @param {Event} event Event object representing the failure. 1035 * @param {number | string} httpError The HTTP error code, or -1 if not an
1036 * HTTP error.
1038 * @private 1037 * @private
1039 */ 1038 */
1040 onPrivetPrintFailed_: function(event) { 1039 onPrintFailed_: function(httpError) {
1041 console.error('Privet printing failed with error code ' + 1040 console.error('Privet printing failed with error code ' + httpError);
1042 event.httpError);
1043 this.printHeader_.setErrorMessage( 1041 this.printHeader_.setErrorMessage(
1044 loadTimeData.getString('couldNotPrint')); 1042 loadTimeData.getString('couldNotPrint'));
1045 }, 1043 },
1046 1044
1047 /** 1045 /**
1048 * Called when the print preview settings need to be changed for testing. 1046 * 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 1047 * @param {Event} event Event object that contains the option that is to
1050 * be changed and what to set that option. 1048 * be changed and what to set that option.
1051 * @private 1049 * @private
1052 */ 1050 */
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
1354 // <include src="search/destination_search.js"> 1352 // <include src="search/destination_search.js">
1355 // <include src="search/provisional_destination_resolver.js"> 1353 // <include src="search/provisional_destination_resolver.js">
1356 1354
1357 window.addEventListener('DOMContentLoaded', function() { 1355 window.addEventListener('DOMContentLoaded', function() {
1358 var previewWindow = /** @type {{isTest: boolean}} */ (window); 1356 var previewWindow = /** @type {{isTest: boolean}} */ (window);
1359 if (!previewWindow.isTest) { 1357 if (!previewWindow.isTest) {
1360 var printPreview = new print_preview.PrintPreview(); 1358 var printPreview = new print_preview.PrintPreview();
1361 printPreview.initialize(); 1359 printPreview.initialize();
1362 } 1360 }
1363 }); 1361 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698