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

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

Issue 2617663002: WIP: run clang-format-js on lots of things (Closed)
Patch Set: merge Created 3 years, 11 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 17 matching lines...) Expand all
28 28
29 // Bind global handlers 29 // Bind global handlers
30 global.setInitialSettings = this.onSetInitialSettings_.bind(this); 30 global.setInitialSettings = this.onSetInitialSettings_.bind(this);
31 global.setUseCloudPrint = this.onSetUseCloudPrint_.bind(this); 31 global.setUseCloudPrint = this.onSetUseCloudPrint_.bind(this);
32 global.setPrinters = this.onSetPrinters_.bind(this); 32 global.setPrinters = this.onSetPrinters_.bind(this);
33 global.updateWithPrinterCapabilities = 33 global.updateWithPrinterCapabilities =
34 this.onUpdateWithPrinterCapabilities_.bind(this); 34 this.onUpdateWithPrinterCapabilities_.bind(this);
35 global.failedToGetPrinterCapabilities = 35 global.failedToGetPrinterCapabilities =
36 this.onFailedToGetPrinterCapabilities_.bind(this); 36 this.onFailedToGetPrinterCapabilities_.bind(this);
37 global.failedToGetPrivetPrinterCapabilities = 37 global.failedToGetPrivetPrinterCapabilities =
38 this.onFailedToGetPrivetPrinterCapabilities_.bind(this); 38 this.onFailedToGetPrivetPrinterCapabilities_.bind(this);
39 global.failedToGetExtensionPrinterCapabilities = 39 global.failedToGetExtensionPrinterCapabilities =
40 this.onFailedToGetExtensionPrinterCapabilities_.bind(this); 40 this.onFailedToGetExtensionPrinterCapabilities_.bind(this);
41 global.reloadPrintersList = this.onReloadPrintersList_.bind(this); 41 global.reloadPrintersList = this.onReloadPrintersList_.bind(this);
42 global.printToCloud = this.onPrintToCloud_.bind(this); 42 global.printToCloud = this.onPrintToCloud_.bind(this);
43 global.fileSelectionCancelled = 43 global.fileSelectionCancelled = this.onFileSelectionCancelled_.bind(this);
44 this.onFileSelectionCancelled_.bind(this); 44 global.fileSelectionCompleted = this.onFileSelectionCompleted_.bind(this);
45 global.fileSelectionCompleted =
46 this.onFileSelectionCompleted_.bind(this);
47 global.printPreviewFailed = this.onPrintPreviewFailed_.bind(this); 45 global.printPreviewFailed = this.onPrintPreviewFailed_.bind(this);
48 global.invalidPrinterSettings = 46 global.invalidPrinterSettings = this.onInvalidPrinterSettings_.bind(this);
49 this.onInvalidPrinterSettings_.bind(this);
50 global.onDidGetDefaultPageLayout = 47 global.onDidGetDefaultPageLayout =
51 this.onDidGetDefaultPageLayout_.bind(this); 48 this.onDidGetDefaultPageLayout_.bind(this);
52 global.onDidGetPreviewPageCount = 49 global.onDidGetPreviewPageCount = this.onDidGetPreviewPageCount_.bind(this);
53 this.onDidGetPreviewPageCount_.bind(this);
54 global.onDidPreviewPage = this.onDidPreviewPage_.bind(this); 50 global.onDidPreviewPage = this.onDidPreviewPage_.bind(this);
55 global.updatePrintPreview = this.onUpdatePrintPreview_.bind(this); 51 global.updatePrintPreview = this.onUpdatePrintPreview_.bind(this);
56 global.onDidGetAccessToken = this.onDidGetAccessToken_.bind(this); 52 global.onDidGetAccessToken = this.onDidGetAccessToken_.bind(this);
57 global.autoCancelForTesting = this.autoCancelForTesting_.bind(this); 53 global.autoCancelForTesting = this.autoCancelForTesting_.bind(this);
58 global.onPrivetPrinterChanged = this.onPrivetPrinterChanged_.bind(this); 54 global.onPrivetPrinterChanged = this.onPrivetPrinterChanged_.bind(this);
59 global.onPrivetCapabilitiesSet = 55 global.onPrivetCapabilitiesSet = this.onPrivetCapabilitiesSet_.bind(this);
60 this.onPrivetCapabilitiesSet_.bind(this);
61 global.onPrivetPrintFailed = this.onPrivetPrintFailed_.bind(this); 56 global.onPrivetPrintFailed = this.onPrivetPrintFailed_.bind(this);
62 global.onExtensionPrintersAdded = 57 global.onExtensionPrintersAdded = this.onExtensionPrintersAdded_.bind(this);
63 this.onExtensionPrintersAdded_.bind(this);
64 global.onExtensionCapabilitiesSet = 58 global.onExtensionCapabilitiesSet =
65 this.onExtensionCapabilitiesSet_.bind(this); 59 this.onExtensionCapabilitiesSet_.bind(this);
66 global.onEnableManipulateSettingsForTest = 60 global.onEnableManipulateSettingsForTest =
67 this.onEnableManipulateSettingsForTest_.bind(this); 61 this.onEnableManipulateSettingsForTest_.bind(this);
68 global.printPresetOptionsFromDocument = 62 global.printPresetOptionsFromDocument =
69 this.onPrintPresetOptionsFromDocument_.bind(this); 63 this.onPrintPresetOptionsFromDocument_.bind(this);
70 global.onProvisionalPrinterResolved = 64 global.onProvisionalPrinterResolved =
71 this.onProvisionalDestinationResolved_.bind(this); 65 this.onProvisionalDestinationResolved_.bind(this);
72 global.failedToResolveProvisionalPrinter = 66 global.failedToResolveProvisionalPrinter =
73 this.failedToResolveProvisionalDestination_.bind(this); 67 this.failedToResolveProvisionalDestination_.bind(this);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 'print_preview.NativeLayer.EXTENSION_CAPABILITIES_SET', 105 'print_preview.NativeLayer.EXTENSION_CAPABILITIES_SET',
112 PRINT_PRESET_OPTIONS: 'print_preview.NativeLayer.PRINT_PRESET_OPTIONS', 106 PRINT_PRESET_OPTIONS: 'print_preview.NativeLayer.PRINT_PRESET_OPTIONS',
113 PROVISIONAL_DESTINATION_RESOLVED: 107 PROVISIONAL_DESTINATION_RESOLVED:
114 'print_preview.NativeLayer.PROVISIONAL_DESTINATION_RESOLVED' 108 'print_preview.NativeLayer.PROVISIONAL_DESTINATION_RESOLVED'
115 }; 109 };
116 110
117 /** 111 /**
118 * Constant values matching printing::DuplexMode enum. 112 * Constant values matching printing::DuplexMode enum.
119 * @enum {number} 113 * @enum {number}
120 */ 114 */
121 NativeLayer.DuplexMode = { 115 NativeLayer.DuplexMode = {SIMPLEX: 0, LONG_EDGE: 1, UNKNOWN_DUPLEX_MODE: -1};
122 SIMPLEX: 0,
123 LONG_EDGE: 1,
124 UNKNOWN_DUPLEX_MODE: -1
125 };
126 116
127 /** 117 /**
128 * Enumeration of color modes used by Chromium. 118 * Enumeration of color modes used by Chromium.
129 * @enum {number} 119 * @enum {number}
130 * @private 120 * @private
131 */ 121 */
132 NativeLayer.ColorMode_ = { 122 NativeLayer.ColorMode_ = {GRAY: 1, COLOR: 2};
133 GRAY: 1,
134 COLOR: 2
135 };
136 123
137 /** 124 /**
138 * Version of the serialized state of the print preview. 125 * Version of the serialized state of the print preview.
139 * @type {number} 126 * @type {number}
140 * @const 127 * @const
141 * @private 128 * @private
142 */ 129 */
143 NativeLayer.SERIALIZED_STATE_VERSION_ = 1; 130 NativeLayer.SERIALIZED_STATE_VERSION_ = 1;
144 131
145 NativeLayer.prototype = { 132 NativeLayer.prototype = {
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 * @param {!print_preview.Destination} destination Destination to print to. 222 * @param {!print_preview.Destination} destination Destination to print to.
236 * @param {!print_preview.ticket_items.Color} color Color ticket item. 223 * @param {!print_preview.ticket_items.Color} color Color ticket item.
237 * @return {number} Native layer color model. 224 * @return {number} Native layer color model.
238 * @private 225 * @private
239 */ 226 */
240 getNativeColorModel_: function(destination, color) { 227 getNativeColorModel_: function(destination, color) {
241 // For non-local printers native color model is ignored anyway. 228 // For non-local printers native color model is ignored anyway.
242 var option = destination.isLocal ? color.getSelectedOption() : null; 229 var option = destination.isLocal ? color.getSelectedOption() : null;
243 var nativeColorModel = parseInt(option ? option.vendor_id : null, 10); 230 var nativeColorModel = parseInt(option ? option.vendor_id : null, 10);
244 if (isNaN(nativeColorModel)) { 231 if (isNaN(nativeColorModel)) {
245 return color.getValue() ? 232 return color.getValue() ? NativeLayer.ColorMode_.COLOR :
246 NativeLayer.ColorMode_.COLOR : NativeLayer.ColorMode_.GRAY; 233 NativeLayer.ColorMode_.GRAY;
247 } 234 }
248 return nativeColorModel; 235 return nativeColorModel;
249 }, 236 },
250 237
251 /** 238 /**
252 * Requests that a preview be generated. The following events may be 239 * Requests that a preview be generated. The following events may be
253 * dispatched in response: 240 * dispatched in response:
254 * - PAGE_COUNT_READY 241 * - PAGE_COUNT_READY
255 * - PAGE_LAYOUT_READY 242 * - PAGE_LAYOUT_READY
256 * - PAGE_PREVIEW_READY 243 * - PAGE_PREVIEW_READY
257 * - PREVIEW_GENERATION_DONE 244 * - PREVIEW_GENERATION_DONE
258 * - PREVIEW_GENERATION_FAIL 245 * - PREVIEW_GENERATION_FAIL
259 * @param {print_preview.Destination} destination Destination to print to. 246 * @param {print_preview.Destination} destination Destination to print to.
260 * @param {!print_preview.PrintTicketStore} printTicketStore Used to get the 247 * @param {!print_preview.PrintTicketStore} printTicketStore Used to get the
261 * state of the print ticket. 248 * state of the print ticket.
262 * @param {!print_preview.DocumentInfo} documentInfo Document data model. 249 * @param {!print_preview.DocumentInfo} documentInfo Document data model.
263 * @param {number} requestId ID of the preview request. 250 * @param {number} requestId ID of the preview request.
264 */ 251 */
265 startGetPreview: function( 252 startGetPreview: function(
266 destination, printTicketStore, documentInfo, requestId) { 253 destination, printTicketStore, documentInfo, requestId) {
267 assert(printTicketStore.isTicketValidForPreview(), 254 assert(
268 'Trying to generate preview when ticket is not valid'); 255 printTicketStore.isTicketValidForPreview(),
256 'Trying to generate preview when ticket is not valid');
269 257
270 var ticket = { 258 var ticket = {
271 'pageRange': printTicketStore.pageRange.getDocumentPageRanges(), 259 'pageRange': printTicketStore.pageRange.getDocumentPageRanges(),
272 'mediaSize': printTicketStore.mediaSize.getValue(), 260 'mediaSize': printTicketStore.mediaSize.getValue(),
273 'landscape': printTicketStore.landscape.getValue(), 261 'landscape': printTicketStore.landscape.getValue(),
274 'color': this.getNativeColorModel_(destination, printTicketStore.color), 262 'color': this.getNativeColorModel_(destination, printTicketStore.color),
275 'headerFooterEnabled': printTicketStore.headerFooter.getValue(), 263 'headerFooterEnabled': printTicketStore.headerFooter.getValue(),
276 'marginsType': printTicketStore.marginsType.getValue(), 264 'marginsType': printTicketStore.marginsType.getValue(),
277 'isFirstRequest': requestId == 0, 265 'isFirstRequest': requestId == 0,
278 'requestID': requestId, 266 'requestID': requestId,
279 'previewModifiable': documentInfo.isModifiable, 267 'previewModifiable': documentInfo.isModifiable,
280 'printToPDF': 268 'printToPDF': destination != null &&
281 destination != null &&
282 destination.id == 269 destination.id ==
283 print_preview.Destination.GooglePromotedId.SAVE_AS_PDF, 270 print_preview.Destination.GooglePromotedId.SAVE_AS_PDF,
284 'printWithCloudPrint': destination != null && !destination.isLocal, 271 'printWithCloudPrint': destination != null && !destination.isLocal,
285 'printWithPrivet': destination != null && destination.isPrivet, 272 'printWithPrivet': destination != null && destination.isPrivet,
286 'printWithExtension': destination != null && destination.isExtension, 273 'printWithExtension': destination != null && destination.isExtension,
287 'deviceName': destination == null ? 'foo' : destination.id, 274 'deviceName': destination == null ? 'foo' : destination.id,
288 'generateDraftData': documentInfo.isModifiable, 275 'generateDraftData': documentInfo.isModifiable,
289 'fitToPageEnabled': printTicketStore.fitToPage.getValue(), 276 'fitToPageEnabled': printTicketStore.fitToPage.getValue(),
290 'scaleFactor': printTicketStore.scaling.getValueAsNumber(), 277 'scaleFactor': printTicketStore.scaling.getValueAsNumber(),
291 'rasterizePDF': printTicketStore.rasterize.getValue(), 278 'rasterizePDF': printTicketStore.rasterize.getValue(),
292 // NOTE: Even though the following fields don't directly relate to the 279 // NOTE: Even though the following fields don't directly relate to the
293 // preview, they still need to be included. 280 // preview, they still need to be included.
294 'duplex': printTicketStore.duplex.getValue() ? 281 'duplex': printTicketStore.duplex.getValue() ?
295 NativeLayer.DuplexMode.LONG_EDGE : NativeLayer.DuplexMode.SIMPLEX, 282 NativeLayer.DuplexMode.LONG_EDGE :
283 NativeLayer.DuplexMode.SIMPLEX,
296 'copies': 1, 284 'copies': 1,
297 'collate': true, 285 'collate': true,
298 'shouldPrintBackgrounds': printTicketStore.cssBackground.getValue(), 286 'shouldPrintBackgrounds': printTicketStore.cssBackground.getValue(),
299 'shouldPrintSelectionOnly': printTicketStore.selectionOnly.getValue() 287 'shouldPrintSelectionOnly': printTicketStore.selectionOnly.getValue()
300 }; 288 };
301 289
302 // Set 'cloudPrintID' only if the destination is not local. 290 // Set 'cloudPrintID' only if the destination is not local.
303 if (destination && !destination.isLocal) { 291 if (destination && !destination.isLocal) {
304 ticket['cloudPrintID'] = destination.id; 292 ticket['cloudPrintID'] = destination.id;
305 } 293 }
306 294
307 if (printTicketStore.marginsType.isCapabilityAvailable() && 295 if (printTicketStore.marginsType.isCapabilityAvailable() &&
308 printTicketStore.marginsType.getValue() == 296 printTicketStore.marginsType.getValue() ==
309 print_preview.ticket_items.MarginsType.Value.CUSTOM) { 297 print_preview.ticket_items.MarginsType.Value.CUSTOM) {
310 var customMargins = printTicketStore.customMargins.getValue(); 298 var customMargins = printTicketStore.customMargins.getValue();
311 var orientationEnum = 299 var orientationEnum =
312 print_preview.ticket_items.CustomMargins.Orientation; 300 print_preview.ticket_items.CustomMargins.Orientation;
313 ticket['marginsCustom'] = { 301 ticket['marginsCustom'] = {
314 'marginTop': customMargins.get(orientationEnum.TOP), 302 'marginTop': customMargins.get(orientationEnum.TOP),
315 'marginRight': customMargins.get(orientationEnum.RIGHT), 303 'marginRight': customMargins.get(orientationEnum.RIGHT),
316 'marginBottom': customMargins.get(orientationEnum.BOTTOM), 304 'marginBottom': customMargins.get(orientationEnum.BOTTOM),
317 'marginLeft': customMargins.get(orientationEnum.LEFT) 305 'marginLeft': customMargins.get(orientationEnum.LEFT)
318 }; 306 };
319 } 307 }
320 308
321 chrome.send( 309 chrome.send('getPreview', [
322 'getPreview', 310 JSON.stringify(ticket), requestId > 0 ? documentInfo.pageCount : -1,
323 [JSON.stringify(ticket), 311 documentInfo.isModifiable
324 requestId > 0 ? documentInfo.pageCount : -1, 312 ]);
325 documentInfo.isModifiable]);
326 }, 313 },
327 314
328 /** 315 /**
329 * Requests that the document be printed. 316 * Requests that the document be printed.
330 * @param {!print_preview.Destination} destination Destination to print to. 317 * @param {!print_preview.Destination} destination Destination to print to.
331 * @param {!print_preview.PrintTicketStore} printTicketStore Used to get the 318 * @param {!print_preview.PrintTicketStore} printTicketStore Used to get the
332 * state of the print ticket. 319 * state of the print ticket.
333 * @param {cloudprint.CloudPrintInterface} cloudPrintInterface Interface 320 * @param {cloudprint.CloudPrintInterface} cloudPrintInterface Interface
334 * to Google Cloud Print. 321 * to Google Cloud Print.
335 * @param {!print_preview.DocumentInfo} documentInfo Document data model. 322 * @param {!print_preview.DocumentInfo} documentInfo Document data model.
336 * @param {boolean=} opt_isOpenPdfInPreview Whether to open the PDF in the 323 * @param {boolean=} opt_isOpenPdfInPreview Whether to open the PDF in the
337 * system's preview application. 324 * system's preview application.
338 * @param {boolean=} opt_showSystemDialog Whether to open system dialog for 325 * @param {boolean=} opt_showSystemDialog Whether to open system dialog for
339 * advanced settings. 326 * advanced settings.
340 */ 327 */
341 startPrint: function(destination, printTicketStore, cloudPrintInterface, 328 startPrint: function(
342 documentInfo, opt_isOpenPdfInPreview, 329 destination, printTicketStore, cloudPrintInterface, documentInfo,
343 opt_showSystemDialog) { 330 opt_isOpenPdfInPreview, opt_showSystemDialog) {
344 assert(printTicketStore.isTicketValid(), 331 assert(
345 'Trying to print when ticket is not valid'); 332 printTicketStore.isTicketValid(),
333 'Trying to print when ticket is not valid');
346 334
347 assert(!opt_showSystemDialog || (cr.isWindows && destination.isLocal), 335 assert(
348 'Implemented for Windows only'); 336 !opt_showSystemDialog || (cr.isWindows && destination.isLocal),
337 'Implemented for Windows only');
349 338
350 var ticket = { 339 var ticket = {
351 'pageRange': printTicketStore.pageRange.getDocumentPageRanges(), 340 'pageRange': printTicketStore.pageRange.getDocumentPageRanges(),
352 'mediaSize': printTicketStore.mediaSize.getValue(), 341 'mediaSize': printTicketStore.mediaSize.getValue(),
353 'pageCount': printTicketStore.pageRange.getPageNumberSet().size, 342 'pageCount': printTicketStore.pageRange.getPageNumberSet().size,
354 'landscape': printTicketStore.landscape.getValue(), 343 'landscape': printTicketStore.landscape.getValue(),
355 'color': this.getNativeColorModel_(destination, printTicketStore.color), 344 'color': this.getNativeColorModel_(destination, printTicketStore.color),
356 'headerFooterEnabled': printTicketStore.headerFooter.getValue(), 345 'headerFooterEnabled': printTicketStore.headerFooter.getValue(),
357 'marginsType': printTicketStore.marginsType.getValue(), 346 'marginsType': printTicketStore.marginsType.getValue(),
358 'generateDraftData': true, // TODO(rltoscano): What should this be? 347 'generateDraftData': true, // TODO(rltoscano): What should this be?
359 'duplex': printTicketStore.duplex.getValue() ? 348 'duplex': printTicketStore.duplex.getValue() ?
360 NativeLayer.DuplexMode.LONG_EDGE : NativeLayer.DuplexMode.SIMPLEX, 349 NativeLayer.DuplexMode.LONG_EDGE :
350 NativeLayer.DuplexMode.SIMPLEX,
361 'copies': printTicketStore.copies.getValueAsNumber(), 351 'copies': printTicketStore.copies.getValueAsNumber(),
362 'collate': printTicketStore.collate.getValue(), 352 'collate': printTicketStore.collate.getValue(),
363 'shouldPrintBackgrounds': printTicketStore.cssBackground.getValue(), 353 'shouldPrintBackgrounds': printTicketStore.cssBackground.getValue(),
364 'shouldPrintSelectionOnly': printTicketStore.selectionOnly.getValue(), 354 'shouldPrintSelectionOnly': printTicketStore.selectionOnly.getValue(),
365 'previewModifiable': documentInfo.isModifiable, 355 'previewModifiable': documentInfo.isModifiable,
366 'printToPDF': destination.id == 356 'printToPDF': destination.id ==
367 print_preview.Destination.GooglePromotedId.SAVE_AS_PDF, 357 print_preview.Destination.GooglePromotedId.SAVE_AS_PDF,
368 'printWithCloudPrint': !destination.isLocal, 358 'printWithCloudPrint': !destination.isLocal,
369 'printWithPrivet': destination.isPrivet, 359 'printWithPrivet': destination.isPrivet,
370 'printWithExtension': destination.isExtension, 360 'printWithExtension': destination.isExtension,
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 print_preview.MeasurementSystem.parseNumberFormat( 462 print_preview.MeasurementSystem.parseNumberFormat(
473 initialSettings['numberFormat']); 463 initialSettings['numberFormat']);
474 var unitType = print_preview.MeasurementSystem.UnitType.IMPERIAL; 464 var unitType = print_preview.MeasurementSystem.UnitType.IMPERIAL;
475 if (initialSettings['measurementSystem'] != null) { 465 if (initialSettings['measurementSystem'] != null) {
476 unitType = initialSettings['measurementSystem']; 466 unitType = initialSettings['measurementSystem'];
477 } 467 }
478 468
479 var nativeInitialSettings = new print_preview.NativeInitialSettings( 469 var nativeInitialSettings = new print_preview.NativeInitialSettings(
480 initialSettings['printAutomaticallyInKioskMode'] || false, 470 initialSettings['printAutomaticallyInKioskMode'] || false,
481 initialSettings['appKioskMode'] || false, 471 initialSettings['appKioskMode'] || false,
482 numberFormatSymbols[0] || ',', 472 numberFormatSymbols[0] || ',', numberFormatSymbols[1] || '.',
483 numberFormatSymbols[1] || '.', 473 unitType, initialSettings['previewModifiable'] || false,
484 unitType,
485 initialSettings['previewModifiable'] || false,
486 initialSettings['initiatorTitle'] || '', 474 initialSettings['initiatorTitle'] || '',
487 initialSettings['documentHasSelection'] || false, 475 initialSettings['documentHasSelection'] || false,
488 initialSettings['shouldPrintSelectionOnly'] || false, 476 initialSettings['shouldPrintSelectionOnly'] || false,
489 initialSettings['printerName'] || null, 477 initialSettings['printerName'] || null,
490 initialSettings['appState'] || null, 478 initialSettings['appState'] || null,
491 initialSettings['defaultDestinationSelectionRules'] || null); 479 initialSettings['defaultDestinationSelectionRules'] || null);
492 480
493 var initialSettingsSetEvent = new Event( 481 var initialSettingsSetEvent =
494 NativeLayer.EventType.INITIAL_SETTINGS_SET); 482 new Event(NativeLayer.EventType.INITIAL_SETTINGS_SET);
495 initialSettingsSetEvent.initialSettings = nativeInitialSettings; 483 initialSettingsSetEvent.initialSettings = nativeInitialSettings;
496 this.dispatchEvent(initialSettingsSetEvent); 484 this.dispatchEvent(initialSettingsSetEvent);
497 }, 485 },
498 486
499 /** 487 /**
500 * Turn on the integration of Cloud Print. 488 * Turn on the integration of Cloud Print.
501 * @param {{cloudPrintURL: string, appKioskMode: string}} settings 489 * @param {{cloudPrintURL: string, appKioskMode: string}} settings
502 * cloudPrintUrl: The URL to use for cloud print servers. 490 * cloudPrintUrl: The URL to use for cloud print servers.
503 * @private 491 * @private
504 */ 492 */
505 onSetUseCloudPrint_: function(settings) { 493 onSetUseCloudPrint_: function(settings) {
506 var cloudPrintEnableEvent = new Event( 494 var cloudPrintEnableEvent =
507 NativeLayer.EventType.CLOUD_PRINT_ENABLE); 495 new Event(NativeLayer.EventType.CLOUD_PRINT_ENABLE);
508 cloudPrintEnableEvent.baseCloudPrintUrl = settings['cloudPrintUrl'] || ''; 496 cloudPrintEnableEvent.baseCloudPrintUrl = settings['cloudPrintUrl'] || '';
509 cloudPrintEnableEvent.appKioskMode = settings['appKioskMode'] || false; 497 cloudPrintEnableEvent.appKioskMode = settings['appKioskMode'] || false;
510 this.dispatchEvent(cloudPrintEnableEvent); 498 this.dispatchEvent(cloudPrintEnableEvent);
511 }, 499 },
512 500
513 /** 501 /**
514 * Updates the print preview with local printers. 502 * Updates the print preview with local printers.
515 * Called from PrintPreviewHandler::SetupPrinterList(). 503 * Called from PrintPreviewHandler::SetupPrinterList().
516 * @param {Array} printers Array of printer info objects. 504 * @param {Array} printers Array of printer info objects.
517 * @private 505 * @private
518 */ 506 */
519 onSetPrinters_: function(printers) { 507 onSetPrinters_: function(printers) {
520 var localDestsSetEvent = new Event( 508 var localDestsSetEvent =
521 NativeLayer.EventType.LOCAL_DESTINATIONS_SET); 509 new Event(NativeLayer.EventType.LOCAL_DESTINATIONS_SET);
522 localDestsSetEvent.destinationInfos = printers; 510 localDestsSetEvent.destinationInfos = printers;
523 this.dispatchEvent(localDestsSetEvent); 511 this.dispatchEvent(localDestsSetEvent);
524 }, 512 },
525 513
526 /** 514 /**
527 * Called when native layer gets settings information for a requested local 515 * Called when native layer gets settings information for a requested local
528 * destination. 516 * destination.
529 * @param {Object} settingsInfo printer setting information. 517 * @param {Object} settingsInfo printer setting information.
530 * @private 518 * @private
531 */ 519 */
532 onUpdateWithPrinterCapabilities_: function(settingsInfo) { 520 onUpdateWithPrinterCapabilities_: function(settingsInfo) {
533 var capsSetEvent = new Event(NativeLayer.EventType.CAPABILITIES_SET); 521 var capsSetEvent = new Event(NativeLayer.EventType.CAPABILITIES_SET);
534 capsSetEvent.settingsInfo = settingsInfo; 522 capsSetEvent.settingsInfo = settingsInfo;
535 this.dispatchEvent(capsSetEvent); 523 this.dispatchEvent(capsSetEvent);
536 }, 524 },
537 525
538 /** 526 /**
539 * Called when native layer gets settings information for a requested local 527 * Called when native layer gets settings information for a requested local
540 * destination. 528 * destination.
541 * @param {string} destinationId Printer affected by error. 529 * @param {string} destinationId Printer affected by error.
542 * @private 530 * @private
543 */ 531 */
544 onFailedToGetPrinterCapabilities_: function(destinationId) { 532 onFailedToGetPrinterCapabilities_: function(destinationId) {
545 var getCapsFailEvent = new Event( 533 var getCapsFailEvent =
546 NativeLayer.EventType.GET_CAPABILITIES_FAIL); 534 new Event(NativeLayer.EventType.GET_CAPABILITIES_FAIL);
547 getCapsFailEvent.destinationId = destinationId; 535 getCapsFailEvent.destinationId = destinationId;
548 getCapsFailEvent.destinationOrigin = 536 getCapsFailEvent.destinationOrigin =
549 print_preview.Destination.Origin.LOCAL; 537 print_preview.Destination.Origin.LOCAL;
550 this.dispatchEvent(getCapsFailEvent); 538 this.dispatchEvent(getCapsFailEvent);
551 }, 539 },
552 540
553 /** 541 /**
554 * Called when native layer gets settings information for a requested privet 542 * Called when native layer gets settings information for a requested privet
555 * destination. 543 * destination.
556 * @param {string} destinationId Printer affected by error. 544 * @param {string} destinationId Printer affected by error.
557 * @private 545 * @private
558 */ 546 */
559 onFailedToGetPrivetPrinterCapabilities_: function(destinationId) { 547 onFailedToGetPrivetPrinterCapabilities_: function(destinationId) {
560 var getCapsFailEvent = new Event( 548 var getCapsFailEvent =
561 NativeLayer.EventType.GET_CAPABILITIES_FAIL); 549 new Event(NativeLayer.EventType.GET_CAPABILITIES_FAIL);
562 getCapsFailEvent.destinationId = destinationId; 550 getCapsFailEvent.destinationId = destinationId;
563 getCapsFailEvent.destinationOrigin = 551 getCapsFailEvent.destinationOrigin =
564 print_preview.Destination.Origin.PRIVET; 552 print_preview.Destination.Origin.PRIVET;
565 this.dispatchEvent(getCapsFailEvent); 553 this.dispatchEvent(getCapsFailEvent);
566 }, 554 },
567 555
568 /** 556 /**
569 * Called when native layer fails to get settings information for a 557 * Called when native layer fails to get settings information for a
570 * requested extension destination. 558 * requested extension destination.
571 * @param {string} destinationId Printer affected by error. 559 * @param {string} destinationId Printer affected by error.
572 * @private 560 * @private
573 */ 561 */
574 onFailedToGetExtensionPrinterCapabilities_: function(destinationId) { 562 onFailedToGetExtensionPrinterCapabilities_: function(destinationId) {
575 var getCapsFailEvent = new Event( 563 var getCapsFailEvent =
576 NativeLayer.EventType.GET_CAPABILITIES_FAIL); 564 new Event(NativeLayer.EventType.GET_CAPABILITIES_FAIL);
577 getCapsFailEvent.destinationId = destinationId; 565 getCapsFailEvent.destinationId = destinationId;
578 getCapsFailEvent.destinationOrigin = 566 getCapsFailEvent.destinationOrigin =
579 print_preview.Destination.Origin.EXTENSION; 567 print_preview.Destination.Origin.EXTENSION;
580 this.dispatchEvent(getCapsFailEvent); 568 this.dispatchEvent(getCapsFailEvent);
581 }, 569 },
582 570
583 /** Reloads the printer list. */ 571 /** Reloads the printer list. */
584 onReloadPrintersList_: function() { 572 onReloadPrintersList_: function() {
585 cr.dispatchSimpleEvent(this, NativeLayer.EventType.DESTINATIONS_RELOAD); 573 cr.dispatchSimpleEvent(this, NativeLayer.EventType.DESTINATIONS_RELOAD);
586 }, 574 },
587 575
588 /** 576 /**
589 * Called from the C++ layer. 577 * Called from the C++ layer.
590 * Take the PDF data handed to us and submit it to the cloud, closing the 578 * Take the PDF data handed to us and submit it to the cloud, closing the
591 * print preview dialog once the upload is successful. 579 * print preview dialog once the upload is successful.
592 * @param {string} data Data to send as the print job. 580 * @param {string} data Data to send as the print job.
593 * @private 581 * @private
594 */ 582 */
595 onPrintToCloud_: function(data) { 583 onPrintToCloud_: function(data) {
596 var printToCloudEvent = new Event( 584 var printToCloudEvent = new Event(NativeLayer.EventType.PRINT_TO_CLOUD);
597 NativeLayer.EventType.PRINT_TO_CLOUD);
598 printToCloudEvent.data = data; 585 printToCloudEvent.data = data;
599 this.dispatchEvent(printToCloudEvent); 586 this.dispatchEvent(printToCloudEvent);
600 }, 587 },
601 588
602 /** 589 /**
603 * Called from PrintPreviewUI::OnFileSelectionCancelled to notify the print 590 * Called from PrintPreviewUI::OnFileSelectionCancelled to notify the print
604 * preview dialog regarding the file selection cancel event. 591 * preview dialog regarding the file selection cancel event.
605 * @private 592 * @private
606 */ 593 */
607 onFileSelectionCancelled_: function() { 594 onFileSelectionCancelled_: function() {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
643 * @param {{contentWidth: number, contentHeight: number, marginLeft: number, 630 * @param {{contentWidth: number, contentHeight: number, marginLeft: number,
644 * marginRight: number, marginTop: number, marginBottom: number, 631 * marginRight: number, marginTop: number, marginBottom: number,
645 * printableAreaX: number, printableAreaY: number, 632 * printableAreaX: number, printableAreaY: number,
646 * printableAreaWidth: number, printableAreaHeight: number}} 633 * printableAreaWidth: number, printableAreaHeight: number}}
647 * pageLayout Specifies default page layout details in points. 634 * pageLayout Specifies default page layout details in points.
648 * @param {boolean} hasCustomPageSizeStyle Indicates whether the previewed 635 * @param {boolean} hasCustomPageSizeStyle Indicates whether the previewed
649 * document has a custom page size style. 636 * document has a custom page size style.
650 * @private 637 * @private
651 */ 638 */
652 onDidGetDefaultPageLayout_: function(pageLayout, hasCustomPageSizeStyle) { 639 onDidGetDefaultPageLayout_: function(pageLayout, hasCustomPageSizeStyle) {
653 var pageLayoutChangeEvent = new Event( 640 var pageLayoutChangeEvent =
654 NativeLayer.EventType.PAGE_LAYOUT_READY); 641 new Event(NativeLayer.EventType.PAGE_LAYOUT_READY);
655 pageLayoutChangeEvent.pageLayout = pageLayout; 642 pageLayoutChangeEvent.pageLayout = pageLayout;
656 pageLayoutChangeEvent.hasCustomPageSizeStyle = hasCustomPageSizeStyle; 643 pageLayoutChangeEvent.hasCustomPageSizeStyle = hasCustomPageSizeStyle;
657 this.dispatchEvent(pageLayoutChangeEvent); 644 this.dispatchEvent(pageLayoutChangeEvent);
658 }, 645 },
659 646
660 /** 647 /**
661 * Update the page count and check the page range. 648 * Update the page count and check the page range.
662 * Called from PrintPreviewUI::OnDidGetPreviewPageCount(). 649 * Called from PrintPreviewUI::OnDidGetPreviewPageCount().
663 * @param {number} pageCount The number of pages. 650 * @param {number} pageCount The number of pages.
664 * @param {number} previewResponseId The preview request id that resulted in 651 * @param {number} previewResponseId The preview request id that resulted in
665 * this response. 652 * this response.
666 * @param {number} fitToPageScaling The scaling percentage required to fit 653 * @param {number} fitToPageScaling The scaling percentage required to fit
667 * the document to page, rounded to the nearest integer. 654 * the document to page, rounded to the nearest integer.
668 * @private 655 * @private
669 */ 656 */
670 onDidGetPreviewPageCount_: function(pageCount, previewResponseId, 657 onDidGetPreviewPageCount_: function(
671 fitToPageScaling) { 658 pageCount, previewResponseId, fitToPageScaling) {
672 var pageCountChangeEvent = new Event( 659 var pageCountChangeEvent =
673 NativeLayer.EventType.PAGE_COUNT_READY); 660 new Event(NativeLayer.EventType.PAGE_COUNT_READY);
674 pageCountChangeEvent.pageCount = pageCount; 661 pageCountChangeEvent.pageCount = pageCount;
675 pageCountChangeEvent.previewResponseId = previewResponseId; 662 pageCountChangeEvent.previewResponseId = previewResponseId;
676 pageCountChangeEvent.fitToPageScaling = fitToPageScaling; 663 pageCountChangeEvent.fitToPageScaling = fitToPageScaling;
677 this.dispatchEvent(pageCountChangeEvent); 664 this.dispatchEvent(pageCountChangeEvent);
678 }, 665 },
679 666
680 /** 667 /**
681 * Notification that a print preview page has been rendered. 668 * Notification that a print preview page has been rendered.
682 * Check if the settings have changed and request a regeneration if needed. 669 * Check if the settings have changed and request a regeneration if needed.
683 * Called from PrintPreviewUI::OnDidPreviewPage(). 670 * Called from PrintPreviewUI::OnDidPreviewPage().
684 * @param {number} pageNumber The page number, 0-based. 671 * @param {number} pageNumber The page number, 0-based.
685 * @param {number} previewUid Preview unique identifier. 672 * @param {number} previewUid Preview unique identifier.
686 * @param {number} previewResponseId The preview request id that resulted in 673 * @param {number} previewResponseId The preview request id that resulted in
687 * this response. 674 * this response.
688 * @private 675 * @private
689 */ 676 */
690 onDidPreviewPage_: function(pageNumber, previewUid, previewResponseId) { 677 onDidPreviewPage_: function(pageNumber, previewUid, previewResponseId) {
691 var pagePreviewGenEvent = new Event( 678 var pagePreviewGenEvent =
692 NativeLayer.EventType.PAGE_PREVIEW_READY); 679 new Event(NativeLayer.EventType.PAGE_PREVIEW_READY);
693 pagePreviewGenEvent.pageIndex = pageNumber; 680 pagePreviewGenEvent.pageIndex = pageNumber;
694 pagePreviewGenEvent.previewUid = previewUid; 681 pagePreviewGenEvent.previewUid = previewUid;
695 pagePreviewGenEvent.previewResponseId = previewResponseId; 682 pagePreviewGenEvent.previewResponseId = previewResponseId;
696 this.dispatchEvent(pagePreviewGenEvent); 683 this.dispatchEvent(pagePreviewGenEvent);
697 }, 684 },
698 685
699 /** 686 /**
700 * Notification that access token is ready. 687 * Notification that access token is ready.
701 * @param {string} authType Type of access token. 688 * @param {string} authType Type of access token.
702 * @param {string} accessToken Access token. 689 * @param {string} accessToken Access token.
703 * @private 690 * @private
704 */ 691 */
705 onDidGetAccessToken_: function(authType, accessToken) { 692 onDidGetAccessToken_: function(authType, accessToken) {
706 var getAccessTokenEvent = new Event( 693 var getAccessTokenEvent =
707 NativeLayer.EventType.ACCESS_TOKEN_READY); 694 new Event(NativeLayer.EventType.ACCESS_TOKEN_READY);
708 getAccessTokenEvent.authType = authType; 695 getAccessTokenEvent.authType = authType;
709 getAccessTokenEvent.accessToken = accessToken; 696 getAccessTokenEvent.accessToken = accessToken;
710 this.dispatchEvent(getAccessTokenEvent); 697 this.dispatchEvent(getAccessTokenEvent);
711 }, 698 },
712 699
713 /** 700 /**
714 * Update the print preview when new preview data is available. 701 * Update the print preview when new preview data is available.
715 * Create the PDF plugin as needed. 702 * Create the PDF plugin as needed.
716 * Called from PrintPreviewUI::PreviewDataIsAvailable(). 703 * Called from PrintPreviewUI::PreviewDataIsAvailable().
717 * @param {number} previewUid Preview unique identifier. 704 * @param {number} previewUid Preview unique identifier.
718 * @param {number} previewResponseId The preview request id that resulted in 705 * @param {number} previewResponseId The preview request id that resulted in
719 * this response. 706 * this response.
720 * @private 707 * @private
721 */ 708 */
722 onUpdatePrintPreview_: function(previewUid, previewResponseId) { 709 onUpdatePrintPreview_: function(previewUid, previewResponseId) {
723 var previewGenDoneEvent = new Event( 710 var previewGenDoneEvent =
724 NativeLayer.EventType.PREVIEW_GENERATION_DONE); 711 new Event(NativeLayer.EventType.PREVIEW_GENERATION_DONE);
725 previewGenDoneEvent.previewUid = previewUid; 712 previewGenDoneEvent.previewUid = previewUid;
726 previewGenDoneEvent.previewResponseId = previewResponseId; 713 previewGenDoneEvent.previewResponseId = previewResponseId;
727 this.dispatchEvent(previewGenDoneEvent); 714 this.dispatchEvent(previewGenDoneEvent);
728 }, 715 },
729 716
730 /** 717 /**
731 * Updates print preset options from source PDF document. 718 * Updates print preset options from source PDF document.
732 * Called from PrintPreviewUI::OnSetOptionsFromDocument(). 719 * Called from PrintPreviewUI::OnSetOptionsFromDocument().
733 * @param {{disableScaling: boolean, copies: number, 720 * @param {{disableScaling: boolean, copies: number,
734 * duplex: number}} options Specifies 721 * duplex: number}} options Specifies
735 * printing options according to source document presets. 722 * printing options according to source document presets.
736 * @private 723 * @private
737 */ 724 */
738 onPrintPresetOptionsFromDocument_: function(options) { 725 onPrintPresetOptionsFromDocument_: function(options) {
739 var printPresetOptionsEvent = new Event( 726 var printPresetOptionsEvent =
740 NativeLayer.EventType.PRINT_PRESET_OPTIONS); 727 new Event(NativeLayer.EventType.PRINT_PRESET_OPTIONS);
741 printPresetOptionsEvent.optionsFromDocument = options; 728 printPresetOptionsEvent.optionsFromDocument = options;
742 this.dispatchEvent(printPresetOptionsEvent); 729 this.dispatchEvent(printPresetOptionsEvent);
743 }, 730 },
744 731
745 /** 732 /**
746 * Simulates a user click on the print preview dialog cancel button. Used 733 * Simulates a user click on the print preview dialog cancel button. Used
747 * only for testing. 734 * only for testing.
748 * @private 735 * @private
749 */ 736 */
750 autoCancelForTesting_: function() { 737 autoCancelForTesting_: function() {
751 var properties = {view: window, bubbles: true, cancelable: true}; 738 var properties = {view: window, bubbles: true, cancelable: true};
752 var click = new MouseEvent('click', properties); 739 var click = new MouseEvent('click', properties);
753 document.querySelector('#print-header .cancel').dispatchEvent(click); 740 document.querySelector('#print-header .cancel').dispatchEvent(click);
754 }, 741 },
755 742
756 /** 743 /**
757 * @param {{serviceName: string, name: string}} printer Specifies 744 * @param {{serviceName: string, name: string}} printer Specifies
758 * information about the printer that was added. 745 * information about the printer that was added.
759 * @private 746 * @private
760 */ 747 */
761 onPrivetPrinterChanged_: function(printer) { 748 onPrivetPrinterChanged_: function(printer) {
762 var privetPrinterChangedEvent = 749 var privetPrinterChangedEvent =
763 new Event(NativeLayer.EventType.PRIVET_PRINTER_CHANGED); 750 new Event(NativeLayer.EventType.PRIVET_PRINTER_CHANGED);
764 privetPrinterChangedEvent.printer = printer; 751 privetPrinterChangedEvent.printer = printer;
765 this.dispatchEvent(privetPrinterChangedEvent); 752 this.dispatchEvent(privetPrinterChangedEvent);
766 }, 753 },
767 754
768 /** 755 /**
769 * @param {Object} printer Specifies information about the printer that was 756 * @param {Object} printer Specifies information about the printer that was
770 * added. 757 * added.
771 * @private 758 * @private
772 */ 759 */
773 onPrivetCapabilitiesSet_: function(printer, capabilities) { 760 onPrivetCapabilitiesSet_: function(printer, capabilities) {
774 var privetCapabilitiesSetEvent = 761 var privetCapabilitiesSetEvent =
775 new Event(NativeLayer.EventType.PRIVET_CAPABILITIES_SET); 762 new Event(NativeLayer.EventType.PRIVET_CAPABILITIES_SET);
776 privetCapabilitiesSetEvent.printer = printer; 763 privetCapabilitiesSetEvent.printer = printer;
777 privetCapabilitiesSetEvent.capabilities = capabilities; 764 privetCapabilitiesSetEvent.capabilities = capabilities;
778 this.dispatchEvent(privetCapabilitiesSetEvent); 765 this.dispatchEvent(privetCapabilitiesSetEvent);
779 }, 766 },
780 767
781 /** 768 /**
782 * @param {string} http_error The HTTP response code or -1 if not an HTTP 769 * @param {string} http_error The HTTP response code or -1 if not an HTTP
783 * error. 770 * error.
784 * @private 771 * @private
785 */ 772 */
786 onPrivetPrintFailed_: function(http_error) { 773 onPrivetPrintFailed_: function(http_error) {
787 var privetPrintFailedEvent = 774 var privetPrintFailedEvent =
788 new Event(NativeLayer.EventType.PRIVET_PRINT_FAILED); 775 new Event(NativeLayer.EventType.PRIVET_PRINT_FAILED);
789 privetPrintFailedEvent.httpError = http_error; 776 privetPrintFailedEvent.httpError = http_error;
790 this.dispatchEvent(privetPrintFailedEvent); 777 this.dispatchEvent(privetPrintFailedEvent);
791 }, 778 },
792 779
793 /** 780 /**
794 * @param {Array<!{extensionId: string, 781 * @param {Array<!{extensionId: string,
795 * extensionName: string, 782 * extensionName: string,
796 * id: string, 783 * id: string,
797 * name: string, 784 * name: string,
798 * description: (string|undefined), 785 * description: (string|undefined),
799 * provisional: (boolean|undefined)}>} printers The list 786 * provisional: (boolean|undefined)}>} printers The list
800 * containing information about printers added by an extension. 787 * containing information about printers added by an extension.
801 * @param {boolean} done Whether this is the final list of extension 788 * @param {boolean} done Whether this is the final list of extension
802 * managed printers. 789 * managed printers.
803 */ 790 */
804 onExtensionPrintersAdded_: function(printers, done) { 791 onExtensionPrintersAdded_: function(printers, done) {
805 var event = new Event(NativeLayer.EventType.EXTENSION_PRINTERS_ADDED); 792 var event = new Event(NativeLayer.EventType.EXTENSION_PRINTERS_ADDED);
806 event.printers = printers; 793 event.printers = printers;
807 event.done = done; 794 event.done = done;
808 this.dispatchEvent(event); 795 this.dispatchEvent(event);
809 }, 796 },
810 797
811 /** 798 /**
812 * Called when an extension responds to a request for an extension printer 799 * Called when an extension responds to a request for an extension printer
813 * capabilities. 800 * capabilities.
814 * @param {string} printerId The printer's ID. 801 * @param {string} printerId The printer's ID.
815 * @param {!Object} capabilities The reported printer capabilities. 802 * @param {!Object} capabilities The reported printer capabilities.
816 */ 803 */
817 onExtensionCapabilitiesSet_: function(printerId, 804 onExtensionCapabilitiesSet_: function(printerId, capabilities) {
818 capabilities) {
819 var event = new Event(NativeLayer.EventType.EXTENSION_CAPABILITIES_SET); 805 var event = new Event(NativeLayer.EventType.EXTENSION_CAPABILITIES_SET);
820 event.printerId = printerId; 806 event.printerId = printerId;
821 event.capabilities = capabilities; 807 event.capabilities = capabilities;
822 this.dispatchEvent(event); 808 this.dispatchEvent(event);
823 }, 809 },
824 810
825 /** 811 /**
826 * Called when Chrome reports that attempt to resolve a provisional 812 * Called when Chrome reports that attempt to resolve a provisional
827 * destination failed. 813 * destination failed.
828 * @param {string} destinationId The provisional destination ID. 814 * @param {string} destinationId The provisional destination ID.
829 * @private 815 * @private
830 */ 816 */
831 failedToResolveProvisionalDestination_: function(destinationId) { 817 failedToResolveProvisionalDestination_: function(destinationId) {
832 var evt = new Event( 818 var evt =
833 NativeLayer.EventType.PROVISIONAL_DESTINATION_RESOLVED); 819 new Event(NativeLayer.EventType.PROVISIONAL_DESTINATION_RESOLVED);
834 evt.provisionalId = destinationId; 820 evt.provisionalId = destinationId;
835 evt.destination = null; 821 evt.destination = null;
836 this.dispatchEvent(evt); 822 this.dispatchEvent(evt);
837 }, 823 },
838 824
839 /** 825 /**
840 * Called when Chrome reports that a provisional destination has been 826 * Called when Chrome reports that a provisional destination has been
841 * successfully resolved. 827 * successfully resolved.
842 * Currently used only for extension provided destinations. 828 * Currently used only for extension provided destinations.
843 * @param {string} provisionalDestinationId The provisional destination id. 829 * @param {string} provisionalDestinationId The provisional destination id.
844 * @param {!{extensionId: string, 830 * @param {!{extensionId: string,
845 * extensionName: string, 831 * extensionName: string,
846 * id: string, 832 * id: string,
847 * name: string, 833 * name: string,
848 * description: (string|undefined)}} destinationInfo The resolved 834 * description: (string|undefined)}} destinationInfo The resolved
849 * destination info. 835 * destination info.
850 * @private 836 * @private
851 */ 837 */
852 onProvisionalDestinationResolved_: function(provisionalDestinationId, 838 onProvisionalDestinationResolved_: function(
853 destinationInfo) { 839 provisionalDestinationId, destinationInfo) {
854 var evt = new Event( 840 var evt =
855 NativeLayer.EventType.PROVISIONAL_DESTINATION_RESOLVED); 841 new Event(NativeLayer.EventType.PROVISIONAL_DESTINATION_RESOLVED);
856 evt.provisionalId = provisionalDestinationId; 842 evt.provisionalId = provisionalDestinationId;
857 evt.destination = destinationInfo; 843 evt.destination = destinationInfo;
858 this.dispatchEvent(evt); 844 this.dispatchEvent(evt);
859 }, 845 },
860 846
861 /** 847 /**
862 * Allows for onManipulateSettings to be called 848 * Allows for onManipulateSettings to be called
863 * from the native layer. 849 * from the native layer.
864 * @private 850 * @private
865 */ 851 */
866 onEnableManipulateSettingsForTest_: function() { 852 onEnableManipulateSettingsForTest_: function() {
867 global.onManipulateSettingsForTest = 853 global.onManipulateSettingsForTest =
868 this.onManipulateSettingsForTest_.bind(this); 854 this.onManipulateSettingsForTest_.bind(this);
869 }, 855 },
870 856
871 /** 857 /**
872 * Dispatches an event to print_preview.js to change 858 * Dispatches an event to print_preview.js to change
873 * a particular setting for print preview. 859 * a particular setting for print preview.
874 * @param {!print_preview.PreviewSettings} settings Object containing the 860 * @param {!print_preview.PreviewSettings} settings Object containing the
875 * value to be changed and that value should be set to. 861 * value to be changed and that value should be set to.
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
920 * @param {boolean} selectionOnly Whether only selected content should be 906 * @param {boolean} selectionOnly Whether only selected content should be
921 * printed. 907 * printed.
922 * @param {?string} systemDefaultDestinationId ID of the system default 908 * @param {?string} systemDefaultDestinationId ID of the system default
923 * destination. 909 * destination.
924 * @param {?string} serializedAppStateStr Serialized app state. 910 * @param {?string} serializedAppStateStr Serialized app state.
925 * @param {?string} serializedDefaultDestinationSelectionRulesStr Serialized 911 * @param {?string} serializedDefaultDestinationSelectionRulesStr Serialized
926 * default destination selection rules. 912 * default destination selection rules.
927 * @constructor 913 * @constructor
928 */ 914 */
929 function NativeInitialSettings( 915 function NativeInitialSettings(
930 isInKioskAutoPrintMode, 916 isInKioskAutoPrintMode, isInAppKioskMode, thousandsDelimeter,
931 isInAppKioskMode, 917 decimalDelimeter, unitType, isDocumentModifiable, documentTitle,
932 thousandsDelimeter, 918 documentHasSelection, selectionOnly, systemDefaultDestinationId,
933 decimalDelimeter, 919 serializedAppStateStr, serializedDefaultDestinationSelectionRulesStr) {
934 unitType,
935 isDocumentModifiable,
936 documentTitle,
937 documentHasSelection,
938 selectionOnly,
939 systemDefaultDestinationId,
940 serializedAppStateStr,
941 serializedDefaultDestinationSelectionRulesStr) {
942
943 /** 920 /**
944 * Whether the print preview should be in auto-print mode. 921 * Whether the print preview should be in auto-print mode.
945 * @type {boolean} 922 * @type {boolean}
946 * @private 923 * @private
947 */ 924 */
948 this.isInKioskAutoPrintMode_ = isInKioskAutoPrintMode; 925 this.isInKioskAutoPrintMode_ = isInKioskAutoPrintMode;
949 926
950 /** 927 /**
951 * Whether the print preview should switch to App Kiosk mode. 928 * Whether the print preview should switch to App Kiosk mode.
952 * @type {boolean} 929 * @type {boolean}
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
1095 return this.serializedDefaultDestinationSelectionRulesStr_; 1072 return this.serializedDefaultDestinationSelectionRulesStr_;
1096 } 1073 }
1097 }; 1074 };
1098 1075
1099 // Export 1076 // Export
1100 return { 1077 return {
1101 NativeInitialSettings: NativeInitialSettings, 1078 NativeInitialSettings: NativeInitialSettings,
1102 NativeLayer: NativeLayer 1079 NativeLayer: NativeLayer
1103 }; 1080 };
1104 }); 1081 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/print_preview/metrics.js ('k') | chrome/browser/resources/print_preview/preview_generator.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698