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

Side by Side Diff: base/base_paths_mac.mm

Issue 10910209: Add new PathService paths for Windows' All Users Desktop and Quick Launch folders. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Try to fix git cl upload Created 8 years, 3 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/base_paths_mac.h" 5 // Defines base::PathProviderMac which replaces base::PathProviderPosix for
6 // OS_MAXOSX in base/path_service.cc.
6 7
7 #include <dlfcn.h> 8 #include <dlfcn.h>
8 #import <Foundation/Foundation.h> 9 #import <Foundation/Foundation.h>
9 #include <mach-o/dyld.h> 10 #include <mach-o/dyld.h>
10 11
12 #include "base/base_paths.h"
11 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
12 #include "base/file_path.h" 14 #include "base/file_path.h"
13 #include "base/file_util.h" 15 #include "base/file_util.h"
14 #include "base/logging.h" 16 #include "base/logging.h"
15 #include "base/mac/foundation_util.h" 17 #include "base/mac/foundation_util.h"
16 #include "base/path_service.h" 18 #include "base/path_service.h"
17 #include "base/string_util.h" 19 #include "base/string_util.h"
18 20
19 namespace { 21 namespace {
20 22
(...skipping 29 matching lines...) Expand all
50 namespace base { 52 namespace base {
51 53
52 bool PathProviderMac(int key, FilePath* result) { 54 bool PathProviderMac(int key, FilePath* result) {
53 switch (key) { 55 switch (key) {
54 case base::FILE_EXE: 56 case base::FILE_EXE:
55 GetNSExecutablePath(result); 57 GetNSExecutablePath(result);
56 return true; 58 return true;
57 case base::FILE_MODULE: 59 case base::FILE_MODULE:
58 return GetModulePathForAddress(result, 60 return GetModulePathForAddress(result,
59 reinterpret_cast<const void*>(&base::PathProviderMac)); 61 reinterpret_cast<const void*>(&base::PathProviderMac));
60 case base::DIR_CACHE:
61 return base::mac::GetUserDirectory(NSCachesDirectory, result);
62 case base::DIR_APP_DATA: { 62 case base::DIR_APP_DATA: {
63 bool success = base::mac::GetUserDirectory(NSApplicationSupportDirectory, 63 bool success = base::mac::GetUserDirectory(NSApplicationSupportDirectory,
64 result); 64 result);
65 #if defined(OS_IOS) 65 #if defined(OS_IOS)
66 // On IOS, this directory does not exist unless it is created explicitly. 66 // On IOS, this directory does not exist unless it is created explicitly.
67 if (success && !file_util::PathExists(*result)) 67 if (success && !file_util::PathExists(*result))
68 success = file_util::CreateDirectory(*result); 68 success = file_util::CreateDirectory(*result);
69 #endif // defined(OS_IOS) 69 #endif // defined(OS_IOS)
70 return success; 70 return success;
71 } 71 }
(...skipping 12 matching lines...) Expand all
84 // src/xcodebuild/{Debug|Release}/Chromium.app/Contents/MacOS/Chromium 84 // src/xcodebuild/{Debug|Release}/Chromium.app/Contents/MacOS/Chromium
85 *result = result->DirName().DirName().DirName().DirName().DirName(); 85 *result = result->DirName().DirName().DirName().DirName().DirName();
86 } else { 86 } else {
87 // Unit tests execute two levels deep from the source root, eg: 87 // Unit tests execute two levels deep from the source root, eg:
88 // src/xcodebuild/{Debug|Release}/base_unittests 88 // src/xcodebuild/{Debug|Release}/base_unittests
89 *result = result->DirName().DirName(); 89 *result = result->DirName().DirName();
90 } 90 }
91 #endif 91 #endif
92 return true; 92 return true;
93 } 93 }
94 case base::DIR_USER_DESKTOP: {
95 return base::mac::GetUserDirectory(NSDesktopDirectory, result);
96 }
97 case base::DIR_CACHE:
brettw 2012/09/14 22:10:06 I'd use {} here to be more in-line with the surrou
gab 2012/09/16 03:13:51 Done (and made the file uniformly respect this syn
98 return base::mac::GetUserDirectory(NSCachesDirectory, result);
94 case base::DIR_HOME: { 99 case base::DIR_HOME: {
95 *result = base::mac::NSStringToFilePath(NSHomeDirectory()); 100 *result = base::mac::NSStringToFilePath(NSHomeDirectory());
96 return true; 101 return true;
97 } 102 }
98 default: 103 default:
99 return false; 104 return false;
100 } 105 }
101 } 106 }
102 107
103 } // namespace base 108 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698