| 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_POSIX) |
| 8 #include <windows.h> | |
| 9 #elif defined(OS_POSIX) | |
| 10 #include <utility> // for pair<> | 8 #include <utility> // for pair<> |
| 11 #endif | 9 #endif |
| 12 | 10 |
| 13 #include <vector> | 11 #include <vector> |
| 14 | 12 |
| 15 #include "base/command_line.h" | 13 #include "base/command_line.h" |
| 16 #include "base/file_path.h" | 14 #include "base/file_path.h" |
| 17 #include "base/file_util.h" | 15 #include "base/file_util.h" |
| 18 #include "base/logging.h" | 16 #include "base/logging.h" |
| 19 #include "base/path_service.h" | 17 #include "base/path_service.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 37 #include "ui/gfx/gtk_native_view_id_manager.h" | 35 #include "ui/gfx/gtk_native_view_id_manager.h" |
| 38 #endif | 36 #endif |
| 39 | 37 |
| 40 #if defined(OS_MACOSX) | 38 #if defined(OS_MACOSX) |
| 41 #include "base/mac/mac_util.h" | 39 #include "base/mac/mac_util.h" |
| 42 #include "content/common/plugin_carbon_interpose_constants_mac.h" | 40 #include "content/common/plugin_carbon_interpose_constants_mac.h" |
| 43 #include "ui/gfx/rect.h" | 41 #include "ui/gfx/rect.h" |
| 44 #endif | 42 #endif |
| 45 | 43 |
| 46 #if defined(OS_WIN) | 44 #if defined(OS_WIN) |
| 45 #include "base/win/windows_version.h" |
| 46 #include "webkit/plugins/npapi/plugin_constants_win.h" |
| 47 #include "webkit/plugins/npapi/webplugin_delegate_impl.h" | 47 #include "webkit/plugins/npapi/webplugin_delegate_impl.h" |
| 48 | 48 |
| 49 namespace { | 49 namespace { |
| 50 | 50 |
| 51 void ReparentPluginWindowHelper(HWND window, HWND parent) { | 51 void ReparentPluginWindowHelper(HWND window, HWND parent) { |
| 52 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 52 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 53 | 53 |
| 54 int window_style = WS_CHILD; | 54 int window_style = WS_CHILD; |
| 55 if (!webkit::npapi::WebPluginDelegateImpl::IsDummyActivationWindow(window)) | 55 if (!webkit::npapi::WebPluginDelegateImpl::IsDummyActivationWindow(window)) |
| 56 window_style |= WS_CLIPCHILDREN | WS_CLIPSIBLINGS; | 56 window_style |= WS_CLIPCHILDREN | WS_CLIPSIBLINGS; |
| 57 | 57 |
| 58 ::SetWindowLongPtr(window, GWL_STYLE, window_style); | 58 ::SetWindowLongPtr(window, GWL_STYLE, window_style); |
| 59 ::SetParent(window, parent); | 59 ::SetParent(window, parent); |
| 60 // Allow the Flash plugin to forward some messages back to Chrome. |
| 61 if (base::win::GetVersion() >= base::win::VERSION_WIN7) |
| 62 ::SetPropW(parent, webkit::npapi::kNativeWindowClassFilterProp, HANDLE(-1)); |
| 60 } | 63 } |
| 61 | 64 |
| 62 } // namespace | 65 } // namespace |
| 63 | 66 |
| 64 void PluginProcessHost::OnPluginWindowDestroyed(HWND window, HWND parent) { | 67 void PluginProcessHost::OnPluginWindowDestroyed(HWND window, HWND parent) { |
| 65 // The window is destroyed at this point, we just care about its parent, which | 68 // The window is destroyed at this point, we just care about its parent, which |
| 66 // is the intermediate window we created. | 69 // is the intermediate window we created. |
| 67 std::set<HWND>::iterator window_index = | 70 std::set<HWND>::iterator window_index = |
| 68 plugin_parent_windows_set_.find(parent); | 71 plugin_parent_windows_set_.find(parent); |
| 69 if (window_index == plugin_parent_windows_set_.end()) | 72 if (window_index == plugin_parent_windows_set_.end()) |
| 70 return; | 73 return; |
| 71 | 74 |
| 72 plugin_parent_windows_set_.erase(window_index); | 75 plugin_parent_windows_set_.erase(window_index); |
| 73 PostMessage(parent, WM_CLOSE, 0, 0); | 76 PostMessage(parent, WM_CLOSE, 0, 0); |
| 74 } | 77 } |
| 75 | 78 |
| 76 void PluginProcessHost::AddWindow(HWND window) { | 79 void PluginProcessHost::AddWindow(HWND window) { |
| 77 plugin_parent_windows_set_.insert(window); | 80 plugin_parent_windows_set_.insert(window); |
| 78 } | 81 } |
| 79 | 82 |
| 80 void PluginProcessHost::OnReparentPluginWindow(HWND window, HWND parent) { | 83 void PluginProcessHost::OnReparentPluginWindow(HWND window, HWND parent) { |
| 81 // Reparent only to our process. | 84 // Reparent only from the plugin process to our process. |
| 82 DWORD process_id = 0; | 85 DWORD process_id = 0; |
| 86 ::GetWindowThreadProcessId(window, &process_id); |
| 87 if (process_id != ::GetProcessId(GetChildProcessHandle())) |
| 88 return; |
| 83 ::GetWindowThreadProcessId(parent, &process_id); | 89 ::GetWindowThreadProcessId(parent, &process_id); |
| 84 if (process_id != ::GetCurrentProcessId()) | 90 if (process_id != ::GetCurrentProcessId()) |
| 85 return; | 91 return; |
| 86 | 92 |
| 87 BrowserThread::PostTask( | 93 BrowserThread::PostTask( |
| 88 BrowserThread::UI, FROM_HERE, | 94 BrowserThread::UI, FROM_HERE, |
| 89 NewRunnableFunction(ReparentPluginWindowHelper, window, parent)); | 95 NewRunnableFunction(ReparentPluginWindowHelper, window, parent)); |
| 90 } | 96 } |
| 91 #endif // defined(OS_WIN) | 97 #endif // defined(OS_WIN) |
| 92 | 98 |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 } | 352 } |
| 347 } | 353 } |
| 348 | 354 |
| 349 void PluginProcessHost::OnChannelCreated( | 355 void PluginProcessHost::OnChannelCreated( |
| 350 const IPC::ChannelHandle& channel_handle) { | 356 const IPC::ChannelHandle& channel_handle) { |
| 351 Client* client = sent_requests_.front(); | 357 Client* client = sent_requests_.front(); |
| 352 | 358 |
| 353 client->OnChannelOpened(channel_handle); | 359 client->OnChannelOpened(channel_handle); |
| 354 sent_requests_.pop(); | 360 sent_requests_.pop(); |
| 355 } | 361 } |
| OLD | NEW |