| Index: content/browser/renderer_host/render_widget_host_impl.cc
|
| diff --git a/content/browser/renderer_host/render_widget_host_impl.cc b/content/browser/renderer_host/render_widget_host_impl.cc
|
| index 09357b1b067ef661ec73a093d98db6402a101705..4925481da2dab94f2703706e00aae1213831e90b 100644
|
| --- a/content/browser/renderer_host/render_widget_host_impl.cc
|
| +++ b/content/browser/renderer_host/render_widget_host_impl.cc
|
| @@ -240,6 +240,9 @@ std::vector<DropData::Metadata> DropDataToMetaData(const DropData& drop_data) {
|
| return metadata;
|
| }
|
|
|
| +base::LazyInstance<RenderWidgetHostImpl::DragStartCallback>::Leaky
|
| + g_drag_start_callback_for_testing = LAZY_INSTANCE_INITIALIZER;
|
| +
|
| } // namespace
|
|
|
| ///////////////////////////////////////////////////////////////////////////////
|
| @@ -1502,8 +1505,14 @@ void RenderWidgetHostImpl::OnStartDragging(
|
| const SkBitmap& bitmap,
|
| const gfx::Vector2d& bitmap_offset_in_dip,
|
| const DragEventSourceInfo& event_info) {
|
| + bool drag_start_handled_by_test = false;
|
| + if (!g_drag_start_callback_for_testing.Get().is_null()) {
|
| + drag_start_handled_by_test = g_drag_start_callback_for_testing.Get().Run(
|
| + drop_data, drag_operations_mask);
|
| + }
|
| +
|
| RenderViewHostDelegateView* view = delegate_->GetDelegateView();
|
| - if (!view) {
|
| + if (!view || drag_start_handled_by_test) {
|
| // Need to clear drag and drop state in blink.
|
| DragSourceSystemDragEnded();
|
| return;
|
| @@ -2530,4 +2539,14 @@ void RenderWidgetHostImpl::GrantFileAccessFromDropData(DropData* drop_data) {
|
| }
|
| }
|
|
|
| +// static
|
| +void RenderWidgetHostImpl::RegisterDragStartCallbackForTesting(
|
| + DragStartCallback callback) {
|
| + // Prevent attempts to register more than one callback.
|
| + DCHECK(callback.is_null() ||
|
| + g_drag_start_callback_for_testing.Get().is_null());
|
| +
|
| + g_drag_start_callback_for_testing.Get() = std::move(callback);
|
| +}
|
| +
|
| } // namespace content
|
|
|