| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/shell/app/shell_main_delegate.h" | 5 #include "extensions/shell/app/shell_main_delegate.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| 11 #include "content/public/browser/browser_main_runner.h" | 11 #include "content/public/browser/browser_main_runner.h" |
| 12 #include "content/public/common/content_switches.h" | 12 #include "content/public/common/content_switches.h" |
| 13 #include "extensions/common/extension_paths.h" | 13 #include "extensions/common/extension_paths.h" |
| 14 #include "extensions/shell/browser/default_shell_browser_main_delegate.h" | 14 #include "extensions/shell/browser/default_shell_browser_main_delegate.h" |
| 15 #include "extensions/shell/browser/shell_content_browser_client.h" | 15 #include "extensions/shell/browser/shell_content_browser_client.h" |
| 16 #include "extensions/shell/common/shell_content_client.h" | 16 #include "extensions/shell/common/shell_content_client.h" |
| 17 #include "extensions/shell/renderer/shell_content_renderer_client.h" | 17 #include "extensions/shell/renderer/shell_content_renderer_client.h" |
| 18 #include "extensions/shell/utility/shell_content_utility_client.h" | 18 #include "extensions/shell/utility/shell_content_utility_client.h" |
| 19 #include "ui/base/resource/resource_bundle.h" | 19 #include "ui/base/resource/resource_bundle.h" |
| 20 | 20 |
| 21 #if defined(OS_CHROMEOS) | 21 #if defined(OS_CHROMEOS) |
| 22 #include "chromeos/chromeos_paths.h" | 22 #include "chromeos/chromeos_paths.h" |
| 23 #endif | 23 #endif |
| 24 | 24 |
| 25 #if defined(OS_MACOSX) |
| 26 #include "base/mac/foundation_util.h" |
| 27 #include "extensions/shell/app/paths_mac.h" |
| 28 #endif |
| 29 |
| 25 #if !defined(DISABLE_NACL) | 30 #if !defined(DISABLE_NACL) |
| 26 #include "components/nacl/common/nacl_switches.h" | 31 #include "components/nacl/common/nacl_switches.h" |
| 27 #if defined(OS_LINUX) | 32 #if defined(OS_LINUX) |
| 28 #include "components/nacl/common/nacl_paths.h" | 33 #include "components/nacl/common/nacl_paths.h" |
| 29 #endif // OS_LINUX | 34 #endif // OS_LINUX |
| 30 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) | 35 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) |
| 31 #include "components/nacl/zygote/nacl_fork_delegate_linux.h" | 36 #include "components/nacl/zygote/nacl_fork_delegate_linux.h" |
| 32 #endif // OS_POSIX && !OS_MACOSX && !OS_ANDROID | 37 #endif // OS_POSIX && !OS_MACOSX && !OS_ANDROID |
| 33 #endif // !DISABLE_NACL | 38 #endif // !DISABLE_NACL |
| 34 | 39 |
| 35 namespace { | 40 namespace { |
| 36 | 41 |
| 37 void InitLogging() { | 42 void InitLogging() { |
| 38 base::FilePath log_filename; | 43 base::FilePath log_filename; |
| 39 PathService::Get(base::DIR_EXE, &log_filename); | 44 PathService::Get(base::DIR_EXE, &log_filename); |
| 40 log_filename = log_filename.AppendASCII("app_shell.log"); | 45 log_filename = log_filename.AppendASCII("app_shell.log"); |
| 41 logging::LoggingSettings settings; | 46 logging::LoggingSettings settings; |
| 42 settings.logging_dest = logging::LOG_TO_ALL; | 47 settings.logging_dest = logging::LOG_TO_ALL; |
| 43 settings.log_file = log_filename.value().c_str(); | 48 settings.log_file = log_filename.value().c_str(); |
| 44 settings.delete_old = logging::DELETE_OLD_LOG_FILE; | 49 settings.delete_old = logging::DELETE_OLD_LOG_FILE; |
| 45 logging::InitLogging(settings); | 50 logging::InitLogging(settings); |
| 46 logging::SetLogItems(true, true, true, true); | 51 logging::SetLogItems(true, true, true, true); |
| 47 } | 52 } |
| 48 | 53 |
| 54 // Returns the path to the extensions_shell_and_test.pak file. |
| 55 base::FilePath GetResourcesPakFilePath() { |
| 56 #if defined(OS_MACOSX) |
| 57 return base::mac::PathForFrameworkBundleResource( |
| 58 CFSTR("extensions_shell_and_test.pak")); |
| 59 #else |
| 60 base::FilePath extensions_shell_and_test_pak_path; |
| 61 PathService::Get(base::DIR_MODULE, &extensions_shell_and_test_pak_path); |
| 62 extensions_shell_and_test_pak_path = |
| 63 extensions_shell_and_test_pak_path.AppendASCII( |
| 64 "extensions_shell_and_test.pak"); |
| 65 return extensions_shell_and_test_pak_path; |
| 66 #endif // OS_MACOSX |
| 67 } |
| 68 |
| 49 } // namespace | 69 } // namespace |
| 50 | 70 |
| 51 namespace extensions { | 71 namespace extensions { |
| 52 | 72 |
| 53 ShellMainDelegate::ShellMainDelegate() { | 73 ShellMainDelegate::ShellMainDelegate() { |
| 54 } | 74 } |
| 55 | 75 |
| 56 ShellMainDelegate::~ShellMainDelegate() { | 76 ShellMainDelegate::~ShellMainDelegate() { |
| 57 } | 77 } |
| 58 | 78 |
| 59 bool ShellMainDelegate::BasicStartupComplete(int* exit_code) { | 79 bool ShellMainDelegate::BasicStartupComplete(int* exit_code) { |
| 60 InitLogging(); | 80 InitLogging(); |
| 61 content_client_.reset(CreateContentClient()); | 81 content_client_.reset(CreateContentClient()); |
| 62 SetContentClient(content_client_.get()); | 82 SetContentClient(content_client_.get()); |
| 63 | 83 |
| 84 #if defined(OS_MACOSX) |
| 85 OverrideChildProcessFilePath(); |
| 86 // This must happen before InitializeResourceBundle. |
| 87 OverrideFrameworkBundlePath(); |
| 88 #endif |
| 89 |
| 64 #if defined(OS_CHROMEOS) | 90 #if defined(OS_CHROMEOS) |
| 65 chromeos::RegisterPathProvider(); | 91 chromeos::RegisterPathProvider(); |
| 66 #endif | 92 #endif |
| 67 #if !defined(DISABLE_NACL) && defined(OS_LINUX) | 93 #if !defined(DISABLE_NACL) && defined(OS_LINUX) |
| 68 nacl::RegisterPathProvider(); | 94 nacl::RegisterPathProvider(); |
| 69 #endif | 95 #endif |
| 70 extensions::RegisterPathProvider(); | 96 extensions::RegisterPathProvider(); |
| 71 return false; | 97 return false; |
| 72 } | 98 } |
| 73 | 99 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 ShellMainDelegate::CreateShellContentRendererClient() { | 143 ShellMainDelegate::CreateShellContentRendererClient() { |
| 118 return new ShellContentRendererClient(); | 144 return new ShellContentRendererClient(); |
| 119 } | 145 } |
| 120 | 146 |
| 121 content::ContentUtilityClient* | 147 content::ContentUtilityClient* |
| 122 ShellMainDelegate::CreateShellContentUtilityClient() { | 148 ShellMainDelegate::CreateShellContentUtilityClient() { |
| 123 return new ShellContentUtilityClient(); | 149 return new ShellContentUtilityClient(); |
| 124 } | 150 } |
| 125 | 151 |
| 126 void ShellMainDelegate::InitializeResourceBundle() { | 152 void ShellMainDelegate::InitializeResourceBundle() { |
| 127 base::FilePath extensions_shell_and_test_pak_path; | |
| 128 PathService::Get(base::DIR_MODULE, &extensions_shell_and_test_pak_path); | |
| 129 ui::ResourceBundle::InitSharedInstanceWithPakPath( | 153 ui::ResourceBundle::InitSharedInstanceWithPakPath( |
| 130 extensions_shell_and_test_pak_path.AppendASCII( | 154 GetResourcesPakFilePath()); |
| 131 "extensions_shell_and_test.pak")); | |
| 132 } | 155 } |
| 133 | 156 |
| 134 // static | 157 // static |
| 135 bool ShellMainDelegate::ProcessNeedsResourceBundle( | 158 bool ShellMainDelegate::ProcessNeedsResourceBundle( |
| 136 const std::string& process_type) { | 159 const std::string& process_type) { |
| 137 // The browser process has no process type flag, but needs resources. | 160 // The browser process has no process type flag, but needs resources. |
| 138 // On Linux the zygote process opens the resources for the renderers. | 161 // On Linux the zygote process opens the resources for the renderers. |
| 139 return process_type.empty() || | 162 return process_type.empty() || |
| 140 process_type == switches::kZygoteProcess || | 163 process_type == switches::kZygoteProcess || |
| 141 process_type == switches::kRendererProcess || | 164 process_type == switches::kRendererProcess || |
| 142 #if !defined(DISABLE_NACL) | 165 #if !defined(DISABLE_NACL) |
| 143 process_type == switches::kNaClLoaderProcess || | 166 process_type == switches::kNaClLoaderProcess || |
| 144 #endif | 167 #endif |
| 145 #if defined(OS_MACOSX) | 168 #if defined(OS_MACOSX) |
| 146 process_type == switches::kGpuProcess || | 169 process_type == switches::kGpuProcess || |
| 147 #endif | 170 #endif |
| 148 process_type == switches::kUtilityProcess; | 171 process_type == switches::kUtilityProcess; |
| 149 } | 172 } |
| 150 | 173 |
| 151 } // namespace extensions | 174 } // namespace extensions |
| OLD | NEW |