Chromium Code Reviews| 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/browser/plugin_process_host.h" | 5 #include "content/browser/plugin_process_host.h" |
| 6 | 6 |
| 7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
| 8 #include <windows.h> | 8 #include <windows.h> |
| 9 #elif defined(OS_POSIX) | 9 #elif defined(OS_POSIX) |
| 10 #include <utility> // for pair<> | 10 #include <utility> // for pair<> |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 39 #include "ui/gfx/gtk_native_view_id_manager.h" | 39 #include "ui/gfx/gtk_native_view_id_manager.h" |
| 40 #endif | 40 #endif |
| 41 | 41 |
| 42 #if defined(OS_MACOSX) | 42 #if defined(OS_MACOSX) |
| 43 #include "base/mac/mac_util.h" | 43 #include "base/mac/mac_util.h" |
| 44 #include "content/common/plugin_carbon_interpose_constants_mac.h" | 44 #include "content/common/plugin_carbon_interpose_constants_mac.h" |
| 45 #include "ui/gfx/rect.h" | 45 #include "ui/gfx/rect.h" |
| 46 #endif | 46 #endif |
| 47 | 47 |
| 48 #if defined(OS_WIN) | 48 #if defined(OS_WIN) |
| 49 #include "webkit/plugins/npapi/webplugin_delegate_impl.h" | |
| 50 | |
| 49 void PluginProcessHost::OnPluginWindowDestroyed(HWND window, HWND parent) { | 51 void PluginProcessHost::OnPluginWindowDestroyed(HWND window, HWND parent) { |
| 50 // The window is destroyed at this point, we just care about its parent, which | 52 // The window is destroyed at this point, we just care about its parent, which |
| 51 // is the intermediate window we created. | 53 // is the intermediate window we created. |
| 52 std::set<HWND>::iterator window_index = | 54 std::set<HWND>::iterator window_index = |
| 53 plugin_parent_windows_set_.find(parent); | 55 plugin_parent_windows_set_.find(parent); |
| 54 if (window_index == plugin_parent_windows_set_.end()) | 56 if (window_index == plugin_parent_windows_set_.end()) |
| 55 return; | 57 return; |
| 56 | 58 |
| 57 plugin_parent_windows_set_.erase(window_index); | 59 plugin_parent_windows_set_.erase(window_index); |
| 58 PostMessage(parent, WM_CLOSE, 0, 0); | 60 PostMessage(parent, WM_CLOSE, 0, 0); |
| 59 } | 61 } |
| 60 | 62 |
| 61 void PluginProcessHost::AddWindow(HWND window) { | 63 void PluginProcessHost::AddWindow(HWND window) { |
| 62 plugin_parent_windows_set_.insert(window); | 64 plugin_parent_windows_set_.insert(window); |
| 63 } | 65 } |
| 64 | 66 |
| 67 void PluginProcessHost::OnReparentPluginWindow(HWND window, HWND parent) { | |
| 68 // Reparent only to our process. | |
| 69 DWORD process_id = 0; | |
| 70 ::GetWindowThreadProcessId(parent, &process_id); | |
| 71 if (::IsWindow(window) && process_id != ::GetCurrentProcessId()) | |
| 72 return; | |
| 73 | |
|
cpu_(ooo_6.6-7.5)
2011/06/07 01:03:36
If IsWindow() returns false you continue?
| |
| 74 if (webkit::npapi::WebPluginDelegateImpl::IsDummyActivationWindow(window)) { | |
| 75 ::SetWindowLongPtr(window, GWL_STYLE, WS_CHILD); | |
| 76 } else { | |
| 77 ::SetWindowLongPtr(window, GWL_STYLE, WS_CHILD | WS_CLIPCHILDREN | | |
| 78 WS_CLIPSIBLINGS); | |
| 79 } | |
| 80 ::SetParent(window, parent); | |
| 81 } | |
| 65 #endif // defined(OS_WIN) | 82 #endif // defined(OS_WIN) |
| 66 | 83 |
| 67 #if defined(TOOLKIT_USES_GTK) | 84 #if defined(TOOLKIT_USES_GTK) |
| 68 void PluginProcessHost::OnMapNativeViewId(gfx::NativeViewId id, | 85 void PluginProcessHost::OnMapNativeViewId(gfx::NativeViewId id, |
| 69 gfx::PluginWindowHandle* output) { | 86 gfx::PluginWindowHandle* output) { |
| 70 *output = 0; | 87 *output = 0; |
| 71 GtkNativeViewManager::GetInstance()->GetXIDForId(output, id); | 88 GtkNativeViewManager::GetInstance()->GetXIDForId(output, id); |
| 72 } | 89 } |
| 73 #endif // defined(TOOLKIT_USES_GTK) | 90 #endif // defined(TOOLKIT_USES_GTK) |
| 74 | 91 |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 238 BrowserChildProcessHost::ForceShutdown(); | 255 BrowserChildProcessHost::ForceShutdown(); |
| 239 } | 256 } |
| 240 | 257 |
| 241 bool PluginProcessHost::OnMessageReceived(const IPC::Message& msg) { | 258 bool PluginProcessHost::OnMessageReceived(const IPC::Message& msg) { |
| 242 bool handled = true; | 259 bool handled = true; |
| 243 IPC_BEGIN_MESSAGE_MAP(PluginProcessHost, msg) | 260 IPC_BEGIN_MESSAGE_MAP(PluginProcessHost, msg) |
| 244 IPC_MESSAGE_HANDLER(PluginProcessHostMsg_ChannelCreated, OnChannelCreated) | 261 IPC_MESSAGE_HANDLER(PluginProcessHostMsg_ChannelCreated, OnChannelCreated) |
| 245 #if defined(OS_WIN) | 262 #if defined(OS_WIN) |
| 246 IPC_MESSAGE_HANDLER(PluginProcessHostMsg_PluginWindowDestroyed, | 263 IPC_MESSAGE_HANDLER(PluginProcessHostMsg_PluginWindowDestroyed, |
| 247 OnPluginWindowDestroyed) | 264 OnPluginWindowDestroyed) |
| 265 IPC_MESSAGE_HANDLER(PluginProcessHostMsg_ReparentPluginWindow, | |
| 266 OnReparentPluginWindow) | |
| 248 #endif | 267 #endif |
| 249 #if defined(TOOLKIT_USES_GTK) | 268 #if defined(TOOLKIT_USES_GTK) |
| 250 IPC_MESSAGE_HANDLER(PluginProcessHostMsg_MapNativeViewId, | 269 IPC_MESSAGE_HANDLER(PluginProcessHostMsg_MapNativeViewId, |
| 251 OnMapNativeViewId) | 270 OnMapNativeViewId) |
| 252 #endif | 271 #endif |
| 253 #if defined(OS_MACOSX) | 272 #if defined(OS_MACOSX) |
| 254 IPC_MESSAGE_HANDLER(PluginProcessHostMsg_PluginSelectWindow, | 273 IPC_MESSAGE_HANDLER(PluginProcessHostMsg_PluginSelectWindow, |
| 255 OnPluginSelectWindow) | 274 OnPluginSelectWindow) |
| 256 IPC_MESSAGE_HANDLER(PluginProcessHostMsg_PluginShowWindow, | 275 IPC_MESSAGE_HANDLER(PluginProcessHostMsg_PluginShowWindow, |
| 257 OnPluginShowWindow) | 276 OnPluginShowWindow) |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 326 } | 345 } |
| 327 } | 346 } |
| 328 | 347 |
| 329 void PluginProcessHost::OnChannelCreated( | 348 void PluginProcessHost::OnChannelCreated( |
| 330 const IPC::ChannelHandle& channel_handle) { | 349 const IPC::ChannelHandle& channel_handle) { |
| 331 Client* client = sent_requests_.front(); | 350 Client* client = sent_requests_.front(); |
| 332 | 351 |
| 333 client->OnChannelOpened(channel_handle); | 352 client->OnChannelOpened(channel_handle); |
| 334 sent_requests_.pop(); | 353 sent_requests_.pop(); |
| 335 } | 354 } |
| OLD | NEW |