| Index: content/browser/browser_plugin/browser_plugin_guest.cc
|
| diff --git a/content/browser/browser_plugin/browser_plugin_guest.cc b/content/browser/browser_plugin/browser_plugin_guest.cc
|
| index 68ab4967f774af83837fb36e59b35cd95304c659..85ac9e197dbf75a8e798c83dc899bad2d5476c5b 100644
|
| --- a/content/browser/browser_plugin/browser_plugin_guest.cc
|
| +++ b/content/browser/browser_plugin/browser_plugin_guest.cc
|
| @@ -6,6 +6,7 @@
|
|
|
| #include <algorithm>
|
|
|
| +#include "base/command_line.h"
|
| #include "base/string_util.h"
|
| #include "base/utf_string_conversions.h"
|
| #include "content/browser/browser_plugin/browser_plugin_embedder.h"
|
| @@ -27,6 +28,7 @@
|
| #include "content/public/browser/resource_request_details.h"
|
| #include "content/public/browser/user_metrics.h"
|
| #include "content/public/browser/web_contents_view.h"
|
| +#include "content/public/common/content_switches.h"
|
| #include "content/public/common/result_codes.h"
|
| #include "content/browser/browser_plugin/browser_plugin_host_factory.h"
|
| #include "net/base/net_errors.h"
|
| @@ -321,13 +323,17 @@ void BrowserPluginGuest::DidCommitProvisionalLoadForFrame(
|
| }
|
|
|
| void BrowserPluginGuest::DidStopLoading(RenderViewHost* render_view_host) {
|
| - // Initiating a drag from inside a guest is currently not supported. So inject
|
| - // some JS to disable it. http://crbug.com/161112
|
| - const char script[] = "window.addEventListener('dragstart', function() { "
|
| - " window.event.preventDefault(); "
|
| - "});";
|
| - render_view_host->ExecuteJavascriptInWebFrame(string16(),
|
| - ASCIIToUTF16(script));
|
| + if (!CommandLine::ForCurrentProcess()->HasSwitch(
|
| + switches::kEnableBrowserPluginCompositing)) {
|
| + // Initiating a drag from inside a guest is currently not supported without
|
| + // the kEnableBrowserPluginCompositing flag. So inject some JS to disable
|
| + // it. http://crbug.com/161112
|
| + const char script[] = "window.addEventListener('dragstart', function() { "
|
| + " window.event.preventDefault(); "
|
| + "});";
|
| + render_view_host->ExecuteJavascriptInWebFrame(string16(),
|
| + ASCIIToUTF16(script));
|
| + }
|
| SendMessageToEmbedder(new BrowserPluginMsg_LoadStop(embedder_routing_id(),
|
| instance_id()));
|
| }
|
| @@ -371,6 +377,7 @@ bool BrowserPluginGuest::OnMessageReceived(const IPC::Message& message) {
|
| bool handled = true;
|
| IPC_BEGIN_MESSAGE_MAP(BrowserPluginGuest, message)
|
| IPC_MESSAGE_HANDLER(ViewHostMsg_CreateWindow, OnCreateWindow)
|
| + IPC_MESSAGE_HANDLER(DragHostMsg_DragStopped, OnDragStopped)
|
| IPC_MESSAGE_HANDLER(ViewHostMsg_HandleInputEvent_ACK, OnHandleInputEventAck)
|
| IPC_MESSAGE_HANDLER(ViewHostMsg_HasTouchEventHandlers,
|
| OnHasTouchEventHandlers)
|
| @@ -382,8 +389,9 @@ bool BrowserPluginGuest::OnMessageReceived(const IPC::Message& message) {
|
| IPC_MESSAGE_HANDLER(ViewHostMsg_ShowPopup, OnShowPopup)
|
| #endif
|
| IPC_MESSAGE_HANDLER(ViewHostMsg_ShowWidget, OnShowWidget)
|
| + IPC_MESSAGE_HANDLER_GENERIC(DragHostMsg_StartDragging,
|
| + OnStartDragging(&handled));
|
| IPC_MESSAGE_HANDLER(ViewHostMsg_TakeFocus, OnTakeFocus)
|
| - IPC_MESSAGE_HANDLER(DragHostMsg_UpdateDragCursor, OnUpdateDragCursor)
|
| IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateFrameName, OnUpdateFrameName)
|
| IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateRect, OnUpdateRect)
|
| IPC_MESSAGE_UNHANDLED(handled = false)
|
| @@ -399,12 +407,15 @@ void BrowserPluginGuest::OnDragStatusUpdate(int instance_id,
|
| RenderViewHost* host = web_contents()->GetRenderViewHost();
|
| switch (drag_status) {
|
| case WebKit::WebDragStatusEnter:
|
| + embedder_web_contents_->GetBrowserPluginEmbedder()->DragEnteredGuest(
|
| + this);
|
| host->DragTargetDragEnter(drop_data, location, location, mask, 0);
|
| break;
|
| case WebKit::WebDragStatusOver:
|
| host->DragTargetDragOver(location, location, mask, 0);
|
| break;
|
| case WebKit::WebDragStatusLeave:
|
| + embedder_web_contents_->GetBrowserPluginEmbedder()->DragLeftGuest(this);
|
| host->DragTargetDragLeave();
|
| break;
|
| case WebKit::WebDragStatusDrop:
|
| @@ -588,6 +599,10 @@ void BrowserPluginGuest::OnCreateWindow(
|
| *cloned_session_storage_namespace_id = 0l;
|
| }
|
|
|
| +void BrowserPluginGuest::OnDragStopped() {
|
| + web_contents()->GetRenderViewHost()->DragSourceSystemDragEnded();
|
| +}
|
| +
|
| void BrowserPluginGuest::OnHandleInputEventAck(
|
| WebKit::WebInputEvent::Type event_type,
|
| InputEventAckState ack_result) {
|
| @@ -635,6 +650,14 @@ void BrowserPluginGuest::OnShowWidget(int route_id,
|
| screen_pos);
|
| }
|
|
|
| +void BrowserPluginGuest::OnStartDragging(bool* handled) {
|
| + embedder_web_contents_->GetBrowserPluginEmbedder()->StartDrag(this);
|
| + // Don't mark as handled, so that it gets passed up the chain and eventually
|
| + // gets to WebContentsViewGuest::StartDragging, which starts the drag on the
|
| + // embedder.
|
| + *handled = false;
|
| +}
|
| +
|
| void BrowserPluginGuest::OnTakeFocus(bool reverse) {
|
| SendMessageToEmbedder(
|
| new BrowserPluginMsg_AdvanceFocus(embedder_routing_id(),
|
| @@ -642,18 +665,6 @@ void BrowserPluginGuest::OnTakeFocus(bool reverse) {
|
| reverse));
|
| }
|
|
|
| -void BrowserPluginGuest::OnUpdateDragCursor(
|
| - WebKit::WebDragOperation operation) {
|
| - RenderViewHostImpl* embedder_render_view_host =
|
| - static_cast<RenderViewHostImpl*>(
|
| - embedder_web_contents_->GetRenderViewHost());
|
| - CHECK(embedder_render_view_host);
|
| - RenderViewHostDelegateView* view =
|
| - embedder_render_view_host->GetDelegate()->GetDelegateView();
|
| - if (view)
|
| - view->UpdateDragCursor(operation);
|
| -}
|
| -
|
| void BrowserPluginGuest::OnUpdateFrameName(int frame_id,
|
| bool is_top_level,
|
| const std::string& name) {
|
|
|