| 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..8710145010fcd30dde60e31a6926276374acbf7d 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"
|
| @@ -58,6 +60,8 @@ BrowserPluginGuest::BrowserPluginGuest(
|
| base::TimeDelta::FromMilliseconds(kHungRendererDelayMs)),
|
| focused_(params.focused),
|
| visible_(params.visible),
|
| + dragging_(false),
|
| + drag_over_(false),
|
| name_(params.name),
|
| auto_size_enabled_(params.auto_size_params.enable),
|
| max_auto_size_(params.auto_size_params.max_size),
|
| @@ -321,13 +325,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 +379,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 +391,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 +409,14 @@ void BrowserPluginGuest::OnDragStatusUpdate(int instance_id,
|
| RenderViewHost* host = web_contents()->GetRenderViewHost();
|
| switch (drag_status) {
|
| case WebKit::WebDragStatusEnter:
|
| + drag_over_ = true;
|
| host->DragTargetDragEnter(drop_data, location, location, mask, 0);
|
| break;
|
| case WebKit::WebDragStatusOver:
|
| host->DragTargetDragOver(location, location, mask, 0);
|
| break;
|
| case WebKit::WebDragStatusLeave:
|
| + drag_over_ = false;
|
| host->DragTargetDragLeave();
|
| break;
|
| case WebKit::WebDragStatusDrop:
|
| @@ -588,6 +600,13 @@ void BrowserPluginGuest::OnCreateWindow(
|
| *cloned_session_storage_namespace_id = 0l;
|
| }
|
|
|
| +void BrowserPluginGuest::OnDragStopped() {
|
| + if (dragging_) {
|
| + web_contents()->GetRenderViewHost()->DragSourceSystemDragEnded();
|
| + dragging_ = false;
|
| + }
|
| +}
|
| +
|
| void BrowserPluginGuest::OnHandleInputEventAck(
|
| WebKit::WebInputEvent::Type event_type,
|
| InputEventAckState ack_result) {
|
| @@ -635,6 +654,14 @@ void BrowserPluginGuest::OnShowWidget(int route_id,
|
| screen_pos);
|
| }
|
|
|
| +void BrowserPluginGuest::OnStartDragging(bool* handled) {
|
| + dragging_ = true;
|
| + // 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 +669,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) {
|
|
|