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

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

Issue 14340003: Rename AuthType to Origin of destination. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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('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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 ANDROID: 'ANDROID_CHROME_SNAPSHOT', 49 ANDROID: 'ANDROID_CHROME_SNAPSHOT',
50 DOCS: 'DOCS', 50 DOCS: 'DOCS',
51 IOS: 'IOS_CHROME_SNAPSHOT' 51 IOS: 'IOS_CHROME_SNAPSHOT'
52 }; 52 };
53 53
54 /** 54 /**
55 * Parses a destination from JSON from a Google Cloud Print search or printer 55 * Parses a destination from JSON from a Google Cloud Print search or printer
56 * response. 56 * response.
57 * @param {!Object} json Object that represents a Google Cloud Print search or 57 * @param {!Object} json Object that represents a Google Cloud Print search or
58 * printer response. 58 * printer response.
59 * @param {!print_preview.Destination.AuthType} authType The authentication 59 * @param {!print_preview.Destination.Origin} origin The origin of the
60 * type used to find printer. 60 * response.
61 * @return {!print_preview.Destination} Parsed destination. 61 * @return {!print_preview.Destination} Parsed destination.
62 */ 62 */
63 CloudDestinationParser.parse = function(json, authType) { 63 CloudDestinationParser.parse = function(json, origin) {
64 if (!json.hasOwnProperty(CloudDestinationParser.Field_.ID) || 64 if (!json.hasOwnProperty(CloudDestinationParser.Field_.ID) ||
65 !json.hasOwnProperty(CloudDestinationParser.Field_.TYPE) || 65 !json.hasOwnProperty(CloudDestinationParser.Field_.TYPE) ||
66 !json.hasOwnProperty(CloudDestinationParser.Field_.DISPLAY_NAME)) { 66 !json.hasOwnProperty(CloudDestinationParser.Field_.DISPLAY_NAME)) {
67 throw Error('Cloud destination does not have an ID or a display name'); 67 throw Error('Cloud destination does not have an ID or a display name');
68 } 68 }
69 var id = json[CloudDestinationParser.Field_.ID]; 69 var id = json[CloudDestinationParser.Field_.ID];
70 var tags = json[CloudDestinationParser.Field_.TAGS] || []; 70 var tags = json[CloudDestinationParser.Field_.TAGS] || [];
71 var connectionStatus = 71 var connectionStatus =
72 json[CloudDestinationParser.Field_.CONNECTION_STATUS] || 72 json[CloudDestinationParser.Field_.CONNECTION_STATUS] ||
73 print_preview.Destination.ConnectionStatus.UNKNOWN; 73 print_preview.Destination.ConnectionStatus.UNKNOWN;
74 var optionalParams = { 74 var optionalParams = {
75 tags: tags, 75 tags: tags,
76 isOwned: arrayContains(tags, CloudDestinationParser.OWNED_TAG_), 76 isOwned: arrayContains(tags, CloudDestinationParser.OWNED_TAG_),
77 lastAccessTime: parseInt( 77 lastAccessTime: parseInt(
78 json[CloudDestinationParser.Field_.LAST_ACCESS], 10) || Date.now(), 78 json[CloudDestinationParser.Field_.LAST_ACCESS], 10) || Date.now(),
79 isTosAccepted: (id == print_preview.Destination.GooglePromotedId.FEDEX) ? 79 isTosAccepted: (id == print_preview.Destination.GooglePromotedId.FEDEX) ?
80 json[CloudDestinationParser.Field_.IS_TOS_ACCEPTED] : null 80 json[CloudDestinationParser.Field_.IS_TOS_ACCEPTED] : null
81 }; 81 };
82 var cloudDest = new print_preview.Destination( 82 var cloudDest = new print_preview.Destination(
83 id, 83 id,
84 CloudDestinationParser.parseType_( 84 CloudDestinationParser.parseType_(
85 json[CloudDestinationParser.Field_.TYPE]), 85 json[CloudDestinationParser.Field_.TYPE]),
86 authType, 86 origin,
87 json[CloudDestinationParser.Field_.DISPLAY_NAME], 87 json[CloudDestinationParser.Field_.DISPLAY_NAME],
88 arrayContains(tags, CloudDestinationParser.RECENT_TAG_) /*isRecent*/, 88 arrayContains(tags, CloudDestinationParser.RECENT_TAG_) /*isRecent*/,
89 connectionStatus, 89 connectionStatus,
90 optionalParams); 90 optionalParams);
91 if (json.hasOwnProperty(CloudDestinationParser.Field_.CAPABILITIES)) { 91 if (json.hasOwnProperty(CloudDestinationParser.Field_.CAPABILITIES)) {
92 cloudDest.capabilities = /*@type {!print_preview.Cdd}*/ ( 92 cloudDest.capabilities = /*@type {!print_preview.Cdd}*/ (
93 json[CloudDestinationParser.Field_.CAPABILITIES]); 93 json[CloudDestinationParser.Field_.CAPABILITIES]);
94 } 94 }
95 return cloudDest; 95 return cloudDest;
96 }; 96 };
(...skipping 14 matching lines...) Expand all
111 } else { 111 } else {
112 return print_preview.Destination.Type.GOOGLE; 112 return print_preview.Destination.Type.GOOGLE;
113 } 113 }
114 }; 114 };
115 115
116 // Export 116 // Export
117 return { 117 return {
118 CloudDestinationParser: CloudDestinationParser 118 CloudDestinationParser: CloudDestinationParser
119 }; 119 };
120 }); 120 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/print_preview/data/app_state.js ('k') | chrome/browser/resources/print_preview/data/destination.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698