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

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: Fully addressed making the .dmg download asynchronously 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 - (void)parseXML{
27 if (omahaResponseXML_) {
28 NSXMLParser* parser = [[NSXMLParser alloc] initWithData:omahaResponseXML_];
29 [parser setDelegate:self];
30 [parser parse];
31 } else {
32 // TODO: error handler
33 }
34 }
35
36 // Method implementation for XMLParserDelegate.
37 // Searches the XML data for the tag "URL" and the subsequent "codebase"
38 // attribute that indicates a URL follows. Copies each URL into an array.
39 // Note that the URLs in the XML file are incomplete. They need the filename
40 // appended to end. The second if statement checks for the tag "package" which
41 // contains the filename we need to complete the URLs.
42 - (void)parser:(NSXMLParser*)parser
43 didStartElement:(NSString*)elementName
44 namespaceURI:(NSString*)namespaceURI
45 qualifiedName:(NSString*)qName
46 attributes:(NSDictionary*)attributeDict {
47 if ([elementName isEqualToString:@"url"]) {
48 if (!chromeIncompleteDownloadURLs_) {
49 chromeIncompleteDownloadURLs_ = [[NSMutableArray alloc] init];
50 }
51 NSString* extractedURL = [attributeDict objectForKey:@"codebase"];
52 [chromeIncompleteDownloadURLs_ addObject: extractedURL];
53 }
54 if ([elementName isEqualToString:@"package"]) {
55 chromeImageFilename_ = [[NSString alloc] initWithFormat:@"%@",
56 [attributeDict objectForKey:@"name"]];
57 }
58 }
59
60 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698