summaryrefslogtreecommitdiffstats
path: root/content/app
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-29 03:44:44 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-29 03:44:44 +0000
commitbadf5cf5f14c65f6c799ef1fec77cde8351339c2 (patch)
tree83690887c035e4b457f00404f126f95ad1a90c06 /content/app
parent8cc9738eff9c169487e8356947d88640659fc497 (diff)
downloadchromium_src-badf5cf5f14c65f6c799ef1fec77cde8351339c2.zip
chromium_src-badf5cf5f14c65f6c799ef1fec77cde8351339c2.tar.gz
chromium_src-badf5cf5f14c65f6c799ef1fec77cde8351339c2.tar.bz2
Expose the sandbox related code through the content API. I did a bit of cleanup while I was doing this.
-got rid of SandboxInitWrapper, since I didn't see a need to expose given that we can just expose sandbox::SandboxInterfaceInfo -got rid of the duplicated code to initialize the broker -since I made MainFunctionParams only have the sandbox struct on Windows, I also made the mac specific auto release pool behind an ifdef as well. It seemed odd to make something so mac specific compile on all platforms to save some #ifdefs. BUG=98716 Review URL: http://codereview.chromium.org/8414020 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@107863 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/app')
-rw-r--r--content/app/content_main.cc42
-rw-r--r--content/app/startup_helper_win.cc2
-rw-r--r--content/app/startup_helper_win.h34
3 files changed, 19 insertions, 59 deletions
diff --git a/content/app/content_main.cc b/content/app/content_main.cc
index 2494dc4..3cbf07f 100644
--- a/content/app/content_main.cc
+++ b/content/app/content_main.cc
@@ -9,22 +9,21 @@
#include "base/debug/debugger.h"
#include "base/i18n/icu_util.h"
#include "base/logging.h"
-#include "base/mac/scoped_nsautorelease_pool.h"
#include "base/memory/scoped_ptr.h"
#include "base/metrics/stats_table.h"
#include "base/process_util.h"
#include "base/stringprintf.h"
#include "base/string_number_conversions.h"
-#include "content/app/startup_helper_win.h"
#include "content/browser/browser_main.h"
#include "content/common/main_function_params.h"
-#include "content/common/sandbox_init_wrapper.h"
#include "content/common/set_process_title.h"
#include "content/public/app/content_main_delegate.h"
+#include "content/public/app/startup_helper_win.h"
#include "content/public/common/content_client.h"
#include "content/public/common/content_constants.h"
#include "content/public/common/content_paths.h"
#include "content/public/common/content_switches.h"
+#include "content/public/common/sandbox_init.h"
#include "crypto/nss_util.h"
#include "ipc/ipc_switches.h"
#include "ui/base/ui_base_switches.h"
@@ -36,6 +35,7 @@
#include <atlapp.h>
#include <malloc.h>
#elif defined(OS_MACOSX)
+#include "base/mac/scoped_nsautorelease_pool.h"
#include "base/mach_ipc_mac.h"
#include "base/system_monitor/system_monitor.h"
#include "content/browser/mach_broker_mac.h"
@@ -219,9 +219,8 @@ int RunZygote(const MainFunctionParams& main_function_params,
base::GetParentProcessId(base::GetCurrentProcId()));
InitializeStatsTable(browser_pid, command_line);
- MainFunctionParams main_params(command_line,
- main_function_params.sandbox_info_,
- main_function_params.autorelease_pool_);
+ MainFunctionParams main_params(command_line);
+
// Get the new process type from the new command line.
std::string process_type =
command_line.GetSwitchValueASCII(switches::kProcessType);
@@ -327,11 +326,13 @@ int ContentMain(int argc,
// The exit manager is in charge of calling the dtors of singleton objects.
base::AtExitManager exit_manager;
+#if defined(OS_MACOSX)
// We need this pool for all the objects created before we get to the
// event loop, but we don't want to leave them hanging around until the
// app quits. Each "main" needs to flush this pool right before it goes into
// its main event loop to get rid of the cruft.
base::mac::ScopedNSAutoreleasePool autorelease_pool;
+#endif
CommandLine::Init(argc, argv);
@@ -415,38 +416,31 @@ int ContentMain(int argc,
if (!process_type.empty())
CommonSubprocessInit(process_type);
- // Initialize the sandbox for this process.
- SandboxInitWrapper sandbox_wrapper;
- bool initialize_sandbox = true;
-
#if defined(OS_WIN)
- sandbox_wrapper.SetServices(sandbox_info);
+ CHECK(content::InitializeSandbox(sandbox_info));
#elif defined(OS_MACOSX)
- // On OS X the renderer sandbox needs to be initialized later in the startup
- // sequence in RendererMainPlatformDelegate::EnableSandbox().
if (process_type == switches::kRendererProcess ||
process_type == switches::kPpapiPluginProcess ||
(delegate && delegate->DelaySandboxInitialization(process_type))) {
- initialize_sandbox = false;
+ // On OS X the renderer sandbox needs to be initialized later in the startup
+ // sequence in RendererMainPlatformDelegate::EnableSandbox().
+ } else {
+ CHECK(content::InitializeSandbox());
}
#endif
- if (initialize_sandbox) {
- bool sandbox_initialized_ok =
- sandbox_wrapper.InitializeSandbox(command_line, process_type);
- // Die if the sandbox can't be enabled.
- CHECK(sandbox_initialized_ok) << "Error initializing sandbox for "
- << process_type;
- }
-
if (delegate) delegate->SandboxInitialized(process_type);
#if defined(OS_POSIX)
SetProcessTitleFromCommandLine(argv);
#endif
- MainFunctionParams main_params(command_line, sandbox_wrapper,
- &autorelease_pool);
+ MainFunctionParams main_params(command_line);
+#if defined(OS_WIN)
+ main_params.sandbox_info = sandbox_info;
+#elif defined(OS_MACOSX)
+ main_params.autorelease_pool = &autorelease_pool;
+#endif
exit_code = RunNamedProcessTypeMain(process_type, main_params, delegate);
diff --git a/content/app/startup_helper_win.cc b/content/app/startup_helper_win.cc
index 8e1a32b..aaba83c 100644
--- a/content/app/startup_helper_win.cc
+++ b/content/app/startup_helper_win.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "content/app/startup_helper_win.h"
+#include "content/public/app/startup_helper_win.h"
#include <crtdbg.h>
#include <new.h>
diff --git a/content/app/startup_helper_win.h b/content/app/startup_helper_win.h
deleted file mode 100644
index e20b638..0000000
--- a/content/app/startup_helper_win.h
+++ /dev/null
@@ -1,34 +0,0 @@
-// Copyright (c) 2011 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 CONTENT_APP_STARTUP_HELPER_WIN_H_
-#define CONTENT_APP_STARTUP_HELPER_WIN_H_
-#pragma once
-
-class CommandLine;
-
-namespace sandbox {
-struct SandboxInterfaceInfo;
-}
-
-// This file contains functions that any embedder that's not using ContentMain
-// will want to call at startup.
-namespace content {
-
-// Initializes the sandbox code and turns on DEP. Note: This function
-// must be *statically* linked into the executable (along with the static
-// sandbox library); it will not work correctly if it is exported from a
-// DLL and linked in.
-void InitializeSandboxInfo(sandbox::SandboxInterfaceInfo* sandbox_info);
-
-// Register the invalid param handler and pure call handler to be able to
-// notify breakpad when it happens.
-void RegisterInvalidParamHandler();
-
-// Sets up the CRT's debugging macros to output to stdout.
-void SetupCRT(const CommandLine& command_line);
-
-} // namespace content
-
-#endif // CONTENT_APP_STARTUP_HELPER_WIN_H_