OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "chrome/plugin/webplugin_proxy.h" | 5 #include "chrome/plugin/webplugin_proxy.h" |
6 | 6 |
7 #include "base/gfx/gdi_util.h" | 7 #include "base/gfx/gdi_util.h" |
8 #include "base/scoped_handle.h" | 8 #include "base/scoped_handle.h" |
9 #include "base/shared_memory.h" | 9 #include "base/shared_memory.h" |
10 #include "base/singleton.h" | 10 #include "base/singleton.h" |
| 11 #include "base/waitable_event.h" |
11 #include "chrome/common/gfx/chrome_canvas.h" | 12 #include "chrome/common/gfx/chrome_canvas.h" |
12 #include "chrome/common/plugin_messages.h" | 13 #include "chrome/common/plugin_messages.h" |
13 #include "chrome/common/win_util.h" | 14 #include "chrome/common/win_util.h" |
14 #include "chrome/plugin/plugin_channel.h" | 15 #include "chrome/plugin/plugin_channel.h" |
15 #include "chrome/plugin/webplugin_delegate_stub.h" | 16 #include "chrome/plugin/webplugin_delegate_stub.h" |
16 #include "chrome/plugin/npobject_proxy.h" | 17 #include "chrome/plugin/npobject_proxy.h" |
17 #include "chrome/plugin/npobject_util.h" | 18 #include "chrome/plugin/npobject_util.h" |
18 #include "skia/ext/platform_device.h" | 19 #include "skia/ext/platform_device.h" |
19 #include "webkit/glue/plugins/webplugin_delegate_impl.h" | 20 #include "webkit/glue/plugins/webplugin_delegate_impl.h" |
20 | 21 |
(...skipping 19 matching lines...) Expand all Loading... |
40 | 41 |
41 HANDLE event; | 42 HANDLE event; |
42 BOOL result = DuplicateHandle(channel->renderer_handle(), | 43 BOOL result = DuplicateHandle(channel->renderer_handle(), |
43 modal_dialog_event, | 44 modal_dialog_event, |
44 GetCurrentProcess(), | 45 GetCurrentProcess(), |
45 &event, | 46 &event, |
46 SYNCHRONIZE, | 47 SYNCHRONIZE, |
47 FALSE, | 48 FALSE, |
48 0); | 49 0); |
49 DCHECK(result) << "Couldn't duplicate the modal dialog handle for the plugin."
; | 50 DCHECK(result) << "Couldn't duplicate the modal dialog handle for the plugin."
; |
50 modal_dialog_event_.Set(event); | 51 modal_dialog_event_.reset(new base::WaitableEvent(event)); |
51 } | 52 } |
52 | 53 |
53 WebPluginProxy::~WebPluginProxy() { | 54 WebPluginProxy::~WebPluginProxy() { |
54 if (cp_browsing_context_) | 55 if (cp_browsing_context_) |
55 GetContextMap().erase(cp_browsing_context_); | 56 GetContextMap().erase(cp_browsing_context_); |
56 } | 57 } |
57 | 58 |
58 bool WebPluginProxy::Send(IPC::Message* msg) { | 59 bool WebPluginProxy::Send(IPC::Message* msg) { |
59 return channel_->Send(msg); | 60 return channel_->Send(msg); |
60 } | 61 } |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 bool success = false; | 115 bool success = false; |
115 void* npobject_ptr; | 116 void* npobject_ptr; |
116 Send(new PluginHostMsg_GetWindowScriptNPObject( | 117 Send(new PluginHostMsg_GetWindowScriptNPObject( |
117 route_id_, npobject_route_id, &success, &npobject_ptr)); | 118 route_id_, npobject_route_id, &success, &npobject_ptr)); |
118 if (!success) | 119 if (!success) |
119 return NULL; | 120 return NULL; |
120 | 121 |
121 window_npobject_ = NPObjectProxy::Create(channel_, | 122 window_npobject_ = NPObjectProxy::Create(channel_, |
122 npobject_route_id, | 123 npobject_route_id, |
123 npobject_ptr, | 124 npobject_ptr, |
124 modal_dialog_event_.Get()); | 125 modal_dialog_event_.get()); |
125 | 126 |
126 return window_npobject_; | 127 return window_npobject_; |
127 } | 128 } |
128 | 129 |
129 NPObject* WebPluginProxy::GetPluginElement() { | 130 NPObject* WebPluginProxy::GetPluginElement() { |
130 if (plugin_element_) | 131 if (plugin_element_) |
131 return NPN_RetainObject(plugin_element_); | 132 return NPN_RetainObject(plugin_element_); |
132 | 133 |
133 int npobject_route_id = channel_->GenerateRouteID(); | 134 int npobject_route_id = channel_->GenerateRouteID(); |
134 bool success = false; | 135 bool success = false; |
135 void* npobject_ptr; | 136 void* npobject_ptr; |
136 Send(new PluginHostMsg_GetPluginElement( | 137 Send(new PluginHostMsg_GetPluginElement( |
137 route_id_, npobject_route_id, &success, &npobject_ptr)); | 138 route_id_, npobject_route_id, &success, &npobject_ptr)); |
138 if (!success) | 139 if (!success) |
139 return NULL; | 140 return NULL; |
140 | 141 |
141 plugin_element_ = NPObjectProxy::Create(channel_, | 142 plugin_element_ = NPObjectProxy::Create(channel_, |
142 npobject_route_id, | 143 npobject_route_id, |
143 npobject_ptr, | 144 npobject_ptr, |
144 modal_dialog_event_.Get()); | 145 modal_dialog_event_.get()); |
145 | 146 |
146 return plugin_element_; | 147 return plugin_element_; |
147 } | 148 } |
148 | 149 |
149 void WebPluginProxy::SetCookie(const GURL& url, | 150 void WebPluginProxy::SetCookie(const GURL& url, |
150 const GURL& policy_url, | 151 const GURL& policy_url, |
151 const std::string& cookie) { | 152 const std::string& cookie) { |
152 Send(new PluginHostMsg_SetCookie(route_id_, url, policy_url, cookie)); | 153 Send(new PluginHostMsg_SetCookie(route_id_, url, policy_url, cookie)); |
153 } | 154 } |
154 | 155 |
155 std::string WebPluginProxy::GetCookies(const GURL& url, | 156 std::string WebPluginProxy::GetCookies(const GURL& url, |
156 const GURL& policy_url) { | 157 const GURL& policy_url) { |
157 std::string cookies; | 158 std::string cookies; |
158 Send(new PluginHostMsg_GetCookies(route_id_, url, policy_url, &cookies)); | 159 Send(new PluginHostMsg_GetCookies(route_id_, url, policy_url, &cookies)); |
159 | 160 |
160 return cookies; | 161 return cookies; |
161 } | 162 } |
162 | 163 |
163 void WebPluginProxy::ShowModalHTMLDialog(const GURL& url, int width, int height, | 164 void WebPluginProxy::ShowModalHTMLDialog(const GURL& url, int width, int height, |
164 const std::string& json_arguments, | 165 const std::string& json_arguments, |
165 std::string* json_retval) { | 166 std::string* json_retval) { |
166 PluginHostMsg_ShowModalHTMLDialog* msg = | 167 PluginHostMsg_ShowModalHTMLDialog* msg = |
167 new PluginHostMsg_ShowModalHTMLDialog( | 168 new PluginHostMsg_ShowModalHTMLDialog( |
168 route_id_, url, width, height, json_arguments, json_retval); | 169 route_id_, url, width, height, json_arguments, json_retval); |
169 | 170 |
170 // Create a new event and set it. This forces us to pump messages while | 171 // Create a new event and set it. This forces us to pump messages while |
171 // waiting for a response (which won't come until the dialog is closed). This | 172 // waiting for a response (which won't come until the dialog is closed). This |
172 // avoids a deadlock. | 173 // avoids a deadlock. |
173 ScopedHandle event(CreateEvent(NULL, FALSE, TRUE, NULL)); | 174 scoped_ptr<base::WaitableEvent> event( |
174 msg->set_pump_messages_event(event); | 175 new base::WaitableEvent(false, true)); |
| 176 msg->set_pump_messages_event(event.get()); |
175 | 177 |
176 Send(msg); | 178 Send(msg); |
177 } | 179 } |
178 | 180 |
179 void WebPluginProxy::OnMissingPluginStatus(int status) { | 181 void WebPluginProxy::OnMissingPluginStatus(int status) { |
180 Send(new PluginHostMsg_MissingPluginStatus(route_id_, status)); | 182 Send(new PluginHostMsg_MissingPluginStatus(route_id_, status)); |
181 } | 183 } |
182 | 184 |
183 CPBrowsingContext WebPluginProxy::GetCPBrowsingContext() { | 185 CPBrowsingContext WebPluginProxy::GetCPBrowsingContext() { |
184 if (cp_browsing_context_ == 0) { | 186 if (cp_browsing_context_ == 0) { |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
385 | 387 |
386 Send(new PluginHostMsg_InitiateHTTPRangeRequest(route_id_, url, | 388 Send(new PluginHostMsg_InitiateHTTPRangeRequest(route_id_, url, |
387 range_info, existing_stream, | 389 range_info, existing_stream, |
388 notify_needed, notify_data)); | 390 notify_needed, notify_data)); |
389 } | 391 } |
390 | 392 |
391 void WebPluginProxy::OnPaint(const gfx::Rect& damaged_rect) { | 393 void WebPluginProxy::OnPaint(const gfx::Rect& damaged_rect) { |
392 Paint(damaged_rect); | 394 Paint(damaged_rect); |
393 Send(new PluginHostMsg_InvalidateRect(route_id_, damaged_rect)); | 395 Send(new PluginHostMsg_InvalidateRect(route_id_, damaged_rect)); |
394 } | 396 } |
OLD | NEW |