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 * A data store that stores destinations and dispatches events when the data | 9 * A data store that stores destinations and dispatches events when the data |
10 * store changes. | 10 * store changes. |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 CACHED_SELECTED_DESTINATION_INFO_READY: | 301 CACHED_SELECTED_DESTINATION_INFO_READY: |
302 'print_preview.DestinationStore.CACHED_SELECTED_DESTINATION_INFO_READY', | 302 'print_preview.DestinationStore.CACHED_SELECTED_DESTINATION_INFO_READY', |
303 SELECTED_DESTINATION_CAPABILITIES_READY: | 303 SELECTED_DESTINATION_CAPABILITIES_READY: |
304 'print_preview.DestinationStore.SELECTED_DESTINATION_CAPABILITIES_READY' | 304 'print_preview.DestinationStore.SELECTED_DESTINATION_CAPABILITIES_READY' |
305 }; | 305 }; |
306 | 306 |
307 /** | 307 /** |
308 * Delay in milliseconds before the destination store ignores the initial | 308 * Delay in milliseconds before the destination store ignores the initial |
309 * destination ID and just selects any printer (since the initial destination | 309 * destination ID and just selects any printer (since the initial destination |
310 * was not found). | 310 * was not found). |
311 * @type {number} | 311 * @private {number} |
312 * @const | 312 * @const |
313 * @private | |
314 */ | 313 */ |
315 DestinationStore.AUTO_SELECT_TIMEOUT_ = 15000; | 314 DestinationStore.AUTO_SELECT_TIMEOUT_ = 15000; |
316 | 315 |
317 /** | 316 /** |
318 * Amount of time spent searching for privet destination, in milliseconds. | 317 * Amount of time spent searching for privet destination, in milliseconds. |
319 * @type {number} | 318 * @private {number} |
320 * @const | 319 * @const |
321 * @private | |
322 */ | 320 */ |
323 DestinationStore.PRIVET_SEARCH_DURATION_ = 5000; | 321 DestinationStore.PRIVET_SEARCH_DURATION_ = 5000; |
324 | 322 |
325 /** | 323 /** |
326 * Maximum amount of time spent searching for extension destinations, in | 324 * Maximum amount of time spent searching for extension destinations, in |
327 * milliseconds. | 325 * milliseconds. |
328 * @type {number} | 326 * @private {number} |
329 * @const | 327 * @const |
330 * @private | |
331 */ | 328 */ |
332 DestinationStore.EXTENSION_SEARCH_DURATION_ = 5000; | 329 DestinationStore.EXTENSION_SEARCH_DURATION_ = 5000; |
333 | 330 |
334 /** | 331 /** |
| 332 * Human readable names for media sizes in the cloud print CDD. |
| 333 * https://developers.google.com/cloud-print/docs/cdd |
| 334 * @private {Object<string>} |
| 335 * @const |
| 336 */ |
| 337 DestinationStore.MEDIA_DISPLAY_NAMES_ = { |
| 338 'ISO_2A0': '2A0', |
| 339 'ISO_A0': 'A0', |
| 340 'ISO_A0X3': 'A0x3', |
| 341 'ISO_A1': 'A1', |
| 342 'ISO_A10': 'A10', |
| 343 'ISO_A1X3': 'A1x3', |
| 344 'ISO_A1X4': 'A1x4', |
| 345 'ISO_A2': 'A2', |
| 346 'ISO_A2X3': 'A2x3', |
| 347 'ISO_A2X4': 'A2x4', |
| 348 'ISO_A2X5': 'A2x5', |
| 349 'ISO_A3': 'A3', |
| 350 'ISO_A3X3': 'A3x3', |
| 351 'ISO_A3X4': 'A3x4', |
| 352 'ISO_A3X5': 'A3x5', |
| 353 'ISO_A3X6': 'A3x6', |
| 354 'ISO_A3X7': 'A3x7', |
| 355 'ISO_A3_EXTRA': 'A3 Extra', |
| 356 'ISO_A4': 'A4', |
| 357 'ISO_A4X3': 'A4x3', |
| 358 'ISO_A4X4': 'A4x4', |
| 359 'ISO_A4X5': 'A4x5', |
| 360 'ISO_A4X6': 'A4x6', |
| 361 'ISO_A4X7': 'A4x7', |
| 362 'ISO_A4X8': 'A4x8', |
| 363 'ISO_A4X9': 'A4x9', |
| 364 'ISO_A4_EXTRA': 'A4 Extra', |
| 365 'ISO_A4_TAB': 'A4 Tab', |
| 366 'ISO_A5': 'A5', |
| 367 'ISO_A5_EXTRA': 'A5 Extra', |
| 368 'ISO_A6': 'A6', |
| 369 'ISO_A7': 'A7', |
| 370 'ISO_A8': 'A8', |
| 371 'ISO_A9': 'A9', |
| 372 'ISO_B0': 'B0', |
| 373 'ISO_B1': 'B1', |
| 374 'ISO_B10': 'B10', |
| 375 'ISO_B2': 'B2', |
| 376 'ISO_B3': 'B3', |
| 377 'ISO_B4': 'B4', |
| 378 'ISO_B5': 'B5', |
| 379 'ISO_B5_EXTRA': 'B5 Extra', |
| 380 'ISO_B6': 'B6', |
| 381 'ISO_B6C4': 'B6C4', |
| 382 'ISO_B7': 'B7', |
| 383 'ISO_B8': 'B8', |
| 384 'ISO_B9': 'B9', |
| 385 'ISO_C0': 'C0', |
| 386 'ISO_C1': 'C1', |
| 387 'ISO_C10': 'C10', |
| 388 'ISO_C2': 'C2', |
| 389 'ISO_C3': 'C3', |
| 390 'ISO_C4': 'C4', |
| 391 'ISO_C5': 'C5', |
| 392 'ISO_C6': 'C6', |
| 393 'ISO_C6C5': 'C6C5', |
| 394 'ISO_C7': 'C7', |
| 395 'ISO_C7C6': 'C7C6', |
| 396 'ISO_C8': 'C8', |
| 397 'ISO_C9': 'C9', |
| 398 'ISO_DL': 'Envelope DL', |
| 399 'ISO_RA0': 'RA0', |
| 400 'ISO_RA1': 'RA1', |
| 401 'ISO_RA2': 'RA2', |
| 402 'ISO_SRA0': 'SRA0', |
| 403 'ISO_SRA1': 'SRA1', |
| 404 'ISO_SRA2': 'SRA2', |
| 405 'JIS_B0': 'B0 (JIS)', |
| 406 'JIS_B1': 'B1 (JIS)', |
| 407 'JIS_B10': 'B10 (JIS)', |
| 408 'JIS_B2': 'B2 (JIS)', |
| 409 'JIS_B3': 'B3 (JIS)', |
| 410 'JIS_B4': 'B4 (JIS)', |
| 411 'JIS_B5': 'B5 (JIS)', |
| 412 'JIS_B6': 'B6 (JIS)', |
| 413 'JIS_B7': 'B7 (JIS)', |
| 414 'JIS_B8': 'B8 (JIS)', |
| 415 'JIS_B9': 'B9 (JIS)', |
| 416 'JIS_EXEC': 'Executive (JIS)', |
| 417 'JPN_CHOU2': 'Choukei 2', |
| 418 'JPN_CHOU3': 'Choukei 3', |
| 419 'JPN_CHOU4': 'Choukei 4', |
| 420 'JPN_HAGAKI': 'Hagaki', |
| 421 'JPN_KAHU': 'Kahu Envelope', |
| 422 'JPN_KAKU2': 'Kaku 2', |
| 423 'JPN_OUFUKU': 'Oufuku Hagaki', |
| 424 'JPN_YOU4': 'You 4', |
| 425 'NA_10X11': '10x11', |
| 426 'NA_10X13': '10x13', |
| 427 'NA_10X14': '10x14', |
| 428 'NA_10X15': '10x15', |
| 429 'NA_11X12': '11x12', |
| 430 'NA_11X15': '11x15', |
| 431 'NA_12X19': '12x19', |
| 432 'NA_5X7': '5x7', |
| 433 'NA_6X9': '6x9', |
| 434 'NA_7X9': '7x9', |
| 435 'NA_9X11': '9x11', |
| 436 'NA_A2': 'A2', |
| 437 'NA_ARCH_A': 'Arch A', |
| 438 'NA_ARCH_B': 'Arch B', |
| 439 'NA_ARCH_C': 'Arch C', |
| 440 'NA_ARCH_D': 'Arch D', |
| 441 'NA_ARCH_E': 'Arch E', |
| 442 'NA_ASME_F': 'ASME F', |
| 443 'NA_B_PLUS': 'B-plus', |
| 444 'NA_C': 'C', |
| 445 'NA_C5': 'C5', |
| 446 'NA_D': 'D', |
| 447 'NA_E': 'E', |
| 448 'NA_EDP': 'EDP', |
| 449 'NA_EUR_EDP': 'European EDP', |
| 450 'NA_EXECUTIVE': 'Executive', |
| 451 'NA_F': 'F', |
| 452 'NA_FANFOLD_EUR': 'FanFold European', |
| 453 'NA_FANFOLD_US': 'FanFold US', |
| 454 'NA_FOOLSCAP': 'FanFold German Legal', |
| 455 'NA_GOVT_LEGAL': 'Government Legal', |
| 456 'NA_GOVT_LETTER': 'Government Letter', |
| 457 'NA_INDEX_3X5': 'Index 3x5', |
| 458 'NA_INDEX_4X6': 'Index 4x6', |
| 459 'NA_INDEX_4X6_EXT': 'Index 4x6 ext', |
| 460 'NA_INDEX_5X8': '5x8', |
| 461 'NA_INVOICE': 'Invoice', |
| 462 'NA_LEDGER': 'Tabloid', // Ledger in portrait is called Tabloid. |
| 463 'NA_LEGAL': 'Legal', |
| 464 'NA_LEGAL_EXTRA': 'Legal extra', |
| 465 'NA_LETTER': 'Letter', |
| 466 'NA_LETTER_EXTRA': 'Letter extra', |
| 467 'NA_LETTER_PLUS': 'Letter plus', |
| 468 'NA_MONARCH': 'Monarch', |
| 469 'NA_NUMBER_10': 'Envelope #10', |
| 470 'NA_NUMBER_11': 'Envelope #11', |
| 471 'NA_NUMBER_12': 'Envelope #12', |
| 472 'NA_NUMBER_14': 'Envelope #14', |
| 473 'NA_NUMBER_9': 'Envelope #9', |
| 474 'NA_PERSONAL': 'Personal', |
| 475 'NA_QUARTO': 'Quarto', |
| 476 'NA_SUPER_A': 'Super A', |
| 477 'NA_SUPER_B': 'Super B', |
| 478 'NA_WIDE_FORMAT': 'Wide format', |
| 479 'OM_DAI_PA_KAI': 'Dai-pa-kai', |
| 480 'OM_FOLIO': 'Folio', |
| 481 'OM_FOLIO_SP': 'Folio SP', |
| 482 'OM_INVITE': 'Invite Envelope', |
| 483 'OM_ITALIAN': 'Italian Envelope', |
| 484 'OM_JUURO_KU_KAI': 'Juuro-ku-kai', |
| 485 'OM_LARGE_PHOTO': 'Large photo', |
| 486 'OM_OFICIO': 'Oficio', |
| 487 'OM_PA_KAI': 'Pa-kai', |
| 488 'OM_POSTFIX': 'Postfix Envelope', |
| 489 'OM_SMALL_PHOTO': 'Small photo', |
| 490 'PRC_1': 'prc1 Envelope', |
| 491 'PRC_10': 'prc10 Envelope', |
| 492 'PRC_16K': 'prc 16k', |
| 493 'PRC_2': 'prc2 Envelope', |
| 494 'PRC_3': 'prc3 Envelope', |
| 495 'PRC_32K': 'prc 32k', |
| 496 'PRC_4': 'prc4 Envelope', |
| 497 'PRC_5': 'prc5 Envelope', |
| 498 'PRC_6': 'prc6 Envelope', |
| 499 'PRC_7': 'prc7 Envelope', |
| 500 'PRC_8': 'prc8 Envelope', |
| 501 'ROC_16K': 'ROC 16K', |
| 502 'ROC_8K': 'ROC 8k', |
| 503 }; |
| 504 |
| 505 /** |
335 * Localizes printer capabilities. | 506 * Localizes printer capabilities. |
336 * @param {!Object} capabilities Printer capabilities to localize. | 507 * @param {!Object} capabilities Printer capabilities to localize. |
337 * @return {!Object} Localized capabilities. | 508 * @return {!Object} Localized capabilities. |
338 * @private | 509 * @private |
339 */ | 510 */ |
340 DestinationStore.localizeCapabilities_ = function(capabilities) { | 511 DestinationStore.localizeCapabilities_ = function(capabilities) { |
341 var mediaSize = capabilities.printer.media_size; | 512 var mediaSize = capabilities.printer.media_size; |
342 if (!mediaSize) | 513 if (!mediaSize) |
343 return capabilities; | 514 return capabilities; |
344 | 515 |
345 var mediaDisplayNames = { | |
346 'ISO_A0': 'A0', | |
347 'ISO_A1': 'A1', | |
348 'ISO_A2': 'A2', | |
349 'ISO_A3': 'A3', | |
350 'ISO_A4': 'A4', | |
351 'ISO_A5': 'A5', | |
352 'ISO_A6': 'A6', | |
353 'JIS_B5': 'B5 (JIS)', | |
354 'NA_EXECUTIVE': 'Executive', | |
355 'NA_LEGAL': 'Legal', | |
356 'NA_LETTER': 'Letter', | |
357 'NA_LEDGER': 'Tabloid', | |
358 'OM_FOLIO': 'Folio' | |
359 }; | |
360 for (var i = 0, media; media = mediaSize.option[i]; i++) { | 516 for (var i = 0, media; media = mediaSize.option[i]; i++) { |
361 // No need to patch capabilities with localized names provided. | 517 // No need to patch capabilities with localized names provided. |
362 if (!media.custom_display_name_localized) { | 518 if (!media.custom_display_name_localized) { |
363 media.custom_display_name = | 519 media.custom_display_name = |
364 media.custom_display_name || | 520 media.custom_display_name || |
365 mediaDisplayNames[media.name] || | 521 DestinationStore.MEDIA_DISPLAY_NAMES_[media.name] || |
366 media.name; | 522 media.name; |
367 } | 523 } |
368 } | 524 } |
369 return capabilities; | 525 return capabilities; |
370 }; | 526 }; |
371 | 527 |
372 /** | 528 /** |
373 * Compare two media sizes by their names. | 529 * Compare two media sizes by their names. |
374 * @param {!Object} a Media to compare. | 530 * @param {!Object} a Media to compare. |
375 * @param {!Object} b Media to compare. | 531 * @param {!Object} b Media to compare. |
(...skipping 1206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1582 return this.getDestinationKey_( | 1738 return this.getDestinationKey_( |
1583 destination.origin, destination.id, destination.account); | 1739 destination.origin, destination.id, destination.account); |
1584 } | 1740 } |
1585 }; | 1741 }; |
1586 | 1742 |
1587 // Export | 1743 // Export |
1588 return { | 1744 return { |
1589 DestinationStore: DestinationStore | 1745 DestinationStore: DestinationStore |
1590 }; | 1746 }; |
1591 }); | 1747 }); |
OLD | NEW |