| 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/browser/plugin_process_host.h" | 5 #include "content/browser/plugin_process_host.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 bool PluginProcessHost::GetWebPluginInfoFromPluginPid(base::ProcessId pid, | 72 bool PluginProcessHost::GetWebPluginInfoFromPluginPid(base::ProcessId pid, |
| 73 WebPluginInfo* info) { | 73 WebPluginInfo* info) { |
| 74 base::AutoLock lock(g_process_webplugin_info_lock.Get()); | 74 base::AutoLock lock(g_process_webplugin_info_lock.Get()); |
| 75 if (!g_process_webplugin_info.Get().count(pid)) | 75 if (!g_process_webplugin_info.Get().count(pid)) |
| 76 return false; | 76 return false; |
| 77 | 77 |
| 78 *info = g_process_webplugin_info.Get()[pid]; | 78 *info = g_process_webplugin_info.Get()[pid]; |
| 79 return true; | 79 return true; |
| 80 } | 80 } |
| 81 | 81 |
| 82 #if defined(OS_WIN) | |
| 83 void PluginProcessHost::OnPluginWindowDestroyed(HWND window, HWND parent) { | |
| 84 // The window is destroyed at this point, we just care about its parent, which | |
| 85 // is the intermediate window we created. | |
| 86 std::set<HWND>::iterator window_index = | |
| 87 plugin_parent_windows_set_.find(parent); | |
| 88 if (window_index == plugin_parent_windows_set_.end()) | |
| 89 return; | |
| 90 | |
| 91 plugin_parent_windows_set_.erase(window_index); | |
| 92 PostMessage(parent, WM_CLOSE, 0, 0); | |
| 93 } | |
| 94 | |
| 95 void PluginProcessHost::AddWindow(HWND window) { | |
| 96 plugin_parent_windows_set_.insert(window); | |
| 97 } | |
| 98 #endif // defined(OS_WIN) | |
| 99 | |
| 100 // NOTE: changes to this class need to be reviewed by the security team. | 82 // NOTE: changes to this class need to be reviewed by the security team. |
| 101 class PluginSandboxedProcessLauncherDelegate | 83 class PluginSandboxedProcessLauncherDelegate |
| 102 : public SandboxedProcessLauncherDelegate { | 84 : public SandboxedProcessLauncherDelegate { |
| 103 public: | 85 public: |
| 104 explicit PluginSandboxedProcessLauncherDelegate(ChildProcessHost* host) | 86 explicit PluginSandboxedProcessLauncherDelegate(ChildProcessHost* host) |
| 105 #if defined(OS_POSIX) | 87 #if defined(OS_POSIX) |
| 106 : ipc_fd_(host->TakeClientFileDescriptor()) | 88 : ipc_fd_(host->TakeClientFileDescriptor()) |
| 107 #endif // OS_POSIX | 89 #endif // OS_POSIX |
| 108 {} | 90 {} |
| 109 | 91 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 129 PluginProcessHost::PluginProcessHost() | 111 PluginProcessHost::PluginProcessHost() |
| 130 : pid_(base::kNullProcessId) | 112 : pid_(base::kNullProcessId) |
| 131 #if defined(OS_MACOSX) | 113 #if defined(OS_MACOSX) |
| 132 , plugin_cursor_visible_(true) | 114 , plugin_cursor_visible_(true) |
| 133 #endif | 115 #endif |
| 134 { | 116 { |
| 135 process_.reset(new BrowserChildProcessHostImpl(PROCESS_TYPE_PLUGIN, this)); | 117 process_.reset(new BrowserChildProcessHostImpl(PROCESS_TYPE_PLUGIN, this)); |
| 136 } | 118 } |
| 137 | 119 |
| 138 PluginProcessHost::~PluginProcessHost() { | 120 PluginProcessHost::~PluginProcessHost() { |
| 139 #if defined(OS_WIN) | 121 #if defined(OS_MACOSX) |
| 140 // We erase HWNDs from the plugin_parent_windows_set_ when we receive a | |
| 141 // notification that the window is being destroyed. If we don't receive this | |
| 142 // notification and the PluginProcessHost instance is being destroyed, it | |
| 143 // means that the plugin process crashed. We paint a sad face in this case in | |
| 144 // the renderer process. To ensure that the sad face shows up, and we don't | |
| 145 // leak HWNDs, we should destroy existing plugin parent windows. | |
| 146 std::set<HWND>::iterator window_index; | |
| 147 for (window_index = plugin_parent_windows_set_.begin(); | |
| 148 window_index != plugin_parent_windows_set_.end(); | |
| 149 ++window_index) { | |
| 150 PostMessage(*window_index, WM_CLOSE, 0, 0); | |
| 151 } | |
| 152 #elif defined(OS_MACOSX) | |
| 153 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 122 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 154 // If the plugin process crashed but had fullscreen windows open at the time, | 123 // If the plugin process crashed but had fullscreen windows open at the time, |
| 155 // make sure that the menu bar is visible. | 124 // make sure that the menu bar is visible. |
| 156 for (size_t i = 0; i < plugin_fullscreen_windows_set_.size(); ++i) { | 125 for (size_t i = 0; i < plugin_fullscreen_windows_set_.size(); ++i) { |
| 157 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 126 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 158 base::Bind(base::mac::ReleaseFullScreen, | 127 base::Bind(base::mac::ReleaseFullScreen, |
| 159 base::mac::kFullScreenModeHideAll)); | 128 base::mac::kFullScreenModeHideAll)); |
| 160 } | 129 } |
| 161 // If the plugin hid the cursor, reset that. | 130 // If the plugin hid the cursor, reset that. |
| 162 if (!plugin_cursor_visible_) { | 131 if (!plugin_cursor_visible_) { |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 Send(new PluginProcessMsg_NotifyRenderersOfPendingShutdown()); | 251 Send(new PluginProcessMsg_NotifyRenderersOfPendingShutdown()); |
| 283 process_->ForceShutdown(); | 252 process_->ForceShutdown(); |
| 284 } | 253 } |
| 285 | 254 |
| 286 bool PluginProcessHost::OnMessageReceived(const IPC::Message& msg) { | 255 bool PluginProcessHost::OnMessageReceived(const IPC::Message& msg) { |
| 287 bool handled = true; | 256 bool handled = true; |
| 288 IPC_BEGIN_MESSAGE_MAP(PluginProcessHost, msg) | 257 IPC_BEGIN_MESSAGE_MAP(PluginProcessHost, msg) |
| 289 IPC_MESSAGE_HANDLER(PluginProcessHostMsg_ChannelCreated, OnChannelCreated) | 258 IPC_MESSAGE_HANDLER(PluginProcessHostMsg_ChannelCreated, OnChannelCreated) |
| 290 IPC_MESSAGE_HANDLER(PluginProcessHostMsg_ChannelDestroyed, | 259 IPC_MESSAGE_HANDLER(PluginProcessHostMsg_ChannelDestroyed, |
| 291 OnChannelDestroyed) | 260 OnChannelDestroyed) |
| 292 #if defined(OS_WIN) | |
| 293 IPC_MESSAGE_HANDLER(PluginProcessHostMsg_PluginWindowDestroyed, | |
| 294 OnPluginWindowDestroyed) | |
| 295 #endif | |
| 296 #if defined(OS_MACOSX) | 261 #if defined(OS_MACOSX) |
| 297 IPC_MESSAGE_HANDLER(PluginProcessHostMsg_PluginShowWindow, | 262 IPC_MESSAGE_HANDLER(PluginProcessHostMsg_PluginShowWindow, |
| 298 OnPluginShowWindow) | 263 OnPluginShowWindow) |
| 299 IPC_MESSAGE_HANDLER(PluginProcessHostMsg_PluginHideWindow, | 264 IPC_MESSAGE_HANDLER(PluginProcessHostMsg_PluginHideWindow, |
| 300 OnPluginHideWindow) | 265 OnPluginHideWindow) |
| 301 IPC_MESSAGE_HANDLER(PluginProcessHostMsg_PluginSetCursorVisibility, | 266 IPC_MESSAGE_HANDLER(PluginProcessHostMsg_PluginSetCursorVisibility, |
| 302 OnPluginSetCursorVisibility) | 267 OnPluginSetCursorVisibility) |
| 303 #endif | 268 #endif |
| 304 IPC_MESSAGE_UNHANDLED(handled = false) | 269 IPC_MESSAGE_UNHANDLED(handled = false) |
| 305 IPC_END_MESSAGE_MAP() | 270 IPC_END_MESSAGE_MAP() |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 433 void PluginProcessHost::GetContexts(ResourceType resource_type, | 398 void PluginProcessHost::GetContexts(ResourceType resource_type, |
| 434 int origin_pid, | 399 int origin_pid, |
| 435 ResourceContext** resource_context, | 400 ResourceContext** resource_context, |
| 436 net::URLRequestContext** request_context) { | 401 net::URLRequestContext** request_context) { |
| 437 *resource_context = | 402 *resource_context = |
| 438 resource_context_map_[origin_pid].resource_context; | 403 resource_context_map_[origin_pid].resource_context; |
| 439 *request_context = (*resource_context)->GetRequestContext(); | 404 *request_context = (*resource_context)->GetRequestContext(); |
| 440 } | 405 } |
| 441 | 406 |
| 442 } // namespace content | 407 } // namespace content |
| OLD | NEW |