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