OLD | NEW |
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 // Defines base::PathProviderMac which replaces base::PathProviderPosix for Mac | 5 // Defines base::PathProviderMac which replaces base::PathProviderPosix for Mac |
6 // in base/path_service.cc. | 6 // in base/path_service.cc. |
7 | 7 |
8 #include <dlfcn.h> | 8 #include <dlfcn.h> |
9 #import <Foundation/Foundation.h> | 9 #import <Foundation/Foundation.h> |
10 #include <mach-o/dyld.h> | 10 #include <mach-o/dyld.h> |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 // The bundled app executables (Chromium, TestShell, etc) live five | 83 // The bundled app executables (Chromium, TestShell, etc) live five |
84 // levels down, eg: | 84 // levels down, eg: |
85 // src/xcodebuild/{Debug|Release}/Chromium.app/Contents/MacOS/Chromium | 85 // src/xcodebuild/{Debug|Release}/Chromium.app/Contents/MacOS/Chromium |
86 *result = result->DirName().DirName().DirName().DirName().DirName(); | 86 *result = result->DirName().DirName().DirName().DirName().DirName(); |
87 } else { | 87 } else { |
88 // Unit tests execute two levels deep from the source root, eg: | 88 // Unit tests execute two levels deep from the source root, eg: |
89 // src/xcodebuild/{Debug|Release}/base_unittests | 89 // src/xcodebuild/{Debug|Release}/base_unittests |
90 *result = result->DirName().DirName(); | 90 *result = result->DirName().DirName(); |
91 } | 91 } |
92 #endif | 92 #endif |
93 if (result->ReferencesParent()) { | |
94 return file_util::AbsolutePath(result); | |
95 } | |
96 return true; | 93 return true; |
97 case base::DIR_USER_DESKTOP: | 94 case base::DIR_USER_DESKTOP: |
98 #if defined(OS_IOS) | 95 #if defined(OS_IOS) |
99 // iOS does not have desktop directories. | 96 // iOS does not have desktop directories. |
100 NOTIMPLEMENTED(); | 97 NOTIMPLEMENTED(); |
101 return false; | 98 return false; |
102 #else | 99 #else |
103 return base::mac::GetUserDirectory(NSDesktopDirectory, result); | 100 return base::mac::GetUserDirectory(NSDesktopDirectory, result); |
104 #endif | 101 #endif |
105 case base::DIR_CACHE: | 102 case base::DIR_CACHE: |
106 return base::mac::GetUserDirectory(NSCachesDirectory, result); | 103 return base::mac::GetUserDirectory(NSCachesDirectory, result); |
107 case base::DIR_HOME: | 104 case base::DIR_HOME: |
108 *result = base::mac::NSStringToFilePath(NSHomeDirectory()); | 105 *result = base::mac::NSStringToFilePath(NSHomeDirectory()); |
109 return true; | 106 return true; |
110 default: | 107 default: |
111 return false; | 108 return false; |
112 } | 109 } |
113 } | 110 } |
114 | 111 |
115 } // namespace base | 112 } // namespace base |
OLD | NEW |