diff options
-rw-r--r-- | base/base_paths_mac.mm | 19 | ||||
-rw-r--r-- | chrome/common/chrome_paths_mac.mm | 20 |
2 files changed, 21 insertions, 18 deletions
diff --git a/base/base_paths_mac.mm b/base/base_paths_mac.mm index 394a588..cd0287c 100644 --- a/base/base_paths_mac.mm +++ b/base/base_paths_mac.mm @@ -19,21 +19,10 @@ bool PathProviderMac(int key, FilePath* result) { switch (key) { case base::FILE_EXE: case base::FILE_MODULE: { - NSString* path = [[NSBundle mainBundle] executablePath]; - cur = [path fileSystemRepresentation]; - break; - } - case base::DIR_APP_DATA: - case base::DIR_LOCAL_APP_DATA: { - // TODO(erikkay): maybe we should remove one of these for mac? The local - // vs. roaming distinction is fairly Windows-specific. - NSArray* dirs = NSSearchPathForDirectoriesInDomains( - NSApplicationSupportDirectory, NSUserDomainMask, YES); - if (!dirs || [dirs count] == 0) - return false; - DCHECK([dirs count] == 1); - NSString* tail = [[NSString alloc] initWithCString:"Google/Chrome"]; - NSString* path = [[dirs lastObject] stringByAppendingPathComponent:tail]; + // Executable path can have relative references ("..") depending on + // how the app was launched. + NSString* path = + [[[NSBundle mainBundle] executablePath] stringByStandardizingPath]; cur = [path fileSystemRepresentation]; break; } diff --git a/chrome/common/chrome_paths_mac.mm b/chrome/common/chrome_paths_mac.mm index e8e8f92..f4ad3d5 100644 --- a/chrome/common/chrome_paths_mac.mm +++ b/chrome/common/chrome_paths_mac.mm @@ -14,9 +14,23 @@ namespace chrome { bool GetDefaultUserDataDirectory(FilePath* result) { - if (!PathService::Get(base::DIR_LOCAL_APP_DATA, result)) - return false; - return true; + bool success = false; + NSArray* dirs = + NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, + NSUserDomainMask, YES); + if ([dirs count] && result) { + NSString* base = [dirs objectAtIndex:0]; +#if defined(GOOGLE_CHROME_BUILD) + base = [base stringByAppendingPathComponent@"Google"]; + NSString* tail = @"Chrome"; +#else + NSString* tail = @"Chromium"; +#endif + NSString* path = [base stringByAppendingPathComponent:tail]; + *result = FilePath([path fileSystemRepresentation]); + success = true; + } + return success; } bool GetUserDocumentsDirectory(FilePath* result) { |