| 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 |
| 11 /** | 11 /** |
| 12 * Parses a local print destination. | 12 * Parses a local print destination. |
| 13 * @param {!Object} destinationInfo Information describing a local print | 13 * @param {!{deviceName: string, |
| 14 * destination. | 14 * printerDescription: string, |
| 15 * printerName: string, |
| 16 * printerOptions: Array}} destinationInfo Information describing |
| 17 * a local print destination. |
| 15 * @return {!print_preview.Destination} Parsed local print destination. | 18 * @return {!print_preview.Destination} Parsed local print destination. |
| 19 * @see chrome/browser/ui/webui/print_preview/print_preview_handler.cc |
| 16 */ | 20 */ |
| 17 LocalDestinationParser.parse = function(destinationInfo) { | 21 LocalDestinationParser.parse = function(destinationInfo) { |
| 18 var options = {'description': destinationInfo.printerDescription}; | 22 var options = {'description': destinationInfo.printerDescription}; |
| 19 if (destinationInfo.printerOptions) { | 23 if (destinationInfo.printerOptions) { |
| 20 // Convert options into cloud print tags format. | 24 // Convert options into cloud print tags format. |
| 21 options.tags = Object.keys(destinationInfo.printerOptions).map( | 25 options.tags = Object.keys(destinationInfo.printerOptions).map( |
| 22 function(key) {return '__cp__' + key + '=' + this[key];}, | 26 function(key) {return '__cp__' + key + '=' + this[key];}, |
| 23 destinationInfo.printerOptions); | 27 destinationInfo.printerOptions); |
| 24 } | 28 } |
| 25 return new print_preview.Destination( | 29 return new print_preview.Destination( |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 | 69 |
| 66 return returnedPrinters; | 70 return returnedPrinters; |
| 67 }; | 71 }; |
| 68 | 72 |
| 69 // Export | 73 // Export |
| 70 return { | 74 return { |
| 71 LocalDestinationParser: LocalDestinationParser, | 75 LocalDestinationParser: LocalDestinationParser, |
| 72 PrivetDestinationParser: PrivetDestinationParser | 76 PrivetDestinationParser: PrivetDestinationParser |
| 73 }; | 77 }; |
| 74 }); | 78 }); |
| OLD | NEW |