OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #include "OmahaXMLRequest.h" | 5 #include "OmahaXMLRequest.h" |
6 | 6 |
7 #include "SystemInfo.h" | 7 #include "SystemInfo.h" |
8 | 8 |
9 @implementation OmahaXMLRequest : NSObject | 9 @implementation OmahaXMLRequest : NSObject |
10 | 10 |
11 + (NSXMLElement*)createElementWithName:(NSString*)name { | 11 + (NSXMLElement*)createElementWithName:(NSString*)name { |
12 return [[NSXMLElement alloc] initWithName:name]; | 12 return [[NSXMLElement alloc] initWithName:name]; |
13 } | 13 } |
14 | 14 |
15 + (void)forElement:(NSXMLElement*)element | 15 + (void)forElement:(NSXMLElement*)element |
16 AddAttribute:(NSString*)attribute | 16 AddAttribute:(NSString*)attribute |
17 WithValue:(NSString*)value { | 17 WithValue:(NSString*)value { |
18 [element | 18 [element |
19 addAttribute:[NSXMLNode attributeWithName:attribute stringValue:value]]; | 19 addAttribute:[NSXMLNode attributeWithName:attribute stringValue:value]]; |
20 } | 20 } |
21 | 21 |
22 // borisv@ indicated that the OS version, platform, appid, and version are the | 22 // borisv@ indicated that the OS version, platform, appid, and version are the |
23 // user attributes that Omaha actually looks at. The other parameters are useful | 23 // user attributes that Omaha actually looks at. The other parameters are useful |
24 // for logging purposes but otherwise not directly used. | 24 // for logging purposes but otherwise not directly used. |
25 + (NSXMLDocument*)createXMLRequestBody { | 25 + (NSXMLDocument*)createXMLRequestBody { |
26 // TODO: might be a good idea in the future to add a version# for this | 26 // TODO: not hard-code protocol version #? |
27 // installer using [[NSBundle mainBundle] | |
28 // objectForInfoDictionaryKey:@"CFBundleShortVersionString"]] | |
29 NSString* protocol = @"3.0"; | 27 NSString* protocol = @"3.0"; |
30 | 28 |
31 NSString* platform = @"mac"; | 29 NSString* platform = @"mac"; |
32 NSString* operatingSystem = [SystemInfo getOSVersion]; | 30 NSString* operatingSystem = [SystemInfo getOSVersion]; |
33 NSString* architecture = [SystemInfo getArch]; | 31 NSString* architecture = [SystemInfo getArch]; |
34 NSString* plat_arch = | 32 NSString* plat_arch = |
35 [NSString stringWithFormat:@"%@_%@", operatingSystem, architecture]; | 33 [NSString stringWithFormat:@"%@_%@", operatingSystem, architecture]; |
36 | 34 |
37 NSString* appid = @"com.google.Chrome"; | 35 NSString* appid = @"com.google.Chrome"; |
38 NSString* version = @"0.0.0.0"; | 36 NSString* version = @"0.0.0.0"; |
(...skipping 26 matching lines...) Expand all Loading... |
65 NSXMLElement* updateChildChild = | 63 NSXMLElement* updateChildChild = |
66 [OmahaXMLRequest createElementWithName:@"updatecheck"]; | 64 [OmahaXMLRequest createElementWithName:@"updatecheck"]; |
67 [appChild addChild:updateChildChild]; | 65 [appChild addChild:updateChildChild]; |
68 | 66 |
69 NSXMLDocument* requestXMLDocument = | 67 NSXMLDocument* requestXMLDocument = |
70 [[NSXMLDocument alloc] initWithRootElement:root]; | 68 [[NSXMLDocument alloc] initWithRootElement:root]; |
71 return requestXMLDocument; | 69 return requestXMLDocument; |
72 } | 70 } |
73 | 71 |
74 @end | 72 @end |
OLD | NEW |