Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(60)

Side by Side Diff: chrome/plugin/webplugin_proxy.cc

Issue 6576020: Remove Gears from Chrome (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: windows fixes Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/plugin/webplugin_proxy.h ('k') | chrome/renderer/render_thread.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "chrome/plugin/webplugin_proxy.h" 5 #include "chrome/plugin/webplugin_proxy.h"
6 6
7 #include "build/build_config.h" 7 #include "build/build_config.h"
8 8
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/scoped_handle.h" 10 #include "base/scoped_handle.h"
(...skipping 27 matching lines...) Expand all
38 #include "ui/base/x/x11_util_internal.h" 38 #include "ui/base/x/x11_util_internal.h"
39 #endif 39 #endif
40 40
41 using WebKit::WebBindings; 41 using WebKit::WebBindings;
42 42
43 using webkit::npapi::WebPluginResourceClient; 43 using webkit::npapi::WebPluginResourceClient;
44 #if defined(OS_MACOSX) 44 #if defined(OS_MACOSX)
45 using webkit::npapi::WebPluginAcceleratedSurface; 45 using webkit::npapi::WebPluginAcceleratedSurface;
46 #endif 46 #endif
47 47
48 typedef std::map<CPBrowsingContext, WebPluginProxy*> ContextMap;
49 static base::LazyInstance<ContextMap> g_context_map(base::LINKER_INITIALIZED);
50
51 WebPluginProxy::WebPluginProxy( 48 WebPluginProxy::WebPluginProxy(
52 PluginChannel* channel, 49 PluginChannel* channel,
53 int route_id, 50 int route_id,
54 const GURL& page_url, 51 const GURL& page_url,
55 gfx::NativeViewId containing_window, 52 gfx::NativeViewId containing_window,
56 int host_render_view_routing_id) 53 int host_render_view_routing_id)
57 : channel_(channel), 54 : channel_(channel),
58 route_id_(route_id), 55 route_id_(route_id),
59 cp_browsing_context_(0),
60 window_npobject_(NULL), 56 window_npobject_(NULL),
61 plugin_element_(NULL), 57 plugin_element_(NULL),
62 delegate_(NULL), 58 delegate_(NULL),
63 waiting_for_paint_(false), 59 waiting_for_paint_(false),
64 containing_window_(containing_window), 60 containing_window_(containing_window),
65 page_url_(page_url), 61 page_url_(page_url),
66 transparent_(false), 62 transparent_(false),
67 host_render_view_routing_id_(host_render_view_routing_id), 63 host_render_view_routing_id_(host_render_view_routing_id),
68 ALLOW_THIS_IN_INITIALIZER_LIST(runnable_method_factory_(this)) { 64 ALLOW_THIS_IN_INITIALIZER_LIST(runnable_method_factory_(this)) {
69 #if defined(USE_X11) 65 #if defined(USE_X11)
(...skipping 11 matching lines...) Expand all
81 77
82 if (vis->red_mask == 0xff0000 && 78 if (vis->red_mask == 0xff0000 &&
83 vis->green_mask == 0xff00 && 79 vis->green_mask == 0xff00 &&
84 vis->blue_mask == 0xff) 80 vis->blue_mask == 0xff)
85 use_shm_pixmap_ = true; 81 use_shm_pixmap_ = true;
86 } 82 }
87 #endif 83 #endif
88 } 84 }
89 85
90 WebPluginProxy::~WebPluginProxy() { 86 WebPluginProxy::~WebPluginProxy() {
91 if (cp_browsing_context_)
92 g_context_map.Get().erase(cp_browsing_context_);
93
94 #if defined(USE_X11) 87 #if defined(USE_X11)
95 if (windowless_shm_pixmap_ != None) 88 if (windowless_shm_pixmap_ != None)
96 XFreePixmap(ui::GetXDisplay(), windowless_shm_pixmap_); 89 XFreePixmap(ui::GetXDisplay(), windowless_shm_pixmap_);
97 #endif 90 #endif
98 91
99 #if defined(OS_MACOSX) 92 #if defined(OS_MACOSX)
100 // Destroy the surface early, since it may send messages during cleanup. 93 // Destroy the surface early, since it may send messages during cleanup.
101 if (accelerated_surface_.get()) 94 if (accelerated_surface_.get())
102 accelerated_surface_.reset(); 95 accelerated_surface_.reset();
103 #endif 96 #endif
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 232
240 std::string WebPluginProxy::GetCookies(const GURL& url, 233 std::string WebPluginProxy::GetCookies(const GURL& url,
241 const GURL& first_party_for_cookies) { 234 const GURL& first_party_for_cookies) {
242 std::string cookies; 235 std::string cookies;
243 Send(new PluginHostMsg_GetCookies(route_id_, url, 236 Send(new PluginHostMsg_GetCookies(route_id_, url,
244 first_party_for_cookies, &cookies)); 237 first_party_for_cookies, &cookies));
245 238
246 return cookies; 239 return cookies;
247 } 240 }
248 241
249 void WebPluginProxy::ShowModalHTMLDialog(const GURL& url, int width, int height,
250 const std::string& json_arguments,
251 std::string* json_retval) {
252 PluginHostMsg_ShowModalHTMLDialog* msg =
253 new PluginHostMsg_ShowModalHTMLDialog(
254 route_id_, url, width, height, json_arguments, json_retval);
255
256 // Pump messages while waiting for a response (which won't come until the
257 // dialog is closed). This avoids a deadlock.
258 msg->EnableMessagePumping();
259 Send(msg);
260 }
261
262 void WebPluginProxy::OnMissingPluginStatus(int status) { 242 void WebPluginProxy::OnMissingPluginStatus(int status) {
263 Send(new PluginHostMsg_MissingPluginStatus(route_id_, status)); 243 Send(new PluginHostMsg_MissingPluginStatus(route_id_, status));
264 } 244 }
265 245
266 CPBrowsingContext WebPluginProxy::GetCPBrowsingContext() {
267 if (cp_browsing_context_ == 0) {
268 Send(new PluginHostMsg_GetCPBrowsingContext(route_id_,
269 &cp_browsing_context_));
270 g_context_map.Get()[cp_browsing_context_] = this;
271 }
272 return cp_browsing_context_;
273 }
274
275 WebPluginProxy* WebPluginProxy::FromCPBrowsingContext(
276 CPBrowsingContext context) {
277 return g_context_map.Get()[context];
278 }
279
280 WebPluginResourceClient* WebPluginProxy::GetResourceClient(int id) { 246 WebPluginResourceClient* WebPluginProxy::GetResourceClient(int id) {
281 ResourceClientMap::iterator iterator = resource_clients_.find(id); 247 ResourceClientMap::iterator iterator = resource_clients_.find(id);
282 // The IPC messages which deal with streams are now asynchronous. It is 248 // The IPC messages which deal with streams are now asynchronous. It is
283 // now possible to receive stream messages from the renderer for streams 249 // now possible to receive stream messages from the renderer for streams
284 // which may have been cancelled by the plugin. 250 // which may have been cancelled by the plugin.
285 if (iterator == resource_clients_.end()) { 251 if (iterator == resource_clients_.end()) {
286 return NULL; 252 return NULL;
287 } 253 }
288 254
289 return iterator->second; 255 return iterator->second;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 memcpy(&params.buffer.front(), buf, len); 309 memcpy(&params.buffer.front(), buf, len);
344 } 310 }
345 311
346 params.notify_id = notify_id; 312 params.notify_id = notify_id;
347 params.popups_allowed = popups_allowed; 313 params.popups_allowed = popups_allowed;
348 params.notify_redirects = notify_redirects; 314 params.notify_redirects = notify_redirects;
349 315
350 Send(new PluginHostMsg_URLRequest(route_id_, params)); 316 Send(new PluginHostMsg_URLRequest(route_id_, params));
351 } 317 }
352 318
353 bool WebPluginProxy::GetDragData(struct NPObject* event, bool add_data,
354 int32* identity, int32* event_id,
355 std::string* type, std::string* data) {
356 DCHECK(event);
357 NPObjectProxy* proxy = NPObjectProxy::GetProxy(event);
358 if (!proxy) // NPObject* event should have/be a renderer proxy.
359 return false;
360
361 NPVariant_Param event_param;
362 event_param.type = NPVARIANT_PARAM_RECEIVER_OBJECT_ROUTING_ID;
363 event_param.npobject_routing_id = proxy->route_id();
364
365 std::vector<NPVariant_Param> values;
366 bool success = false;
367 Send(new PluginHostMsg_GetDragData(route_id_, event_param, add_data,
368 &values, &success));
369 if (!success)
370 return false;
371
372 DCHECK(values.size() == 4);
373 DCHECK(values[0].type == NPVARIANT_PARAM_INT);
374 *identity = static_cast<int32>(values[0].int_value);
375 DCHECK(values[1].type == NPVARIANT_PARAM_INT);
376 *event_id = static_cast<int32>(values[1].int_value);
377 DCHECK(values[2].type == NPVARIANT_PARAM_STRING);
378 type->swap(values[2].string_value);
379 if (add_data && (values[3].type == NPVARIANT_PARAM_STRING))
380 data->swap(values[3].string_value);
381
382 return true;
383 }
384
385 bool WebPluginProxy::SetDropEffect(struct NPObject* event, int effect) {
386 DCHECK(event);
387 NPObjectProxy* proxy = NPObjectProxy::GetProxy(event);
388 if (!proxy) // NPObject* event should have/be a renderer proxy.
389 return false;
390
391 NPVariant_Param event_param;
392 event_param.type = NPVARIANT_PARAM_RECEIVER_OBJECT_ROUTING_ID;
393 event_param.npobject_routing_id = proxy->route_id();
394
395 bool success = false;
396 Send(new PluginHostMsg_SetDropEffect(route_id_, event_param, effect,
397 &success));
398 return success;
399 }
400
401 void WebPluginProxy::Paint(const gfx::Rect& rect) { 319 void WebPluginProxy::Paint(const gfx::Rect& rect) {
402 #if defined(OS_MACOSX) 320 #if defined(OS_MACOSX)
403 if (!windowless_context_.get()) 321 if (!windowless_context_.get())
404 return; 322 return;
405 #else 323 #else
406 if (!windowless_canvas_.get()) 324 if (!windowless_canvas_.get())
407 return; 325 return;
408 #endif 326 #endif
409 327
410 // Clear the damaged area so that if the plugin doesn't paint there we won't 328 // Clear the damaged area so that if the plugin doesn't paint there we won't
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
730 resource_clients_.erase(index++); 648 resource_clients_.erase(index++);
731 } else { 649 } else {
732 index++; 650 index++;
733 } 651 }
734 } 652 }
735 } 653 }
736 654
737 void WebPluginProxy::URLRedirectResponse(bool allow, int resource_id) { 655 void WebPluginProxy::URLRedirectResponse(bool allow, int resource_id) {
738 Send(new PluginHostMsg_URLRedirectResponse(route_id_, allow, resource_id)); 656 Send(new PluginHostMsg_URLRedirectResponse(route_id_, allow, resource_id));
739 } 657 }
740
OLDNEW
« no previous file with comments | « chrome/plugin/webplugin_proxy.h ('k') | chrome/renderer/render_thread.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698