Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
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
3 // found in the LICENSE file.
5 #include "base/base_paths_mac.h"
7 #import <Cocoa/Cocoa.h>
9 #include "base/file_path.h"
10 #include "base/file_util.h"
11 #include "base/logging.h"
12 #include "base/mac_util.h"
13 #include "base/path_service.h"
14 #include "base/string_util.h"
16 namespace base {
18 bool PathProviderMac(int key, FilePath* result) {
19 std::string cur;
20 switch (key) {
21 case base::FILE_EXE:
22 case base::FILE_MODULE: {
23 // Executable path can have relative references ("..") depending on
24 // how the app was launched.
25 NSString* path =
26 [[[NSBundle mainBundle] executablePath] stringByStandardizingPath];
27 cur = [path fileSystemRepresentation];
28 break;
29 }
30 case base::DIR_SOURCE_ROOT: {
31 FilePath path;
32 PathService::Get(base::DIR_EXE, &path);
33 if (mac_util::AmIBundled()) {
34 // The bundled app executables (Chromium, TestShell, etc) live five
35 // levels down, eg:
36 // src/xcodebuild/{Debug|Release}/Chromium.app/Contents/MacOS/Chromium.
37 path = path.DirName();
38 path = path.DirName();
39 path = path.DirName();
40 path = path.DirName();
41 *result = path.DirName();
42 } else {
43 // Unit tests execute two levels deep from the source root, eg:
44 // src/xcodebuild/{Debug|Release}/base_unittests
45 path = path.DirName();
46 *result = path.DirName();
47 }
48 return true;
49 }
50 default:
51 return false;
52 }
54 *result = FilePath(cur);
55 return true;
56 }
58 } // namespace base