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

Side by Side Diff: chrome/browser/resources/print_preview/data/local_parsers.js

Issue 214443007: Pass location and description of local printers into print preview. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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 | Annotate | Revision Log
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.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 {!Object} destinationInfo Information describing a local print
14 * destination. 14 * destination.
15 * @return {!print_preview.Destination} Parsed local print destination. 15 * @return {!print_preview.Destination} Parsed local print destination.
16 */ 16 */
17 LocalDestinationParser.parse = function(destinationInfo) { 17 LocalDestinationParser.parse = function (destinationInfo) {
18 // Convert options into cloud print tags format.
19 var tags = Object.keys(destinationInfo.printerOptions).map(function (key) {
20 return "__cp__" + key + "=" + this[key]
Aleksey Shlyapnikov 2014/03/28 20:26:16 I'd use more specific prefix, __cp_local__ or some
21 }, destinationInfo.printerOptions);
18 return new print_preview.Destination( 22 return new print_preview.Destination(
19 destinationInfo.deviceName, 23 destinationInfo.deviceName,
20 print_preview.Destination.Type.LOCAL, 24 print_preview.Destination.Type.LOCAL,
21 print_preview.Destination.Origin.LOCAL, 25 print_preview.Destination.Origin.LOCAL,
22 destinationInfo.printerName, 26 destinationInfo.printerName,
23 false /*isRecent*/, 27 false /*isRecent*/,
24 print_preview.Destination.ConnectionStatus.ONLINE); 28 print_preview.Destination.ConnectionStatus.ONLINE,
29 {
30 'tags': tags,
31 'description': destinationInfo.printerDescription
32 });
25 }; 33 };
26 34
27 /** Namespace that contains a method to parse local print capabilities. */ 35 /** Namespace that contains a method to parse local print capabilities. */
28 function LocalCapabilitiesParser() {}; 36 function LocalCapabilitiesParser() {};
29 37
30 /** 38 /**
31 * Parses local print capabilities. 39 * Parses local print capabilities.
32 * @param {!Object} settingsInfo Object that describes local print 40 * @param {!Object} settingsInfo Object that describes local print
33 * capabilities. 41 * capabilities.
34 * @return {!print_preview.Cdd} Parsed local print capabilities. 42 * @return {!print_preview.Cdd} Parsed local print capabilities.
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 print_preview.Destination.Type.LOCAL, 106 print_preview.Destination.Type.LOCAL,
99 print_preview.Destination.Origin.PRIVET, 107 print_preview.Destination.Origin.PRIVET,
100 destinationInfo.name, 108 destinationInfo.name,
101 false /*isRecent*/, 109 false /*isRecent*/,
102 print_preview.Destination.ConnectionStatus.ONLINE, 110 print_preview.Destination.ConnectionStatus.ONLINE,
103 { cloudID: destinationInfo.cloudID })); 111 { cloudID: destinationInfo.cloudID }));
104 } 112 }
105 113
106 if (destinationInfo.isUnregistered) { 114 if (destinationInfo.isUnregistered) {
107 returnedPrinters.push(new print_preview.Destination( 115 returnedPrinters.push(new print_preview.Destination(
108 destinationInfo.serviceName, 116 destinationInfo.serviceName,
109 print_preview.Destination.Type.GOOGLE, 117 print_preview.Destination.Type.GOOGLE,
110 print_preview.Destination.Origin.PRIVET, 118 print_preview.Destination.Origin.PRIVET,
111 destinationInfo.name, 119 destinationInfo.name,
112 false /*isRecent*/, 120 false /*isRecent*/,
113 print_preview.Destination.ConnectionStatus.UNREGISTERED)); 121 print_preview.Destination.ConnectionStatus.UNREGISTERED));
114 } 122 }
115 123
116 return returnedPrinters; 124 return returnedPrinters;
117 }; 125 };
118 126
119 // Export 127 // Export
120 return { 128 return {
121 LocalCapabilitiesParser: LocalCapabilitiesParser, 129 LocalCapabilitiesParser: LocalCapabilitiesParser,
122 LocalDestinationParser: LocalDestinationParser, 130 LocalDestinationParser: LocalDestinationParser,
123 PrivetDestinationParser: PrivetDestinationParser 131 PrivetDestinationParser: PrivetDestinationParser
124 }; 132 };
125 }); 133 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698