| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 #include "base/base_paths_mac.h" |
| 6 | 6 |
| 7 #import <Foundation/Foundation.h> | 7 #import <Foundation/Foundation.h> |
| 8 #include <mach-o/dyld.h> | 8 #include <mach-o/dyld.h> |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 } // namespace | 40 } // namespace |
| 41 | 41 |
| 42 namespace base { | 42 namespace base { |
| 43 | 43 |
| 44 bool PathProviderMac(int key, FilePath* result) { | 44 bool PathProviderMac(int key, FilePath* result) { |
| 45 switch (key) { | 45 switch (key) { |
| 46 case base::FILE_EXE: | 46 case base::FILE_EXE: |
| 47 case base::FILE_MODULE: { | 47 case base::FILE_MODULE: { |
| 48 return GetNSExecutablePath(result); | 48 return GetNSExecutablePath(result); |
| 49 } | 49 } |
| 50 case base::DIR_CACHE: | 50 case base::DIR_USER_CACHE: |
| 51 return mac_util::GetUserDirectory(NSCachesDirectory, result); | 51 return mac_util::GetUserDirectory(NSCachesDirectory, result); |
| 52 case base::DIR_APP_DATA: | 52 case base::DIR_APP_DATA: |
| 53 return mac_util::GetUserDirectory(NSApplicationSupportDirectory, result); | 53 return mac_util::GetUserDirectory(NSApplicationSupportDirectory, result); |
| 54 case base::DIR_SOURCE_ROOT: { | 54 case base::DIR_SOURCE_ROOT: { |
| 55 // Go through PathService to catch overrides. | 55 // Go through PathService to catch overrides. |
| 56 if (PathService::Get(base::FILE_EXE, result)) { | 56 if (PathService::Get(base::FILE_EXE, result)) { |
| 57 // Start with the executable's directory. | 57 // Start with the executable's directory. |
| 58 *result = result->DirName(); | 58 *result = result->DirName(); |
| 59 if (mac_util::AmIBundled()) { | 59 if (mac_util::AmIBundled()) { |
| 60 // The bundled app executables (Chromium, TestShell, etc) live five | 60 // The bundled app executables (Chromium, TestShell, etc) live five |
| 61 // levels down, eg: | 61 // levels down, eg: |
| 62 // src/xcodebuild/{Debug|Release}/Chromium.app/Contents/MacOS/Chromium | 62 // src/xcodebuild/{Debug|Release}/Chromium.app/Contents/MacOS/Chromium |
| 63 *result = result->DirName().DirName().DirName().DirName().DirName(); | 63 *result = result->DirName().DirName().DirName().DirName().DirName(); |
| 64 } else { | 64 } else { |
| 65 // Unit tests execute two levels deep from the source root, eg: | 65 // Unit tests execute two levels deep from the source root, eg: |
| 66 // src/xcodebuild/{Debug|Release}/base_unittests | 66 // src/xcodebuild/{Debug|Release}/base_unittests |
| 67 *result = result->DirName().DirName(); | 67 *result = result->DirName().DirName(); |
| 68 } | 68 } |
| 69 } | 69 } |
| 70 return true; | 70 return true; |
| 71 } | 71 } |
| 72 default: | 72 default: |
| 73 return false; | 73 return false; |
| 74 } | 74 } |
| 75 } | 75 } |
| 76 | 76 |
| 77 } // namespace base | 77 } // namespace base |
| OLD | NEW |