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

Side by Side 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, 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 unified diff | Download patch
OLDNEW
(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 "parser.h"
6
7 @implementation Parser
8
9 - (id)init {
10 if( self = [super init] ) {
Elly Fong-Jones 2016/06/24 17:26:02 proper style is "if ((self = [super init])) {" for
11 _chromeDownloadURLs = [[NSMutableArray alloc] init];
12 }
13 return self;
14 }
15
16 - (void)parseXML:(NSData*)someData {
Elly Fong-Jones 2016/06/24 17:26:01 This probably needs more robust error handling tha
17 NSData *data = someData;
18 NSXMLParser *parser = [[NSXMLParser alloc] initWithData:data];
19 [parser setDelegate:self];
20 bool success = [parser parse];
21 if (!success) {
22 NSError *err = [parser parserError];
23 NSLog(@"%@",err);
24 }
25 }
26
27 - (void)appendFilenameToURL {
Elly Fong-Jones 2016/06/24 17:26:02 This definitely needs an explanatory comment.
28 int count = [_chromeDownloadURLs count];
29 for (int i = 0; i < count; i++) {
30 NSString *fullFilename = [[_chromeDownloadURLs objectAtIndex:i]
31 stringByAppendingString: _filename];
32 [_chromeDownloadURLs replaceObjectAtIndex:i withObject: fullFilename];
33 }
34 }
35
36 - (void)parser:(NSXMLParser *)parser
Elly Fong-Jones 2016/06/24 17:26:02 This should have a comment remarking that it's par
37 didStartElement:(NSString *)elementName
38 namespaceURI:(NSString *)namespaceURI
39 qualifiedName:(NSString *)qName
40 attributes:(NSDictionary *)attributeDict {
41 if ([elementName isEqualToString:@"url"]) {
42 NSString *extractedURL = [attributeDict objectForKey:@"codebase"];
43 [_chromeDownloadURLs addObject: extractedURL];
44 }
45 if ([elementName isEqualToString:@"package"]) {
46 _filename = [attributeDict objectForKey:@"name"];
47 }
48 }
49
50 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698