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

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

Issue 10108001: Refactor print preview web ui (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixes broken tests Created 8 years, 7 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 | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 cr.define('print_preview', function() {
6 'use strict';
7
8 /**
9 * An interface to the native Chromium printing system layer.
10 * @constructor
11 * @extends {cr.EventTarget}
12 */
13 function NativeLayer() {
14 cr.EventTarget.call(this);
15
16 // Bind global handlers
17 global['setInitialSettings'] = this.onSetInitialSettings_.bind(this);
18 global['setUseCloudPrint'] = this.onSetUseCloudPrint_.bind(this);
19 global['setPrinters'] = this.onSetPrinters_.bind(this);
20 global['updateWithPrinterCapabilities'] =
21 this.onUpdateWithPrinterCapabilities_.bind(this);
22 global['reloadPrintersList'] = this.onReloadPrintersList_.bind(this);
23 global['printToCloud'] = this.onPrintToCloud_.bind(this);
24 global['fileSelectionCancelled'] =
25 this.onFileSelectionCancelled_.bind(this);
26 global['fileSelectionCompleted'] =
27 this.onFileSelectionCompleted_.bind(this);
28 global['printPreviewFailed'] = this.onPrintPreviewFailed_.bind(this);
29 global['invalidPrinterSettings'] =
30 this.onInvalidPrinterSettings_.bind(this);
31 global['onDidGetDefaultPageLayout'] =
32 this.onDidGetDefaultPageLayout_.bind(this);
33 global['onDidGetPreviewPageCount'] =
34 this.onDidGetPreviewPageCount_.bind(this);
35 global['reloadPreviewPages'] = this.onReloadPreviewPages_.bind(this);
36 global['onDidPreviewPage'] = this.onDidPreviewPage_.bind(this);
37 global['updatePrintPreview'] = this.onUpdatePrintPreview_.bind(this);
38 };
39
40 /**
41 * Event types dispatched from the Chromium native layer.
42 * @enum {string}
43 * @const
44 */
45 NativeLayer.EventType = {
46 CAPABILITIES_SET: 'print_preview.NativeLayer.CAPABILITIES_SET',
47 CLOUD_PRINT_ENABLE: 'print_preview.NativeLayer.CLOUD_PRINT_ENABLE',
48 DESTINATIONS_RELOAD: 'print_preview.NativeLayer.DESTINATIONS_RELOAD',
49 FILE_SELECTION_CANCEL: 'print_preview.NativeLayer.FILE_SELECTION_CANCEL',
50 FILE_SELECTION_COMPLETE:
51 'print_preview.NativeLayer.FILE_SELECTION_COMPLETE',
52 INITIAL_SETTINGS_SET: 'print_preview.NativeLayer.INITIAL_SETTINGS_SET',
53 LOCAL_DESTINATIONS_SET: 'print_preview.NativeLayer.LOCAL_DESTINATIONS_SET',
54 PAGE_COUNT_READY: 'print_preview.NativeLayer.PAGE_COUNT_READY',
55 PAGE_LAYOUT_READY: 'print_preview.NativeLayer.PAGE_LAYOUT_READY',
56 PAGE_PREVIEW_READY: 'print_preview.NativeLayer.PAGE_PREVIEW_READY',
57 PREVIEW_GENERATION_DONE:
58 'print_preview.NativeLayer.PREVIEW_GENERATION_DONE',
59 PREVIEW_GENERATION_FAIL:
60 'print_preview.NativeLayer.PREVIEW_GENERATION_FAIL',
61 PREVIEW_RELOAD: 'print_preview.NativeLayer.PREVIEW_RELOAD',
62 PRINT_TO_CLOUD: 'print_preview.NativeLayer.PRINT_TO_CLOUD',
63 SETTINGS_INVALID: 'print_preview.NativeLayer.SETTINGS_INVALID'
64 };
65
66 /**
67 * Constant values matching printing::DuplexMode enum.
68 * @enum {number}
69 */
70 NativeLayer.DuplexMode = {
71 SIMPLEX: 0,
72 LONG_EDGE: 1,
73 UNKNOWN_DUPLEX_MODE: -1
74 };
75
76 /**
77 * Enumeration of color modes used by Chromium.
78 * @enum {number}
79 * @private
80 */
81 NativeLayer.ColorMode_ = {
82 GRAY: 1,
83 COLOR: 2
84 };
85
86 NativeLayer.prototype = {
87 __proto__: cr.EventTarget.prototype,
88
89 /** Gets the initial settings to initialize the print preview with. */
90 startGetInitialSettings: function() {
91 chrome.send('getInitialSettings');
92 },
93
94 /**
95 * Requests the system's local print destinations. A LOCAL_DESTINATIONS_SET
96 * event will be dispatched in response.
97 */
98 startGetLocalDestinations: function() {
99 chrome.send('getPrinters');
100 },
101
102 /**
103 * Requests the destination's printing capabilities. A CAPABILITIES_SET
104 * event will be dispatched in response.
105 * @param {string} destinationId ID of the destination.
106 */
107 startGetLocalDestinationCapabilities: function(destinationId) {
108 chrome.send('getPrinterCapabilities', [destinationId]);
109 },
110
111 /**
112 * Requests that a preview be generated. The following events may be
113 * dispatched in response:
114 * - PAGE_COUNT_READY
115 * - PAGE_LAYOUT_READY
116 * - PAGE_PREVIEW_READY
117 * - PREVIEW_GENERATION_DONE
118 * - PREVIEW_GENERATION_FAIL
119 * - PREVIEW_RELOAD
120 * @param {print_preview.Destination} destination Destination to print to.
121 * @param {!print_preview.PrintTicketStore} printTicketStore Used to get the
122 * state of the print ticket.
123 * @param {number} ID of the preview request.
124 */
125 startGetPreview: function(destination, printTicketStore, requestId) {
126 if (!printTicketStore.isTicketValid()) {
127 throw Error('Trying to generate preview when ticket is not valid');
128 }
129
130 var pageRanges = [];
131 if (requestId > 0 &&
132 !printTicketStore.isDocumentModifiable &&
133 printTicketStore.hasPageRangeCapability()) {
134 pageRanges = printTicketStore.getPageNumberSet().getPageRanges();
135 }
136
137 var ticket = {
138 'pageRange': pageRanges, // pageRanges,
139 'landscape': printTicketStore.isLandscapeEnabled(),
140 'color': printTicketStore.isColorEnabled() ?
141 NativeLayer.ColorMode_.COLOR : NativeLayer.ColorMode_.GRAY,
142 'headerFooterEnabled': printTicketStore.isHeaderFooterEnabled(),
143 'marginsType': printTicketStore.getMarginsType(),
144 'isFirstRequest': requestId == 0,
145 'requestID': requestId,
146 'previewModifiable': printTicketStore.isDocumentModifiable,
147 'printToPDF': destination != null && destination.isPrintToPdf,
148 'printWithCloudPrint': destination != null && !destination.isLocal,
149 'deviceName': destination == null ? 'foo' : destination.id,
150 'cloudPrintID': destination == null ? 'foo' : destination.id,
151 'generateDraftData': printTicketStore.isDocumentModifiable,
152
153 // NOTE: Even though the following fields don't directly relate to the
154 // preview, they still need to be included.
155 'duplex': printTicketStore.isDuplexEnabled() ?
156 NativeLayer.DuplexMode.LONG_EDGE : NativeLayer.DuplexMode.SIMPLEX,
157 'copies': printTicketStore.getCopies(),
158 'collate': printTicketStore.isCollateEnabled()
159 };
160
161 if (printTicketStore.hasMarginsCapability() &&
162 printTicketStore.getMarginsType() ==
163 print_preview.ticket_items.MarginsType.Value.CUSTOM) {
164 var customMarginsInPts = printTicketStore.getCustomMarginsInPts();
165 var orientationEnum =
166 print_preview.ticket_items.CustomMargins.Orientation;
167 ticket['marginsCustom'] = {
168 'marginTop': customMarginsInPts.get(orientationEnum.TOP),
169 'marginRight': customMarginsInPts.get(orientationEnum.RIGHT),
170 'marginBottom': customMarginsInPts.get(orientationEnum.BOTTOM),
171 'marginLeft': customMarginsInPts.get(orientationEnum.LEFT)
172 };
173 }
174
175 chrome.send(
176 'getPreview',
177 [JSON.stringify(ticket), -1, printTicketStore.isDocumentModifiable]);
178 },
179
180 /**
181 * Persists the selected destination and print ticket for the next print
182 * session.
183 * @param {!print_preview.Destination} destination Destination to save.
184 * @param {!print_preview.PrintTicketStore} printTicketStore Used for
185 * generating the serialized print ticket to persist.
186 */
187 startSaveDestinationAndTicket: function(destination, printTicketStore) {
188 var destinationAndTicket = {
189 'destination': destination.serialize(),
190 'printTicket': printTicketStore.serialize()
191 };
192 chrome.send(
193 'saveLastPrinter',
194 [destination.id, JSON.stringify(destinationAndTicket)]);
195 },
196
197 /**
198 * Requests that the document be printed.
199 * @param {!print_preview.Destination} destination Destination to print to.
200 * @param {!print_preview.PrintTicketStore} printTicketStore Used to get the
201 * state of the print ticket.
202 * @param {print_preview.CloudPrintInterface} cloudPrintInterface Interface
203 * to Google Cloud Print.
204 */
205 startPrint: function(destination, printTicketStore, cloudPrintInterface) {
206 if (!printTicketStore.isTicketValid()) {
207 throw Error(
208 'Requesting ticket for preview generator when ticket is not valid');
209 }
210
211 var ticket = {
212 'pageRange': printTicketStore.hasPageRangeCapability() ?
213 printTicketStore.getPageNumberSet().getPageRanges() : [],
214 'landscape': printTicketStore.isLandscapeEnabled(),
215 'color': printTicketStore.isColorEnabled() ?
216 NativeLayer.ColorMode_.COLOR : NativeLayer.ColorMode_.GRAY,
217 'headerFooterEnabled': printTicketStore.isHeaderFooterEnabled(),
218 'marginsType': printTicketStore.getMarginsType(),
219 'generateDraftData': true, // TODO What should this value be?
220 'duplex': printTicketStore.isDuplexEnabled() ?
221 NativeLayer.DuplexMode.LONG_EDGE : NativeLayer.DuplexMode.SIMPLEX,
222 'copies': printTicketStore.getCopies(),
223 'collate': printTicketStore.isCollateEnabled(),
224 'previewModifiable': printTicketStore.isDocumentModifiable,
225 'printToPDF': destination.isPrintToPdf,
226 'printWithCloudPrint': !destination.isLocal,
227 'deviceName': destination.id,
228 'isFirstRequest': false,
229 'requestID': -1
230 };
231
232 if (!destination.isLocal && !destination.isPrintWithCloudPrint) {
233 // We can't set cloudPrintID if the destination is "Print with Cloud
234 // Print" because the native system will try to print to Google Cloud
235 // Print with this ID instead of opening a Google Cloud Print dialog.
236 ticket['cloudPrintID'] = destination.id;
237 }
238
239 if (printTicketStore.hasMarginsCapability() &&
240 printTicketStore.getMarginsType() ==
241 print_preview.ticket_items.MarginsType.Value.CUSTOM) {
242 var customMarginsInPts = printTicketStore.getCustomMargins();
243 var orientationEnum =
244 print_preview.ticket_items.CustomMargins.Orientation;
245 ticket['marginsCustom'] = {
246 'marginTop': customMarginsInPts.get(orientationEnum.TOP),
247 'marginRight': customMarginsInPts.get(orientationEnum.RIGHT),
248 'marginBottom': customMarginsInPts.get(orientationEnum.BOTTOM),
249 'marginLeft': customMarginsInPts.get(orientationEnum.LEFT)
250 };
251 }
252
253 var cloudTicket = null;
254 if (!destination.isLocal) {
255 if (!cloudPrintInterface) {
256 throw Error(
257 'Trying to print to a cloud destination but Google Cloud Print ' +
258 'integration is disabled');
259 }
260 cloudTicket = cloudPrintInterface.createPrintTicket(
261 destination, printTicketStore);
262 cloudTicket = JSON.stringify(cloudTicket);
263 }
264
265 chrome.send('print', [JSON.stringify(ticket), cloudTicket]);
266 },
267
268 /** Requests that the current pending print request be cancelled. */
269 startCancelPendingPrint: function() {
270 chrome.send('cancelPendingPrintRequest');
271 },
272
273 /** Shows the system's native printing dialog. */
274 startShowSystemDialog: function() {
275 chrome.send('showSystemDialog');
276 },
277
278 /** Closes the print preview dialog. */
279 startCloseDialog: function() {
280 chrome.send('closePrintPreviewTab');
281 chrome.send('DialogClose');
282 },
283
284 /** Hide the print preview dialog and allow the native layer to close it. */
285 startHideDialog: function() {
286 chrome.send('hidePreview');
287 },
288
289 /**
290 * Opens the Google Cloud Print sign-in dialog. The DESTINATIONS_RELOAD
291 * event will be dispatched in response.
292 */
293 startCloudPrintSignIn: function() {
294 chrome.send('signIn');
295 },
296
297 /** Navigates the user to the system printer settings interface. */
298 startManageLocalPrinters: function() {
299 chrome.send('manageLocalPrinters');
300 },
301
302 /** Navigates the user to the Google Cloud Print management page. */
303 startManageCloudPrinters: function() {
304 chrome.send('manageCloudPrinters');
305 },
306
307 /**
308 * @param {object} initialSettings Object containing all initial settings.
309 */
310 onSetInitialSettings_: function(initialSettings) {
311 // Not using initialSettings['initiatorTabTitle'] since the print preview
312 // no longer opens in a new tab. And because of this,
313 // localStrings.getStringF('printPreviewTitleFormat', initiatorTabTitle)
314 // is also not used.
315 // TODO Remove those unused local strings.
316
317 // TODO Use initialSettings['cloudPrintData'] to prepopulate destination
318 // and initial print ticket.
319 var numberFormatSymbols =
320 print_preview.MeasurementSystem.parseNumberFormat(
321 initialSettings['numberFormat']);
322 var unitType = print_preview.MeasurementSystem.UnitType.IMPERIAL;
323 if (initialSettings['measurementSystem'] != null) {
324 unitType = initialSettings['measurementSystem'];
325 }
326 var measurementSystem = new print_preview.MeasurementSystem(
327 numberFormatSymbols[0],
328 numberFormatSymbols[1],
329 unitType);
330
331 var customMargins = null;
332 if (initialSettings.hasOwnProperty('marginTop') &&
333 initialSettings.hasOwnProperty('marginRight') &&
334 initialSettings.hasOwnProperty('marginBottom') &&
335 initialSettings.hasOwnProperty('marginLeft')) {
336 customMargins = new print_preview.Margins(
337 initialSettings['marginTop'] || 0,
338 initialSettings['marginRight'] || 0,
339 initialSettings['marginBottom'] || 0,
340 initialSettings['marginLeft'] || 0);
341 }
342
343 var marginsType = null;
344 if (initialSettings.hasOwnProperty('marginsType')) {
345 marginsType = initialSettings['marginsType'];
346 }
347
348 var nativeInitialSettings = new print_preview.NativeInitialSettings(
349 initialSettings['printAutomaticallyInKioskMode'] || false,
350 numberFormatSymbols[0] || ',',
351 numberFormatSymbols[1] || '.',
352 unitType,
353 initialSettings['previewModifiable'] || false,
354 marginsType,
355 customMargins,
356 initialSettings['duplex'] || false,
357 initialSettings['headerFooterEnabled'] || false,
358 initialSettings['printerName'] || null);
359
360 var initialSettingsSetEvent = new cr.Event(
361 print_preview.NativeLayer.EventType.INITIAL_SETTINGS_SET);
362 initialSettingsSetEvent.initialSettings = nativeInitialSettings;
363 this.dispatchEvent(initialSettingsSetEvent);
364 },
365
366 /**
367 * Turn on the integration of Cloud Print.
368 * @param {string} cloudPrintURL The URL to use for cloud print servers.
369 * @private
370 */
371 onSetUseCloudPrint_: function(cloudPrintURL) {
372 var cloudPrintEnableEvent = new cr.Event(
373 print_preview.NativeLayer.EventType.CLOUD_PRINT_ENABLE);
374 cloudPrintEnableEvent.baseCloudPrintUrl = cloudPrintURL;
375 this.dispatchEvent(cloudPrintEnableEvent);
376 },
377
378 /**
379 * Updates the print preview with local printers.
380 * Called from PrintPreviewHandler::SetupPrinterList().
381 * @param {Array} printers Array of printer info objects.
382 * @private
383 */
384 onSetPrinters_: function(printers) {
385 var localDestsSetEvent = new cr.Event(
386 print_preview.NativeLayer.EventType.LOCAL_DESTINATIONS_SET);
387 localDestsSetEvent.destinationInfos = printers;
388 this.dispatchEvent(localDestsSetEvent);
389 },
390
391 /**
392 * Called when native layer gets settings information for a requested local
393 * destination.
394 * @param {Object} settingsInfo printer setting information.
395 * @private
396 */
397 onUpdateWithPrinterCapabilities_: function(settingsInfo) {
398 var capsSetEvent = new cr.Event(
399 print_preview.NativeLayer.EventType.CAPABILITIES_SET);
400 capsSetEvent.settingsInfo = settingsInfo;
401 this.dispatchEvent(capsSetEvent);
402 },
403
404 /** Reloads the printer list. */
405 onReloadPrintersList_: function() {
406 cr.dispatchSimpleEvent(
407 this, print_preview.NativeLayer.EventType.DESTINATIONS_RELOAD);
408 },
409
410 /**
411 * Called from the C++ layer.
412 * Take the PDF data handed to us and submit it to the cloud, closing the
413 * print preview tab once the upload is successful.
414 * @param {string} data Data to send as the print job.
415 * @private
416 */
417 onPrintToCloud_: function(data) {
418 var printToCloudEvent = new cr.Event(
419 print_preview.NativeLayer.EventType.PRINT_TO_CLOUD);
420 printToCloudEvent.data = data;
421 this.dispatchEvent(printToCloudEvent);
422 },
423
424 /**
425 * Called from PrintPreviewUI::OnFileSelectionCancelled to notify the print
426 * preview tab regarding the file selection cancel event.
427 * @private
428 */
429 onFileSelectionCancelled_: function() {
430 cr.dispatchSimpleEvent(
431 this, print_preview.NativeLayer.EventType.FILE_SELECTION_CANCEL);
432 },
433
434 /**
435 * Called from PrintPreviewUI::OnFileSelectionCompleted to notify the print
436 * preview tab regarding the file selection completed event.
437 * @private
438 */
439 onFileSelectionCompleted_: function() {
440 // If the file selection is completed and the tab is not already closed it
441 // means that a pending print to pdf request exists.
442 cr.dispatchSimpleEvent(
443 this, print_preview.NativeLayer.EventType.FILE_SELECTION_COMPLETE);
444 },
445
446 /**
447 * Display an error message when print preview fails.
448 * Called from PrintPreviewMessageHandler::OnPrintPreviewFailed().
449 * @private
450 */
451 onPrintPreviewFailed_: function() {
452 cr.dispatchSimpleEvent(
453 this, print_preview.NativeLayer.EventType.PREVIEW_GENERATION_FAIL);
454 },
455
456 /**
457 * Display an error message when encountered invalid printer settings.
458 * Called from PrintPreviewMessageHandler::OnInvalidPrinterSettings().
459 * @private
460 */
461 onInvalidPrinterSettings_: function() {
462 cr.dispatchSimpleEvent(
463 this, print_preview.NativeLayer.EventType.SETTINGS_INVALID);
464 },
465
466 /**
467 * @param {{contentWidth: number, contentHeight: number, marginLeft: number,
468 * marginRight: number, marginTop: number, marginBottom: number,
469 * printableAreaX: number, printableAreaY: number,
470 * printableAreaWidth: number, printableAreaHeight: number}}
471 * pageLayout Specifies default page layout details in points.
472 * @param {boolean} hasCustomPageSizeStyle Indicates whether the previewed
473 * document has a custom page size style.
474 * @private
475 */
476 onDidGetDefaultPageLayout_: function(pageLayout, hasCustomPageSizeStyle) {
477 var pageLayoutChangeEvent = new cr.Event(
478 print_preview.NativeLayer.EventType.PAGE_LAYOUT_READY);
479 pageLayoutChangeEvent.pageLayout = pageLayout;
480 pageLayoutChangeEvent.hasCustomPageSizeStyle = hasCustomPageSizeStyle;
481 this.dispatchEvent(pageLayoutChangeEvent);
482 },
483
484 /**
485 * Update the page count and check the page range.
486 * Called from PrintPreviewUI::OnDidGetPreviewPageCount().
487 * @param {number} pageCount The number of pages.
488 * @param {number} previewResponseId The preview request id that resulted in
489 * this response.
490 * @private
491 */
492 onDidGetPreviewPageCount_: function(pageCount, previewResponseId) {
493 var pageCountChangeEvent = new cr.Event(
494 print_preview.NativeLayer.EventType.PAGE_COUNT_READY);
495 pageCountChangeEvent.pageCount = pageCount;
496 pageCountChangeEvent.previewResponseId = previewResponseId;
497 this.dispatchEvent(pageCountChangeEvent);
498 },
499
500 /**
501 * Called when no pipelining previewed pages.
502 * @param {string} previewUid Preview unique identifier.
503 * @param {number} previewResponseId The preview request id that resulted in
504 * this response.
505 * @private
506 */
507 onReloadPreviewPages_: function(previewUid, previewResponseId) {
508 var previewReloadEvent = new cr.Event(
509 print_preview.NativeLayer.EventType.PREVIEW_RELOAD);
510 previewReloadEvent.previewUid = previewUid;
511 previewReloadEvent.previewResponseId = previewResponseId;
512 this.dispatchEvent(previewReloadEvent);
513 },
514
515 /**
516 * Notification that a print preview page has been rendered.
517 * Check if the settings have changed and request a regeneration if needed.
518 * Called from PrintPreviewUI::OnDidPreviewPage().
519 * @param {number} pageNumber The page number, 0-based.
520 * @param {string} previewUid Preview unique identifier.
521 * @param {number} previewResponseId The preview request id that resulted in
522 * this response.
523 * @private
524 */
525 onDidPreviewPage_: function(pageNumber, previewUid, previewResponseId) {
526 var pagePreviewGenEvent = new cr.Event(
527 print_preview.NativeLayer.EventType.PAGE_PREVIEW_READY);
528 pagePreviewGenEvent.pageIndex = pageNumber;
529 pagePreviewGenEvent.previewUid = previewUid;
530 pagePreviewGenEvent.previewResponseId = previewResponseId;
531 this.dispatchEvent(pagePreviewGenEvent);
532 },
533
534 /**
535 * Update the print preview when new preview data is available.
536 * Create the PDF plugin as needed.
537 * Called from PrintPreviewUI::PreviewDataIsAvailable().
538 * @param {string} previewUid Preview unique identifier.
539 * @param {number} previewResponseId The preview request id that resulted in
540 * this response.
541 * @private
542 */
543 onUpdatePrintPreview_: function(previewUid, previewResponseId) {
544 var previewGenDoneEvent = new cr.Event(
545 print_preview.NativeLayer.EventType.PREVIEW_GENERATION_DONE);
546 previewGenDoneEvent.previewUid = previewUid;
547 previewGenDoneEvent.previewResponseId = previewResponseId;
548 this.dispatchEvent(previewGenDoneEvent);
549 }
550 };
551
552 /**
553 * Initial settings retrieved from the native layer.
554 * @param {boolean} isInKioskAutoPrintMode Whether the print preview should be
555 * in auto-print mode.
556 * @param {string} thousandsDelimeter Character delimeter of thousands digits.
557 * @param {string} decimalDelimeter Character delimeter of the decimal point.
558 * @param {print_preview.MeasurementSystem.UnitType} unitType Unit type of
559 * local machine's measurement system.
560 * @param {boolean} isDocumentModifiable Whether the document to print is
561 * modifiable.
562 * @param {?print_preview.ticket_items.MarginsType.Value} marginsType Initial
563 * margins type.
564 * @param {print_preview.Margins} customMargins Initial custom margins.
565 * @param {boolean} isDuplexEnabled Whether duplexing is initially enabled.
566 * @param {boolean} isHeaderFooterEnabled Whether the header-footer is
567 * initially enabled.
568 * @param {?string} initialDestinationId ID of the destination to initially
569 * select.
570 * @constructor
571 */
572 function NativeInitialSettings(
573 isInKioskAutoPrintMode,
574 thousandsDelimeter,
575 decimalDelimeter,
576 unitType,
577 isDocumentModifiable,
578 marginsType,
579 customMargins,
580 isDuplexEnabled,
581 isHeaderFooterEnabled,
582 initialDestinationId) {
583
584 /**
585 * Whether the print preview should be in auto-print mode.
586 * @type {boolean}
587 * @private
588 */
589 this.isInKioskAutoPrintMode_ = isInKioskAutoPrintMode;
590
591 /**
592 * Character delimeter of thousands digits.
593 * @type {string}
594 * @private
595 */
596 this.thousandsDelimeter_ = thousandsDelimeter;
597
598 /**
599 * Character delimeter of the decimal point.
600 * @type {string}
601 * @private
602 */
603 this.decimalDelimeter_ = decimalDelimeter;
604
605 /**
606 * Unit type of local machine's measurement system.
607 * @type {string}
608 * @private
609 */
610 this.unitType_ = unitType;
611
612 /**
613 * Whether the document to print is modifiable.
614 * @type {boolean}
615 * @private
616 */
617 this.isDocumentModifiable_ = isDocumentModifiable;
618
619 /**
620 * Initial margins type.
621 * @type {?print_preview.ticket_items.MarginsType.Value}
622 * @private
623 */
624 this.marginsType_ = marginsType;
625
626 /**
627 * Initial custom margins.
628 * @type {print_preview.Margins}
629 * @private
630 */
631 this.customMargins_ = customMargins;
632
633 /**
634 * Whether duplexing is initially enabled.
635 * @type {boolean}
636 * @private
637 */
638 this.isDuplexEnabled_ = isDuplexEnabled;
639
640 /**
641 * Whether the header-footer is initially enabled.
642 * @type {boolean}
643 * @private
644 */
645 this.isHeaderFooterEnabled_ = isHeaderFooterEnabled;
646
647 /**
648 * ID of the initially selected destination.
649 * @type {?string}
650 * @private
651 */
652 this.initialDestinationId_ = initialDestinationId;
653 };
654
655 NativeInitialSettings.prototype = {
656 /**
657 * @return {boolean} Whether the print preview should be in auto-print mode.
658 */
659 get isInKioskAutoPrintMode() {
660 return this.isInKioskAutoPrintMode_;
661 },
662
663 /** @return {string} Character delimeter of thousands digits. */
664 get thousandsDelimeter() {
665 return this.thousandsDelimeter_;
666 },
667
668 /** @return {string} Character delimeter of the decimal point. */
669 get decimalDelimeter() {
670 return this.decimalDelimeter_;
671 },
672
673 /**
674 * @return {print_preview.MeasurementSystem.UnitType} Unit type of local
675 * machine's measurement system.
676 */
677 get unitType() {
678 return this.unitType_;
679 },
680
681 /** @return {boolean} Whether the document to print is modifiable. */
682 get isDocumentModifiable() {
683 return this.isDocumentModifiable_;
684 },
685
686 /**
687 * @return {?print_preview.ticket_items.MarginsType.Value} Initial margins
688 * type or {@code null} if not initially set.
689 */
690 get marginsType() {
691 return this.marginsType_;
692 },
693
694 /** @return {print_preview.Margins} Initial custom margins. */
695 get customMargins() {
696 return this.customMargins_;
697 },
698
699 /** @return {boolean} Whether duplexing is initially enabled. */
700 get isDuplexEnabled() {
701 return this.isDuplexEnabled_;
702 },
703
704 /** @return {boolean} Whether the header-footer is initially enabled. */
705 get isHeaderFooterEnabled() {
706 this.isHeaderFooterEnabled_;
707 },
708
709 /** @return {?string} ID of the initially selected destination. */
710 get initialDestinationId() {
711 return this.initialDestinationId_;
712 }
713 };
714
715 // Export
716 return {
717 NativeInitialSettings: NativeInitialSettings,
718 NativeLayer: NativeLayer
719 };
720 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698