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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
59 print_preview.Destination.Type.GOOGLE, | 59 print_preview.Destination.Type.GOOGLE, |
60 print_preview.Destination.Origin.PRIVET, | 60 print_preview.Destination.Origin.PRIVET, |
61 destinationInfo.name, | 61 destinationInfo.name, |
62 false /*isRecent*/, | 62 false /*isRecent*/, |
63 print_preview.Destination.ConnectionStatus.UNREGISTERED)); | 63 print_preview.Destination.ConnectionStatus.UNREGISTERED)); |
64 } | 64 } |
65 | 65 |
66 return returnedPrinters; | 66 return returnedPrinters; |
67 }; | 67 }; |
68 | 68 |
69 function ExtensionDestinationParser() {} | |
70 | |
71 /** | |
72 * Separator used to separate extension and printer ID when generating an | |
73 * extension destination ID. | |
74 * @type {string} | |
75 * @private | |
76 */ | |
77 ExtensionDestinationParser.ID_SEPARATOR_ = ':'; | |
78 | |
79 /** | |
80 * Given an extension ID and a printer ID in the extension's namespace, it | |
81 * generates a destination ID for an extension managed printer. | |
82 * @param {string} extensionID The ID of the extension that manages the | |
83 * printer. | |
84 * @param {string} printerID The ID of the printer reported by the extension. | |
85 * @return {string} The generated extension destination ID. | |
86 */ | |
87 ExtensionDestinationParser.generateDestinationID = function(extensionID, | |
Aleksey Shlyapnikov
2015/02/03 20:18:24
generateDestinationId
tbarzic
2015/02/04 02:21:23
removed
| |
88 printerID) { | |
89 return [extensionID, printerID].join( | |
90 ExtensionDestinationParser.ID_SEPARATOR_); | |
91 }; | |
92 | |
93 /** | |
94 * Parses an extension destination ID. | |
95 * @param {string} destinationID The destination ID that should be parsed. | |
96 * @return {!{extensionID: string, printerID: string}} The parsed extension | |
97 * and printer IDs. | |
98 */ | |
99 ExtensionDestinationParser.parseDestinationID = function(destinationID) { | |
Aleksey Shlyapnikov
2015/02/03 20:18:24
parseDestinationId
tbarzic
2015/02/04 02:21:23
removed
| |
100 var splitID = destinationID.split(ExtensionDestinationParser.ID_SEPARATOR_); | |
Aleksey Shlyapnikov
2015/02/03 20:18:24
splitId
tbarzic
2015/02/04 02:21:23
removed
| |
101 var extensionId = splitID[0]; | |
102 splitID.shift(); | |
103 return { | |
104 extensionID: extensionId, | |
105 printerID: splitID.join(ExtensionDestinationParser.ID_SEPARATOR_) | |
106 }; | |
107 }; | |
Aleksey Shlyapnikov
2015/02/03 20:18:24
I've read your discussion about gluing/parsing the
tbarzic
2015/02/04 02:21:23
OK sounds good; Done
| |
108 | |
109 /** | |
110 * Parses an extension destination from an extension supplied printer | |
111 * description. | |
112 * @param {!Object} destinationInfo Object describing an extension printer. | |
113 * @return {!print_preview.Destination} Parsed destination. | |
114 */ | |
115 ExtensionDestinationParser.parse = function(destinationInfo) { | |
116 return new print_preview.Destination( | |
117 ExtensionDestinationParser.generateDestinationID( | |
118 destinationInfo.extensionId, destinationInfo.id), | |
119 print_preview.Destination.Type.LOCAL, | |
120 print_preview.Destination.Origin.EXTENSION, | |
121 destinationInfo.name, | |
122 false /* isRecent */, | |
123 print_preview.Destination.ConnectionStatus.ONLINE, | |
124 {description: destinationInfo.description || '', | |
125 extensionID: destinationInfo.extensionId}); | |
Aleksey Shlyapnikov
2015/02/03 20:18:24
extensionId
Anyway, please change all ...ID ident
tbarzic
2015/02/04 02:21:23
Done.
| |
126 }; | |
127 | |
69 // Export | 128 // Export |
70 return { | 129 return { |
71 LocalDestinationParser: LocalDestinationParser, | 130 LocalDestinationParser: LocalDestinationParser, |
72 PrivetDestinationParser: PrivetDestinationParser | 131 PrivetDestinationParser: PrivetDestinationParser, |
132 ExtensionDestinationParser: ExtensionDestinationParser | |
73 }; | 133 }; |
74 }); | 134 }); |
OLD | NEW |