| Index: chrome/browser/resources/print_preview/native_layer.js
|
| diff --git a/chrome/browser/resources/print_preview/native_layer.js b/chrome/browser/resources/print_preview/native_layer.js
|
| index e0c54bc360b0fe104d2f383b49db9cabe8577fe0..eddc0b94e530681417b1086df968496897bec086 100644
|
| --- a/chrome/browser/resources/print_preview/native_layer.js
|
| +++ b/chrome/browser/resources/print_preview/native_layer.js
|
| @@ -35,32 +35,26 @@ cr.define('print_preview', function() {
|
| global.failedToGetPrinterCapabilities =
|
| this.onFailedToGetPrinterCapabilities_.bind(this);
|
| global.failedToGetPrivetPrinterCapabilities =
|
| - this.onFailedToGetPrivetPrinterCapabilities_.bind(this);
|
| + this.onFailedToGetPrivetPrinterCapabilities_.bind(this);
|
| global.failedToGetExtensionPrinterCapabilities =
|
| this.onFailedToGetExtensionPrinterCapabilities_.bind(this);
|
| global.reloadPrintersList = this.onReloadPrintersList_.bind(this);
|
| global.printToCloud = this.onPrintToCloud_.bind(this);
|
| - global.fileSelectionCancelled =
|
| - this.onFileSelectionCancelled_.bind(this);
|
| - global.fileSelectionCompleted =
|
| - this.onFileSelectionCompleted_.bind(this);
|
| + global.fileSelectionCancelled = this.onFileSelectionCancelled_.bind(this);
|
| + global.fileSelectionCompleted = this.onFileSelectionCompleted_.bind(this);
|
| global.printPreviewFailed = this.onPrintPreviewFailed_.bind(this);
|
| - global.invalidPrinterSettings =
|
| - this.onInvalidPrinterSettings_.bind(this);
|
| + global.invalidPrinterSettings = this.onInvalidPrinterSettings_.bind(this);
|
| global.onDidGetDefaultPageLayout =
|
| this.onDidGetDefaultPageLayout_.bind(this);
|
| - global.onDidGetPreviewPageCount =
|
| - this.onDidGetPreviewPageCount_.bind(this);
|
| + global.onDidGetPreviewPageCount = this.onDidGetPreviewPageCount_.bind(this);
|
| global.onDidPreviewPage = this.onDidPreviewPage_.bind(this);
|
| global.updatePrintPreview = this.onUpdatePrintPreview_.bind(this);
|
| global.onDidGetAccessToken = this.onDidGetAccessToken_.bind(this);
|
| global.autoCancelForTesting = this.autoCancelForTesting_.bind(this);
|
| global.onPrivetPrinterChanged = this.onPrivetPrinterChanged_.bind(this);
|
| - global.onPrivetCapabilitiesSet =
|
| - this.onPrivetCapabilitiesSet_.bind(this);
|
| + global.onPrivetCapabilitiesSet = this.onPrivetCapabilitiesSet_.bind(this);
|
| global.onPrivetPrintFailed = this.onPrivetPrintFailed_.bind(this);
|
| - global.onExtensionPrintersAdded =
|
| - this.onExtensionPrintersAdded_.bind(this);
|
| + global.onExtensionPrintersAdded = this.onExtensionPrintersAdded_.bind(this);
|
| global.onExtensionCapabilitiesSet =
|
| this.onExtensionCapabilitiesSet_.bind(this);
|
| global.onEnableManipulateSettingsForTest =
|
| @@ -118,21 +112,14 @@ cr.define('print_preview', function() {
|
| * Constant values matching printing::DuplexMode enum.
|
| * @enum {number}
|
| */
|
| - NativeLayer.DuplexMode = {
|
| - SIMPLEX: 0,
|
| - LONG_EDGE: 1,
|
| - UNKNOWN_DUPLEX_MODE: -1
|
| - };
|
| + NativeLayer.DuplexMode = {SIMPLEX: 0, LONG_EDGE: 1, UNKNOWN_DUPLEX_MODE: -1};
|
|
|
| /**
|
| * Enumeration of color modes used by Chromium.
|
| * @enum {number}
|
| * @private
|
| */
|
| - NativeLayer.ColorMode_ = {
|
| - GRAY: 1,
|
| - COLOR: 2
|
| - };
|
| + NativeLayer.ColorMode_ = {GRAY: 1, COLOR: 2};
|
|
|
| /**
|
| * Version of the serialized state of the print preview.
|
| @@ -242,8 +229,8 @@ cr.define('print_preview', function() {
|
| var option = destination.isLocal ? color.getSelectedOption() : null;
|
| var nativeColorModel = parseInt(option ? option.vendor_id : null, 10);
|
| if (isNaN(nativeColorModel)) {
|
| - return color.getValue() ?
|
| - NativeLayer.ColorMode_.COLOR : NativeLayer.ColorMode_.GRAY;
|
| + return color.getValue() ? NativeLayer.ColorMode_.COLOR :
|
| + NativeLayer.ColorMode_.GRAY;
|
| }
|
| return nativeColorModel;
|
| },
|
| @@ -264,8 +251,9 @@ cr.define('print_preview', function() {
|
| */
|
| startGetPreview: function(
|
| destination, printTicketStore, documentInfo, requestId) {
|
| - assert(printTicketStore.isTicketValidForPreview(),
|
| - 'Trying to generate preview when ticket is not valid');
|
| + assert(
|
| + printTicketStore.isTicketValidForPreview(),
|
| + 'Trying to generate preview when ticket is not valid');
|
|
|
| var ticket = {
|
| 'pageRange': printTicketStore.pageRange.getDocumentPageRanges(),
|
| @@ -277,8 +265,7 @@ cr.define('print_preview', function() {
|
| 'isFirstRequest': requestId == 0,
|
| 'requestID': requestId,
|
| 'previewModifiable': documentInfo.isModifiable,
|
| - 'printToPDF':
|
| - destination != null &&
|
| + 'printToPDF': destination != null &&
|
| destination.id ==
|
| print_preview.Destination.GooglePromotedId.SAVE_AS_PDF,
|
| 'printWithCloudPrint': destination != null && !destination.isLocal,
|
| @@ -292,7 +279,8 @@ cr.define('print_preview', function() {
|
| // NOTE: Even though the following fields don't directly relate to the
|
| // preview, they still need to be included.
|
| 'duplex': printTicketStore.duplex.getValue() ?
|
| - NativeLayer.DuplexMode.LONG_EDGE : NativeLayer.DuplexMode.SIMPLEX,
|
| + NativeLayer.DuplexMode.LONG_EDGE :
|
| + NativeLayer.DuplexMode.SIMPLEX,
|
| 'copies': 1,
|
| 'collate': true,
|
| 'shouldPrintBackgrounds': printTicketStore.cssBackground.getValue(),
|
| @@ -318,11 +306,10 @@ cr.define('print_preview', function() {
|
| };
|
| }
|
|
|
| - chrome.send(
|
| - 'getPreview',
|
| - [JSON.stringify(ticket),
|
| - requestId > 0 ? documentInfo.pageCount : -1,
|
| - documentInfo.isModifiable]);
|
| + chrome.send('getPreview', [
|
| + JSON.stringify(ticket), requestId > 0 ? documentInfo.pageCount : -1,
|
| + documentInfo.isModifiable
|
| + ]);
|
| },
|
|
|
| /**
|
| @@ -338,14 +325,16 @@ cr.define('print_preview', function() {
|
| * @param {boolean=} opt_showSystemDialog Whether to open system dialog for
|
| * advanced settings.
|
| */
|
| - startPrint: function(destination, printTicketStore, cloudPrintInterface,
|
| - documentInfo, opt_isOpenPdfInPreview,
|
| - opt_showSystemDialog) {
|
| - assert(printTicketStore.isTicketValid(),
|
| - 'Trying to print when ticket is not valid');
|
| + startPrint: function(
|
| + destination, printTicketStore, cloudPrintInterface, documentInfo,
|
| + opt_isOpenPdfInPreview, opt_showSystemDialog) {
|
| + assert(
|
| + printTicketStore.isTicketValid(),
|
| + 'Trying to print when ticket is not valid');
|
|
|
| - assert(!opt_showSystemDialog || (cr.isWindows && destination.isLocal),
|
| - 'Implemented for Windows only');
|
| + assert(
|
| + !opt_showSystemDialog || (cr.isWindows && destination.isLocal),
|
| + 'Implemented for Windows only');
|
|
|
| var ticket = {
|
| 'pageRange': printTicketStore.pageRange.getDocumentPageRanges(),
|
| @@ -355,9 +344,10 @@ cr.define('print_preview', function() {
|
| 'color': this.getNativeColorModel_(destination, printTicketStore.color),
|
| 'headerFooterEnabled': printTicketStore.headerFooter.getValue(),
|
| 'marginsType': printTicketStore.marginsType.getValue(),
|
| - 'generateDraftData': true, // TODO(rltoscano): What should this be?
|
| + 'generateDraftData': true, // TODO(rltoscano): What should this be?
|
| 'duplex': printTicketStore.duplex.getValue() ?
|
| - NativeLayer.DuplexMode.LONG_EDGE : NativeLayer.DuplexMode.SIMPLEX,
|
| + NativeLayer.DuplexMode.LONG_EDGE :
|
| + NativeLayer.DuplexMode.SIMPLEX,
|
| 'copies': printTicketStore.copies.getValueAsNumber(),
|
| 'collate': printTicketStore.collate.getValue(),
|
| 'shouldPrintBackgrounds': printTicketStore.cssBackground.getValue(),
|
| @@ -479,10 +469,8 @@ cr.define('print_preview', function() {
|
| var nativeInitialSettings = new print_preview.NativeInitialSettings(
|
| initialSettings['printAutomaticallyInKioskMode'] || false,
|
| initialSettings['appKioskMode'] || false,
|
| - numberFormatSymbols[0] || ',',
|
| - numberFormatSymbols[1] || '.',
|
| - unitType,
|
| - initialSettings['previewModifiable'] || false,
|
| + numberFormatSymbols[0] || ',', numberFormatSymbols[1] || '.',
|
| + unitType, initialSettings['previewModifiable'] || false,
|
| initialSettings['initiatorTitle'] || '',
|
| initialSettings['documentHasSelection'] || false,
|
| initialSettings['shouldPrintSelectionOnly'] || false,
|
| @@ -490,8 +478,8 @@ cr.define('print_preview', function() {
|
| initialSettings['appState'] || null,
|
| initialSettings['defaultDestinationSelectionRules'] || null);
|
|
|
| - var initialSettingsSetEvent = new Event(
|
| - NativeLayer.EventType.INITIAL_SETTINGS_SET);
|
| + var initialSettingsSetEvent =
|
| + new Event(NativeLayer.EventType.INITIAL_SETTINGS_SET);
|
| initialSettingsSetEvent.initialSettings = nativeInitialSettings;
|
| this.dispatchEvent(initialSettingsSetEvent);
|
| },
|
| @@ -503,8 +491,8 @@ cr.define('print_preview', function() {
|
| * @private
|
| */
|
| onSetUseCloudPrint_: function(settings) {
|
| - var cloudPrintEnableEvent = new Event(
|
| - NativeLayer.EventType.CLOUD_PRINT_ENABLE);
|
| + var cloudPrintEnableEvent =
|
| + new Event(NativeLayer.EventType.CLOUD_PRINT_ENABLE);
|
| cloudPrintEnableEvent.baseCloudPrintUrl = settings['cloudPrintUrl'] || '';
|
| cloudPrintEnableEvent.appKioskMode = settings['appKioskMode'] || false;
|
| this.dispatchEvent(cloudPrintEnableEvent);
|
| @@ -517,8 +505,8 @@ cr.define('print_preview', function() {
|
| * @private
|
| */
|
| onSetPrinters_: function(printers) {
|
| - var localDestsSetEvent = new Event(
|
| - NativeLayer.EventType.LOCAL_DESTINATIONS_SET);
|
| + var localDestsSetEvent =
|
| + new Event(NativeLayer.EventType.LOCAL_DESTINATIONS_SET);
|
| localDestsSetEvent.destinationInfos = printers;
|
| this.dispatchEvent(localDestsSetEvent);
|
| },
|
| @@ -542,8 +530,8 @@ cr.define('print_preview', function() {
|
| * @private
|
| */
|
| onFailedToGetPrinterCapabilities_: function(destinationId) {
|
| - var getCapsFailEvent = new Event(
|
| - NativeLayer.EventType.GET_CAPABILITIES_FAIL);
|
| + var getCapsFailEvent =
|
| + new Event(NativeLayer.EventType.GET_CAPABILITIES_FAIL);
|
| getCapsFailEvent.destinationId = destinationId;
|
| getCapsFailEvent.destinationOrigin =
|
| print_preview.Destination.Origin.LOCAL;
|
| @@ -557,8 +545,8 @@ cr.define('print_preview', function() {
|
| * @private
|
| */
|
| onFailedToGetPrivetPrinterCapabilities_: function(destinationId) {
|
| - var getCapsFailEvent = new Event(
|
| - NativeLayer.EventType.GET_CAPABILITIES_FAIL);
|
| + var getCapsFailEvent =
|
| + new Event(NativeLayer.EventType.GET_CAPABILITIES_FAIL);
|
| getCapsFailEvent.destinationId = destinationId;
|
| getCapsFailEvent.destinationOrigin =
|
| print_preview.Destination.Origin.PRIVET;
|
| @@ -572,8 +560,8 @@ cr.define('print_preview', function() {
|
| * @private
|
| */
|
| onFailedToGetExtensionPrinterCapabilities_: function(destinationId) {
|
| - var getCapsFailEvent = new Event(
|
| - NativeLayer.EventType.GET_CAPABILITIES_FAIL);
|
| + var getCapsFailEvent =
|
| + new Event(NativeLayer.EventType.GET_CAPABILITIES_FAIL);
|
| getCapsFailEvent.destinationId = destinationId;
|
| getCapsFailEvent.destinationOrigin =
|
| print_preview.Destination.Origin.EXTENSION;
|
| @@ -593,8 +581,7 @@ cr.define('print_preview', function() {
|
| * @private
|
| */
|
| onPrintToCloud_: function(data) {
|
| - var printToCloudEvent = new Event(
|
| - NativeLayer.EventType.PRINT_TO_CLOUD);
|
| + var printToCloudEvent = new Event(NativeLayer.EventType.PRINT_TO_CLOUD);
|
| printToCloudEvent.data = data;
|
| this.dispatchEvent(printToCloudEvent);
|
| },
|
| @@ -650,8 +637,8 @@ cr.define('print_preview', function() {
|
| * @private
|
| */
|
| onDidGetDefaultPageLayout_: function(pageLayout, hasCustomPageSizeStyle) {
|
| - var pageLayoutChangeEvent = new Event(
|
| - NativeLayer.EventType.PAGE_LAYOUT_READY);
|
| + var pageLayoutChangeEvent =
|
| + new Event(NativeLayer.EventType.PAGE_LAYOUT_READY);
|
| pageLayoutChangeEvent.pageLayout = pageLayout;
|
| pageLayoutChangeEvent.hasCustomPageSizeStyle = hasCustomPageSizeStyle;
|
| this.dispatchEvent(pageLayoutChangeEvent);
|
| @@ -667,10 +654,10 @@ cr.define('print_preview', function() {
|
| * the document to page, rounded to the nearest integer.
|
| * @private
|
| */
|
| - onDidGetPreviewPageCount_: function(pageCount, previewResponseId,
|
| - fitToPageScaling) {
|
| - var pageCountChangeEvent = new Event(
|
| - NativeLayer.EventType.PAGE_COUNT_READY);
|
| + onDidGetPreviewPageCount_: function(
|
| + pageCount, previewResponseId, fitToPageScaling) {
|
| + var pageCountChangeEvent =
|
| + new Event(NativeLayer.EventType.PAGE_COUNT_READY);
|
| pageCountChangeEvent.pageCount = pageCount;
|
| pageCountChangeEvent.previewResponseId = previewResponseId;
|
| pageCountChangeEvent.fitToPageScaling = fitToPageScaling;
|
| @@ -688,8 +675,8 @@ cr.define('print_preview', function() {
|
| * @private
|
| */
|
| onDidPreviewPage_: function(pageNumber, previewUid, previewResponseId) {
|
| - var pagePreviewGenEvent = new Event(
|
| - NativeLayer.EventType.PAGE_PREVIEW_READY);
|
| + var pagePreviewGenEvent =
|
| + new Event(NativeLayer.EventType.PAGE_PREVIEW_READY);
|
| pagePreviewGenEvent.pageIndex = pageNumber;
|
| pagePreviewGenEvent.previewUid = previewUid;
|
| pagePreviewGenEvent.previewResponseId = previewResponseId;
|
| @@ -703,8 +690,8 @@ cr.define('print_preview', function() {
|
| * @private
|
| */
|
| onDidGetAccessToken_: function(authType, accessToken) {
|
| - var getAccessTokenEvent = new Event(
|
| - NativeLayer.EventType.ACCESS_TOKEN_READY);
|
| + var getAccessTokenEvent =
|
| + new Event(NativeLayer.EventType.ACCESS_TOKEN_READY);
|
| getAccessTokenEvent.authType = authType;
|
| getAccessTokenEvent.accessToken = accessToken;
|
| this.dispatchEvent(getAccessTokenEvent);
|
| @@ -720,8 +707,8 @@ cr.define('print_preview', function() {
|
| * @private
|
| */
|
| onUpdatePrintPreview_: function(previewUid, previewResponseId) {
|
| - var previewGenDoneEvent = new Event(
|
| - NativeLayer.EventType.PREVIEW_GENERATION_DONE);
|
| + var previewGenDoneEvent =
|
| + new Event(NativeLayer.EventType.PREVIEW_GENERATION_DONE);
|
| previewGenDoneEvent.previewUid = previewUid;
|
| previewGenDoneEvent.previewResponseId = previewResponseId;
|
| this.dispatchEvent(previewGenDoneEvent);
|
| @@ -736,8 +723,8 @@ cr.define('print_preview', function() {
|
| * @private
|
| */
|
| onPrintPresetOptionsFromDocument_: function(options) {
|
| - var printPresetOptionsEvent = new Event(
|
| - NativeLayer.EventType.PRINT_PRESET_OPTIONS);
|
| + var printPresetOptionsEvent =
|
| + new Event(NativeLayer.EventType.PRINT_PRESET_OPTIONS);
|
| printPresetOptionsEvent.optionsFromDocument = options;
|
| this.dispatchEvent(printPresetOptionsEvent);
|
| },
|
| @@ -760,7 +747,7 @@ cr.define('print_preview', function() {
|
| */
|
| onPrivetPrinterChanged_: function(printer) {
|
| var privetPrinterChangedEvent =
|
| - new Event(NativeLayer.EventType.PRIVET_PRINTER_CHANGED);
|
| + new Event(NativeLayer.EventType.PRIVET_PRINTER_CHANGED);
|
| privetPrinterChangedEvent.printer = printer;
|
| this.dispatchEvent(privetPrinterChangedEvent);
|
| },
|
| @@ -772,7 +759,7 @@ cr.define('print_preview', function() {
|
| */
|
| onPrivetCapabilitiesSet_: function(printer, capabilities) {
|
| var privetCapabilitiesSetEvent =
|
| - new Event(NativeLayer.EventType.PRIVET_CAPABILITIES_SET);
|
| + new Event(NativeLayer.EventType.PRIVET_CAPABILITIES_SET);
|
| privetCapabilitiesSetEvent.printer = printer;
|
| privetCapabilitiesSetEvent.capabilities = capabilities;
|
| this.dispatchEvent(privetCapabilitiesSetEvent);
|
| @@ -785,7 +772,7 @@ cr.define('print_preview', function() {
|
| */
|
| onPrivetPrintFailed_: function(http_error) {
|
| var privetPrintFailedEvent =
|
| - new Event(NativeLayer.EventType.PRIVET_PRINT_FAILED);
|
| + new Event(NativeLayer.EventType.PRIVET_PRINT_FAILED);
|
| privetPrintFailedEvent.httpError = http_error;
|
| this.dispatchEvent(privetPrintFailedEvent);
|
| },
|
| @@ -814,8 +801,7 @@ cr.define('print_preview', function() {
|
| * @param {string} printerId The printer's ID.
|
| * @param {!Object} capabilities The reported printer capabilities.
|
| */
|
| - onExtensionCapabilitiesSet_: function(printerId,
|
| - capabilities) {
|
| + onExtensionCapabilitiesSet_: function(printerId, capabilities) {
|
| var event = new Event(NativeLayer.EventType.EXTENSION_CAPABILITIES_SET);
|
| event.printerId = printerId;
|
| event.capabilities = capabilities;
|
| @@ -829,8 +815,8 @@ cr.define('print_preview', function() {
|
| * @private
|
| */
|
| failedToResolveProvisionalDestination_: function(destinationId) {
|
| - var evt = new Event(
|
| - NativeLayer.EventType.PROVISIONAL_DESTINATION_RESOLVED);
|
| + var evt =
|
| + new Event(NativeLayer.EventType.PROVISIONAL_DESTINATION_RESOLVED);
|
| evt.provisionalId = destinationId;
|
| evt.destination = null;
|
| this.dispatchEvent(evt);
|
| @@ -849,20 +835,20 @@ cr.define('print_preview', function() {
|
| * destination info.
|
| * @private
|
| */
|
| - onProvisionalDestinationResolved_: function(provisionalDestinationId,
|
| - destinationInfo) {
|
| - var evt = new Event(
|
| - NativeLayer.EventType.PROVISIONAL_DESTINATION_RESOLVED);
|
| + onProvisionalDestinationResolved_: function(
|
| + provisionalDestinationId, destinationInfo) {
|
| + var evt =
|
| + new Event(NativeLayer.EventType.PROVISIONAL_DESTINATION_RESOLVED);
|
| evt.provisionalId = provisionalDestinationId;
|
| evt.destination = destinationInfo;
|
| this.dispatchEvent(evt);
|
| },
|
|
|
| - /**
|
| - * Allows for onManipulateSettings to be called
|
| - * from the native layer.
|
| - * @private
|
| - */
|
| + /**
|
| + * Allows for onManipulateSettings to be called
|
| + * from the native layer.
|
| + * @private
|
| + */
|
| onEnableManipulateSettingsForTest_: function() {
|
| global.onManipulateSettingsForTest =
|
| this.onManipulateSettingsForTest_.bind(this);
|
| @@ -927,19 +913,10 @@ cr.define('print_preview', function() {
|
| * @constructor
|
| */
|
| function NativeInitialSettings(
|
| - isInKioskAutoPrintMode,
|
| - isInAppKioskMode,
|
| - thousandsDelimeter,
|
| - decimalDelimeter,
|
| - unitType,
|
| - isDocumentModifiable,
|
| - documentTitle,
|
| - documentHasSelection,
|
| - selectionOnly,
|
| - systemDefaultDestinationId,
|
| - serializedAppStateStr,
|
| - serializedDefaultDestinationSelectionRulesStr) {
|
| -
|
| + isInKioskAutoPrintMode, isInAppKioskMode, thousandsDelimeter,
|
| + decimalDelimeter, unitType, isDocumentModifiable, documentTitle,
|
| + documentHasSelection, selectionOnly, systemDefaultDestinationId,
|
| + serializedAppStateStr, serializedDefaultDestinationSelectionRulesStr) {
|
| /**
|
| * Whether the print preview should be in auto-print mode.
|
| * @type {boolean}
|
|
|