ipc/chromium/src/base/base_paths_mac.mm

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
michael@0 2 // Use of this source code is governed by a BSD-style license that can be
michael@0 3 // found in the LICENSE file.
michael@0 4
michael@0 5 #include "base/base_paths_mac.h"
michael@0 6
michael@0 7 #import <Cocoa/Cocoa.h>
michael@0 8
michael@0 9 #include "base/file_path.h"
michael@0 10 #include "base/file_util.h"
michael@0 11 #include "base/logging.h"
michael@0 12 #include "base/mac_util.h"
michael@0 13 #include "base/path_service.h"
michael@0 14 #include "base/string_util.h"
michael@0 15
michael@0 16 namespace base {
michael@0 17
michael@0 18 bool PathProviderMac(int key, FilePath* result) {
michael@0 19 std::string cur;
michael@0 20 switch (key) {
michael@0 21 case base::FILE_EXE:
michael@0 22 case base::FILE_MODULE: {
michael@0 23 // Executable path can have relative references ("..") depending on
michael@0 24 // how the app was launched.
michael@0 25 NSString* path =
michael@0 26 [[[NSBundle mainBundle] executablePath] stringByStandardizingPath];
michael@0 27 cur = [path fileSystemRepresentation];
michael@0 28 break;
michael@0 29 }
michael@0 30 case base::DIR_SOURCE_ROOT: {
michael@0 31 FilePath path;
michael@0 32 PathService::Get(base::DIR_EXE, &path);
michael@0 33 if (mac_util::AmIBundled()) {
michael@0 34 // The bundled app executables (Chromium, TestShell, etc) live five
michael@0 35 // levels down, eg:
michael@0 36 // src/xcodebuild/{Debug|Release}/Chromium.app/Contents/MacOS/Chromium.
michael@0 37 path = path.DirName();
michael@0 38 path = path.DirName();
michael@0 39 path = path.DirName();
michael@0 40 path = path.DirName();
michael@0 41 *result = path.DirName();
michael@0 42 } else {
michael@0 43 // Unit tests execute two levels deep from the source root, eg:
michael@0 44 // src/xcodebuild/{Debug|Release}/base_unittests
michael@0 45 path = path.DirName();
michael@0 46 *result = path.DirName();
michael@0 47 }
michael@0 48 return true;
michael@0 49 }
michael@0 50 default:
michael@0 51 return false;
michael@0 52 }
michael@0 53
michael@0 54 *result = FilePath(cur);
michael@0 55 return true;
michael@0 56 }
michael@0 57
michael@0 58 } // namespace base

mercurial