| 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 /** Namespace that contains a method to parse local print destinations. */ | 8 /** Namespace that contains a method to parse local print destinations. */ |
| 9 function LocalDestinationParser() {}; | 9 function LocalDestinationParser() {}; |
| 10 | 10 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 return new print_preview.Destination( | 25 return new print_preview.Destination( |
| 26 destinationInfo.deviceName, | 26 destinationInfo.deviceName, |
| 27 print_preview.Destination.Type.LOCAL, | 27 print_preview.Destination.Type.LOCAL, |
| 28 print_preview.Destination.Origin.LOCAL, | 28 print_preview.Destination.Origin.LOCAL, |
| 29 destinationInfo.printerName, | 29 destinationInfo.printerName, |
| 30 false /*isRecent*/, | 30 false /*isRecent*/, |
| 31 print_preview.Destination.ConnectionStatus.ONLINE, | 31 print_preview.Destination.ConnectionStatus.ONLINE, |
| 32 options); | 32 options); |
| 33 }; | 33 }; |
| 34 | 34 |
| 35 /** Namespace that contains a method to parse local print capabilities. */ | |
| 36 function LocalCapabilitiesParser() {}; | |
| 37 | |
| 38 /** | |
| 39 * Parses local print capabilities. | |
| 40 * @param {!Object} settingsInfo Object that describes local print | |
| 41 * capabilities. | |
| 42 * @return {!print_preview.Cdd} Parsed local print capabilities. | |
| 43 */ | |
| 44 LocalCapabilitiesParser.parse = function(settingsInfo) { | |
| 45 var cdd = { | |
| 46 version: '1.0', | |
| 47 printer: { | |
| 48 collate: {'default': true} | |
| 49 } | |
| 50 }; | |
| 51 | |
| 52 if (!settingsInfo['disableColorOption']) { | |
| 53 cdd.printer.color = { | |
| 54 option: [ | |
| 55 { | |
| 56 type: 'STANDARD_COLOR', | |
| 57 is_default: !!settingsInfo['setColorAsDefault'] | |
| 58 }, | |
| 59 { | |
| 60 type: 'STANDARD_MONOCHROME', | |
| 61 is_default: !settingsInfo['setColorAsDefault'] | |
| 62 } | |
| 63 ] | |
| 64 }; | |
| 65 } | |
| 66 | |
| 67 if (!settingsInfo['disableCopiesOption']) { | |
| 68 cdd.printer.copies = {'default': 1}; | |
| 69 } | |
| 70 | |
| 71 if (settingsInfo['printerDefaultDuplexValue'] != | |
| 72 print_preview.NativeLayer.DuplexMode.UNKNOWN_DUPLEX_MODE) { | |
| 73 cdd.printer.duplex = { | |
| 74 option: [ | |
| 75 {type: 'NO_DUPLEX', is_default: !settingsInfo['setDuplexAsDefault']}, | |
| 76 {type: 'LONG_EDGE', is_default: !!settingsInfo['setDuplexAsDefault']} | |
| 77 ] | |
| 78 }; | |
| 79 } | |
| 80 | |
| 81 if (!settingsInfo['disableLandscapeOption']) { | |
| 82 cdd.printer.page_orientation = { | |
| 83 option: [ | |
| 84 {type: 'PORTRAIT', is_default: true}, | |
| 85 {type: 'LANDSCAPE'} | |
| 86 ] | |
| 87 }; | |
| 88 } | |
| 89 | |
| 90 return cdd; | |
| 91 }; | |
| 92 | |
| 93 function PrivetDestinationParser() {} | 35 function PrivetDestinationParser() {} |
| 94 | 36 |
| 95 /** | 37 /** |
| 96 * Parses a privet destination as one or more local printers. | 38 * Parses a privet destination as one or more local printers. |
| 97 * @param {!Object} destinationInfo Object that describes a privet printer. | 39 * @param {!Object} destinationInfo Object that describes a privet printer. |
| 98 * @return {!Array.<!print_preview.Destination>} Parsed destination info. | 40 * @return {!Array.<!print_preview.Destination>} Parsed destination info. |
| 99 */ | 41 */ |
| 100 PrivetDestinationParser.parse = function(destinationInfo) { | 42 PrivetDestinationParser.parse = function(destinationInfo) { |
| 101 var returnedPrinters = []; | 43 var returnedPrinters = []; |
| 102 | 44 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 119 destinationInfo.name, | 61 destinationInfo.name, |
| 120 false /*isRecent*/, | 62 false /*isRecent*/, |
| 121 print_preview.Destination.ConnectionStatus.UNREGISTERED)); | 63 print_preview.Destination.ConnectionStatus.UNREGISTERED)); |
| 122 } | 64 } |
| 123 | 65 |
| 124 return returnedPrinters; | 66 return returnedPrinters; |
| 125 }; | 67 }; |
| 126 | 68 |
| 127 // Export | 69 // Export |
| 128 return { | 70 return { |
| 129 LocalCapabilitiesParser: LocalCapabilitiesParser, | |
| 130 LocalDestinationParser: LocalDestinationParser, | 71 LocalDestinationParser: LocalDestinationParser, |
| 131 PrivetDestinationParser: PrivetDestinationParser | 72 PrivetDestinationParser: PrivetDestinationParser |
| 132 }; | 73 }; |
| 133 }); | 74 }); |
| OLD | NEW |