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

Side by Side Diff: chrome/installer/mac/app/OmahaXMLParser.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 unified diff | Download patch
« no previous file with comments | « chrome/installer/mac/app/OmahaXMLParser.h ('k') | chrome/installer/mac/app/OmahaXMLRequest.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "OmahaXMLParser.h"
6
7 @implementation OmahaXMLParser
8
9 - (NSMutableArray*)chromeIncompleteDownloadURLs {
10 return chromeIncompleteDownloadURLs_;
11 }
12
13 - (NSString*)chromeImageFilename {
14 return chromeImageFilename_;
15 }
16
17 // Sets up instance of NSXMLParser and calls on delegate methods to do actual
18 // parsing work.
19 - (NSArray*)parseXML:(NSData*)omahaResponseXML error:(NSError**)error {
20 NSXMLParser* parser = [[NSXMLParser alloc] initWithData:omahaResponseXML];
21 [parser setDelegate:self];
22 BOOL success = [parser parse];
23 if (!success) {
24 *error = [parser parserError];
25 }
26
27 return chromeIncompleteDownloadURLs_;
28 }
29
30 // Method implementation for XMLParserDelegate.
31 // Searches the XML data for the tag "URL" and the subsequent "codebase"
32 // attribute that indicates a URL follows. Copies each URL into an array.
33 // Note that the URLs in the XML file are incomplete. They need the filename
34 // appended to end. The second if statement checks for the tag "package" which
35 // contains the filename we need to complete the URLs.
36 - (void)parser:(NSXMLParser*)parser
37 didStartElement:(NSString*)elementName
38 namespaceURI:(NSString*)namespaceURI
39 qualifiedName:(NSString*)qName
40 attributes:(NSDictionary*)attributeDict {
41 if ([elementName isEqualToString:@"url"]) {
42 if (!chromeIncompleteDownloadURLs_) {
43 chromeIncompleteDownloadURLs_ = [[NSMutableArray alloc] init];
44 }
45 NSString* extractedURL = [attributeDict objectForKey:@"codebase"];
46 [chromeIncompleteDownloadURLs_ addObject:extractedURL];
47 }
48 if ([elementName isEqualToString:@"package"]) {
49 chromeImageFilename_ = [[NSString alloc]
50 initWithFormat:@"%@", [attributeDict objectForKey:@"name"]];
51 }
52 }
53
54 @end
OLDNEW
« no previous file with comments | « chrome/installer/mac/app/OmahaXMLParser.h ('k') | chrome/installer/mac/app/OmahaXMLRequest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698