Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4829)

Unified Diff: chrome/plugin/plugin_thread.cc

Issue 149424: linux: move gtk_init to the right thread (Closed)
Patch Set: Remove TODO Created 11 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/plugin/plugin_main.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/plugin/plugin_thread.cc
diff --git a/chrome/plugin/plugin_thread.cc b/chrome/plugin/plugin_thread.cc
index 2701f5b543bf7ceddda9d823cadd3342f9684a4a..a595776a1566269f7ae12baa5b2cbce7c304f36c 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();
« no previous file with comments | « chrome/plugin/plugin_main.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698