| 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.define('print_preview', function() { | 5 cr.define('print_preview', function() { |
| 6 'use strict'; | 6 'use strict'; |
| 7 | 7 |
| 8 /** | 8 /** |
| 9 * An interface to the native Chromium printing system layer. | 9 * An interface to the native Chromium printing system layer. |
| 10 * @constructor | 10 * @constructor |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 * dispatched in response: | 193 * dispatched in response: |
| 194 * - PAGE_COUNT_READY | 194 * - PAGE_COUNT_READY |
| 195 * - PAGE_LAYOUT_READY | 195 * - PAGE_LAYOUT_READY |
| 196 * - PAGE_PREVIEW_READY | 196 * - PAGE_PREVIEW_READY |
| 197 * - PREVIEW_GENERATION_DONE | 197 * - PREVIEW_GENERATION_DONE |
| 198 * - PREVIEW_GENERATION_FAIL | 198 * - PREVIEW_GENERATION_FAIL |
| 199 * @param {print_preview.Destination} destination Destination to print to. | 199 * @param {print_preview.Destination} destination Destination to print to. |
| 200 * @param {!print_preview.PrintTicketStore} printTicketStore Used to get the | 200 * @param {!print_preview.PrintTicketStore} printTicketStore Used to get the |
| 201 * state of the print ticket. | 201 * state of the print ticket. |
| 202 * @param {!print_preview.DocumentInfo} documentInfo Document data model. | 202 * @param {!print_preview.DocumentInfo} documentInfo Document data model. |
| 203 * @param {number} ID of the preview request. | 203 * @param {number} requestId ID of the preview request. |
| 204 */ | 204 */ |
| 205 startGetPreview: function( | 205 startGetPreview: function( |
| 206 destination, printTicketStore, documentInfo, requestId) { | 206 destination, printTicketStore, documentInfo, requestId) { |
| 207 assert(printTicketStore.isTicketValidForPreview(), | 207 assert(printTicketStore.isTicketValidForPreview(), |
| 208 'Trying to generate preview when ticket is not valid'); | 208 'Trying to generate preview when ticket is not valid'); |
| 209 | 209 |
| 210 var ticket = { | 210 var ticket = { |
| 211 'pageRange': printTicketStore.pageRange.getDocumentPageRanges(), | 211 'pageRange': printTicketStore.pageRange.getDocumentPageRanges(), |
| 212 'mediaSize': printTicketStore.mediaSize.getValue(), | 212 'mediaSize': printTicketStore.mediaSize.getValue(), |
| 213 'landscape': printTicketStore.landscape.getValue(), | 213 'landscape': printTicketStore.landscape.getValue(), |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 428 initialSettings['appState'] || null); | 428 initialSettings['appState'] || null); |
| 429 | 429 |
| 430 var initialSettingsSetEvent = new Event( | 430 var initialSettingsSetEvent = new Event( |
| 431 NativeLayer.EventType.INITIAL_SETTINGS_SET); | 431 NativeLayer.EventType.INITIAL_SETTINGS_SET); |
| 432 initialSettingsSetEvent.initialSettings = nativeInitialSettings; | 432 initialSettingsSetEvent.initialSettings = nativeInitialSettings; |
| 433 this.dispatchEvent(initialSettingsSetEvent); | 433 this.dispatchEvent(initialSettingsSetEvent); |
| 434 }, | 434 }, |
| 435 | 435 |
| 436 /** | 436 /** |
| 437 * Turn on the integration of Cloud Print. | 437 * Turn on the integration of Cloud Print. |
| 438 * @param {string} cloudPrintURL The URL to use for cloud print servers. | 438 * @param {{cloudPrintURL: string, appKioskMode: string}} settings |
| 439 * cloudPrintUrl: The URL to use for cloud print servers. |
| 439 * @private | 440 * @private |
| 440 */ | 441 */ |
| 441 onSetUseCloudPrint_: function(settings) { | 442 onSetUseCloudPrint_: function(settings) { |
| 442 var cloudPrintEnableEvent = new Event( | 443 var cloudPrintEnableEvent = new Event( |
| 443 NativeLayer.EventType.CLOUD_PRINT_ENABLE); | 444 NativeLayer.EventType.CLOUD_PRINT_ENABLE); |
| 444 cloudPrintEnableEvent.baseCloudPrintUrl = settings['cloudPrintUrl'] || ''; | 445 cloudPrintEnableEvent.baseCloudPrintUrl = settings['cloudPrintUrl'] || ''; |
| 445 cloudPrintEnableEvent.appKioskMode = settings['appKioskMode'] || false; | 446 cloudPrintEnableEvent.appKioskMode = settings['appKioskMode'] || false; |
| 446 this.dispatchEvent(cloudPrintEnableEvent); | 447 this.dispatchEvent(cloudPrintEnableEvent); |
| 447 }, | 448 }, |
| 448 | 449 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 467 */ | 468 */ |
| 468 onUpdateWithPrinterCapabilities_: function(settingsInfo) { | 469 onUpdateWithPrinterCapabilities_: function(settingsInfo) { |
| 469 var capsSetEvent = new Event(NativeLayer.EventType.CAPABILITIES_SET); | 470 var capsSetEvent = new Event(NativeLayer.EventType.CAPABILITIES_SET); |
| 470 capsSetEvent.settingsInfo = settingsInfo; | 471 capsSetEvent.settingsInfo = settingsInfo; |
| 471 this.dispatchEvent(capsSetEvent); | 472 this.dispatchEvent(capsSetEvent); |
| 472 }, | 473 }, |
| 473 | 474 |
| 474 /** | 475 /** |
| 475 * Called when native layer gets settings information for a requested local | 476 * Called when native layer gets settings information for a requested local |
| 476 * destination. | 477 * destination. |
| 477 * @param {string} printerId printer affected by error. | 478 * @param {string} destinationId Printer affected by error. |
| 478 * @private | 479 * @private |
| 479 */ | 480 */ |
| 480 onFailedToGetPrinterCapabilities_: function(destinationId) { | 481 onFailedToGetPrinterCapabilities_: function(destinationId) { |
| 481 var getCapsFailEvent = new Event( | 482 var getCapsFailEvent = new Event( |
| 482 NativeLayer.EventType.GET_CAPABILITIES_FAIL); | 483 NativeLayer.EventType.GET_CAPABILITIES_FAIL); |
| 483 getCapsFailEvent.destinationId = destinationId; | 484 getCapsFailEvent.destinationId = destinationId; |
| 484 getCapsFailEvent.destinationOrigin = | 485 getCapsFailEvent.destinationOrigin = |
| 485 print_preview.Destination.Origin.LOCAL; | 486 print_preview.Destination.Origin.LOCAL; |
| 486 this.dispatchEvent(getCapsFailEvent); | 487 this.dispatchEvent(getCapsFailEvent); |
| 487 }, | 488 }, |
| 488 | 489 |
| 489 /** | 490 /** |
| 490 * Called when native layer gets settings information for a requested privet | 491 * Called when native layer gets settings information for a requested privet |
| 491 * destination. | 492 * destination. |
| 492 * @param {string} printerId printer affected by error. | 493 * @param {string} destinationId Printer affected by error. |
| 493 * @private | 494 * @private |
| 494 */ | 495 */ |
| 495 onFailedToGetPrivetPrinterCapabilities_: function(destinationId) { | 496 onFailedToGetPrivetPrinterCapabilities_: function(destinationId) { |
| 496 var getCapsFailEvent = new Event( | 497 var getCapsFailEvent = new Event( |
| 497 NativeLayer.EventType.GET_CAPABILITIES_FAIL); | 498 NativeLayer.EventType.GET_CAPABILITIES_FAIL); |
| 498 getCapsFailEvent.destinationId = destinationId; | 499 getCapsFailEvent.destinationId = destinationId; |
| 499 getCapsFailEvent.destinationOrigin = | 500 getCapsFailEvent.destinationOrigin = |
| 500 print_preview.Destination.Origin.PRIVET; | 501 print_preview.Destination.Origin.PRIVET; |
| 501 this.dispatchEvent(getCapsFailEvent); | 502 this.dispatchEvent(getCapsFailEvent); |
| 502 }, | 503 }, |
| (...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 941 return this.serializedAppStateStr_; | 942 return this.serializedAppStateStr_; |
| 942 } | 943 } |
| 943 }; | 944 }; |
| 944 | 945 |
| 945 // Export | 946 // Export |
| 946 return { | 947 return { |
| 947 NativeInitialSettings: NativeInitialSettings, | 948 NativeInitialSettings: NativeInitialSettings, |
| 948 NativeLayer: NativeLayer | 949 NativeLayer: NativeLayer |
| 949 }; | 950 }; |
| 950 }); | 951 }); |
| OLD | NEW |