OLD | NEW |
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/npobject_util.h" | 24 #include "content/child/npapi/npobject_util.h" |
25 #include "content/child/npapi/plugin_lib.h" | 25 #include "content/child/npapi/plugin_lib.h" |
26 #include "content/child/npapi/webplugin_delegate_impl.h" | |
27 #include "content/common/plugin_process_messages.h" | 26 #include "content/common/plugin_process_messages.h" |
28 #include "content/public/common/content_switches.h" | 27 #include "content/public/common/content_switches.h" |
29 #include "content/public/plugin/content_plugin_client.h" | 28 #include "content/public/plugin/content_plugin_client.h" |
30 #include "ipc/ipc_channel_handle.h" | 29 #include "ipc/ipc_channel_handle.h" |
31 #include "webkit/glue/webkit_glue.h" | 30 #include "webkit/glue/webkit_glue.h" |
32 #include "webkit/plugins/npapi/plugin_utils.h" | |
33 | 31 |
34 #if defined(TOOLKIT_GTK) | 32 #if defined(TOOLKIT_GTK) |
35 #include "ui/gfx/gtk_util.h" | 33 #include "ui/gfx/gtk_util.h" |
36 #endif | 34 #endif |
37 | 35 |
38 #if defined(USE_X11) | 36 #if defined(USE_X11) |
39 #include "ui/base/x/x11_util.h" | 37 #include "ui/base/x/x11_util.h" |
40 #endif | 38 #endif |
41 | 39 |
42 namespace content { | 40 namespace content { |
(...skipping 26 matching lines...) Expand all Loading... |
69 base::KillProcess(base::GetCurrentProcessHandle(), 0, false); | 67 base::KillProcess(base::GetCurrentProcessHandle(), 0, false); |
70 } | 68 } |
71 }; | 69 }; |
72 | 70 |
73 } // namespace | 71 } // namespace |
74 | 72 |
75 static base::LazyInstance<base::ThreadLocalPointer<PluginThread> > lazy_tls = | 73 static base::LazyInstance<base::ThreadLocalPointer<PluginThread> > lazy_tls = |
76 LAZY_INSTANCE_INITIALIZER; | 74 LAZY_INSTANCE_INITIALIZER; |
77 | 75 |
78 PluginThread::PluginThread() | 76 PluginThread::PluginThread() |
79 : preloaded_plugin_module_(NULL) { | 77 : preloaded_plugin_module_(NULL), |
| 78 forcefully_terminate_plugin_process_(false) { |
80 base::FilePath plugin_path = | 79 base::FilePath plugin_path = |
81 CommandLine::ForCurrentProcess()->GetSwitchValuePath( | 80 CommandLine::ForCurrentProcess()->GetSwitchValuePath( |
82 switches::kPluginPath); | 81 switches::kPluginPath); |
83 | 82 |
84 lazy_tls.Pointer()->Set(this); | 83 lazy_tls.Pointer()->Set(this); |
85 #if defined(USE_AURA) | 84 #if defined(USE_AURA) |
86 // TODO(saintlou): | 85 // TODO(saintlou): |
87 #elif defined(TOOLKIT_GTK) | 86 #elif defined(TOOLKIT_GTK) |
88 { | 87 { |
89 // XEmbed plugins assume they are hosted in a Gtk application, so we need | 88 // XEmbed plugins assume they are hosted in a Gtk application, so we need |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 | 127 |
129 // Certain plugins, such as flash, steal the unhandled exception filter | 128 // Certain plugins, such as flash, steal the unhandled exception filter |
130 // thus we never get crash reports when they fault. This call fixes it. | 129 // thus we never get crash reports when they fault. This call fixes it. |
131 message_loop()->set_exception_restoration(true); | 130 message_loop()->set_exception_restoration(true); |
132 channel()->AddFilter(new EnsureTerminateMessageFilter()); | 131 channel()->AddFilter(new EnsureTerminateMessageFilter()); |
133 } | 132 } |
134 | 133 |
135 PluginThread::~PluginThread() { | 134 PluginThread::~PluginThread() { |
136 } | 135 } |
137 | 136 |
| 137 void PluginThread::SetForcefullyTerminatePluginProcess() { |
| 138 forcefully_terminate_plugin_process_ = true; |
| 139 } |
| 140 |
138 void PluginThread::Shutdown() { | 141 void PluginThread::Shutdown() { |
139 if (preloaded_plugin_module_) { | 142 if (preloaded_plugin_module_) { |
140 base::UnloadNativeLibrary(preloaded_plugin_module_); | 143 base::UnloadNativeLibrary(preloaded_plugin_module_); |
141 preloaded_plugin_module_ = NULL; | 144 preloaded_plugin_module_ = NULL; |
142 } | 145 } |
143 NPChannelBase::CleanupChannels(); | 146 NPChannelBase::CleanupChannels(); |
144 PluginLib::UnloadAllPlugins(); | 147 PluginLib::UnloadAllPlugins(); |
145 | 148 |
146 if (webkit::npapi::ShouldForcefullyTerminatePluginProcess()) | 149 if (forcefully_terminate_plugin_process_) |
147 base::KillProcess(base::GetCurrentProcessHandle(), 0, /* wait= */ false); | 150 base::KillProcess(base::GetCurrentProcessHandle(), 0, /* wait= */ false); |
148 | 151 |
149 lazy_tls.Pointer()->Set(NULL); | 152 lazy_tls.Pointer()->Set(NULL); |
150 } | 153 } |
151 | 154 |
152 PluginThread* PluginThread::current() { | 155 PluginThread* PluginThread::current() { |
153 return lazy_tls.Pointer()->Get(); | 156 return lazy_tls.Pointer()->Get(); |
154 } | 157 } |
155 | 158 |
156 bool PluginThread::OnControlMessageReceived(const IPC::Message& msg) { | 159 bool PluginThread::OnControlMessageReceived(const IPC::Message& msg) { |
(...skipping 23 matching lines...) Expand all Loading... |
180 } | 183 } |
181 | 184 |
182 Send(new PluginProcessHostMsg_ChannelCreated(channel_handle)); | 185 Send(new PluginProcessHostMsg_ChannelCreated(channel_handle)); |
183 } | 186 } |
184 | 187 |
185 void PluginThread::OnNotifyRenderersOfPendingShutdown() { | 188 void PluginThread::OnNotifyRenderersOfPendingShutdown() { |
186 PluginChannel::NotifyRenderersOfPendingShutdown(); | 189 PluginChannel::NotifyRenderersOfPendingShutdown(); |
187 } | 190 } |
188 | 191 |
189 } // namespace content | 192 } // namespace content |
OLD | NEW |