OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/browser_plugin/browser_plugin_guest.h" | 5 #include "content/browser/browser_plugin/browser_plugin_guest.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/pickle.h" | 10 #include "base/pickle.h" |
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
465 bool BrowserPluginGuest::Find(int request_id, | 465 bool BrowserPluginGuest::Find(int request_id, |
466 const base::string16& search_text, | 466 const base::string16& search_text, |
467 const blink::WebFindOptions& options) { | 467 const blink::WebFindOptions& options) { |
468 return delegate_->Find(request_id, search_text, options); | 468 return delegate_->Find(request_id, search_text, options); |
469 } | 469 } |
470 | 470 |
471 bool BrowserPluginGuest::StopFinding(StopFindAction action) { | 471 bool BrowserPluginGuest::StopFinding(StopFindAction action) { |
472 return delegate_->StopFinding(action); | 472 return delegate_->StopFinding(action); |
473 } | 473 } |
474 | 474 |
475 void BrowserPluginGuest::ResendEventToEmbedder( | |
476 const blink::WebInputEvent& event) { | |
477 if (!attached() || !owner_web_contents_) | |
478 return; | |
479 | |
480 DCHECK(browser_plugin_instance_id_); | |
481 RenderViewHost* rvh = embedder_web_contents()->GetRenderViewHost(); | |
kenrb
2015/09/14 15:48:51
I would prefer if you accessed the main RenderFram
wjmaclean
2015/09/14 20:47:21
Done.
| |
482 | |
483 if (event.type == blink::WebInputEvent::GestureScrollUpdate) { | |
484 blink::WebGestureEvent resent_gesture_event; | |
485 memcpy(&resent_gesture_event, &event, sizeof(blink::WebGestureEvent)); | |
486 // Mark the resend source with the browser plugin's instance id, so the | |
487 // correct browser_plugin will know to ignore the event. | |
488 resent_gesture_event.resendSource = browser_plugin_instance_id_; | |
489 RenderWidgetHostImpl* host = RenderWidgetHostImpl::From(rvh); | |
490 bool needs_wrapping = !host->is_in_gesture_scroll(); | |
491 if (needs_wrapping) { | |
492 blink::WebGestureEvent wrap_gesture_scroll_begin; | |
493 wrap_gesture_scroll_begin.type = blink::WebInputEvent::GestureScrollBegin; | |
494 wrap_gesture_scroll_begin.data.scrollBegin.deltaXHint = 0; | |
495 wrap_gesture_scroll_begin.data.scrollBegin.deltaYHint = 0; | |
496 wrap_gesture_scroll_begin.resendSource = browser_plugin_instance_id_; | |
497 host->ForwardGestureEvent(wrap_gesture_scroll_begin); | |
498 } | |
499 host->ForwardGestureEvent(resent_gesture_event); | |
500 if (needs_wrapping) { | |
501 blink::WebGestureEvent wrap_gesture_scroll_end; | |
502 wrap_gesture_scroll_end.type = blink::WebInputEvent::GestureScrollEnd; | |
503 wrap_gesture_scroll_end.resendSource = browser_plugin_instance_id_; | |
504 host->ForwardGestureEvent(wrap_gesture_scroll_end); | |
505 } | |
506 } else if (event.type == blink::WebInputEvent::MouseWheel) { | |
507 blink::WebMouseWheelEvent resent_wheel_event; | |
508 memcpy(&resent_wheel_event, &event, sizeof(blink::WebMouseWheelEvent)); | |
509 resent_wheel_event.resendSource = browser_plugin_instance_id_; | |
510 RenderWidgetHostImpl::From(rvh)->ForwardWheelEvent(resent_wheel_event); | |
511 } else { | |
512 NOTIMPLEMENTED(); | |
513 } | |
514 | |
515 } | |
516 | |
475 WebContentsImpl* BrowserPluginGuest::GetWebContents() const { | 517 WebContentsImpl* BrowserPluginGuest::GetWebContents() const { |
476 return static_cast<WebContentsImpl*>(web_contents()); | 518 return static_cast<WebContentsImpl*>(web_contents()); |
477 } | 519 } |
478 | 520 |
479 gfx::Point BrowserPluginGuest::GetScreenCoordinates( | 521 gfx::Point BrowserPluginGuest::GetScreenCoordinates( |
480 const gfx::Point& relative_position) const { | 522 const gfx::Point& relative_position) const { |
481 if (!attached()) | 523 if (!attached()) |
482 return relative_position; | 524 return relative_position; |
483 | 525 |
484 gfx::Point screen_pos(relative_position); | 526 gfx::Point screen_pos(relative_position); |
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1000 range, character_bounds); | 1042 range, character_bounds); |
1001 } | 1043 } |
1002 #endif | 1044 #endif |
1003 | 1045 |
1004 void BrowserPluginGuest::SetContextMenuPosition(const gfx::Point& position) { | 1046 void BrowserPluginGuest::SetContextMenuPosition(const gfx::Point& position) { |
1005 if (delegate_) | 1047 if (delegate_) |
1006 delegate_->SetContextMenuPosition(position); | 1048 delegate_->SetContextMenuPosition(position); |
1007 } | 1049 } |
1008 | 1050 |
1009 } // namespace content | 1051 } // namespace content |
OLD | NEW |