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

Unified Diff: chrome/installer/mac/app/OmahaXMLRequest.m

Issue 2094583004: Initial commit for Chrome metainstaller on Mac. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Made small changes according to LGTM comments Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/installer/mac/app/OmahaXMLRequest.h ('k') | chrome/installer/mac/app/SystemInfo.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/installer/mac/app/OmahaXMLRequest.m
diff --git a/chrome/installer/mac/app/OmahaXMLRequest.m b/chrome/installer/mac/app/OmahaXMLRequest.m
new file mode 100644
index 0000000000000000000000000000000000000000..8dad34210f7caf518cfabf2460e26041bfc96173
--- /dev/null
+++ b/chrome/installer/mac/app/OmahaXMLRequest.m
@@ -0,0 +1,74 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#import <Foundation/Foundation.h>
+
+#include "OmahaXMLRequest.h"
+#include "SystemInfo.h"
+
+@implementation OmahaXMLRequest : NSObject
+
++ (NSXMLElement*)createElementWithName:(NSString*)name {
+ return [[NSXMLElement alloc] initWithName:name];
+}
+
++ (void)forElement:(NSXMLElement*)element
+ AddAttribute:(NSString*)attribute
+ WithValue:(NSString*)value {
+ [element
+ addAttribute:[NSXMLNode attributeWithName:attribute stringValue:value]];
+}
+
+// borisv@ indicated that the OS version, platform, appid, and version are the
+// user attributes that Omaha actually looks at. The other parameters are useful
+// for logging purposes but otherwise not directly used.
++ (NSXMLDocument*)createXMLRequestBody {
+ // NOTE: might be a good idea in the future to add a version# for this
+ // installer
+ NSString* protocol = @"3.0";
+
+ NSString* platform = @"mac";
+ NSString* operatingSystem = [SystemInfo getOSVersion];
+ NSString* architecture = [SystemInfo getArch];
+ NSString* plat_arch =
+ [NSString stringWithFormat:@"%@_%@", operatingSystem, architecture];
+
+ NSString* appid = @"com.google.Chrome";
+ NSString* version = @"0.0.0.0";
+ NSString* language = @"en-us";
+
+ NSXMLElement* root = [OmahaXMLRequest createElementWithName:@"request"];
+ [OmahaXMLRequest forElement:root AddAttribute:@"protocol" WithValue:protocol];
+
+ NSXMLElement* osChild = [OmahaXMLRequest createElementWithName:@"os"];
+ [OmahaXMLRequest forElement:osChild
+ AddAttribute:@"platform"
+ WithValue:platform];
+ [OmahaXMLRequest forElement:osChild
+ AddAttribute:@"version"
+ WithValue:operatingSystem];
+ [OmahaXMLRequest forElement:osChild
+ AddAttribute:@"arch"
+ WithValue:architecture];
+ [OmahaXMLRequest forElement:osChild AddAttribute:@"sp" WithValue:plat_arch];
+ [root addChild:osChild];
+
+ NSXMLElement* appChild = [OmahaXMLRequest createElementWithName:@"app"];
+ [OmahaXMLRequest forElement:appChild AddAttribute:@"appid" WithValue:appid];
+ [OmahaXMLRequest forElement:appChild
+ AddAttribute:@"version"
+ WithValue:version];
+ [OmahaXMLRequest forElement:appChild AddAttribute:@"lang" WithValue:language];
+ [root addChild:appChild];
+
+ NSXMLElement* updateChildChild =
+ [OmahaXMLRequest createElementWithName:@"updatecheck"];
+ [appChild addChild:updateChildChild];
+
+ NSXMLDocument* requestXMLDocument =
+ [[NSXMLDocument alloc] initWithRootElement:root];
+ return requestXMLDocument;
+}
+
+@end
« no previous file with comments | « chrome/installer/mac/app/OmahaXMLRequest.h ('k') | chrome/installer/mac/app/SystemInfo.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698