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('cloudprint', function() { | 5 cr.define('cloudprint', function() { |
6 'use strict'; | 6 'use strict'; |
7 | 7 |
8 /** Namespace which contains a method to parse cloud destinations directly. */ | 8 /** Namespace which contains a method to parse cloud destinations directly. */ |
9 function CloudDestinationParser() {}; | 9 function CloudDestinationParser() {}; |
10 | 10 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 var cloudDest = new print_preview.Destination( | 88 var cloudDest = new print_preview.Destination( |
89 id, | 89 id, |
90 CloudDestinationParser.parseType_( | 90 CloudDestinationParser.parseType_( |
91 json[CloudDestinationParser.Field_.TYPE]), | 91 json[CloudDestinationParser.Field_.TYPE]), |
92 origin, | 92 origin, |
93 json[CloudDestinationParser.Field_.DISPLAY_NAME], | 93 json[CloudDestinationParser.Field_.DISPLAY_NAME], |
94 arrayContains(tags, CloudDestinationParser.RECENT_TAG_) /*isRecent*/, | 94 arrayContains(tags, CloudDestinationParser.RECENT_TAG_) /*isRecent*/, |
95 connectionStatus, | 95 connectionStatus, |
96 optionalParams); | 96 optionalParams); |
97 if (json.hasOwnProperty(CloudDestinationParser.Field_.CAPABILITIES)) { | 97 if (json.hasOwnProperty(CloudDestinationParser.Field_.CAPABILITIES)) { |
98 cloudDest.capabilities = /*@type {!print_preview.Cdd}*/ ( | 98 cloudDest.capabilities = /** @type {!print_preview.Cdd} */( |
99 json[CloudDestinationParser.Field_.CAPABILITIES]); | 99 json[CloudDestinationParser.Field_.CAPABILITIES]); |
100 } | 100 } |
101 return cloudDest; | 101 return cloudDest; |
102 }; | 102 }; |
103 | 103 |
104 /** | 104 /** |
105 * Parses the destination type. | 105 * Parses the destination type. |
106 * @param {string} typeStr Destination type given by the Google Cloud Print | 106 * @param {string} typeStr Destination type given by the Google Cloud Print |
107 * server. | 107 * server. |
108 * @return {!print_preview.Destination.Type} Destination type. | 108 * @return {!print_preview.Destination.Type} Destination type. |
109 * @private | 109 * @private |
110 */ | 110 */ |
111 CloudDestinationParser.parseType_ = function(typeStr) { | 111 CloudDestinationParser.parseType_ = function(typeStr) { |
112 if (typeStr == CloudDestinationParser.CloudType_.ANDROID || | 112 if (typeStr == CloudDestinationParser.CloudType_.ANDROID || |
113 typeStr == CloudDestinationParser.CloudType_.IOS) { | 113 typeStr == CloudDestinationParser.CloudType_.IOS) { |
114 return print_preview.Destination.Type.MOBILE; | 114 return print_preview.Destination.Type.MOBILE; |
115 } else if (typeStr == CloudDestinationParser.CloudType_.DOCS) { | 115 } else if (typeStr == CloudDestinationParser.CloudType_.DOCS) { |
116 return print_preview.Destination.Type.GOOGLE_PROMOTED; | 116 return print_preview.Destination.Type.GOOGLE_PROMOTED; |
117 } else { | 117 } else { |
118 return print_preview.Destination.Type.GOOGLE; | 118 return print_preview.Destination.Type.GOOGLE; |
119 } | 119 } |
120 }; | 120 }; |
121 | 121 |
122 // Export | 122 // Export |
123 return { | 123 return { |
124 CloudDestinationParser: CloudDestinationParser | 124 CloudDestinationParser: CloudDestinationParser |
125 }; | 125 }; |
126 }); | 126 }); |
OLD | NEW |