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

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

Issue 2108833002: Remove Simplify Page option from Print Preview (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Mark histogram entries as unused Created 4 years, 5 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 cr.exportPath('print_preview'); 5 cr.exportPath('print_preview');
6 6
7 /** 7 /**
8 * @typedef {{selectSaveAsPdfDestination: boolean, 8 * @typedef {{selectSaveAsPdfDestination: boolean,
9 * layoutSettings.portrait: boolean, 9 * layoutSettings.portrait: boolean,
10 * pageRange: string, 10 * pageRange: string,
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 this.onPrivetCapabilitiesSet_.bind(this); 60 this.onPrivetCapabilitiesSet_.bind(this);
61 global.onPrivetPrintFailed = this.onPrivetPrintFailed_.bind(this); 61 global.onPrivetPrintFailed = this.onPrivetPrintFailed_.bind(this);
62 global.onExtensionPrintersAdded = 62 global.onExtensionPrintersAdded =
63 this.onExtensionPrintersAdded_.bind(this); 63 this.onExtensionPrintersAdded_.bind(this);
64 global.onExtensionCapabilitiesSet = 64 global.onExtensionCapabilitiesSet =
65 this.onExtensionCapabilitiesSet_.bind(this); 65 this.onExtensionCapabilitiesSet_.bind(this);
66 global.onEnableManipulateSettingsForTest = 66 global.onEnableManipulateSettingsForTest =
67 this.onEnableManipulateSettingsForTest_.bind(this); 67 this.onEnableManipulateSettingsForTest_.bind(this);
68 global.printPresetOptionsFromDocument = 68 global.printPresetOptionsFromDocument =
69 this.onPrintPresetOptionsFromDocument_.bind(this); 69 this.onPrintPresetOptionsFromDocument_.bind(this);
70 global.allowDistillPage =
71 this.allowDistillPage_.bind(this);
72 global.onProvisionalPrinterResolved = 70 global.onProvisionalPrinterResolved =
73 this.onProvisionalDestinationResolved_.bind(this); 71 this.onProvisionalDestinationResolved_.bind(this);
74 global.failedToResolveProvisionalPrinter = 72 global.failedToResolveProvisionalPrinter =
75 this.failedToResolveProvisionalDestination_.bind(this); 73 this.failedToResolveProvisionalDestination_.bind(this);
76 }; 74 };
77 75
78 /** 76 /**
79 * Event types dispatched from the Chromium native layer. 77 * Event types dispatched from the Chromium native layer.
80 * @enum {string} 78 * @enum {string}
81 * @const 79 * @const
82 */ 80 */
83 NativeLayer.EventType = { 81 NativeLayer.EventType = {
84 ACCESS_TOKEN_READY: 'print_preview.NativeLayer.ACCESS_TOKEN_READY', 82 ACCESS_TOKEN_READY: 'print_preview.NativeLayer.ACCESS_TOKEN_READY',
85 ALLOW_DISTILL_PAGE: 'print_preview.NativeLayer.ALLOW_DISTILL_PAGE',
86 CAPABILITIES_SET: 'print_preview.NativeLayer.CAPABILITIES_SET', 83 CAPABILITIES_SET: 'print_preview.NativeLayer.CAPABILITIES_SET',
87 CLOUD_PRINT_ENABLE: 'print_preview.NativeLayer.CLOUD_PRINT_ENABLE', 84 CLOUD_PRINT_ENABLE: 'print_preview.NativeLayer.CLOUD_PRINT_ENABLE',
88 DESTINATIONS_RELOAD: 'print_preview.NativeLayer.DESTINATIONS_RELOAD', 85 DESTINATIONS_RELOAD: 'print_preview.NativeLayer.DESTINATIONS_RELOAD',
89 DISABLE_SCALING: 'print_preview.NativeLayer.DISABLE_SCALING', 86 DISABLE_SCALING: 'print_preview.NativeLayer.DISABLE_SCALING',
90 FILE_SELECTION_CANCEL: 'print_preview.NativeLayer.FILE_SELECTION_CANCEL', 87 FILE_SELECTION_CANCEL: 'print_preview.NativeLayer.FILE_SELECTION_CANCEL',
91 FILE_SELECTION_COMPLETE: 88 FILE_SELECTION_COMPLETE:
92 'print_preview.NativeLayer.FILE_SELECTION_COMPLETE', 89 'print_preview.NativeLayer.FILE_SELECTION_COMPLETE',
93 GET_CAPABILITIES_FAIL: 'print_preview.NativeLayer.GET_CAPABILITIES_FAIL', 90 GET_CAPABILITIES_FAIL: 'print_preview.NativeLayer.GET_CAPABILITIES_FAIL',
94 INITIAL_SETTINGS_SET: 'print_preview.NativeLayer.INITIAL_SETTINGS_SET', 91 INITIAL_SETTINGS_SET: 'print_preview.NativeLayer.INITIAL_SETTINGS_SET',
95 LOCAL_DESTINATIONS_SET: 'print_preview.NativeLayer.LOCAL_DESTINATIONS_SET', 92 LOCAL_DESTINATIONS_SET: 'print_preview.NativeLayer.LOCAL_DESTINATIONS_SET',
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 destination, printTicketStore, documentInfo, requestId) { 266 destination, printTicketStore, documentInfo, requestId) {
270 assert(printTicketStore.isTicketValidForPreview(), 267 assert(printTicketStore.isTicketValidForPreview(),
271 'Trying to generate preview when ticket is not valid'); 268 'Trying to generate preview when ticket is not valid');
272 269
273 var ticket = { 270 var ticket = {
274 'pageRange': printTicketStore.pageRange.getDocumentPageRanges(), 271 'pageRange': printTicketStore.pageRange.getDocumentPageRanges(),
275 'mediaSize': printTicketStore.mediaSize.getValue(), 272 'mediaSize': printTicketStore.mediaSize.getValue(),
276 'landscape': printTicketStore.landscape.getValue(), 273 'landscape': printTicketStore.landscape.getValue(),
277 'color': this.getNativeColorModel_(destination, printTicketStore.color), 274 'color': this.getNativeColorModel_(destination, printTicketStore.color),
278 'headerFooterEnabled': printTicketStore.headerFooter.getValue(), 275 'headerFooterEnabled': printTicketStore.headerFooter.getValue(),
279 'distillPage': printTicketStore.distillPage.getValue(),
280 'marginsType': printTicketStore.marginsType.getValue(), 276 'marginsType': printTicketStore.marginsType.getValue(),
281 'isFirstRequest': requestId == 0, 277 'isFirstRequest': requestId == 0,
282 'requestID': requestId, 278 'requestID': requestId,
283 'previewModifiable': documentInfo.isModifiable, 279 'previewModifiable': documentInfo.isModifiable,
284 'printToPDF': 280 'printToPDF':
285 destination != null && 281 destination != null &&
286 destination.id == 282 destination.id ==
287 print_preview.Destination.GooglePromotedId.SAVE_AS_PDF, 283 print_preview.Destination.GooglePromotedId.SAVE_AS_PDF,
288 'printWithCloudPrint': destination != null && !destination.isLocal, 284 'printWithCloudPrint': destination != null && !destination.isLocal,
289 'printWithPrivet': destination != null && destination.isPrivet, 285 'printWithPrivet': destination != null && destination.isPrivet,
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 assert(!opt_showSystemDialog || (cr.isWindows && destination.isLocal), 346 assert(!opt_showSystemDialog || (cr.isWindows && destination.isLocal),
351 'Implemented for Windows only'); 347 'Implemented for Windows only');
352 348
353 var ticket = { 349 var ticket = {
354 'pageRange': printTicketStore.pageRange.getDocumentPageRanges(), 350 'pageRange': printTicketStore.pageRange.getDocumentPageRanges(),
355 'mediaSize': printTicketStore.mediaSize.getValue(), 351 'mediaSize': printTicketStore.mediaSize.getValue(),
356 'pageCount': printTicketStore.pageRange.getPageNumberSet().size, 352 'pageCount': printTicketStore.pageRange.getPageNumberSet().size,
357 'landscape': printTicketStore.landscape.getValue(), 353 'landscape': printTicketStore.landscape.getValue(),
358 'color': this.getNativeColorModel_(destination, printTicketStore.color), 354 'color': this.getNativeColorModel_(destination, printTicketStore.color),
359 'headerFooterEnabled': printTicketStore.headerFooter.getValue(), 355 'headerFooterEnabled': printTicketStore.headerFooter.getValue(),
360 'distillPage': printTicketStore.distillPage.getValue(),
361 'marginsType': printTicketStore.marginsType.getValue(), 356 'marginsType': printTicketStore.marginsType.getValue(),
362 'generateDraftData': true, // TODO(rltoscano): What should this be? 357 'generateDraftData': true, // TODO(rltoscano): What should this be?
363 'duplex': printTicketStore.duplex.getValue() ? 358 'duplex': printTicketStore.duplex.getValue() ?
364 NativeLayer.DuplexMode.LONG_EDGE : NativeLayer.DuplexMode.SIMPLEX, 359 NativeLayer.DuplexMode.LONG_EDGE : NativeLayer.DuplexMode.SIMPLEX,
365 'copies': printTicketStore.copies.getValueAsNumber(), 360 'copies': printTicketStore.copies.getValueAsNumber(),
366 'collate': printTicketStore.collate.getValue(), 361 'collate': printTicketStore.collate.getValue(),
367 'shouldPrintBackgrounds': printTicketStore.cssBackground.getValue(), 362 'shouldPrintBackgrounds': printTicketStore.cssBackground.getValue(),
368 'shouldPrintSelectionOnly': printTicketStore.selectionOnly.getValue(), 363 'shouldPrintSelectionOnly': printTicketStore.selectionOnly.getValue(),
369 'previewModifiable': documentInfo.isModifiable, 364 'previewModifiable': documentInfo.isModifiable,
370 'printToPDF': destination.id == 365 'printToPDF': destination.id ==
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
734 * @private 729 * @private
735 */ 730 */
736 onPrintPresetOptionsFromDocument_: function(options) { 731 onPrintPresetOptionsFromDocument_: function(options) {
737 var printPresetOptionsEvent = new Event( 732 var printPresetOptionsEvent = new Event(
738 NativeLayer.EventType.PRINT_PRESET_OPTIONS); 733 NativeLayer.EventType.PRINT_PRESET_OPTIONS);
739 printPresetOptionsEvent.optionsFromDocument = options; 734 printPresetOptionsEvent.optionsFromDocument = options;
740 this.dispatchEvent(printPresetOptionsEvent); 735 this.dispatchEvent(printPresetOptionsEvent);
741 }, 736 },
742 737
743 /** 738 /**
744 * Updates the interface to show the "Simplify Page" option.
745 * @private
746 */
747 allowDistillPage_: function() {
748 var allowDistillPageEvent = new Event(
749 NativeLayer.EventType.ALLOW_DISTILL_PAGE);
750 this.dispatchEvent(allowDistillPageEvent);
751 },
752
753 /**
754 * Simulates a user click on the print preview dialog cancel button. Used 739 * Simulates a user click on the print preview dialog cancel button. Used
755 * only for testing. 740 * only for testing.
756 * @private 741 * @private
757 */ 742 */
758 autoCancelForTesting_: function() { 743 autoCancelForTesting_: function() {
759 var properties = {view: window, bubbles: true, cancelable: true}; 744 var properties = {view: window, bubbles: true, cancelable: true};
760 var click = new MouseEvent('click', properties); 745 var click = new MouseEvent('click', properties);
761 document.querySelector('#print-header .cancel').dispatchEvent(click); 746 document.querySelector('#print-header .cancel').dispatchEvent(click);
762 }, 747 },
763 748
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
1103 return this.serializedDefaultDestinationSelectionRulesStr_; 1088 return this.serializedDefaultDestinationSelectionRulesStr_;
1104 } 1089 }
1105 }; 1090 };
1106 1091
1107 // Export 1092 // Export
1108 return { 1093 return {
1109 NativeInitialSettings: NativeInitialSettings, 1094 NativeInitialSettings: NativeInitialSettings,
1110 NativeLayer: NativeLayer 1095 NativeLayer: NativeLayer
1111 }; 1096 };
1112 }); 1097 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698