Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
|
Yoyo Zhou
2014/12/10 02:18:19
This is very similar to content/shell/app/paths_ma
| |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "extensions/shell/app/paths_mac.h" | |
| 6 | |
| 7 #include "base/files/file_path.h" | |
| 8 #include "base/logging.h" | |
| 9 #include "base/path_service.h" | |
| 10 #include "base/mac/bundle_locations.h" | |
| 11 #include "base/mac/foundation_util.h" | |
| 12 #include "content/public/common/content_paths.h" | |
| 13 | |
| 14 namespace extensions { | |
| 15 | |
| 16 namespace { | |
| 17 | |
| 18 base::FilePath GetFrameworksPath() { | |
| 19 base::FilePath path; | |
| 20 PathService::Get(base::FILE_EXE, &path); | |
| 21 // We now have a path .../App Shell.app/Contents/MacOS/App Shell, and want to | |
| 22 // transform it into \ | |
| 23 // .../App Shell.app/Contents/Frameworks/App Shell Framework.framework. | |
| 24 // But if it's App Shell Helper.app (inside Frameworks), we must go deeper. | |
| 25 if (base::mac::IsBackgroundOnlyProcess()) { | |
| 26 path = path.DirName().DirName().DirName().DirName().DirName(); | |
| 27 } else { | |
| 28 path = path.DirName().DirName(); | |
| 29 } | |
| 30 DCHECK_EQ("Contents", path.BaseName().value()); | |
| 31 path = path.Append("Frameworks"); | |
| 32 return path; | |
| 33 } | |
| 34 | |
| 35 } // namespace | |
| 36 | |
| 37 void OverrideFrameworkBundlePath() { | |
| 38 base::FilePath path = | |
| 39 GetFrameworksPath().Append("App Shell Framework.framework"); | |
| 40 base::mac::SetOverrideFrameworkBundlePath(path); | |
| 41 } | |
| 42 | |
| 43 void OverrideChildProcessFilePath() { | |
| 44 base::FilePath path = GetFrameworksPath() | |
| 45 .Append("App Shell Helper.app") | |
| 46 .Append("Contents") | |
| 47 .Append("MacOS") | |
| 48 .Append("App Shell Helper"); | |
| 49 PathService::Override(content::CHILD_PROCESS_EXE, path); | |
| 50 } | |
| 51 | |
| 52 base::FilePath GetResourcesPakFilePath() { | |
| 53 return base::mac::PathForFrameworkBundleResource( | |
| 54 CFSTR("extensions_shell_and_test.pak")); | |
| 55 } | |
| 56 | |
| 57 } // namespace extensions | |
| OLD | NEW |