| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/shell/shell_main_delegate.h" | 5 #include "content/shell/shell_main_delegate.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "content/public/common/content_paths.h" |
| 10 #include "content/public/common/content_switches.h" | 11 #include "content/public/common/content_switches.h" |
| 11 #include "content/shell/shell_content_browser_client.h" | 12 #include "content/shell/shell_content_browser_client.h" |
| 12 #include "content/shell/shell_content_plugin_client.h" | 13 #include "content/shell/shell_content_plugin_client.h" |
| 13 #include "content/shell/shell_content_renderer_client.h" | 14 #include "content/shell/shell_content_renderer_client.h" |
| 14 #include "content/shell/shell_content_utility_client.h" | 15 #include "content/shell/shell_content_utility_client.h" |
| 15 #include "content/shell/shell_render_process_observer.h" | 16 #include "content/shell/shell_render_process_observer.h" |
| 16 #include "ui/base/resource/resource_bundle.h" | 17 #include "ui/base/resource/resource_bundle.h" |
| 17 #include "ui/base/ui_base_paths.h" | 18 #include "ui/base/ui_base_paths.h" |
| 18 | 19 |
| 20 #if defined(OS_MACOSX) |
| 21 #include "base/mac/foundation_util.h" |
| 22 #endif |
| 23 |
| 24 #if defined(OS_MACOSX) |
| 25 namespace { |
| 26 |
| 27 void OverrideChildProcessPath() { |
| 28 if (base::mac::IsBackgroundOnlyProcess()) { |
| 29 // The background-only process is the helper; no overriding needed. |
| 30 return; |
| 31 } |
| 32 |
| 33 // Start out with the path to the running executable. |
| 34 FilePath helper_path; |
| 35 PathService::Get(base::FILE_EXE, &helper_path); |
| 36 |
| 37 // One step up to MacOS, another to Contents. |
| 38 helper_path = helper_path.DirName().DirName(); |
| 39 DCHECK_EQ(helper_path.BaseName().value(), "Contents"); |
| 40 |
| 41 // Go into the frameworks directory. |
| 42 helper_path = helper_path.Append("Frameworks"); |
| 43 |
| 44 // And the app path. |
| 45 helper_path = helper_path.Append("Content Shell Helper.app") |
| 46 .Append("Contents") |
| 47 .Append("MacOS") |
| 48 .Append("Content Shell Helper"); |
| 49 |
| 50 PathService::Override(content::CHILD_PROCESS_EXE, helper_path); |
| 51 } |
| 52 |
| 53 } |
| 54 #endif // OS_MACOSX |
| 55 |
| 19 ShellMainDelegate::ShellMainDelegate() { | 56 ShellMainDelegate::ShellMainDelegate() { |
| 20 } | 57 } |
| 21 | 58 |
| 22 ShellMainDelegate::~ShellMainDelegate() { | 59 ShellMainDelegate::~ShellMainDelegate() { |
| 23 } | 60 } |
| 24 | 61 |
| 25 bool ShellMainDelegate::BasicStartupComplete(int* exit_code) { | 62 bool ShellMainDelegate::BasicStartupComplete(int* exit_code) { |
| 26 return false; | 63 return false; |
| 27 } | 64 } |
| 28 | 65 |
| 29 void ShellMainDelegate::PreSandboxStartup() { | 66 void ShellMainDelegate::PreSandboxStartup() { |
| 67 #if defined(OS_MACOSX) |
| 68 OverrideChildProcessPath(); |
| 69 #endif // OS_MACOSX |
| 70 |
| 30 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 71 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 31 std::string process_type = | 72 std::string process_type = |
| 32 command_line.GetSwitchValueASCII(switches::kProcessType); | 73 command_line.GetSwitchValueASCII(switches::kProcessType); |
| 33 | 74 |
| 34 content::SetContentClient(&content_client_); | 75 content::SetContentClient(&content_client_); |
| 35 InitializeShellContentClient(process_type); | 76 InitializeShellContentClient(process_type); |
| 36 | 77 |
| 37 InitializeResourceBundle(); | 78 InitializeResourceBundle(); |
| 38 } | 79 } |
| 39 | 80 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 } | 135 } |
| 95 } | 136 } |
| 96 | 137 |
| 97 void ShellMainDelegate::InitializeResourceBundle() { | 138 void ShellMainDelegate::InitializeResourceBundle() { |
| 98 FilePath pak_dir; | 139 FilePath pak_dir; |
| 99 PathService::Get(base::DIR_MODULE, &pak_dir); | 140 PathService::Get(base::DIR_MODULE, &pak_dir); |
| 100 | 141 |
| 101 FilePath pak_file = pak_dir.Append(FILE_PATH_LITERAL("content_shell.pak")); | 142 FilePath pak_file = pak_dir.Append(FILE_PATH_LITERAL("content_shell.pak")); |
| 102 ui::ResourceBundle::InitSharedInstanceWithPakFile(pak_file); | 143 ui::ResourceBundle::InitSharedInstanceWithPakFile(pak_file); |
| 103 } | 144 } |
| OLD | NEW |