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 30 matching lines...) Expand all Loading... |
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" | 49 #include "webkit/plugins/npapi/webplugin_delegate_impl.h" |
50 | 50 |
| 51 namespace { |
| 52 |
| 53 void ReparentPluginWindowHelper(HWND window, HWND parent) { |
| 54 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 55 |
| 56 int window_style = WS_CHILD; |
| 57 if (!webkit::npapi::WebPluginDelegateImpl::IsDummyActivationWindow(window)) |
| 58 window_style |= WS_CLIPCHILDREN | WS_CLIPSIBLINGS; |
| 59 |
| 60 ::SetWindowLongPtr(window, GWL_STYLE, window_style); |
| 61 ::SetParent(window, parent); |
| 62 } |
| 63 |
| 64 } // namespace |
| 65 |
51 void PluginProcessHost::OnPluginWindowDestroyed(HWND window, HWND parent) { | 66 void PluginProcessHost::OnPluginWindowDestroyed(HWND window, HWND parent) { |
52 // The window is destroyed at this point, we just care about its parent, which | 67 // The window is destroyed at this point, we just care about its parent, which |
53 // is the intermediate window we created. | 68 // is the intermediate window we created. |
54 std::set<HWND>::iterator window_index = | 69 std::set<HWND>::iterator window_index = |
55 plugin_parent_windows_set_.find(parent); | 70 plugin_parent_windows_set_.find(parent); |
56 if (window_index == plugin_parent_windows_set_.end()) | 71 if (window_index == plugin_parent_windows_set_.end()) |
57 return; | 72 return; |
58 | 73 |
59 plugin_parent_windows_set_.erase(window_index); | 74 plugin_parent_windows_set_.erase(window_index); |
60 PostMessage(parent, WM_CLOSE, 0, 0); | 75 PostMessage(parent, WM_CLOSE, 0, 0); |
61 } | 76 } |
62 | 77 |
63 void PluginProcessHost::AddWindow(HWND window) { | 78 void PluginProcessHost::AddWindow(HWND window) { |
64 plugin_parent_windows_set_.insert(window); | 79 plugin_parent_windows_set_.insert(window); |
65 } | 80 } |
66 | 81 |
67 void PluginProcessHost::OnReparentPluginWindow(HWND window, HWND parent) { | 82 void PluginProcessHost::OnReparentPluginWindow(HWND window, HWND parent) { |
68 // Reparent only to our process. | 83 // Reparent only to our process. |
69 DWORD process_id = 0; | 84 DWORD process_id = 0; |
70 ::GetWindowThreadProcessId(parent, &process_id); | 85 ::GetWindowThreadProcessId(parent, &process_id); |
71 if (process_id != ::GetCurrentProcessId()) | 86 if (process_id != ::GetCurrentProcessId()) |
72 return; | 87 return; |
73 | 88 |
74 if (webkit::npapi::WebPluginDelegateImpl::IsDummyActivationWindow(window)) { | 89 BrowserThread::PostTask( |
75 ::SetWindowLongPtr(window, GWL_STYLE, WS_CHILD); | 90 BrowserThread::UI, FROM_HERE, |
76 } else { | 91 NewRunnableFunction(ReparentPluginWindowHelper, window, parent)); |
77 ::SetWindowLongPtr(window, GWL_STYLE, WS_CHILD | WS_CLIPCHILDREN | | |
78 WS_CLIPSIBLINGS); | |
79 } | |
80 ::SetParent(window, parent); | |
81 } | 92 } |
82 #endif // defined(OS_WIN) | 93 #endif // defined(OS_WIN) |
83 | 94 |
84 #if defined(TOOLKIT_USES_GTK) | 95 #if defined(TOOLKIT_USES_GTK) |
85 void PluginProcessHost::OnMapNativeViewId(gfx::NativeViewId id, | 96 void PluginProcessHost::OnMapNativeViewId(gfx::NativeViewId id, |
86 gfx::PluginWindowHandle* output) { | 97 gfx::PluginWindowHandle* output) { |
87 *output = 0; | 98 *output = 0; |
88 GtkNativeViewManager::GetInstance()->GetXIDForId(output, id); | 99 GtkNativeViewManager::GetInstance()->GetXIDForId(output, id); |
89 } | 100 } |
90 #endif // defined(TOOLKIT_USES_GTK) | 101 #endif // defined(TOOLKIT_USES_GTK) |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 } | 356 } |
346 } | 357 } |
347 | 358 |
348 void PluginProcessHost::OnChannelCreated( | 359 void PluginProcessHost::OnChannelCreated( |
349 const IPC::ChannelHandle& channel_handle) { | 360 const IPC::ChannelHandle& channel_handle) { |
350 Client* client = sent_requests_.front(); | 361 Client* client = sent_requests_.front(); |
351 | 362 |
352 client->OnChannelOpened(channel_handle); | 363 client->OnChannelOpened(channel_handle); |
353 sent_requests_.pop(); | 364 sent_requests_.pop(); |
354 } | 365 } |
OLD | NEW |