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/plugin/plugin_thread.h" | 5 #include "content/plugin/plugin_thread.h" |
6 | 6 |
7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
8 | 8 |
9 #if defined(TOOLKIT_USES_GTK) | 9 #if defined(TOOLKIT_USES_GTK) |
10 #include <gtk/gtk.h> | 10 #include <gtk/gtk.h> |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 } | 62 } |
63 }; | 63 }; |
64 | 64 |
65 } // namespace | 65 } // namespace |
66 | 66 |
67 static base::LazyInstance<base::ThreadLocalPointer<PluginThread> > lazy_tls( | 67 static base::LazyInstance<base::ThreadLocalPointer<PluginThread> > lazy_tls( |
68 base::LINKER_INITIALIZED); | 68 base::LINKER_INITIALIZED); |
69 | 69 |
70 PluginThread::PluginThread() | 70 PluginThread::PluginThread() |
71 : preloaded_plugin_module_(NULL) { | 71 : preloaded_plugin_module_(NULL) { |
72 plugin_path_ = | 72 FilePath plugin_path = CommandLine::ForCurrentProcess()->GetSwitchValuePath( |
73 CommandLine::ForCurrentProcess()->GetSwitchValuePath( | 73 switches::kPluginPath); |
74 switches::kPluginPath); | |
75 | 74 |
76 lazy_tls.Pointer()->Set(this); | 75 lazy_tls.Pointer()->Set(this); |
77 #if defined(USE_AURA) | 76 #if defined(USE_AURA) |
78 // TODO(saintlou): | 77 // TODO(saintlou): |
79 #elif defined(TOOLKIT_USES_GTK) | 78 #elif defined(TOOLKIT_USES_GTK) |
80 { | 79 { |
81 // XEmbed plugins assume they are hosted in a Gtk application, so we need | 80 // XEmbed plugins assume they are hosted in a Gtk application, so we need |
82 // to initialize Gtk in the plugin process. | 81 // to initialize Gtk in the plugin process. |
83 g_thread_init(NULL); | 82 g_thread_init(NULL); |
84 | 83 |
85 // Flash has problems receiving clicks with newer GTKs due to the | 84 // Flash has problems receiving clicks with newer GTKs due to the |
86 // client-side windows change. To be safe, we just always set the | 85 // client-side windows change. To be safe, we just always set the |
87 // backwards-compat environment variable. | 86 // backwards-compat environment variable. |
88 setenv("GDK_NATIVE_WINDOWS", "1", 1); | 87 setenv("GDK_NATIVE_WINDOWS", "1", 1); |
89 | 88 |
90 gfx::GtkInitFromCommandLine(*CommandLine::ForCurrentProcess()); | 89 gfx::GtkInitFromCommandLine(*CommandLine::ForCurrentProcess()); |
91 | 90 |
92 // GTK after 2.18 resets the environment variable. But if we're using | 91 // GTK after 2.18 resets the environment variable. But if we're using |
93 // nspluginwrapper, that means it'll spawn its subprocess without the | 92 // nspluginwrapper, that means it'll spawn its subprocess without the |
94 // environment variable! So set it again. | 93 // environment variable! So set it again. |
95 setenv("GDK_NATIVE_WINDOWS", "1", 1); | 94 setenv("GDK_NATIVE_WINDOWS", "1", 1); |
96 } | 95 } |
97 | 96 |
98 ui::SetDefaultX11ErrorHandlers(); | 97 ui::SetDefaultX11ErrorHandlers(); |
99 #endif | 98 #endif |
100 | 99 |
101 PatchNPNFunctions(); | 100 PatchNPNFunctions(); |
102 | 101 |
103 // Preload the library to avoid loading, unloading then reloading | 102 // Preload the library to avoid loading, unloading then reloading |
104 preloaded_plugin_module_ = base::LoadNativeLibrary(plugin_path_, NULL); | 103 preloaded_plugin_module_ = base::LoadNativeLibrary(plugin_path, NULL); |
105 | 104 |
106 scoped_refptr<webkit::npapi::PluginLib> plugin( | 105 scoped_refptr<webkit::npapi::PluginLib> plugin( |
107 webkit::npapi::PluginLib::CreatePluginLib(plugin_path_)); | 106 webkit::npapi::PluginLib::CreatePluginLib(plugin_path)); |
108 if (plugin.get()) { | 107 if (plugin.get()) { |
109 plugin->NP_Initialize(); | 108 plugin->NP_Initialize(); |
110 // For OOP plugins the plugin dll will be unloaded during process shutdown | 109 // For OOP plugins the plugin dll will be unloaded during process shutdown |
111 // time. | 110 // time. |
112 plugin->set_defer_unload(true); | 111 plugin->set_defer_unload(true); |
113 } | 112 } |
114 | 113 |
115 content::GetContentClient()->plugin()->PluginProcessStarted( | 114 content::GetContentClient()->plugin()->PluginProcessStarted( |
116 plugin.get() ? plugin->plugin_info().name : string16()); | 115 plugin.get() ? plugin->plugin_info().name : string16()); |
117 | 116 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 #endif | 163 #endif |
165 channel->set_incognito(incognito); | 164 channel->set_incognito(incognito); |
166 } | 165 } |
167 | 166 |
168 Send(new PluginProcessHostMsg_ChannelCreated(channel_handle)); | 167 Send(new PluginProcessHostMsg_ChannelCreated(channel_handle)); |
169 } | 168 } |
170 | 169 |
171 void PluginThread::OnNotifyRenderersOfPendingShutdown() { | 170 void PluginThread::OnNotifyRenderersOfPendingShutdown() { |
172 PluginChannel::NotifyRenderersOfPendingShutdown(); | 171 PluginChannel::NotifyRenderersOfPendingShutdown(); |
173 } | 172 } |
OLD | NEW |