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

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: Fixed majority of comments excluding refactoring for blocks in main. 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 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)initWithXML:(NSData*)omahaResponseXML{
10 // if ((self = [super init])) {
11 // omahaResponseXML_ = omahaResponseXML;
12 // }
13 // return self;
14 //}
15
16 - (NSMutableArray*)chromeIncompleteDownloadURLs{
17 return chromeIncompleteDownloadURLs_;
18 }
19
20 - (NSString*)chromeImageFilename{
21 return chromeImageFilename_;
22 }
23
24 // Sets up instance of NSXMLParser and calls on delegate methods to do actual
25 // parsing work.
26 - (NSArray*)parseXML:(NSData*)omahaResponseXML error:(NSError**)error{
27
28 NSXMLParser* parser = [[NSXMLParser alloc] initWithData:omahaResponseXML];
29 [parser setDelegate:self];
30 BOOL success = [parser parse];
31 if (!success) {
32 *error = [parser parserError];
33 }
34
35 return chromeIncompleteDownloadURLs_;
36 }
37
38 // Method implementation for XMLParserDelegate.
39 // Searches the XML data for the tag "URL" and the subsequent "codebase"
40 // attribute that indicates a URL follows. Copies each URL into an array.
41 // Note that the URLs in the XML file are incomplete. They need the filename
42 // appended to end. The second if statement checks for the tag "package" which
43 // contains the filename we need to complete the URLs.
44 - (void)parser:(NSXMLParser*)parser
45 didStartElement:(NSString*)elementName
46 namespaceURI:(NSString*)namespaceURI
47 qualifiedName:(NSString*)qName
48 attributes:(NSDictionary*)attributeDict {
49 if ([elementName isEqualToString:@"url"]) {
50 if (!chromeIncompleteDownloadURLs_) {
51 chromeIncompleteDownloadURLs_ = [[NSMutableArray alloc] init];
52 }
53 NSString* extractedURL = [attributeDict objectForKey:@"codebase"];
54 [chromeIncompleteDownloadURLs_ addObject: extractedURL];
55 }
56 if ([elementName isEqualToString:@"package"]) {
57 chromeImageFilename_ = [[NSString alloc] initWithFormat:@"%@",
58 [attributeDict objectForKey:@"name"]];
59 }
60 }
61
62 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698