diff options
author | tc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-04 18:20:17 +0000 |
---|---|---|
committer | tc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-04 18:20:17 +0000 |
commit | 0d5529391070e6d4ad1093f02c4491f2b2854ebf (patch) | |
tree | 7d7f06698657f06d451321e6c73d59cb00cdd3f4 | |
parent | cd115c31a6cddacccb8f4958dd7afb2395d2d674 (diff) | |
download | chromium_src-0d5529391070e6d4ad1093f02c4491f2b2854ebf.zip chromium_src-0d5529391070e6d4ad1093f02c4491f2b2854ebf.tar.gz chromium_src-0d5529391070e6d4ad1093f02c4491f2b2854ebf.tar.bz2 |
Revert "Make chrome/renderer/render_main.cc cross-platform + OS X bringup."
This reverts commit r9141.
TBR=jeremy
Review URL: http://codereview.chromium.org/21049
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9145 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/chrome.xcodeproj/project.pbxproj | 24 | ||||
-rw-r--r-- | chrome/common/resource_bundle.h | 3 | ||||
-rw-r--r-- | chrome/common/sandbox_init_wrapper.cc | 15 | ||||
-rw-r--r-- | chrome/renderer/renderer.vcproj | 8 | ||||
-rw-r--r-- | chrome/renderer/renderer_main.cc | 53 | ||||
-rwxr-xr-x | chrome/renderer/renderer_main_platform_delegate.h | 39 | ||||
-rw-r--r-- | chrome/renderer/renderer_main_platform_delegate_mac.cc | 44 | ||||
-rwxr-xr-x | chrome/renderer/renderer_main_platform_delegate_win.cc | 78 |
8 files changed, 60 insertions, 204 deletions
diff --git a/chrome/chrome.xcodeproj/project.pbxproj b/chrome/chrome.xcodeproj/project.pbxproj index 56566e8..079868c9 100644 --- a/chrome/chrome.xcodeproj/project.pbxproj +++ b/chrome/chrome.xcodeproj/project.pbxproj @@ -247,8 +247,6 @@ B503E1030F017C1000547DC6 /* librenderer.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4D640CEB0EAE86BD00EBCFC0 /* librenderer.a */; }; B507AC1F0F0048E10060FEE8 /* ipc_sync_message.cc in Sources */ = {isa = PBXBuildFile; fileRef = 4D7BFBBA0E9D4C9F009A6919 /* ipc_sync_message.cc */; }; B507AC440F004B610060FEE8 /* ipc_sync_message_unittest.cc in Sources */ = {isa = PBXBuildFile; fileRef = 4D7BFBBC0E9D4C9F009A6919 /* ipc_sync_message_unittest.cc */; }; - B51F6D150F37C4DC00152D66 /* renderer_main_platform_delegate_mac.cc in Sources */ = {isa = PBXBuildFile; fileRef = B51F6D130F37C4DC00152D66 /* renderer_main_platform_delegate_mac.cc */; }; - B51F6D2E0F37D04200152D66 /* renderer_main.cc in Sources */ = {isa = PBXBuildFile; fileRef = 4D640CD90EAE868600EBCFC0 /* renderer_main.cc */; }; B52E29BE0F0AA333008AD1C8 /* l10n_util_unittest.cc in Sources */ = {isa = PBXBuildFile; fileRef = 4D7BFBCB0E9D4C9F009A6919 /* l10n_util_unittest.cc */; }; B54BD8FC0ED622C00093FD54 /* mach_message_source_mac.cc in Sources */ = {isa = PBXBuildFile; fileRef = B54BD8FA0ED622C00093FD54 /* mach_message_source_mac.cc */; }; B555B2230F21506300F751B9 /* metrics_log.cc in Sources */ = {isa = PBXBuildFile; fileRef = B555B2200F21504D00F751B9 /* metrics_log.cc */; }; @@ -1910,9 +1908,6 @@ A7CBAD370F322A7E00360BF5 /* shell_dialogs_mac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = shell_dialogs_mac.mm; path = cocoa/shell_dialogs_mac.mm; sourceTree = "<group>"; }; A9C335E39D39A7DE087850FC /* url_pattern_unittest.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = url_pattern_unittest.cc; path = common/extensions/url_pattern_unittest.cc; sourceTree = SOURCE_ROOT; }; B503E0FB0F01764800547DC6 /* user_script_slave_unittest.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = user_script_slave_unittest.cc; sourceTree = "<group>"; }; - B51F6D110F37C4DC00152D66 /* renderer_main_platform_delegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = renderer_main_platform_delegate.h; sourceTree = "<group>"; }; - B51F6D120F37C4DC00152D66 /* renderer_main_platform_delegate_win.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = renderer_main_platform_delegate_win.cc; sourceTree = "<group>"; }; - B51F6D130F37C4DC00152D66 /* renderer_main_platform_delegate_mac.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = renderer_main_platform_delegate_mac.cc; sourceTree = "<group>"; }; B54BD8FA0ED622C00093FD54 /* mach_message_source_mac.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = mach_message_source_mac.cc; sourceTree = "<group>"; }; B54BD8FB0ED622C00093FD54 /* mach_message_source_mac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mach_message_source_mac.h; sourceTree = "<group>"; }; B555B2160F21504D00F751B9 /* metrics_service.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = metrics_service.h; path = metrics/metrics_service.h; sourceTree = "<group>"; }; @@ -2390,9 +2385,6 @@ 4D640CD70EAE868600EBCFC0 /* render_widget_unittest.cc */, 4D640CD80EAE868600EBCFC0 /* renderer_glue.cc */, 4D640CD90EAE868600EBCFC0 /* renderer_main.cc */, - B51F6D110F37C4DC00152D66 /* renderer_main_platform_delegate.h */, - B51F6D120F37C4DC00152D66 /* renderer_main_platform_delegate_win.cc */, - B51F6D130F37C4DC00152D66 /* renderer_main_platform_delegate_mac.cc */, 4D640CDA0EAE868600EBCFC0 /* renderer_resources.h */, 4D640CC90EAE868600EBCFC0 /* user_script_slave.cc */, 4D640CCA0EAE868600EBCFC0 /* user_script_slave.h */, @@ -4508,21 +4500,19 @@ buildActionMask = 2147483647; files = ( 4D640CF30EAE86E300EBCFC0 /* about_handler.cc in Sources */, - 3380A69B0F2E91AE004EF74F /* child_process.cc in Sources */, - 3380A69F0F2E91E5004EF74F /* chrome_plugin_lib.cc in Sources */, E45076D90F1538E4003BE099 /* dom_automation_controller.cc in Sources */, E45076C90F1537F5003BE099 /* dom_ui_bindings.cc in Sources */, E45076CB0F15380C003BE099 /* external_host_bindings.cc in Sources */, - 3380A6A30F2E9207004EF74F /* ipc_sync_channel.cc in Sources */, + B503E0F00F0175FD00547DC6 /* user_script_slave.cc in Sources */, E45076CF0F153871003BE099 /* localized_error.cc in Sources */, 4D640CF40EAE86EA00EBCFC0 /* render_dns_queue.cc in Sources */, - B503E0F00F0175FD00547DC6 /* user_script_slave.cc in Sources */, - 3380A9D70F2FC8F9004EF74F /* render_dns_master.cc in Sources */, - B51F6D2E0F37D04200152D66 /* renderer_main.cc in Sources */, - B51F6D150F37C4DC00152D66 /* renderer_main_platform_delegate_mac.cc in Sources */, - 3380A6A10F2E91F9004EF74F /* render_process.cc in Sources */, - 3380A69D0F2E91D4004EF74F /* render_thread.cc in Sources */, 4D640CF50EAE86EF00EBCFC0 /* visitedlink_slave.cc in Sources */, + 3380A69B0F2E91AE004EF74F /* child_process.cc in Sources */, + 3380A69D0F2E91D4004EF74F /* render_thread.cc in Sources */, + 3380A69F0F2E91E5004EF74F /* chrome_plugin_lib.cc in Sources */, + 3380A6A10F2E91F9004EF74F /* render_process.cc in Sources */, + 3380A6A30F2E9207004EF74F /* ipc_sync_channel.cc in Sources */, + 3380A9D70F2FC8F9004EF74F /* render_dns_master.cc in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/chrome/common/resource_bundle.h b/chrome/common/resource_bundle.h index 0143ec2..7af3ac8 100644 --- a/chrome/common/resource_bundle.h +++ b/chrome/common/resource_bundle.h @@ -119,9 +119,6 @@ class ResourceBundle { #elif defined(OS_LINUX) // Linux will use base::DataPack. TODO(evanm): finish this. typedef base::DataPack* DataHandle; -#elif defined(OS_MACOSX) - // TODO(port): Implement resource loading on OS X. - typedef void* DataHandle; #endif // Ctor/dtor are private, since we're a singleton. diff --git a/chrome/common/sandbox_init_wrapper.cc b/chrome/common/sandbox_init_wrapper.cc index e7228aa..f72c2df 100644 --- a/chrome/common/sandbox_init_wrapper.cc +++ b/chrome/common/sandbox_init_wrapper.cc @@ -7,6 +7,12 @@ #include "base/command_line.h" #include "chrome/common/chrome_switches.h" +#if defined(OS_MACOSX) +extern "C" { +#include <sandbox.h> +} +#endif + #if defined(OS_WIN) void SandboxInitWrapper::SetServices(sandbox::SandboxInterfaceInfo* info) { @@ -31,8 +37,13 @@ void SandboxInitWrapper::InitializeSandbox(const CommandLine& command_line, #if defined(OS_WIN) target_services_->Init(); #elif defined(OS_MACOSX) - // Nothing to do here for OS X, see renderer_main_platform_delegate_mac.cc - // For Sandbox initialization. + // TODO(pinkerton): note, this leaks |error_buff|. What do we want to + // do with the error? Pass it back to main? + char* error_buff; + int error = sandbox_init(kSBXProfilePureComputation, SANDBOX_NAMED, + &error_buff); + if (error) + exit(-1); #endif } } diff --git a/chrome/renderer/renderer.vcproj b/chrome/renderer/renderer.vcproj index 289fc28..06d85bd 100644 --- a/chrome/renderer/renderer.vcproj +++ b/chrome/renderer/renderer.vcproj @@ -302,14 +302,6 @@ > </File> <File - RelativePath=".\renderer_main_platform_delegate.h" - > - </File> - <File - RelativePath=".\renderer_main_platform_delegate_win.cc" - > - </File> - <File RelativePath=".\renderer_resources.h" > </File> diff --git a/chrome/renderer/renderer_main.cc b/chrome/renderer/renderer_main.cc index 7d28ecf..9635d7a 100644 --- a/chrome/renderer/renderer_main.cc +++ b/chrome/renderer/renderer_main.cc @@ -15,11 +15,10 @@ #include "chrome/common/logging_chrome.h" #include "chrome/common/main_function_params.h" #include "chrome/common/resource_bundle.h" -#if defined(OS_WIN) #include "chrome/common/win_util.h" -#endif -#include "chrome/renderer/renderer_main_platform_delegate.h" #include "chrome/renderer/render_process.h" +#include "chrome/test/injection_test_dll.h" +#include "sandbox/src/sandbox.h" #include "chromium_strings.h" #include "generated_resources.h" @@ -38,22 +37,19 @@ static void HandleRendererErrorTestParameters(const CommandLine& command_line) { *bad_pointer = 0; } -#if defined(OS_WIN) if (command_line.HasSwitch(switches::kRendererStartupDialog)) { std::wstring title = l10n_util::GetString(IDS_PRODUCT_NAME); title += L" renderer"; // makes attaching to process easier MessageBox(NULL, L"renderer starting...", title.c_str(), MB_OK | MB_SETFOREGROUND); } -#else - NOTIMPLEMENTED(); -#endif // !OS_WIN } // mainline routine for running as the Rendererer process int RendererMain(const MainFunctionParams& parameters) { const CommandLine& parsed_command_line = parameters.command_line_; - RendererMainPlatformDelegate platform(parameters); + sandbox::TargetServices* target_services = + parameters.sandbox_info_.TargetServices(); StatsScope<StatsCounterTimer> startup_timer(chrome::Counters::renderer_main()); @@ -66,10 +62,22 @@ int RendererMain(const MainFunctionParams& parameters) { // Initialize the SystemMonitor base::SystemMonitor::Start(); - platform.PlatformInitialize(); + CoInitialize(NULL); + DLOG(INFO) << "Started renderer with " << + parsed_command_line.command_line_string(); + + HMODULE sandbox_test_module = NULL; bool no_sandbox = parsed_command_line.HasSwitch(switches::kNoSandbox); - platform.InitSandboxTests(no_sandbox); + if (target_services && !no_sandbox) { + // The command line might specify a test dll to load. + if (parsed_command_line.HasSwitch(switches::kTestSandbox)) { + std::wstring test_dll_name = + parsed_command_line.GetSwitchValue(switches::kTestSandbox); + sandbox_test_module = LoadLibrary(test_dll_name.c_str()); + DCHECK(sandbox_test_module); + } + } HandleRendererErrorTestParameters(parsed_command_line); @@ -78,10 +86,28 @@ int RendererMain(const MainFunctionParams& parameters) { if (RenderProcess::GlobalInit(channel_name)) { bool run_loop = true; if (!no_sandbox) { - run_loop = platform.EnableSandbox(); + if (target_services) { + target_services->LowerToken(); + } else { + run_loop = false; + } } - platform.RunSandboxTests(); + if (sandbox_test_module) { + RunRendererTests run_security_tests = + reinterpret_cast<RunRendererTests>(GetProcAddress(sandbox_test_module, + kRenderTestCall)); + DCHECK(run_security_tests); + if (run_security_tests) { + int test_count = 0; + DLOG(INFO) << "Running renderer security tests"; + BOOL result = run_security_tests(&test_count); + DCHECK(result) << "Test number " << test_count << " has failed."; + // If we are in release mode, debug or crash the process. + if (!result) + __debugbreak(); + } + } startup_timer.Stop(); // End of Startup Time Measurement. @@ -93,7 +119,8 @@ int RendererMain(const MainFunctionParams& parameters) { RenderProcess::GlobalCleanup(); } - platform.PlatformUninitialize(); + + CoUninitialize(); return 0; } diff --git a/chrome/renderer/renderer_main_platform_delegate.h b/chrome/renderer/renderer_main_platform_delegate.h deleted file mode 100755 index 8f1e453..0000000 --- a/chrome/renderer/renderer_main_platform_delegate.h +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_RENDERER_RENDERER_PLATFORM_DELEGATE_H_ -#define CHROME_RENDERER_RENDERER_PLATFORM_DELEGATE_H_ - -#include "chrome/common/main_function_params.h" - -class RendererMainPlatformDelegate { - public: - RendererMainPlatformDelegate(const MainFunctionParams& parameters); - ~RendererMainPlatformDelegate(); - - // Called first thing and last thing in the process' lifecycle, i.e. before - // the sandbox is enabled. - void PlatformInitialize(); - void PlatformUninitialize(); - - // Gives us an opportunity to initialize state used for tests before enabling - // the sandbox. - bool InitSandboxTests(bool no_sandbox); - - // Initiate Lockdown, returns true on success. - bool EnableSandbox(); - - // Runs Sandbox tests. - void RunSandboxTests(); - - private: - const MainFunctionParams& parameters_; -#if defined(OS_WIN) - HMODULE sandbox_test_module_; -#endif - - DISALLOW_COPY_AND_ASSIGN(RendererMainPlatformDelegate); -}; - -#endif // CHROME_RENDERER_RENDERER_PLATFORM_DELEGATE_H_ diff --git a/chrome/renderer/renderer_main_platform_delegate_mac.cc b/chrome/renderer/renderer_main_platform_delegate_mac.cc deleted file mode 100644 index 022cb02..0000000 --- a/chrome/renderer/renderer_main_platform_delegate_mac.cc +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/renderer/renderer_main_platform_delegate.h" - -extern "C" { -#include <sandbox.h> -} - -RendererMainPlatformDelegate::RendererMainPlatformDelegate( - const MainFunctionParams& parameters) - : parameters_(parameters) { -} - -RendererMainPlatformDelegate::~RendererMainPlatformDelegate() { -} - -void RendererMainPlatformDelegate::PlatformInitialize() { -} - -void RendererMainPlatformDelegate::PlatformUninitialize() { -} - -bool RendererMainPlatformDelegate::InitSandboxTests(bool no_sandbox) { - return true; -} - -bool RendererMainPlatformDelegate::EnableSandbox() { - char* error_buff = NULL; - int error = sandbox_init(kSBXProfilePureComputation, SANDBOX_NAMED, - &error_buff); - bool success = (error == 0 && error_buff == NULL); - if (error == -1) { - LOG(ERROR) << "Failed to Initialize Sandbox: " << error_buff; - } - sandbox_free_error(error_buff); - return success; -} - -void RendererMainPlatformDelegate::RunSandboxTests() { - // Should run sandbox unit tests. - NOTIMPLEMENTED(); -} diff --git a/chrome/renderer/renderer_main_platform_delegate_win.cc b/chrome/renderer/renderer_main_platform_delegate_win.cc deleted file mode 100755 index f4280a7..0000000 --- a/chrome/renderer/renderer_main_platform_delegate_win.cc +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/renderer/renderer_main_platform_delegate.h" - -#include <windows.h> - -#include "base/command_line.h" -#include "chrome/common/chrome_constants.h" -#include "chrome/common/chrome_switches.h" -#include "chrome/test/injection_test_dll.h" -#include "sandbox/src/sandbox.h" - -RendererMainPlatformDelegate::RendererMainPlatformDelegate( - const MainFunctionParams& parameters) - : parameters_(parameters), - sandbox_test_module_(NULL) { -} - -RendererMainPlatformDelegate::~RendererMainPlatformDelegate() { -} - -void RendererMainPlatformDelegate::PlatformInitialize() { - CoInitialize(NULL); -} - -void RendererMainPlatformDelegate::PlatformUninitialize() { - CoUninitialize(); -} - -bool RendererMainPlatformDelegate::InitSandboxTests(bool no_sandbox) { - const CommandLine& command_line = parameters_.command_line_; - - DLOG(INFO) << "Started renderer with " << command_line.command_line_string(); - - sandbox::TargetServices* target_services = - parameters_.sandbox_info_.TargetServices(); - - if (target_services && !no_sandbox) { - std::wstring test_dll_name = - command_line.GetSwitchValue(switches::kTestSandbox); - if (!test_dll_name.empty()) { - sandbox_test_module_ = LoadLibrary(test_dll_name.c_str()); - DCHECK(sandbox_test_module_); - if (!sandbox_test_module_) { - return false; - } - } - } - return true; -} - -bool RendererMainPlatformDelegate::EnableSandbox() { - sandbox::TargetServices* target_services = - parameters_.sandbox_info_.TargetServices(); - - if (target_services) { - target_services->LowerToken(); - return true; - } - return false; -} - -void RendererMainPlatformDelegate::RunSandboxTests() { - if (sandbox_test_module_) { - RunRendererTests run_security_tests = - reinterpret_cast<RunRendererTests>(GetProcAddress(sandbox_test_module_, - kRenderTestCall)); - DCHECK(run_security_tests); - if (run_security_tests) { - int test_count = 0; - DLOG(INFO) << "Running renderer security tests"; - BOOL result = run_security_tests(&test_count); - CHECK(result) << "Test number " << test_count << " has failed."; - } - } -} |