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

Side by Side Diff: chrome/browser/file_select_helper_mac.mm

Issue 2713293002: Allow $TMPDIR to set temporary directory on OS X. (Closed)
Patch Set: Created 3 years, 9 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 | « base/files/file_util_mac.mm ('k') | remoting/host/mac/me2me_preference_pane.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/file_select_helper.h" 5 #include "chrome/browser/file_select_helper.h"
6 6
7 #include <Cocoa/Cocoa.h> 7 #include <Cocoa/Cocoa.h>
8 #include <sys/stat.h> 8 #include <sys/stat.h>
9 9
10 #include "base/files/file.h" 10 #include "base/files/file.h"
11 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
12 #include "base/files/file_util.h" 12 #include "base/files/file_util.h"
13 #include "base/mac/foundation_util.h" 13 #include "base/mac/foundation_util.h"
14 #include "content/public/browser/browser_thread.h" 14 #include "content/public/browser/browser_thread.h"
15 #include "third_party/zlib/google/zip.h" 15 #include "third_party/zlib/google/zip.h"
16 #include "ui/shell_dialogs/selected_file_info.h" 16 #include "ui/shell_dialogs/selected_file_info.h"
17 17
18 namespace { 18 namespace {
19 19
20 // Given the |path| of a package, returns the destination that the package 20 // Given the |path| of a package, returns the destination that the package
21 // should be zipped to. Returns an empty path on any errors. 21 // should be zipped to. Returns an empty path on any errors.
iannucci 2017/02/24 20:56:01 This comment seems... misleading at best? `path` i
22 base::FilePath ZipDestination(const base::FilePath& path) { 22 base::FilePath ZipDestination(const base::FilePath& path) {
23 NSMutableString* dest = 23 base::FilePath dest;
24 [NSMutableString stringWithString:NSTemporaryDirectory()];
25 24
26 // Couldn't get the temporary directory. 25 if (!base::GetTempDir(dest)) {
27 if (!dest) 26 // Couldn't get the temporary directory.
28 return base::FilePath(); 27 return base::FilePath();
28 }
29 29
30 [dest appendFormat:@"%@/zip_cache/%@", 30 // TMPDIR/<bundleID>/zip_cache/<GUID>
31 [[NSBundle mainBundle] bundleIdentifier],
32 [[NSProcessInfo processInfo] globallyUniqueString]];
33 31
34 return base::mac::NSStringToFilePath(dest); 32 NSString* bundleID = [[NSBundle mainBundle] bundleIdentifier];
33 dest.Append(base::mac::NSStringToString(bundleID))
34
35 dest.Append("zip_cache")
36
37 NSString* GUID = [[NSProcessInfo processInfo] globallyUniqueString];
38 dest.Append(base::mac::NSStringToString(GUID))
39
40 return dest;
35 } 41 }
36 42
37 // Returns the path of the package and its components relative to the package's 43 // Returns the path of the package and its components relative to the package's
38 // parent directory. 44 // parent directory.
39 std::vector<base::FilePath> RelativePathsForPackage( 45 std::vector<base::FilePath> RelativePathsForPackage(
40 const base::FilePath& package) { 46 const base::FilePath& package) {
41 // Get the base directory. 47 // Get the base directory.
42 base::FilePath base_dir = package.DirName(); 48 base::FilePath base_dir = package.DirName();
43 49
44 // Add the package as the first relative path. 50 // Add the package as the first relative path.
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 // need to be deleted now. 137 // need to be deleted now.
132 if (!web_contents_) { 138 if (!web_contents_) {
133 DeleteTemporaryFiles(); 139 DeleteTemporaryFiles();
134 RunFileChooserEnd(); 140 RunFileChooserEnd();
135 return; 141 return;
136 } 142 }
137 } 143 }
138 144
139 NotifyRenderFrameHostAndEnd(files); 145 NotifyRenderFrameHostAndEnd(files);
140 } 146 }
OLDNEW
« no previous file with comments | « base/files/file_util_mac.mm ('k') | remoting/host/mac/me2me_preference_pane.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698