Chromium Code Reviews| 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..bd001bc02bef9377f88f8f7876f3391ef3882037 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())); |
| } |
| @@ -369,8 +377,16 @@ void BrowserPluginGuest::RenderViewGone(base::TerminationStatus status) { |
| bool BrowserPluginGuest::OnMessageReceived(const IPC::Message& message) { |
| bool handled = true; |
| + if (message.type() == DragHostMsg_StartDragging::ID) { |
| + dragging_ = true; |
|
Fady Samuel
2013/02/01 14:59:28
Use IPC_MESSAGE_HANDLER_GENERIC(DragHostMsg_StartD
mthiesse
2013/02/01 15:43:54
Done.
|
| + // 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. |
| + return false; |
| + } |
| 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) |
| @@ -383,7 +399,6 @@ bool BrowserPluginGuest::OnMessageReceived(const IPC::Message& message) { |
| #endif |
| IPC_MESSAGE_HANDLER(ViewHostMsg_ShowWidget, OnShowWidget) |
| 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 +414,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 +605,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) { |
| @@ -642,18 +666,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) { |