summaryrefslogtreecommitdiffstats
path: root/chrome/renderer
diff options
context:
space:
mode:
authortc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-04 18:20:17 +0000
committertc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-04 18:20:17 +0000
commit0d5529391070e6d4ad1093f02c4491f2b2854ebf (patch)
tree7d7f06698657f06d451321e6c73d59cb00cdd3f4 /chrome/renderer
parentcd115c31a6cddacccb8f4958dd7afb2395d2d674 (diff)
downloadchromium_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
Diffstat (limited to 'chrome/renderer')
-rw-r--r--chrome/renderer/renderer.vcproj8
-rw-r--r--chrome/renderer/renderer_main.cc53
-rwxr-xr-xchrome/renderer/renderer_main_platform_delegate.h39
-rw-r--r--chrome/renderer/renderer_main_platform_delegate_mac.cc44
-rwxr-xr-xchrome/renderer/renderer_main_platform_delegate_win.cc78
5 files changed, 40 insertions, 182 deletions
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.";
- }
- }
-}