1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/ipc/chromium/src/base/base_paths_mac.mm Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,58 @@ 1.4 +// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1.5 +// Use of this source code is governed by a BSD-style license that can be 1.6 +// found in the LICENSE file. 1.7 + 1.8 +#include "base/base_paths_mac.h" 1.9 + 1.10 +#import <Cocoa/Cocoa.h> 1.11 + 1.12 +#include "base/file_path.h" 1.13 +#include "base/file_util.h" 1.14 +#include "base/logging.h" 1.15 +#include "base/mac_util.h" 1.16 +#include "base/path_service.h" 1.17 +#include "base/string_util.h" 1.18 + 1.19 +namespace base { 1.20 + 1.21 +bool PathProviderMac(int key, FilePath* result) { 1.22 + std::string cur; 1.23 + switch (key) { 1.24 + case base::FILE_EXE: 1.25 + case base::FILE_MODULE: { 1.26 + // Executable path can have relative references ("..") depending on 1.27 + // how the app was launched. 1.28 + NSString* path = 1.29 + [[[NSBundle mainBundle] executablePath] stringByStandardizingPath]; 1.30 + cur = [path fileSystemRepresentation]; 1.31 + break; 1.32 + } 1.33 + case base::DIR_SOURCE_ROOT: { 1.34 + FilePath path; 1.35 + PathService::Get(base::DIR_EXE, &path); 1.36 + if (mac_util::AmIBundled()) { 1.37 + // The bundled app executables (Chromium, TestShell, etc) live five 1.38 + // levels down, eg: 1.39 + // src/xcodebuild/{Debug|Release}/Chromium.app/Contents/MacOS/Chromium. 1.40 + path = path.DirName(); 1.41 + path = path.DirName(); 1.42 + path = path.DirName(); 1.43 + path = path.DirName(); 1.44 + *result = path.DirName(); 1.45 + } else { 1.46 + // Unit tests execute two levels deep from the source root, eg: 1.47 + // src/xcodebuild/{Debug|Release}/base_unittests 1.48 + path = path.DirName(); 1.49 + *result = path.DirName(); 1.50 + } 1.51 + return true; 1.52 + } 1.53 + default: 1.54 + return false; 1.55 + } 1.56 + 1.57 + *result = FilePath(cur); 1.58 + return true; 1.59 +} 1.60 + 1.61 +} // namespace base