diff options
author | piman@google.com <piman@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-10 00:13:24 +0000 |
---|---|---|
committer | piman@google.com <piman@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-10 00:13:24 +0000 |
commit | 2a59d815c77f388d9da7741ce23404a7234c9b45 (patch) | |
tree | 64ca1ce68f1515969e7c0b75cba97b4d8875e38a /chrome/plugin | |
parent | 75ae449e5e83d3f81fabcd3910901be2bdfa1f7b (diff) | |
download | chromium_src-2a59d815c77f388d9da7741ce23404a7234c9b45.zip chromium_src-2a59d815c77f388d9da7741ce23404a7234c9b45.tar.gz chromium_src-2a59d815c77f388d9da7741ce23404a7234c9b45.tar.bz2 |
linux: move gtk_init to the right thread
In the plugin process, gtk_init needs to be called from the UI thread (PluginThread) not the main thread (PluginMain) which is an IO thread.
Review URL: http://codereview.chromium.org/149424
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20340 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/plugin')
-rw-r--r-- | chrome/plugin/plugin_main.cc | 16 | ||||
-rw-r--r-- | chrome/plugin/plugin_thread.cc | 21 |
2 files changed, 21 insertions, 16 deletions
diff --git a/chrome/plugin/plugin_main.cc b/chrome/plugin/plugin_main.cc index a710b70..fb8880f 100644 --- a/chrome/plugin/plugin_main.cc +++ b/chrome/plugin/plugin_main.cc @@ -67,22 +67,6 @@ int PluginMain(const MainFunctionParams& parameters) { MB_OK | MB_SETFOREGROUND); } #else -#if defined(OS_LINUX) - { - // XEmbed plugins assume they are hosted in a Gtk application, so we need - // to initialize Gtk in the plugin process. - // TODO(evanm): hoist this up nearer to where we have argc/argv. - const std::vector<std::string>& args = parameters.command_line_.argv(); - int argc = args.size(); - scoped_array<const char *> argv(new const char *[argc + 1]); - for (int i = 0; i < argc; ++i) { - argv[i] = args[i].c_str(); - } - argv[argc] = NULL; - const char **argv_pointer = argv.get(); - gtk_init(&argc, const_cast<char***>(&argv_pointer)); - } -#endif NOTIMPLEMENTED() << " non-windows startup, plugin startup dialog etc."; #endif diff --git a/chrome/plugin/plugin_thread.cc b/chrome/plugin/plugin_thread.cc index 2701f5b..a595776 100644 --- a/chrome/plugin/plugin_thread.cc +++ b/chrome/plugin/plugin_thread.cc @@ -54,6 +54,27 @@ void PluginThread::OnControlMessageReceived(const IPC::Message& msg) { void PluginThread::Init() { lazy_tls.Pointer()->Set(this); +#if defined(OS_LINUX) + { + // XEmbed plugins assume they are hosted in a Gtk application, so we need + // to initialize Gtk in the plugin process. + const std::vector<std::string>& args = + CommandLine::ForCurrentProcess()->argv(); + int argc = args.size(); + scoped_array<char *> argv(new char *[argc + 1]); + for (size_t i = 0; i < args.size(); ++i) { + // TODO(piman@google.com): can gtk_init modify argv? Just being safe + // here. + argv[i] = strdup(args[i].c_str()); + } + argv[argc] = NULL; + char **argv_pointer = argv.get(); + gtk_init(&argc, &argv_pointer); + for (size_t i = 0; i < args.size(); ++i) { + free(argv[i]); + } + } +#endif ChildThread::Init(); PatchNPNFunctions(); |