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 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
452 bool BrowserPluginGuest::Find(int request_id, | 452 bool BrowserPluginGuest::Find(int request_id, |
453 const base::string16& search_text, | 453 const base::string16& search_text, |
454 const blink::WebFindOptions& options) { | 454 const blink::WebFindOptions& options) { |
455 return delegate_->Find(request_id, search_text, options); | 455 return delegate_->Find(request_id, search_text, options); |
456 } | 456 } |
457 | 457 |
458 bool BrowserPluginGuest::StopFinding(StopFindAction action) { | 458 bool BrowserPluginGuest::StopFinding(StopFindAction action) { |
459 return delegate_->StopFinding(action); | 459 return delegate_->StopFinding(action); |
460 } | 460 } |
461 | 461 |
| 462 void BrowserPluginGuest::ResendEventToEmbedder( |
| 463 const blink::WebInputEvent& event) { |
| 464 if (!attached() || !owner_web_contents_) |
| 465 return; |
| 466 |
| 467 DCHECK(browser_plugin_instance_id_); |
| 468 RenderWidgetHostImpl* host = |
| 469 embedder_web_contents()->GetMainFrame()->GetRenderWidgetHost(); |
| 470 |
| 471 gfx::Vector2d offset_from_embedder = guest_window_rect_.OffsetFromOrigin(); |
| 472 if (event.type == blink::WebInputEvent::GestureScrollUpdate) { |
| 473 blink::WebGestureEvent resent_gesture_event; |
| 474 memcpy(&resent_gesture_event, &event, sizeof(blink::WebGestureEvent)); |
| 475 resent_gesture_event.x += offset_from_embedder.x(); |
| 476 resent_gesture_event.y += offset_from_embedder.y(); |
| 477 // Mark the resend source with the browser plugin's instance id, so the |
| 478 // correct browser_plugin will know to ignore the event. |
| 479 resent_gesture_event.resendingPluginId = browser_plugin_instance_id_; |
| 480 host->ForwardGestureEvent(resent_gesture_event); |
| 481 } else if (event.type == blink::WebInputEvent::MouseWheel) { |
| 482 blink::WebMouseWheelEvent resent_wheel_event; |
| 483 memcpy(&resent_wheel_event, &event, sizeof(blink::WebMouseWheelEvent)); |
| 484 resent_wheel_event.x += offset_from_embedder.x(); |
| 485 resent_wheel_event.y += offset_from_embedder.y(); |
| 486 resent_wheel_event.resendingPluginId = browser_plugin_instance_id_; |
| 487 host->ForwardWheelEvent(resent_wheel_event); |
| 488 } else { |
| 489 NOTIMPLEMENTED(); |
| 490 } |
| 491 } |
| 492 |
462 WebContentsImpl* BrowserPluginGuest::GetWebContents() const { | 493 WebContentsImpl* BrowserPluginGuest::GetWebContents() const { |
463 return static_cast<WebContentsImpl*>(web_contents()); | 494 return static_cast<WebContentsImpl*>(web_contents()); |
464 } | 495 } |
465 | 496 |
466 gfx::Point BrowserPluginGuest::GetScreenCoordinates( | 497 gfx::Point BrowserPluginGuest::GetScreenCoordinates( |
467 const gfx::Point& relative_position) const { | 498 const gfx::Point& relative_position) const { |
468 if (!attached()) | 499 if (!attached()) |
469 return relative_position; | 500 return relative_position; |
470 | 501 |
471 gfx::Point screen_pos(relative_position); | 502 gfx::Point screen_pos(relative_position); |
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
980 range, character_bounds); | 1011 range, character_bounds); |
981 } | 1012 } |
982 #endif | 1013 #endif |
983 | 1014 |
984 void BrowserPluginGuest::SetContextMenuPosition(const gfx::Point& position) { | 1015 void BrowserPluginGuest::SetContextMenuPosition(const gfx::Point& position) { |
985 if (delegate_) | 1016 if (delegate_) |
986 delegate_->SetContextMenuPosition(position); | 1017 delegate_->SetContextMenuPosition(position); |
987 } | 1018 } |
988 | 1019 |
989 } // namespace content | 1020 } // namespace content |
OLD | NEW |