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

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

Issue 2094583004: Initial commit for Chrome metainstaller on Mac. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
Index: chrome/installer/mac/app/parser.m
diff --git a/chrome/installer/mac/app/parser.m b/chrome/installer/mac/app/parser.m
new file mode 100644
index 0000000000000000000000000000000000000000..909290321a3fc291689e919dfbdb7a3da4ac5d38
--- /dev/null
+++ b/chrome/installer/mac/app/parser.m
@@ -0,0 +1,50 @@
+// Copyright (c) 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 "parser.h"
+
+@implementation Parser
+
+- (id)init {
+ if( self = [super init] ) {
Elly Fong-Jones 2016/06/24 17:26:02 proper style is "if ((self = [super init])) {" for
+ _chromeDownloadURLs = [[NSMutableArray alloc] init];
+ }
+ return self;
+}
+
+- (void)parseXML:(NSData*)someData {
Elly Fong-Jones 2016/06/24 17:26:01 This probably needs more robust error handling tha
+ NSData *data = someData;
+ NSXMLParser *parser = [[NSXMLParser alloc] initWithData:data];
+ [parser setDelegate:self];
+ bool success = [parser parse];
+ if (!success) {
+ NSError *err = [parser parserError];
+ NSLog(@"%@",err);
+ }
+}
+
+- (void)appendFilenameToURL {
Elly Fong-Jones 2016/06/24 17:26:02 This definitely needs an explanatory comment.
+ int count = [_chromeDownloadURLs count];
+ for (int i = 0; i < count; i++) {
+ NSString *fullFilename = [[_chromeDownloadURLs objectAtIndex:i]
+ stringByAppendingString: _filename];
+ [_chromeDownloadURLs replaceObjectAtIndex:i withObject: fullFilename];
+ }
+}
+
+- (void)parser:(NSXMLParser *)parser
Elly Fong-Jones 2016/06/24 17:26:02 This should have a comment remarking that it's par
+ didStartElement:(NSString *)elementName
+ namespaceURI:(NSString *)namespaceURI
+ qualifiedName:(NSString *)qName
+ attributes:(NSDictionary *)attributeDict {
+ if ([elementName isEqualToString:@"url"]) {
+ NSString *extractedURL = [attributeDict objectForKey:@"codebase"];
+ [_chromeDownloadURLs addObject: extractedURL];
+ }
+ if ([elementName isEqualToString:@"package"]) {
+ _filename = [attributeDict objectForKey:@"name"];
+ }
+}
+
+@end

Powered by Google App Engine
This is Rietveld 408576698