OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #import <Foundation/Foundation.h> |
| 6 #include "OmahaXMLRequest.h" |
| 7 #include "SystemInfo.h" |
| 8 |
| 9 @implementation OmahaXMLRequest : NSObject |
| 10 |
| 11 // borisv@ indicated that the OS version, platform, appid, and version are the |
| 12 // user attributes that Omaha actually looks at. The other parameters are useful |
| 13 // for logging purposes but otherwise not directly used. |
| 14 + (NSXMLDocument*)createXMLRequestBody { |
| 15 NSString* protocol = @"3.0"; |
| 16 NSString* keystoneVersion = @"KeystoneAgent-1.99.4.0"; |
| 17 |
| 18 NSString* platform = @"mac"; |
| 19 NSString* operatingSystem = [SystemInfo getOSVersion]; |
| 20 NSString* architecture = [SystemInfo getArch]; |
| 21 NSString* plat_arch = [NSString stringWithFormat:@"%@_%@", operatingSystem, |
| 22 architecture]; |
| 23 |
| 24 NSString* appid = @"com.google.Chrome"; |
| 25 NSString* version = @"0.0.0.0"; |
| 26 NSString* language = @"en-us"; |
| 27 |
| 28 NSXMLElement* root = [[NSXMLElement alloc] initWithName:@"request"]; |
| 29 [root addAttribute:[NSXMLNode attributeWithName:@"protocol" |
| 30 stringValue:protocol]]; |
| 31 [root addAttribute:[NSXMLNode attributeWithName:@"version" |
| 32 stringValue:keystoneVersion]]; |
| 33 |
| 34 NSXMLElement* osChild = [[NSXMLElement alloc] initWithName:@"os"]; |
| 35 [osChild addAttribute:[NSXMLNode attributeWithName:@"platform" |
| 36 stringValue:platform]]; |
| 37 [osChild addAttribute:[NSXMLNode attributeWithName:@"version" |
| 38 stringValue:operatingSystem]]; |
| 39 [osChild addAttribute:[NSXMLNode attributeWithName:@"arch" |
| 40 stringValue:architecture]]; |
| 41 [osChild addAttribute:[NSXMLNode attributeWithName:@"sp" |
| 42 stringValue:plat_arch]]; |
| 43 [root addChild:osChild]; |
| 44 |
| 45 NSXMLElement* appChild = [[NSXMLElement alloc] initWithName:@"app"]; |
| 46 [appChild addAttribute:[NSXMLNode attributeWithName:@"appid" |
| 47 stringValue:appid]]; |
| 48 [appChild addAttribute:[NSXMLNode attributeWithName:@"version" |
| 49 stringValue:version]]; |
| 50 [appChild addAttribute:[NSXMLNode attributeWithName:@"lang" |
| 51 stringValue:language]]; |
| 52 [root addChild:appChild]; |
| 53 |
| 54 NSXMLElement* updateChildChild = [[NSXMLElement alloc] |
| 55 initWithName:@"updatecheck"]; |
| 56 [appChild addChild:updateChildChild]; |
| 57 |
| 58 NSXMLDocument* requestXMLDocument = [[NSXMLDocument alloc] |
| 59 initWithRootElement:root]; |
| 60 return requestXMLDocument; |
| 61 } |
| 62 |
| 63 @end |
OLD | NEW |