| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "content/browser/browser_main_loop.h" | 5 #include "content/browser/browser_main_loop.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 #if defined(OS_WIN) | 29 #if defined(OS_WIN) |
| 30 #include <windows.h> | 30 #include <windows.h> |
| 31 #include <commctrl.h> | 31 #include <commctrl.h> |
| 32 #include <ole2.h> | 32 #include <ole2.h> |
| 33 #include <shellapi.h> | 33 #include <shellapi.h> |
| 34 | 34 |
| 35 #include "ui/base/l10n/l10n_util_win.h" | 35 #include "ui/base/l10n/l10n_util_win.h" |
| 36 #include "net/base/winsock_init.h" | 36 #include "net/base/winsock_init.h" |
| 37 #endif | 37 #endif |
| 38 | 38 |
| 39 #if defined(OS_LINUX) | 39 #if defined(OS_LINUX) || defined(OS_OPENBSD) |
| 40 #include <glib-object.h> | 40 #include <glib-object.h> |
| 41 #endif | 41 #endif |
| 42 | 42 |
| 43 #if defined(OS_CHROMEOS) | 43 #if defined(OS_CHROMEOS) |
| 44 #include <dbus/dbus-glib.h> | 44 #include <dbus/dbus-glib.h> |
| 45 #endif | 45 #endif |
| 46 | 46 |
| 47 #if defined(TOOLKIT_USES_GTK) | 47 #if defined(TOOLKIT_USES_GTK) |
| 48 #include "ui/gfx/gtk_util.h" | 48 #include "ui/gfx/gtk_util.h" |
| 49 #endif | 49 #endif |
| (...skipping 12 matching lines...) Expand all Loading... |
| 62 // code en masse out of chrome_main for now. | 62 // code en masse out of chrome_main for now. |
| 63 const char* sandbox_binary = NULL; | 63 const char* sandbox_binary = NULL; |
| 64 struct stat st; | 64 struct stat st; |
| 65 | 65 |
| 66 // In Chromium branded builds, developers can set an environment variable to | 66 // In Chromium branded builds, developers can set an environment variable to |
| 67 // use the development sandbox. See | 67 // use the development sandbox. See |
| 68 // http://code.google.com/p/chromium/wiki/LinuxSUIDSandboxDevelopment | 68 // http://code.google.com/p/chromium/wiki/LinuxSUIDSandboxDevelopment |
| 69 if (stat("/proc/self/exe", &st) == 0 && st.st_uid == getuid()) | 69 if (stat("/proc/self/exe", &st) == 0 && st.st_uid == getuid()) |
| 70 sandbox_binary = getenv("CHROME_DEVEL_SANDBOX"); | 70 sandbox_binary = getenv("CHROME_DEVEL_SANDBOX"); |
| 71 | 71 |
| 72 #if defined(LINUX_SANDBOX_PATH) | 72 #if defined(OS_LINUX) |
| 73 if (!sandbox_binary) | 73 if (!sandbox_binary) |
| 74 sandbox_binary = LINUX_SANDBOX_PATH; | 74 sandbox_binary = LINUX_SANDBOX_PATH; |
| 75 #endif | 75 #endif |
| 76 | 76 |
| 77 std::string sandbox_cmd; | 77 std::string sandbox_cmd; |
| 78 if (sandbox_binary && !parsed_command_line.HasSwitch(switches::kNoSandbox)) | 78 if (sandbox_binary && !parsed_command_line.HasSwitch(switches::kNoSandbox)) |
| 79 sandbox_cmd = sandbox_binary; | 79 sandbox_cmd = sandbox_binary; |
| 80 | 80 |
| 81 // Tickle the sandbox host and zygote host so they fork now. | 81 // Tickle the sandbox host and zygote host so they fork now. |
| 82 RenderSandboxHostLinux* shost = RenderSandboxHostLinux::GetInstance(); | 82 RenderSandboxHostLinux* shost = RenderSandboxHostLinux::GetInstance(); |
| 83 shost->Init(sandbox_cmd); | 83 shost->Init(sandbox_cmd); |
| 84 ZygoteHost* zhost = ZygoteHost::GetInstance(); | 84 ZygoteHost* zhost = ZygoteHost::GetInstance(); |
| 85 zhost->Init(sandbox_cmd); | 85 zhost->Init(sandbox_cmd); |
| 86 } | 86 } |
| 87 #endif | 87 #endif |
| 88 | 88 |
| 89 #if defined(OS_LINUX) | 89 #if defined(OS_LINUX) || defined(OS_OPENBSD) |
| 90 static void GLibLogHandler(const gchar* log_domain, | 90 static void GLibLogHandler(const gchar* log_domain, |
| 91 GLogLevelFlags log_level, | 91 GLogLevelFlags log_level, |
| 92 const gchar* message, | 92 const gchar* message, |
| 93 gpointer userdata) { | 93 gpointer userdata) { |
| 94 if (!log_domain) | 94 if (!log_domain) |
| 95 log_domain = "<unknown>"; | 95 log_domain = "<unknown>"; |
| 96 if (!message) | 96 if (!message) |
| 97 message = "<no message>"; | 97 message = "<no message>"; |
| 98 | 98 |
| 99 if (strstr(message, "Loading IM context type") || | 99 if (strstr(message, "Loading IM context type") || |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 main_thread_.reset(new BrowserThread(BrowserThread::UI, | 298 main_thread_.reset(new BrowserThread(BrowserThread::UI, |
| 299 MessageLoop::current())); | 299 MessageLoop::current())); |
| 300 } | 300 } |
| 301 | 301 |
| 302 void BrowserMainLoop::InitializeToolkit() { | 302 void BrowserMainLoop::InitializeToolkit() { |
| 303 // TODO(evan): this function is rather subtle, due to the variety | 303 // TODO(evan): this function is rather subtle, due to the variety |
| 304 // of intersecting ifdefs we have. To keep it easy to follow, there | 304 // of intersecting ifdefs we have. To keep it easy to follow, there |
| 305 // are no #else branches on any #ifs. | 305 // are no #else branches on any #ifs. |
| 306 // TODO(stevenjb): Move platform specific code into platform specific Parts | 306 // TODO(stevenjb): Move platform specific code into platform specific Parts |
| 307 // (Need to add InitializeToolkit stage to BrowserParts). | 307 // (Need to add InitializeToolkit stage to BrowserParts). |
| 308 #if defined(OS_LINUX) | 308 #if defined(OS_LINUX) || defined(OS_OPENBSD) |
| 309 // We want to call g_thread_init(), but in some codepaths (tests) it | 309 // We want to call g_thread_init(), but in some codepaths (tests) it |
| 310 // is possible it has already been called. In older versions of | 310 // is possible it has already been called. In older versions of |
| 311 // GTK, it is an error to call g_thread_init twice; unfortunately, | 311 // GTK, it is an error to call g_thread_init twice; unfortunately, |
| 312 // the API to tell whether it has been called already was also only | 312 // the API to tell whether it has been called already was also only |
| 313 // added in a newer version of GTK! Thankfully, this non-intuitive | 313 // added in a newer version of GTK! Thankfully, this non-intuitive |
| 314 // check is actually equivalent and sufficient to work around the | 314 // check is actually equivalent and sufficient to work around the |
| 315 // error. | 315 // error. |
| 316 if (!g_thread_supported()) | 316 if (!g_thread_supported()) |
| 317 g_thread_init(NULL); | 317 g_thread_init(NULL); |
| 318 // Glib type system initialization. Needed at least for gconf, | 318 // Glib type system initialization. Needed at least for gconf, |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 MessageLoopForUI::current()->PostTask(FROM_HERE, parameters_.ui_task); | 359 MessageLoopForUI::current()->PostTask(FROM_HERE, parameters_.ui_task); |
| 360 | 360 |
| 361 #if defined(OS_MACOSX) | 361 #if defined(OS_MACOSX) |
| 362 MessageLoopForUI::current()->Run(); | 362 MessageLoopForUI::current()->Run(); |
| 363 #else | 363 #else |
| 364 MessageLoopForUI::current()->RunWithDispatcher(NULL); | 364 MessageLoopForUI::current()->RunWithDispatcher(NULL); |
| 365 #endif | 365 #endif |
| 366 } | 366 } |
| 367 | 367 |
| 368 } // namespace content | 368 } // namespace content |
| OLD | NEW |