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

Side by Side Diff: content/plugin/plugin_thread.cc

Issue 19761007: Move NPAPI implementation out of webkit/plugins/npapi and into content. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix mac Created 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_GTK) 9 #if defined(TOOLKIT_GTK)
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/bind.h" 18 #include "base/bind.h"
19 #include "base/command_line.h" 19 #include "base/command_line.h"
20 #include "base/lazy_instance.h" 20 #include "base/lazy_instance.h"
21 #include "base/process_util.h" 21 #include "base/process_util.h"
22 #include "base/threading/thread_local.h" 22 #include "base/threading/thread_local.h"
23 #include "content/child/child_process.h" 23 #include "content/child/child_process.h"
24 #include "content/child/npapi/plugin_lib.h"
25 #include "content/child/npapi/webplugin_delegate_impl.h"
24 #include "content/child/npobject_util.h" 26 #include "content/child/npobject_util.h"
25 #include "content/common/plugin_process_messages.h" 27 #include "content/common/plugin_process_messages.h"
26 #include "content/public/common/content_switches.h" 28 #include "content/public/common/content_switches.h"
27 #include "content/public/plugin/content_plugin_client.h" 29 #include "content/public/plugin/content_plugin_client.h"
28 #include "ipc/ipc_channel_handle.h" 30 #include "ipc/ipc_channel_handle.h"
29 #include "webkit/glue/webkit_glue.h" 31 #include "webkit/glue/webkit_glue.h"
30 #include "webkit/plugins/npapi/plugin_lib.h"
31 #include "webkit/plugins/npapi/plugin_list.h"
32 #include "webkit/plugins/npapi/plugin_utils.h" 32 #include "webkit/plugins/npapi/plugin_utils.h"
33 #include "webkit/plugins/npapi/webplugin_delegate_impl.h"
34 33
35 #if defined(TOOLKIT_GTK) 34 #if defined(TOOLKIT_GTK)
36 #include "ui/gfx/gtk_util.h" 35 #include "ui/gfx/gtk_util.h"
37 #endif 36 #endif
38 37
39 #if defined(USE_X11) 38 #if defined(USE_X11)
40 #include "ui/base/x/x11_util.h" 39 #include "ui/base/x/x11_util.h"
41 #endif 40 #endif
42 41
43 namespace content { 42 namespace content {
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 } 108 }
110 109
111 ui::SetDefaultX11ErrorHandlers(); 110 ui::SetDefaultX11ErrorHandlers();
112 #endif 111 #endif
113 112
114 PatchNPNFunctions(); 113 PatchNPNFunctions();
115 114
116 // Preload the library to avoid loading, unloading then reloading 115 // Preload the library to avoid loading, unloading then reloading
117 preloaded_plugin_module_ = base::LoadNativeLibrary(plugin_path, NULL); 116 preloaded_plugin_module_ = base::LoadNativeLibrary(plugin_path, NULL);
118 117
119 scoped_refptr<webkit::npapi::PluginLib> plugin( 118 scoped_refptr<PluginLib> plugin(PluginLib::CreatePluginLib(plugin_path));
120 webkit::npapi::PluginLib::CreatePluginLib(plugin_path));
121 if (plugin.get()) { 119 if (plugin.get()) {
122 plugin->NP_Initialize(); 120 plugin->NP_Initialize();
123 // For OOP plugins the plugin dll will be unloaded during process shutdown 121 // For OOP plugins the plugin dll will be unloaded during process shutdown
124 // time. 122 // time.
125 plugin->set_defer_unload(true); 123 plugin->set_defer_unload(true);
126 } 124 }
127 125
128 GetContentClient()->plugin()->PluginProcessStarted( 126 GetContentClient()->plugin()->PluginProcessStarted(
129 plugin.get() ? plugin->plugin_info().name : string16()); 127 plugin.get() ? plugin->plugin_info().name : string16());
130 128
131 // Certain plugins, such as flash, steal the unhandled exception filter 129 // Certain plugins, such as flash, steal the unhandled exception filter
132 // thus we never get crash reports when they fault. This call fixes it. 130 // thus we never get crash reports when they fault. This call fixes it.
133 message_loop()->set_exception_restoration(true); 131 message_loop()->set_exception_restoration(true);
134 channel()->AddFilter(new EnsureTerminateMessageFilter()); 132 channel()->AddFilter(new EnsureTerminateMessageFilter());
135 } 133 }
136 134
137 PluginThread::~PluginThread() { 135 PluginThread::~PluginThread() {
138 } 136 }
139 137
140 void PluginThread::Shutdown() { 138 void PluginThread::Shutdown() {
141 if (preloaded_plugin_module_) { 139 if (preloaded_plugin_module_) {
142 base::UnloadNativeLibrary(preloaded_plugin_module_); 140 base::UnloadNativeLibrary(preloaded_plugin_module_);
143 preloaded_plugin_module_ = NULL; 141 preloaded_plugin_module_ = NULL;
144 } 142 }
145 NPChannelBase::CleanupChannels(); 143 NPChannelBase::CleanupChannels();
146 webkit::npapi::PluginLib::UnloadAllPlugins(); 144 PluginLib::UnloadAllPlugins();
147 145
148 if (webkit::npapi::ShouldForcefullyTerminatePluginProcess()) 146 if (webkit::npapi::ShouldForcefullyTerminatePluginProcess())
149 base::KillProcess(base::GetCurrentProcessHandle(), 0, /* wait= */ false); 147 base::KillProcess(base::GetCurrentProcessHandle(), 0, /* wait= */ false);
150 148
151 lazy_tls.Pointer()->Set(NULL); 149 lazy_tls.Pointer()->Set(NULL);
152 } 150 }
153 151
154 PluginThread* PluginThread::current() { 152 PluginThread* PluginThread::current() {
155 return lazy_tls.Pointer()->Get(); 153 return lazy_tls.Pointer()->Get();
156 } 154 }
(...skipping 25 matching lines...) Expand all
182 } 180 }
183 181
184 Send(new PluginProcessHostMsg_ChannelCreated(channel_handle)); 182 Send(new PluginProcessHostMsg_ChannelCreated(channel_handle));
185 } 183 }
186 184
187 void PluginThread::OnNotifyRenderersOfPendingShutdown() { 185 void PluginThread::OnNotifyRenderersOfPendingShutdown() {
188 PluginChannel::NotifyRenderersOfPendingShutdown(); 186 PluginChannel::NotifyRenderersOfPendingShutdown();
189 } 187 }
190 188
191 } // namespace content 189 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698