| 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.h" | 5 #include "content/browser/browser_main.h" |
| 6 | 6 |
| 7 #include "base/allocator/allocator_shim.h" | 7 #include "base/allocator/allocator_shim.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 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 "base/win/scoped_com_initializer.h" | 35 #include "base/win/scoped_com_initializer.h" |
| 36 #include "net/base/winsock_init.h" | 36 #include "net/base/winsock_init.h" |
| 37 #include "sandbox/src/sandbox.h" | 37 #include "sandbox/src/sandbox.h" |
| 38 #include "ui/base/l10n/l10n_util_win.h" | 38 #include "ui/base/l10n/l10n_util_win.h" |
| 39 #endif | 39 #endif |
| 40 | 40 |
| 41 #if defined(OS_LINUX) |
| 42 #include <glib-object.h> |
| 43 #endif |
| 44 |
| 41 #if defined(OS_CHROMEOS) | 45 #if defined(OS_CHROMEOS) |
| 42 #include <dbus/dbus-glib.h> | 46 #include <dbus/dbus-glib.h> |
| 43 #endif | 47 #endif |
| 44 | 48 |
| 45 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 49 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
| 46 #include <sys/stat.h> | 50 #include <sys/stat.h> |
| 47 | 51 |
| 48 #include "content/browser/renderer_host/render_sandbox_host_linux.h" | 52 #include "content/browser/renderer_host/render_sandbox_host_linux.h" |
| 49 #include "content/browser/zygote_host_linux.h" | 53 #include "content/browser/zygote_host_linux.h" |
| 50 #endif | 54 #endif |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 sandbox_cmd = sandbox_binary; | 101 sandbox_cmd = sandbox_binary; |
| 98 | 102 |
| 99 // Tickle the sandbox host and zygote host so they fork now. | 103 // Tickle the sandbox host and zygote host so they fork now. |
| 100 RenderSandboxHostLinux* shost = RenderSandboxHostLinux::GetInstance(); | 104 RenderSandboxHostLinux* shost = RenderSandboxHostLinux::GetInstance(); |
| 101 shost->Init(sandbox_cmd); | 105 shost->Init(sandbox_cmd); |
| 102 ZygoteHost* zhost = ZygoteHost::GetInstance(); | 106 ZygoteHost* zhost = ZygoteHost::GetInstance(); |
| 103 zhost->Init(sandbox_cmd); | 107 zhost->Init(sandbox_cmd); |
| 104 } | 108 } |
| 105 #endif | 109 #endif |
| 106 | 110 |
| 107 #if defined(TOOLKIT_USES_GTK) | 111 #if defined(OS_LINUX) |
| 108 static void GLibLogHandler(const gchar* log_domain, | 112 static void GLibLogHandler(const gchar* log_domain, |
| 109 GLogLevelFlags log_level, | 113 GLogLevelFlags log_level, |
| 110 const gchar* message, | 114 const gchar* message, |
| 111 gpointer userdata) { | 115 gpointer userdata) { |
| 112 if (!log_domain) | 116 if (!log_domain) |
| 113 log_domain = "<unknown>"; | 117 log_domain = "<unknown>"; |
| 114 if (!message) | 118 if (!message) |
| 115 message = "<no message>"; | 119 message = "<no message>"; |
| 116 | 120 |
| 117 if (strstr(message, "Loading IM context type") || | 121 if (strstr(message, "Loading IM context type") || |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 // Register the main thread by instantiating it, but don't call any methods. | 273 // Register the main thread by instantiating it, but don't call any methods. |
| 270 main_thread_.reset(new BrowserThread(BrowserThread::UI, | 274 main_thread_.reset(new BrowserThread(BrowserThread::UI, |
| 271 MessageLoop::current())); | 275 MessageLoop::current())); |
| 272 } | 276 } |
| 273 | 277 |
| 274 void BrowserMainParts::InitializeToolkit() { | 278 void BrowserMainParts::InitializeToolkit() { |
| 275 // TODO(evan): this function is rather subtle, due to the variety | 279 // TODO(evan): this function is rather subtle, due to the variety |
| 276 // of intersecting ifdefs we have. To keep it easy to follow, there | 280 // of intersecting ifdefs we have. To keep it easy to follow, there |
| 277 // are no #else branches on any #ifs. | 281 // are no #else branches on any #ifs. |
| 278 | 282 |
| 279 #if defined(TOOLKIT_USES_GTK) | 283 #if defined(OS_LINUX) |
| 280 // We want to call g_thread_init(), but in some codepaths (tests) it | 284 // We want to call g_thread_init(), but in some codepaths (tests) it |
| 281 // is possible it has already been called. In older versions of | 285 // is possible it has already been called. In older versions of |
| 282 // GTK, it is an error to call g_thread_init twice; unfortunately, | 286 // GTK, it is an error to call g_thread_init twice; unfortunately, |
| 283 // the API to tell whether it has been called already was also only | 287 // the API to tell whether it has been called already was also only |
| 284 // added in a newer version of GTK! Thankfully, this non-intuitive | 288 // added in a newer version of GTK! Thankfully, this non-intuitive |
| 285 // check is actually equivalent and sufficient to work around the | 289 // check is actually equivalent and sufficient to work around the |
| 286 // error. | 290 // error. |
| 287 if (!g_thread_supported()) | 291 if (!g_thread_supported()) |
| 288 g_thread_init(NULL); | 292 g_thread_init(NULL); |
| 289 // Glib type system initialization. Needed at least for gconf, | 293 // Glib type system initialization. Needed at least for gconf, |
| 290 // used in net/proxy/proxy_config_service_linux.cc. Most likely | 294 // used in net/proxy/proxy_config_service_linux.cc. Most likely |
| 291 // this is superfluous as gtk_init() ought to do this. It's | 295 // this is superfluous as gtk_init() ought to do this. It's |
| 292 // definitely harmless, so retained as a reminder of this | 296 // definitely harmless, so retained as a reminder of this |
| 293 // requirement for gconf. | 297 // requirement for gconf. |
| 294 g_type_init(); | 298 g_type_init(); |
| 295 #if defined(OS_CHROMEOS) | 299 #if defined(OS_CHROMEOS) |
| 296 // ChromeOS still uses dbus-glib, so initialize its threading here. | 300 // ChromeOS still uses dbus-glib, so initialize its threading here. |
| 297 // TODO(satorux, stevenjb): remove this once it is no longer needed. | 301 // TODO(satorux, stevenjb): remove this once it is no longer needed. |
| 298 dbus_g_thread_init(); | 302 dbus_g_thread_init(); |
| 299 #endif | 303 #endif |
| 300 #if defined(USE_AURA) | 304 #if !defined(USE_AURA) |
| 301 // TODO(oshima|saintlou): Remove this once we remove gtk from build | |
| 302 base::MessagePumpX::DisableGtkMessagePump(); | |
| 303 #else | |
| 304 gfx::GtkInitFromCommandLine(parameters().command_line_); | 305 gfx::GtkInitFromCommandLine(parameters().command_line_); |
| 305 #endif | 306 #endif |
| 306 SetUpGLibLogHandler(); | 307 SetUpGLibLogHandler(); |
| 307 #endif | 308 #endif |
| 308 | 309 |
| 309 #if defined(TOOLKIT_GTK) | 310 #if defined(TOOLKIT_GTK) |
| 310 // It is important for this to happen before the first run dialog, as it | 311 // It is important for this to happen before the first run dialog, as it |
| 311 // styles the dialog as well. | 312 // styles the dialog as well. |
| 312 gfx::InitRCStyles(); | 313 gfx::InitRCStyles(); |
| 313 #endif | 314 #endif |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 419 base::win::ScopedCOMInitializer com_initializer; | 420 base::win::ScopedCOMInitializer com_initializer; |
| 420 #endif // OS_WIN | 421 #endif // OS_WIN |
| 421 | 422 |
| 422 base::StatisticsRecorder statistics; | 423 base::StatisticsRecorder statistics; |
| 423 | 424 |
| 424 parts->RunMainMessageLoopParts(); | 425 parts->RunMainMessageLoopParts(); |
| 425 | 426 |
| 426 TRACE_EVENT_END_ETW("BrowserMain", 0, 0); | 427 TRACE_EVENT_END_ETW("BrowserMain", 0, 0); |
| 427 return parts->result_code(); | 428 return parts->result_code(); |
| 428 } | 429 } |
| OLD | NEW |