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

Unified Diff: chrome/installer/mac/app/downloader.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/downloader.m
diff --git a/chrome/installer/mac/app/downloader.m b/chrome/installer/mac/app/downloader.m
new file mode 100644
index 0000000000000000000000000000000000000000..c7fca4a4d4fc54232ef680ee3d76e620036ecd57
--- /dev/null
+++ b/chrome/installer/mac/app/downloader.m
@@ -0,0 +1,41 @@
+// 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 <Foundation/Foundation.h>
+#import "downloader.h"
+#import "parser.h"
+
+NSURL* getChromeImageURL(NSData* someData) {
+ Parser *parser = [[Parser alloc] init];
+ [parser parseXML:someData];
+ [parser appendFilenameToURL];
+
+ NSArray *downloadLinks = [NSArray arrayWithArray: parser.chromeDownloadURLs];
Elly Fong-Jones 2016/06/24 17:26:01 no space after colon
+ NSString *chromeURLString = [downloadLinks firstObject];
Elly Fong-Jones 2016/06/24 17:26:01 can downloadLinks ever be empty? What if parser fa
+
+ return [NSURL URLWithString: chromeURLString];
+}
+
+NSData* downloadChromeAsData(NSURL* chromeURL) {
+ return [NSData dataWithContentsOfURL:chromeURL];
Elly Fong-Jones 2016/06/24 17:26:01 [NSData dataWithContentsOfURL:] will do the entire
+}
+
+NSString* getDownloadsFilePath() {
+ NSArray *downloadPaths = NSSearchPathForDirectoriesInDomains(
+ NSDownloadsDirectory, NSUserDomainMask, YES);
+ NSString *downloadDirectory = [downloadPaths objectAtIndex:0];
+ NSString *filePath = [NSString stringWithFormat:@"%@/%@",
+ downloadDirectory, @"GoogleChrome.dmg"];
Elly Fong-Jones 2016/06/24 17:26:01 I think it would be nicer to use [NSString pathWit
+ return filePath;
+}
+
+void writeDataToDisk(NSData* topSecretData) {
Elly Fong-Jones 2016/06/24 17:26:01 is it really top secret? :)
+ if (topSecretData) {
+ NSString *filePath = getDownloadsFilePath();
+ [topSecretData writeToFile:filePath atomically:YES];
+ NSLog(@"File was downloaded to %@.", filePath);
+ } else {
+ NSLog(@"Error downloading file.");
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698