summaryrefslogtreecommitdiffstats
path: root/chrome/browser/browser_main_gtk.cc
diff options
context:
space:
mode:
authorBen Murdoch <benm@google.com>2010-11-25 19:40:10 +0000
committerBen Murdoch <benm@google.com>2010-12-03 13:52:53 +0000
commit4a5e2dc747d50c653511c68ccb2cfbfb740bd5a7 (patch)
tree938665d93a11fe7a6d0124e3c1e020d1f9d3f947 /chrome/browser/browser_main_gtk.cc
parent7c627d87728a355737862918d144f98f69406954 (diff)
downloadexternal_chromium-4a5e2dc747d50c653511c68ccb2cfbfb740bd5a7.zip
external_chromium-4a5e2dc747d50c653511c68ccb2cfbfb740bd5a7.tar.gz
external_chromium-4a5e2dc747d50c653511c68ccb2cfbfb740bd5a7.tar.bz2
Merge Chromium at r66597: Initial merge by git.
Change-Id: I9639f8a997f90ec219573aa22a49f5dbde78cc7b
Diffstat (limited to 'chrome/browser/browser_main_gtk.cc')
-rw-r--r--chrome/browser/browser_main_gtk.cc62
1 files changed, 60 insertions, 2 deletions
diff --git a/chrome/browser/browser_main_gtk.cc b/chrome/browser/browser_main_gtk.cc
index 8790726..e86cf72 100644
--- a/chrome/browser/browser_main_gtk.cc
+++ b/chrome/browser/browser_main_gtk.cc
@@ -2,7 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/browser_main.h"
+#include "chrome/browser/browser_main_gtk.h"
+
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
#include "app/x11_util.h"
#include "app/x11_util_internal.h"
@@ -12,8 +16,15 @@
#include "chrome/browser/browser_main_gtk.h"
#include "chrome/browser/browser_main_win.h"
#include "chrome/browser/metrics/metrics_service.h"
+#include "chrome/browser/renderer_host/render_sandbox_host_linux.h"
+#include "chrome/browser/zygote_host_linux.h"
+#include "chrome/common/chrome_switches.h"
#include "chrome/common/result_codes.h"
+#if defined(USE_NSS)
+#include "base/nss_util.h"
+#endif
+
#if defined(USE_LINUX_BREAKPAD)
#include "chrome/app/breakpad_linux.h"
#endif
@@ -34,7 +45,7 @@ int BrowserX11IOErrorHandler(Display* d) {
if (!g_in_x11_io_error_handler) {
g_in_x11_io_error_handler = true;
LOG(ERROR) << "X IO Error detected";
- BrowserList::WindowsSessionEnding();
+ BrowserList::SessionEnding();
}
return 0;
@@ -42,6 +53,45 @@ int BrowserX11IOErrorHandler(Display* d) {
} // namespace
+void BrowserMainPartsGtk::PreEarlyInitialization() {
+ BrowserMainPartsPosix::PreEarlyInitialization();
+
+ SetupSandbox();
+
+#if defined(USE_NSS)
+ // We want to be sure to init NSPR on the main thread.
+ base::EnsureNSPRInit();
+#endif
+}
+
+void BrowserMainPartsGtk::SetupSandbox() {
+ // TODO(evanm): move this into SandboxWrapper; I'm just trying to move this
+ // code en masse out of chrome_dll_main for now.
+ const char* sandbox_binary = NULL;
+ struct stat st;
+
+ // In Chromium branded builds, developers can set an environment variable to
+ // use the development sandbox. See
+ // http://code.google.com/p/chromium/wiki/LinuxSUIDSandboxDevelopment
+ if (stat("/proc/self/exe", &st) == 0 && st.st_uid == getuid())
+ sandbox_binary = getenv("CHROME_DEVEL_SANDBOX");
+
+#if defined(LINUX_SANDBOX_PATH)
+ if (!sandbox_binary)
+ sandbox_binary = LINUX_SANDBOX_PATH;
+#endif
+
+ std::string sandbox_cmd;
+ if (sandbox_binary && !parsed_command_line().HasSwitch(switches::kNoSandbox))
+ sandbox_cmd = sandbox_binary;
+
+ // Tickle the sandbox host and zygote host so they fork now.
+ RenderSandboxHostLinux* shost = Singleton<RenderSandboxHostLinux>::get();
+ shost->Init(sandbox_cmd);
+ ZygoteHost* zhost = Singleton<ZygoteHost>::get();
+ zhost->Init(sandbox_cmd);
+}
+
void DidEndMainMessageLoop() {
}
@@ -82,3 +132,11 @@ void SetBrowserX11ErrorHandlers() {
BrowserX11ErrorHandler,
BrowserX11IOErrorHandler);
}
+
+#if !defined(OS_CHROMEOS)
+// static
+BrowserMainParts* BrowserMainParts::CreateBrowserMainParts(
+ const MainFunctionParams& parameters) {
+ return new BrowserMainPartsGtk(parameters);
+}
+#endif