| 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 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 | 79 |
| 80 cr.define('print_preview', function() { | 80 cr.define('print_preview', function() { |
| 81 'use strict'; | 81 'use strict'; |
| 82 | 82 |
| 83 /** | 83 /** |
| 84 * An interface to the native Chromium printing system layer. | 84 * An interface to the native Chromium printing system layer. |
| 85 * @constructor | 85 * @constructor |
| 86 */ | 86 */ |
| 87 function NativeLayer() { | 87 function NativeLayer() { |
| 88 // Bind global handlers | 88 // Bind global handlers |
| 89 global.setUseCloudPrint = this.onSetUseCloudPrint_.bind(this); | |
| 90 global.reloadPrintersList = this.onReloadPrintersList_.bind(this); | 89 global.reloadPrintersList = this.onReloadPrintersList_.bind(this); |
| 91 global.printPreviewFailed = this.onPrintPreviewFailed_.bind(this); | 90 global.printPreviewFailed = this.onPrintPreviewFailed_.bind(this); |
| 92 global.invalidPrinterSettings = this.onInvalidPrinterSettings_.bind(this); | 91 global.invalidPrinterSettings = this.onInvalidPrinterSettings_.bind(this); |
| 93 global.onDidGetDefaultPageLayout = | 92 global.onDidGetDefaultPageLayout = |
| 94 this.onDidGetDefaultPageLayout_.bind(this); | 93 this.onDidGetDefaultPageLayout_.bind(this); |
| 95 global.onDidGetPreviewPageCount = this.onDidGetPreviewPageCount_.bind(this); | 94 global.onDidGetPreviewPageCount = this.onDidGetPreviewPageCount_.bind(this); |
| 96 global.onDidPreviewPage = this.onDidPreviewPage_.bind(this); | 95 global.onDidPreviewPage = this.onDidPreviewPage_.bind(this); |
| 97 global.updatePrintPreview = this.onUpdatePrintPreview_.bind(this); | 96 global.updatePrintPreview = this.onUpdatePrintPreview_.bind(this); |
| 98 global.onEnableManipulateSettingsForTest = | 97 global.onEnableManipulateSettingsForTest = |
| 99 this.onEnableManipulateSettingsForTest_.bind(this); | 98 this.onEnableManipulateSettingsForTest_.bind(this); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 124 NativeLayer.setInstance = function(instance) { | 123 NativeLayer.setInstance = function(instance) { |
| 125 currentInstance = instance; | 124 currentInstance = instance; |
| 126 }; | 125 }; |
| 127 | 126 |
| 128 /** | 127 /** |
| 129 * Event types dispatched from the Chromium native layer. | 128 * Event types dispatched from the Chromium native layer. |
| 130 * @enum {string} | 129 * @enum {string} |
| 131 * @const | 130 * @const |
| 132 */ | 131 */ |
| 133 NativeLayer.EventType = { | 132 NativeLayer.EventType = { |
| 134 CLOUD_PRINT_ENABLE: 'print_preview.NativeLayer.CLOUD_PRINT_ENABLE', | |
| 135 DESTINATIONS_RELOAD: 'print_preview.NativeLayer.DESTINATIONS_RELOAD', | 133 DESTINATIONS_RELOAD: 'print_preview.NativeLayer.DESTINATIONS_RELOAD', |
| 136 DISABLE_SCALING: 'print_preview.NativeLayer.DISABLE_SCALING', | 134 DISABLE_SCALING: 'print_preview.NativeLayer.DISABLE_SCALING', |
| 137 MANIPULATE_SETTINGS_FOR_TEST: | 135 MANIPULATE_SETTINGS_FOR_TEST: |
| 138 'print_preview.NativeLayer.MANIPULATE_SETTINGS_FOR_TEST', | 136 'print_preview.NativeLayer.MANIPULATE_SETTINGS_FOR_TEST', |
| 139 PAGE_COUNT_READY: 'print_preview.NativeLayer.PAGE_COUNT_READY', | 137 PAGE_COUNT_READY: 'print_preview.NativeLayer.PAGE_COUNT_READY', |
| 140 PAGE_LAYOUT_READY: 'print_preview.NativeLayer.PAGE_LAYOUT_READY', | 138 PAGE_LAYOUT_READY: 'print_preview.NativeLayer.PAGE_LAYOUT_READY', |
| 141 PAGE_PREVIEW_READY: 'print_preview.NativeLayer.PAGE_PREVIEW_READY', | 139 PAGE_PREVIEW_READY: 'print_preview.NativeLayer.PAGE_PREVIEW_READY', |
| 142 PREVIEW_GENERATION_DONE: | 140 PREVIEW_GENERATION_DONE: |
| 143 'print_preview.NativeLayer.PREVIEW_GENERATION_DONE', | 141 'print_preview.NativeLayer.PREVIEW_GENERATION_DONE', |
| 144 PREVIEW_GENERATION_FAIL: | 142 PREVIEW_GENERATION_FAIL: |
| (...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 547 */ | 545 */ |
| 548 startManageCloudDestinations: function(user) { | 546 startManageCloudDestinations: function(user) { |
| 549 chrome.send('manageCloudPrinters', [user || '']); | 547 chrome.send('manageCloudPrinters', [user || '']); |
| 550 }, | 548 }, |
| 551 | 549 |
| 552 /** Forces browser to open a new tab with the given URL address. */ | 550 /** Forces browser to open a new tab with the given URL address. */ |
| 553 startForceOpenNewTab: function(url) { | 551 startForceOpenNewTab: function(url) { |
| 554 chrome.send('forceOpenNewTab', [url]); | 552 chrome.send('forceOpenNewTab', [url]); |
| 555 }, | 553 }, |
| 556 | 554 |
| 557 /** | |
| 558 * Turn on the integration of Cloud Print. | |
| 559 * @param {{cloudPrintURL: string, appKioskMode: string}} settings | |
| 560 * cloudPrintUrl: The URL to use for cloud print servers. | |
| 561 * @private | |
| 562 */ | |
| 563 onSetUseCloudPrint_: function(settings) { | |
| 564 var cloudPrintEnableEvent = | |
| 565 new Event(NativeLayer.EventType.CLOUD_PRINT_ENABLE); | |
| 566 cloudPrintEnableEvent.baseCloudPrintUrl = settings['cloudPrintUrl'] || ''; | |
| 567 cloudPrintEnableEvent.appKioskMode = settings['appKioskMode'] || false; | |
| 568 this.eventTarget_.dispatchEvent(cloudPrintEnableEvent); | |
| 569 }, | |
| 570 | |
| 571 /** Reloads the printer list. */ | 555 /** Reloads the printer list. */ |
| 572 onReloadPrintersList_: function() { | 556 onReloadPrintersList_: function() { |
| 573 cr.dispatchSimpleEvent( | 557 cr.dispatchSimpleEvent( |
| 574 this.eventTarget_, NativeLayer.EventType.DESTINATIONS_RELOAD); | 558 this.eventTarget_, NativeLayer.EventType.DESTINATIONS_RELOAD); |
| 575 }, | 559 }, |
| 576 | 560 |
| 577 /** | 561 /** |
| 578 * Display an error message when print preview fails. | 562 * Display an error message when print preview fails. |
| 579 * Called from PrintPreviewMessageHandler::OnPrintPreviewFailed(). | 563 * Called from PrintPreviewMessageHandler::OnPrintPreviewFailed(). |
| 580 * @private | 564 * @private |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 899 return this.serializedDefaultDestinationSelectionRulesStr_; | 883 return this.serializedDefaultDestinationSelectionRulesStr_; |
| 900 } | 884 } |
| 901 }; | 885 }; |
| 902 | 886 |
| 903 // Export | 887 // Export |
| 904 return { | 888 return { |
| 905 NativeInitialSettings: NativeInitialSettings, | 889 NativeInitialSettings: NativeInitialSettings, |
| 906 NativeLayer: NativeLayer | 890 NativeLayer: NativeLayer |
| 907 }; | 891 }; |
| 908 }); | 892 }); |
| OLD | NEW |