OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/plugin/plugin_thread.h" | 5 #include "chrome/plugin/plugin_thread.h" |
6 | 6 |
7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
8 | 8 |
9 #if defined(USE_X11) | 9 #if defined(USE_X11) |
10 #include <gtk/gtk.h> | 10 #include <gtk/gtk.h> |
11 #elif defined(OS_MACOSX) | 11 #elif defined(OS_MACOSX) |
12 #include <CoreFoundation/CoreFoundation.h> | 12 #include <CoreFoundation/CoreFoundation.h> |
13 #endif | 13 #endif |
14 | 14 |
15 #include <string> | 15 #include <string> |
16 #include <vector> | 16 #include <vector> |
17 | 17 |
18 #include "base/command_line.h" | 18 #include "base/command_line.h" |
19 #include "base/lazy_instance.h" | 19 #include "base/lazy_instance.h" |
20 #include "base/process_util.h" | 20 #include "base/process_util.h" |
21 #include "base/thread_local.h" | 21 #include "base/thread_local.h" |
22 #include "chrome/common/child_process.h" | 22 #include "chrome/common/child_process.h" |
23 #include "chrome/common/chrome_plugin_lib.h" | 23 #include "chrome/common/chrome_plugin_lib.h" |
24 #include "chrome/common/chrome_switches.h" | 24 #include "chrome/common/chrome_switches.h" |
25 #include "chrome/common/plugin_messages.h" | 25 #include "chrome/common/plugin_messages.h" |
26 #include "chrome/common/render_messages.h" | 26 #include "chrome/common/render_messages.h" |
27 #include "chrome/plugin/chrome_plugin_host.h" | 27 #include "chrome/plugin/chrome_plugin_host.h" |
28 #include "chrome/plugin/npobject_util.h" | 28 #include "chrome/plugin/npobject_util.h" |
29 #include "chrome/renderer/render_thread.h" | 29 #include "chrome/renderer/render_thread.h" |
| 30 #include "gfx/gtk_util.h" |
30 #include "ipc/ipc_channel_handle.h" | 31 #include "ipc/ipc_channel_handle.h" |
31 #include "net/base/net_errors.h" | 32 #include "net/base/net_errors.h" |
32 #include "webkit/glue/plugins/plugin_lib.h" | 33 #include "webkit/glue/plugins/plugin_lib.h" |
33 #include "webkit/glue/webkit_glue.h" | 34 #include "webkit/glue/webkit_glue.h" |
34 #include "webkit/glue/plugins/webplugin_delegate_impl.h" | 35 #include "webkit/glue/plugins/webplugin_delegate_impl.h" |
35 | 36 |
36 #if defined(USE_X11) | 37 #if defined(USE_X11) |
37 #include "app/x11_util.h" | 38 #include "app/x11_util.h" |
38 #elif defined(OS_MACOSX) | 39 #elif defined(OS_MACOSX) |
39 #include "app/l10n_util.h" | 40 #include "app/l10n_util.h" |
(...skipping 11 matching lines...) Expand all Loading... |
51 plugin_path_ = | 52 plugin_path_ = |
52 CommandLine::ForCurrentProcess()->GetSwitchValuePath( | 53 CommandLine::ForCurrentProcess()->GetSwitchValuePath( |
53 switches::kPluginPath); | 54 switches::kPluginPath); |
54 | 55 |
55 lazy_tls.Pointer()->Set(this); | 56 lazy_tls.Pointer()->Set(this); |
56 #if defined(OS_LINUX) | 57 #if defined(OS_LINUX) |
57 { | 58 { |
58 // XEmbed plugins assume they are hosted in a Gtk application, so we need | 59 // XEmbed plugins assume they are hosted in a Gtk application, so we need |
59 // to initialize Gtk in the plugin process. | 60 // to initialize Gtk in the plugin process. |
60 g_thread_init(NULL); | 61 g_thread_init(NULL); |
61 const std::vector<std::string>& args = | |
62 CommandLine::ForCurrentProcess()->argv(); | |
63 int argc = args.size(); | |
64 scoped_array<char *> argv(new char *[argc + 1]); | |
65 for (size_t i = 0; i < args.size(); ++i) { | |
66 // TODO(piman@google.com): can gtk_init modify argv? Just being safe | |
67 // here. | |
68 argv[i] = strdup(args[i].c_str()); | |
69 } | |
70 argv[argc] = NULL; | |
71 char **argv_pointer = argv.get(); | |
72 | 62 |
73 // Flash has problems receiving clicks with newer GTKs due to the | 63 // Flash has problems receiving clicks with newer GTKs due to the |
74 // client-side windows change. To be safe, we just always set the | 64 // client-side windows change. To be safe, we just always set the |
75 // backwards-compat environment variable. | 65 // backwards-compat environment variable. |
76 setenv("GDK_NATIVE_WINDOWS", "1", 1); | 66 setenv("GDK_NATIVE_WINDOWS", "1", 1); |
77 | 67 |
78 gtk_init(&argc, &argv_pointer); | 68 gfx::GtkInitFromCommandLine(*CommandLine::ForCurrentProcess()); |
79 | 69 |
80 // GTK after 2.18 resets the environment variable. But if we're using | 70 // GTK after 2.18 resets the environment variable. But if we're using |
81 // nspluginwrapper, that means it'll spawn its subprocess without the | 71 // nspluginwrapper, that means it'll spawn its subprocess without the |
82 // environment variable! So set it again. | 72 // environment variable! So set it again. |
83 setenv("GDK_NATIVE_WINDOWS", "1", 1); | 73 setenv("GDK_NATIVE_WINDOWS", "1", 1); |
84 | |
85 for (size_t i = 0; i < args.size(); ++i) { | |
86 free(argv[i]); | |
87 } | |
88 } | 74 } |
89 | 75 |
90 x11_util::SetDefaultX11ErrorHandlers(); | 76 x11_util::SetDefaultX11ErrorHandlers(); |
91 #endif | 77 #endif |
92 | 78 |
93 PatchNPNFunctions(); | 79 PatchNPNFunctions(); |
94 | 80 |
95 // Preload the library to avoid loading, unloading then reloading | 81 // Preload the library to avoid loading, unloading then reloading |
96 preloaded_plugin_module_ = base::LoadNativeLibrary(plugin_path_); | 82 preloaded_plugin_module_ = base::LoadNativeLibrary(plugin_path_); |
97 | 83 |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 } | 222 } |
237 | 223 |
238 if (!result || net_error != net::OK) | 224 if (!result || net_error != net::OK) |
239 return false; | 225 return false; |
240 | 226 |
241 *proxy_list = proxy_result; | 227 *proxy_list = proxy_result; |
242 return true; | 228 return true; |
243 } | 229 } |
244 | 230 |
245 } // namespace webkit_glue | 231 } // namespace webkit_glue |
OLD | NEW |