Remove dead BrowserPlugin drag and drop code
There is still some drag and drop code in BrowserPlugin classes. This code is all either dead or a no-op, which we now remove. There is also some drag and drop test supporting code that is no longer invoked by any test, which we also remove. Note that via manual testing, drag and drop of links over a webview continues to have no effect, and drag and drop of draggable elements continues to work. Bug: 533069 Change-Id: Ie9291306eff1d5f2d92c8f7c1917d6a8dbfa5d86 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2562784 Reviewed-by: Nasko Oskov <nasko@chromium.org> Reviewed-by: Istiaque Ahmed <lazyboy@chromium.org> Reviewed-by: James MacLean <wjmaclean@chromium.org> Commit-Queue: Kevin McNee <mcnee@chromium.org> Cr-Commit-Position: refs/heads/master@{#832925}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
0de0f451bf
commit
55f431479c
chrome
browser
apps
guest_view
test
content/browser
browser_plugin
renderer_host
web_contents
extensions
tools/metrics/histograms
@ -321,16 +321,6 @@ class WebViewInteractiveTest : public extensions::PlatformAppBrowserTest {
|
||||
|
||||
gfx::Rect offset = embedder_web_contents_->GetContainerBounds();
|
||||
corner_ = offset.origin();
|
||||
|
||||
const testing::TestInfo* const test_info =
|
||||
testing::UnitTest::GetInstance()->current_test_info();
|
||||
const char* prefix = "DragDropWithinWebView";
|
||||
if (!strncmp(test_info->name(), prefix, strlen(prefix))) {
|
||||
// In the drag drop test we add 20px padding to the page body because on
|
||||
// windows if we get too close to the edge of the window the resize cursor
|
||||
// appears and we start dragging the window edge.
|
||||
corner_.Offset(20, 20);
|
||||
}
|
||||
}
|
||||
|
||||
content::WebContents* guest_web_contents() {
|
||||
@ -465,58 +455,6 @@ class WebViewInteractiveTest : public extensions::PlatformAppBrowserTest {
|
||||
false, false, false);
|
||||
}
|
||||
|
||||
void DragTestStep1() {
|
||||
// Move mouse to start of text.
|
||||
MoveMouseInsideWindow(gfx::Point(45, 8));
|
||||
MoveMouseInsideWindow(gfx::Point(45, 9));
|
||||
SendMouseEvent(ui_controls::LEFT, ui_controls::DOWN);
|
||||
|
||||
MoveMouseInsideWindow(gfx::Point(74, 12));
|
||||
MoveMouseInsideWindow(gfx::Point(78, 12));
|
||||
|
||||
// Now wait a bit before moving mouse to initiate drag/drop.
|
||||
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
|
||||
FROM_HERE,
|
||||
base::BindOnce(&WebViewInteractiveTest::DragTestStep2,
|
||||
base::Unretained(this)),
|
||||
base::TimeDelta::FromMilliseconds(200));
|
||||
}
|
||||
|
||||
void DragTestStep2() {
|
||||
// Drag source over target.
|
||||
MoveMouseInsideWindow(gfx::Point(76, 76));
|
||||
|
||||
// Create a second mouse over the source to trigger the drag over event.
|
||||
MoveMouseInsideWindow(gfx::Point(76, 77));
|
||||
|
||||
// Release mouse to drop.
|
||||
SendMouseEvent(ui_controls::LEFT, ui_controls::UP);
|
||||
SendMouseClick(ui_controls::LEFT);
|
||||
|
||||
quit_closure_.Run();
|
||||
|
||||
// Note that following ExtensionTestMessageListener and ExecuteScript*
|
||||
// call must be after we quit |quit_closure_|. Otherwise the class
|
||||
// here won't be able to receive messages sent by chrome.test.sendMessage.
|
||||
// This is because of the nature of drag and drop code (esp. the
|
||||
// MessageLoop) in it.
|
||||
|
||||
// Now check if we got a drop and read the drop data.
|
||||
embedder_web_contents_ = GetFirstAppWindowWebContents();
|
||||
ExtensionTestMessageListener drop_listener("guest-got-drop", false);
|
||||
EXPECT_TRUE(content::ExecuteScript(embedder_web_contents_,
|
||||
"window.checkIfGuestGotDrop()"));
|
||||
EXPECT_TRUE(drop_listener.WaitUntilSatisfied());
|
||||
|
||||
std::string last_drop_data;
|
||||
EXPECT_TRUE(content::ExecuteScriptAndExtractString(
|
||||
embedder_web_contents_,
|
||||
"window.domAutomationController.send(getLastDropData())",
|
||||
&last_drop_data));
|
||||
|
||||
last_drop_data_ = last_drop_data;
|
||||
}
|
||||
|
||||
void FullscreenTestHelper(const std::string& test_name,
|
||||
const std::string& test_dir) {
|
||||
TestHelper(test_name, test_dir, NO_TEST_SERVER);
|
||||
@ -541,9 +479,6 @@ class WebViewInteractiveTest : public extensions::PlatformAppBrowserTest {
|
||||
gfx::Point corner_;
|
||||
bool mouse_click_result_;
|
||||
bool first_click_;
|
||||
// Only used in drag/drop test.
|
||||
base::Closure quit_closure_;
|
||||
std::string last_drop_data_;
|
||||
};
|
||||
|
||||
class WebViewImeInteractiveTest : public WebViewInteractiveTest {
|
||||
@ -591,7 +526,6 @@ class WebViewImeInteractiveTest : public WebViewInteractiveTest {
|
||||
};
|
||||
};
|
||||
|
||||
class WebViewDragDropInteractiveTest : public WebViewInteractiveTest {};
|
||||
class WebViewNewWindowInteractiveTest : public WebViewInteractiveTest {};
|
||||
class WebViewFocusInteractiveTest : public WebViewInteractiveTest {};
|
||||
class WebViewPointerLockInteractiveTest : public WebViewInteractiveTest {};
|
||||
|
@ -1,17 +0,0 @@
|
||||
/**
|
||||
* Copyright 2013 The Chromium Authors. All rights reserved.
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
body { margin: 0px; padding: 0px; }
|
||||
|
||||
.dragMe { -webkit-user-drag: element; }
|
||||
|
||||
.destination {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 50px;
|
||||
width: 300px;
|
||||
height: 100px;
|
||||
background-color: blue;
|
||||
}
|
@ -1,177 +0,0 @@
|
||||
// Copyright 2013 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
var embedder = null;
|
||||
var $ = function(id) {
|
||||
return document.getElementById(id);
|
||||
};
|
||||
|
||||
var LOG = function(msg) {
|
||||
window.console.log(msg);
|
||||
};
|
||||
|
||||
var dragStarted = false;
|
||||
var dropData = 'Uninitialized';
|
||||
var dropped = false;
|
||||
var isDragInterrupted = false;
|
||||
var sentConnectedMessage = false;
|
||||
|
||||
// Number of mousemove events recorded after (most recent) mousedown and before
|
||||
// (most recent) mouseup.
|
||||
var numDocumentMouseMoves = 0;
|
||||
|
||||
var sendGuestGotDrop = function() {
|
||||
embedder.postMessage(JSON.stringify(['guest-got-drop', dropData]), '*');
|
||||
};
|
||||
|
||||
window.addEventListener('resize', function(e) {
|
||||
if (!embedder) {
|
||||
return;
|
||||
}
|
||||
resized = true;
|
||||
embedder.postMessage(JSON.stringify(['resized']), '*');
|
||||
});
|
||||
|
||||
var maybeSendConnected = function() {
|
||||
LOG('maybeSendConnected, sentConnectedMessage: ' + sentConnectedMessage);
|
||||
if (!sentConnectedMessage && embedder) {
|
||||
LOG('Inside');
|
||||
sentConnectedMessage = true;
|
||||
embedder.postMessage(JSON.stringify(['connected']), '*');
|
||||
}
|
||||
};
|
||||
|
||||
var resetState = function() {
|
||||
LOG('guest.resetState');
|
||||
resetSelection();
|
||||
|
||||
dropped = false;
|
||||
dragStarted = false;
|
||||
isDragInterrupted = false;
|
||||
|
||||
embedder.postMessage(JSON.stringify(['resetStateReply']), '*');
|
||||
};
|
||||
|
||||
window.addEventListener('message', function(e) {
|
||||
embedder = e.source;
|
||||
var data = JSON.parse(e.data)[0];
|
||||
if (data == 'create-channel') {
|
||||
maybeSendConnected();
|
||||
} else if (data == 'resetState') {
|
||||
resetState();
|
||||
}
|
||||
});
|
||||
|
||||
var doPostMessage = function(msg) {
|
||||
embedder.postMessage(JSON.stringify([msg]), '*');
|
||||
};
|
||||
|
||||
var resetSelection = function() {
|
||||
var selection = window.getSelection();
|
||||
var range = document.createRange();
|
||||
range.selectNodeContents($('dragMe'));
|
||||
selection.removeAllRanges();
|
||||
selection.addRange(range);
|
||||
LOG('Restored selection');
|
||||
};
|
||||
|
||||
var setUpGuest = function() {
|
||||
window.console.log('n.guest.setUpGuest');
|
||||
|
||||
document.body.style.width = '300px';
|
||||
document.body.style.background = '#CCCCCC';
|
||||
|
||||
document.body.innerHTML +=
|
||||
'<div class="dragMe" id="dragMe">Drop me</div>' +
|
||||
'<div class="destination" id="dest"></div>';
|
||||
|
||||
document.body.addEventListener('mousemove', function(e) {
|
||||
LOG('document.mousemove: ' + e.clientX + ', ' + e.clientY);
|
||||
++numDocumentMouseMoves;
|
||||
});
|
||||
document.body.addEventListener('mousedown', function(e) {
|
||||
LOG('document.mousedown: ' + e.clientX + ', ' + e.clientY);
|
||||
numDocumentMouseMoves = 0;
|
||||
});
|
||||
document.body.addEventListener('mouseup', function(e) {
|
||||
LOG('document.mouseup: ' + e.clientX + ', ' + e.clientY);
|
||||
LOG('numDocumentMouseMoves: ' + numDocumentMouseMoves);
|
||||
LOG('dragStarted: ' + dragStarted +
|
||||
', isDragInterrupted: ' + isDragInterrupted);
|
||||
if (!dragStarted && !isDragInterrupted) {
|
||||
LOG('Guest drag operation was interrupted by an unexpected mouseup');
|
||||
isDragInterrupted = true;
|
||||
embedder.postMessage(JSON.stringify(
|
||||
['guest-got-drop', 'drag-interrupted-by-mouseup']), '*');
|
||||
}
|
||||
|
||||
numDocumentMouseMoves = 0;
|
||||
});
|
||||
|
||||
// Select the text to drag.
|
||||
resetSelection();
|
||||
|
||||
// Whole bunch of drag/drop events on destination node follows.
|
||||
// We only need to make sure we preventDefault in dragenter and
|
||||
// dragover.
|
||||
var destNode = $('dest');
|
||||
var srcNode = $('dragMe');
|
||||
|
||||
srcNode.addEventListener('mousemove', function(e) {
|
||||
LOG('s.mousemove ' + e.clientX + ', ' + e.clientY);
|
||||
});
|
||||
srcNode.addEventListener('mousedown', function(e) {
|
||||
LOG('s.mousedown ' + e.clientX + ', ' + e.clientY);
|
||||
});
|
||||
srcNode.addEventListener('mouseup', function(e) {
|
||||
LOG('s.mouseup ' + e.clientX + ', ' + e.clientY);
|
||||
});
|
||||
|
||||
destNode.addEventListener('dragenter', function(e) {
|
||||
LOG('d.dragenter');
|
||||
e.preventDefault();
|
||||
}, false);
|
||||
|
||||
destNode.addEventListener('dragover', function(e) {
|
||||
LOG('d.dragover');
|
||||
e.preventDefault();
|
||||
}, false);
|
||||
|
||||
destNode.addEventListener('dragleave', function(e) {
|
||||
LOG('d.dragleave');
|
||||
}, false);
|
||||
|
||||
destNode.addEventListener('drop', function (e) {
|
||||
LOG('d.drop');
|
||||
dropped = true;
|
||||
dropData = e.dataTransfer.getData('Text');
|
||||
sendGuestGotDrop();
|
||||
}, false);
|
||||
|
||||
destNode.addEventListener('dragend', function (e) {
|
||||
LOG('d.dragend');
|
||||
}, false);
|
||||
|
||||
srcNode.addEventListener('dragstart', function(e) {
|
||||
LOG('s.dragstart');
|
||||
dragStarted = true;
|
||||
}, false);
|
||||
srcNode.addEventListener('dragend', function(e) {
|
||||
LOG('s.dragend');
|
||||
}, false);
|
||||
srcNode.addEventListener('dragexit', function(e) {
|
||||
LOG('s.dragexit');
|
||||
}, false);
|
||||
srcNode.addEventListener('dragleave', function(e) {
|
||||
LOG('s.dragleave');
|
||||
}, false);
|
||||
|
||||
destNode.addEventListener('dragexit', function(e) {
|
||||
LOG('s.dragexit');
|
||||
}, false);
|
||||
|
||||
LOG('set up complete');
|
||||
};
|
||||
|
||||
setUpGuest();
|
@ -1,23 +0,0 @@
|
||||
<!--
|
||||
* Copyright 2013 The Chromium Authors. All rights reserved. Use of this
|
||||
* source code is governed by a BSD-style license that can be found in the
|
||||
* LICENSE file.
|
||||
-->
|
||||
<html><head>
|
||||
<style type="text/css">
|
||||
* {
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
-webkit-user-select: auto;
|
||||
}
|
||||
body {
|
||||
padding: 20px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body style="background: #FFFF00;">
|
||||
<div id="webview-tag-container" style="height:150px;">
|
||||
</div>
|
||||
<script src="main.js"></script>
|
||||
</body>
|
||||
</html>
|
@ -1,110 +0,0 @@
|
||||
// Copyright 2013 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
window.lastDropData = 'Uninitialized';
|
||||
|
||||
var LOG = function(msg) {
|
||||
window.console.log(msg);
|
||||
};
|
||||
|
||||
// Whether or not we were asked by cpp to read lastDropData.
|
||||
var isCheckingIfGuestGotDrop = false;
|
||||
// Whether or not guest has seen a 'drop' operation in dnd.
|
||||
var gotDropFromGuest = false;
|
||||
var sentConnectedMsg = false;
|
||||
var sentGuestGotDropMsg = false;
|
||||
|
||||
// Called from web_view_interactive_ui_tests.cc.
|
||||
window.checkIfGuestGotDrop = function() {
|
||||
LOG('embedder.window.checkIfGuestGotDrop()');
|
||||
isCheckingIfGuestGotDrop = true;
|
||||
maybeSendGuestGotDropMsg();
|
||||
};
|
||||
|
||||
// Called from web_view_interactive_ui_tests.cc.
|
||||
window.resetState = function() {
|
||||
LOG('embedder.window.resetState');
|
||||
isCheckingIfGuestGotDrop = false;
|
||||
sentGuestGotDropMsg = false;
|
||||
gotDropFromGuest = false;
|
||||
webview.contentWindow.postMessage(JSON.stringify(['resetState']), '*');
|
||||
};
|
||||
|
||||
// Called from web_view_interactive_ui_tests.cc.
|
||||
window.getLastDropData = function() {
|
||||
LOG('getLastDropData: returns [' + lastDropData + ']');
|
||||
return window.lastDropData;
|
||||
};
|
||||
|
||||
var maybeSendGuestGotDropMsg = function() {
|
||||
LOG('maybeSendGuestGotDropMsg, ' +
|
||||
'isCheckingIfGuestGotDrop: ' + isCheckingIfGuestGotDrop +
|
||||
', sentGuestGotDropMsg: ' + sentGuestGotDropMsg +
|
||||
', gotDropFromGuest: ' + gotDropFromGuest);
|
||||
if (isCheckingIfGuestGotDrop && !sentGuestGotDropMsg && gotDropFromGuest) {
|
||||
sentGuestGotDropMsg = true;
|
||||
chrome.test.sendMessage('guest-got-drop');
|
||||
}
|
||||
};
|
||||
|
||||
var startTest = function() {
|
||||
var guestURL = 'about:blank'; // Actual contents are injected below.
|
||||
document.querySelector('#webview-tag-container').innerHTML =
|
||||
'<webview id=\'webview\' style="width: 300px; height: 150px; ' +
|
||||
'margin: 0; padding: 0;"' +
|
||||
' src="' + guestURL + '"' +
|
||||
'></webview>';
|
||||
|
||||
window.addEventListener('message', onPostMessageReceived, false);
|
||||
var webview = document.getElementById('webview');
|
||||
webview.addEventListener('loadstop', function(e) {
|
||||
LOG('loadstop');
|
||||
webview.insertCSS({file: 'guest.css'}, function() {
|
||||
LOG('insertCSS response.');
|
||||
webview.executeScript({file: 'guest.js'}, function(results) {
|
||||
LOG('executeScript response, length: ' + results.length);
|
||||
webview.contentWindow.postMessage(
|
||||
JSON.stringify(['create-channel']), '*');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// For debug messages from guests.
|
||||
webview.addEventListener('consolemessage', function(e) {
|
||||
LOG('[Guest]: ' + e.message);
|
||||
});
|
||||
};
|
||||
|
||||
var onPostMessageReceived = function(e) {
|
||||
LOG('embedder.onPostMessageReceived');
|
||||
var data = JSON.parse(e.data);
|
||||
LOG('data: ' + data);
|
||||
switch (data[0]) {
|
||||
case 'connected':
|
||||
// Trigger a resize event on the guest so that we make sure
|
||||
// we are painted before we attempt to start drag/drop test.
|
||||
document.getElementById('webview').style.height = '200px';
|
||||
break;
|
||||
case 'resized':
|
||||
LOG('resized msg, sentConnectedMsg: ' + sentConnectedMsg);
|
||||
if (!sentConnectedMsg) {
|
||||
sentConnectedMsg = true;
|
||||
chrome.test.sendMessage('connected');
|
||||
}
|
||||
break;
|
||||
case 'guest-got-drop':
|
||||
window.lastDropData = data[1];
|
||||
gotDropFromGuest = true;
|
||||
maybeSendGuestGotDropMsg();
|
||||
break;
|
||||
case 'resetStateReply':
|
||||
chrome.test.sendMessage('resetStateReply');
|
||||
break;
|
||||
default:
|
||||
LOG('ERR: curious message received in emb: ' + data);
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
startTest();
|
@ -1,14 +0,0 @@
|
||||
{
|
||||
"name": "<webview> drag and drop",
|
||||
"manifest_version": 2,
|
||||
"description": "Drag and drop within a webview, currently requires --enable-browser-tag-drag-drop flag to work",
|
||||
"version": "1",
|
||||
"permissions": [
|
||||
"webview"
|
||||
],
|
||||
"app": {
|
||||
"background": {
|
||||
"scripts": ["test.js"]
|
||||
}
|
||||
}
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
// Copyright 2013 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
chrome.app.runtime.onLaunched.addListener(function() {
|
||||
chrome.app.window.create('main.html', {}, function () {});
|
||||
});
|
@ -5,20 +5,17 @@
|
||||
#include "content/browser/browser_plugin/browser_plugin_embedder.h"
|
||||
|
||||
#include "base/bind.h"
|
||||
#include "content/browser/bad_message.h"
|
||||
#include "content/browser/browser_plugin/browser_plugin_guest.h"
|
||||
#include "content/browser/renderer_host/render_view_host_impl.h"
|
||||
#include "content/browser/web_contents/web_contents_impl.h"
|
||||
#include "content/public/browser/browser_context.h"
|
||||
#include "content/public/browser/browser_plugin_guest_manager.h"
|
||||
#include "content/public/browser/native_web_keyboard_event.h"
|
||||
#include "content/public/browser/render_view_host.h"
|
||||
#include "ui/events/keycodes/keyboard_codes.h"
|
||||
|
||||
namespace content {
|
||||
|
||||
BrowserPluginEmbedder::BrowserPluginEmbedder(WebContentsImpl* web_contents)
|
||||
: web_contents_(web_contents), guest_drag_ending_(false) {}
|
||||
: web_contents_(web_contents) {}
|
||||
|
||||
BrowserPluginEmbedder::~BrowserPluginEmbedder() = default;
|
||||
|
||||
@ -28,19 +25,6 @@ BrowserPluginEmbedder* BrowserPluginEmbedder::Create(
|
||||
return new BrowserPluginEmbedder(web_contents);
|
||||
}
|
||||
|
||||
bool BrowserPluginEmbedder::DragEnteredGuest(BrowserPluginGuest* guest) {
|
||||
guest_dragging_over_ = guest->AsWeakPtr();
|
||||
return guest_started_drag_.get() == guest;
|
||||
}
|
||||
|
||||
void BrowserPluginEmbedder::DragLeftGuest(BrowserPluginGuest* guest) {
|
||||
// Avoid race conditions in switching between guests being hovered over by
|
||||
// only un-setting if the caller is marked as the guest being dragged over.
|
||||
if (guest_dragging_over_.get() == guest) {
|
||||
guest_dragging_over_.reset();
|
||||
}
|
||||
}
|
||||
|
||||
// static
|
||||
bool BrowserPluginEmbedder::CancelDialogs(WebContents* guest_web_contents) {
|
||||
static_cast<WebContentsImpl*>(guest_web_contents)
|
||||
@ -59,59 +43,11 @@ void BrowserPluginEmbedder::CancelGuestDialogs() {
|
||||
base::BindRepeating(&BrowserPluginEmbedder::CancelDialogs));
|
||||
}
|
||||
|
||||
void BrowserPluginEmbedder::StartDrag(BrowserPluginGuest* guest) {
|
||||
guest_started_drag_ = guest->AsWeakPtr();
|
||||
guest_drag_ending_ = false;
|
||||
}
|
||||
|
||||
BrowserPluginGuestManager*
|
||||
BrowserPluginEmbedder::GetBrowserPluginGuestManager() const {
|
||||
return web_contents_->GetBrowserContext()->GetGuestManager();
|
||||
}
|
||||
|
||||
void BrowserPluginEmbedder::ClearGuestDragStateIfApplicable() {
|
||||
// The order at which we observe SystemDragEnded() and DragSourceEndedAt() is
|
||||
// platform dependent.
|
||||
// In OSX, we see SystemDragEnded() first, where in aura, we see
|
||||
// DragSourceEndedAt() first. For this reason, we check if both methods were
|
||||
// called before resetting |guest_started_drag_|.
|
||||
if (guest_drag_ending_) {
|
||||
if (guest_started_drag_)
|
||||
guest_started_drag_.reset();
|
||||
} else {
|
||||
guest_drag_ending_ = true;
|
||||
}
|
||||
}
|
||||
|
||||
void BrowserPluginEmbedder::DragSourceEndedAt(float client_x,
|
||||
float client_y,
|
||||
float screen_x,
|
||||
float screen_y,
|
||||
blink::DragOperation operation) {
|
||||
if (guest_started_drag_) {
|
||||
gfx::Point guest_offset =
|
||||
guest_started_drag_->GetScreenCoordinates(gfx::Point());
|
||||
guest_started_drag_->DragSourceEndedAt(client_x - guest_offset.x(),
|
||||
client_y - guest_offset.y(), screen_x, screen_y, operation);
|
||||
}
|
||||
ClearGuestDragStateIfApplicable();
|
||||
}
|
||||
|
||||
void BrowserPluginEmbedder::SystemDragEnded() {
|
||||
// When the embedder's drag/drop operation ends, we need to pass the message
|
||||
// to the guest that initiated the drag/drop operation. This will ensure that
|
||||
// the guest's RVH state is reset properly.
|
||||
if (guest_started_drag_)
|
||||
guest_started_drag_->EmbedderSystemDragEnded();
|
||||
|
||||
guest_dragging_over_.reset();
|
||||
ClearGuestDragStateIfApplicable();
|
||||
}
|
||||
|
||||
bool BrowserPluginEmbedder::OnUpdateDragCursor() {
|
||||
return !!guest_dragging_over_;
|
||||
}
|
||||
|
||||
bool BrowserPluginEmbedder::HandleKeyboardEvent(
|
||||
const NativeWebKeyboardEvent& event) {
|
||||
if ((event.windows_key_code != ui::VKEY_ESCAPE) ||
|
||||
|
@ -15,9 +15,7 @@
|
||||
#define CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_EMBEDDER_H_
|
||||
|
||||
#include "base/macros.h"
|
||||
#include "base/memory/weak_ptr.h"
|
||||
#include "content/common/content_export.h"
|
||||
#include "third_party/blink/public/common/page/drag_operation.h"
|
||||
|
||||
namespace content {
|
||||
|
||||
@ -35,36 +33,9 @@ class CONTENT_EXPORT BrowserPluginEmbedder {
|
||||
|
||||
static BrowserPluginEmbedder* Create(WebContentsImpl* web_contents);
|
||||
|
||||
// Sends a 'dragend' message to the guest that started the drag.
|
||||
void DragSourceEndedAt(float client_x,
|
||||
float client_y,
|
||||
float screen_x,
|
||||
float screen_y,
|
||||
blink::DragOperation operation);
|
||||
|
||||
// Indicates that a drag operation has entered into the bounds of a given
|
||||
// |guest|. Returns whether the |guest| also started the operation.
|
||||
bool DragEnteredGuest(BrowserPluginGuest* guest);
|
||||
|
||||
// Indicates that a drag operation has left the bounds of a given |guest|.
|
||||
void DragLeftGuest(BrowserPluginGuest* guest);
|
||||
|
||||
// Closes modal dialogs in all of the guests.
|
||||
void CancelGuestDialogs();
|
||||
|
||||
// Called by WebContentsViewGuest when a drag operation is started within
|
||||
// |guest|. This |guest| will be signaled at the end of the drag operation.
|
||||
void StartDrag(BrowserPluginGuest* guest);
|
||||
|
||||
// Sends EndSystemDrag message to the guest that initiated the last drag/drop
|
||||
// operation, if there's any.
|
||||
void SystemDragEnded();
|
||||
|
||||
// The page wants to update the mouse cursor during a drag & drop
|
||||
// operation. This update will be suppressed if the cursor is dragging over a
|
||||
// guest.
|
||||
bool OnUpdateDragCursor();
|
||||
|
||||
// Used to handle special keyboard events.
|
||||
bool HandleKeyboardEvent(const NativeWebKeyboardEvent& event);
|
||||
|
||||
@ -82,8 +53,6 @@ class CONTENT_EXPORT BrowserPluginEmbedder {
|
||||
|
||||
BrowserPluginGuestManager* GetBrowserPluginGuestManager() const;
|
||||
|
||||
void ClearGuestDragStateIfApplicable();
|
||||
|
||||
// Closes modal dialogs in |guest_web_contents|.
|
||||
static bool CancelDialogs(WebContents* guest_web_contents);
|
||||
|
||||
@ -95,20 +64,6 @@ class CONTENT_EXPORT BrowserPluginEmbedder {
|
||||
// Pointer to the WebContentsImpl that owns this object.
|
||||
WebContentsImpl* web_contents_;
|
||||
|
||||
// Used to correctly update the cursor when dragging over a guest, and to
|
||||
// handle a race condition when dropping onto the guest that started the drag
|
||||
// (the race is that the dragend message arrives before the drop message so
|
||||
// the drop never takes place).
|
||||
// crbug.com/233571
|
||||
base::WeakPtr<BrowserPluginGuest> guest_dragging_over_;
|
||||
|
||||
// Pointer to the guest that started the drag, used to forward necessary drag
|
||||
// status messages to the correct guest.
|
||||
base::WeakPtr<BrowserPluginGuest> guest_started_drag_;
|
||||
|
||||
// Keeps track of "dragend" state.
|
||||
bool guest_drag_ending_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(BrowserPluginEmbedder);
|
||||
};
|
||||
|
||||
|
@ -37,9 +37,6 @@ BrowserPluginGuest::BrowserPluginGuest(WebContentsImpl* web_contents,
|
||||
: WebContentsObserver(web_contents),
|
||||
owner_web_contents_(nullptr),
|
||||
initialized_(false),
|
||||
last_drag_status_(blink::kWebDragStatusUnknown),
|
||||
seen_embedder_system_drag_ended_(false),
|
||||
seen_embedder_drag_source_ended_at_(false),
|
||||
delegate_(delegate) {
|
||||
DCHECK(web_contents);
|
||||
DCHECK(delegate);
|
||||
@ -64,10 +61,6 @@ void BrowserPluginGuest::Init() {
|
||||
InitInternal(owner_web_contents);
|
||||
}
|
||||
|
||||
base::WeakPtr<BrowserPluginGuest> BrowserPluginGuest::AsWeakPtr() {
|
||||
return weak_ptr_factory_.GetWeakPtr();
|
||||
}
|
||||
|
||||
void BrowserPluginGuest::SetFocus(bool focused,
|
||||
blink::mojom::FocusType focus_type) {
|
||||
RenderWidgetHostView* rwhv = web_contents()->GetRenderWidgetHostView();
|
||||
@ -151,59 +144,6 @@ WebContentsImpl* BrowserPluginGuest::GetWebContents() const {
|
||||
return static_cast<WebContentsImpl*>(web_contents());
|
||||
}
|
||||
|
||||
gfx::Point BrowserPluginGuest::GetScreenCoordinates(
|
||||
const gfx::Point& relative_position) const {
|
||||
return relative_position;
|
||||
}
|
||||
|
||||
void BrowserPluginGuest::DragSourceEndedAt(float client_x,
|
||||
float client_y,
|
||||
float screen_x,
|
||||
float screen_y,
|
||||
blink::DragOperation operation) {
|
||||
web_contents()->GetRenderViewHost()->GetWidget()->DragSourceEndedAt(
|
||||
gfx::PointF(client_x, client_y), gfx::PointF(screen_x, screen_y),
|
||||
operation);
|
||||
seen_embedder_drag_source_ended_at_ = true;
|
||||
EndSystemDragIfApplicable();
|
||||
}
|
||||
|
||||
void BrowserPluginGuest::EndSystemDragIfApplicable() {
|
||||
// Ideally we'd want either WebDragStatusDrop or WebDragStatusLeave...
|
||||
// Call guest RVH->DragSourceSystemDragEnded() correctly on the guest where
|
||||
// the drag was initiated. Calling DragSourceSystemDragEnded() correctly
|
||||
// means we call it in all cases and also make sure we only call it once.
|
||||
// This ensures that the input state of the guest stays correct, otherwise
|
||||
// it will go stale and won't accept any further input events.
|
||||
//
|
||||
// The strategy used here to call DragSourceSystemDragEnded() on the RVH
|
||||
// is when the following conditions are met:
|
||||
// a. Embedder has seen SystemDragEnded()
|
||||
// b. Embedder has seen DragSourceEndedAt()
|
||||
// c. The guest has seen some drag status update other than
|
||||
// WebDragStatusUnknown. Note that this step should ideally be done
|
||||
// differently: The guest has seen at least one of
|
||||
// {WebDragStatusOver, WebDragStatusDrop}. However, if a user drags
|
||||
// a source quickly outside of <webview> bounds, then the
|
||||
// BrowserPluginGuest never sees any of these drag status updates,
|
||||
// there we just check whether we've seen any drag status update or
|
||||
// not.
|
||||
if (last_drag_status_ != blink::kWebDragStatusOver &&
|
||||
seen_embedder_drag_source_ended_at_ && seen_embedder_system_drag_ended_) {
|
||||
RenderViewHostImpl* guest_rvh = static_cast<RenderViewHostImpl*>(
|
||||
GetWebContents()->GetRenderViewHost());
|
||||
guest_rvh->GetWidget()->DragSourceSystemDragEnded();
|
||||
last_drag_status_ = blink::kWebDragStatusUnknown;
|
||||
seen_embedder_system_drag_ended_ = false;
|
||||
seen_embedder_drag_source_ended_at_ = false;
|
||||
}
|
||||
}
|
||||
|
||||
void BrowserPluginGuest::EmbedderSystemDragEnded() {
|
||||
seen_embedder_system_drag_ended_ = true;
|
||||
EndSystemDragIfApplicable();
|
||||
}
|
||||
|
||||
void BrowserPluginGuest::SendTextInputTypeChangedToView(
|
||||
RenderWidgetHostViewBase* guest_rwhv) {
|
||||
if (!guest_rwhv)
|
||||
|
@ -27,10 +27,8 @@
|
||||
#include "content/public/browser/guest_host.h"
|
||||
#include "content/public/browser/web_contents_observer.h"
|
||||
#include "mojo/public/cpp/bindings/pending_remote.h"
|
||||
#include "third_party/blink/public/common/page/drag_operation.h"
|
||||
#include "third_party/blink/public/mojom/choosers/popup_menu.mojom.h"
|
||||
#include "third_party/blink/public/mojom/input/focus_type.mojom-forward.h"
|
||||
#include "third_party/blink/public/web/web_drag_status.h"
|
||||
#include "ui/base/ime/mojom/text_input_state.mojom.h"
|
||||
|
||||
namespace content {
|
||||
@ -117,16 +115,6 @@ class CONTENT_EXPORT BrowserPluginGuest : public GuestHost,
|
||||
|
||||
gfx::Point GetScreenCoordinates(const gfx::Point& relative_position) const;
|
||||
|
||||
void DragSourceEndedAt(float client_x,
|
||||
float client_y,
|
||||
float screen_x,
|
||||
float screen_y,
|
||||
blink::DragOperation operation);
|
||||
|
||||
// Called when the drag started by this guest ends at an OS-level.
|
||||
void EmbedderSystemDragEnded();
|
||||
void EndSystemDragIfApplicable();
|
||||
|
||||
protected:
|
||||
// BrowserPluginGuest is a WebContentsObserver of |web_contents| and
|
||||
// |web_contents| has to stay valid for the lifetime of BrowserPluginGuest.
|
||||
@ -152,19 +140,8 @@ class CONTENT_EXPORT BrowserPluginGuest : public GuestHost,
|
||||
// Using scoped_ptr to avoid including the header file: view_messages.h.
|
||||
ui::mojom::TextInputStatePtr last_text_input_state_;
|
||||
|
||||
// Last seen state of drag status update.
|
||||
blink::WebDragStatus last_drag_status_;
|
||||
// Whether or not our embedder has seen a SystemDragEnded() call.
|
||||
bool seen_embedder_system_drag_ended_;
|
||||
// Whether or not our embedder has seen a DragSourceEndedAt() call.
|
||||
bool seen_embedder_drag_source_ended_at_;
|
||||
|
||||
BrowserPluginGuestDelegate* const delegate_;
|
||||
|
||||
// Weak pointer used to ask GeolocationPermissionContext about geolocation
|
||||
// permission.
|
||||
base::WeakPtrFactory<BrowserPluginGuest> weak_ptr_factory_{this};
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(BrowserPluginGuest);
|
||||
};
|
||||
|
||||
|
@ -122,10 +122,6 @@ RenderViewHostDelegateView* RenderWidgetHostDelegate::GetDelegateView() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool RenderWidgetHostDelegate::OnUpdateDragCursor() {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool RenderWidgetHostDelegate::IsWidgetForMainFrame(RenderWidgetHostImpl*) {
|
||||
return false;
|
||||
}
|
||||
|
@ -266,9 +266,6 @@ class CONTENT_EXPORT RenderWidgetHostDelegate {
|
||||
// Returns the associated RenderViewHostDelegateView*, if possible.
|
||||
virtual RenderViewHostDelegateView* GetDelegateView();
|
||||
|
||||
// Allow the delegate to handle the cursor update. Returns true if handled.
|
||||
virtual bool OnUpdateDragCursor();
|
||||
|
||||
// Returns true if the provided RenderWidgetHostImpl matches the current
|
||||
// RenderWidgetHost on the main frame, and false otherwise.
|
||||
virtual bool IsWidgetForMainFrame(RenderWidgetHostImpl*);
|
||||
|
@ -1973,9 +1973,6 @@ void RenderWidgetHostImpl::SelectionBoundsChanged(
|
||||
}
|
||||
|
||||
void RenderWidgetHostImpl::OnUpdateDragCursor(DragOperation current_op) {
|
||||
if (delegate_->OnUpdateDragCursor())
|
||||
return;
|
||||
|
||||
RenderViewHostDelegateView* view = delegate_->GetDelegateView();
|
||||
if (view)
|
||||
view->UpdateDragCursor(current_op);
|
||||
|
@ -4129,12 +4129,6 @@ TextInputManager* WebContentsImpl::GetTextInputManager() {
|
||||
return text_input_manager_.get();
|
||||
}
|
||||
|
||||
bool WebContentsImpl::OnUpdateDragCursor() {
|
||||
OPTIONAL_TRACE_EVENT0("content", "WebContentsImpl::OnUpdateDragCursor");
|
||||
return browser_plugin_embedder_ &&
|
||||
browser_plugin_embedder_->OnUpdateDragCursor();
|
||||
}
|
||||
|
||||
bool WebContentsImpl::IsWidgetForMainFrame(
|
||||
RenderWidgetHostImpl* render_widget_host) {
|
||||
return render_widget_host == GetMainFrame()->GetRenderWidgetHost();
|
||||
@ -4693,10 +4687,6 @@ void WebContentsImpl::DragSourceEndedAt(float client_x,
|
||||
RenderWidgetHost* source_rwh) {
|
||||
OPTIONAL_TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("content.verbose"),
|
||||
"WebContentsImpl::DragSourceEndedAt");
|
||||
if (browser_plugin_embedder_) {
|
||||
browser_plugin_embedder_->DragSourceEndedAt(client_x, client_y, screen_x,
|
||||
screen_y, operation);
|
||||
}
|
||||
if (source_rwh) {
|
||||
source_rwh->DragSourceEndedAt(gfx::PointF(client_x, client_y),
|
||||
gfx::PointF(screen_x, screen_y), operation);
|
||||
@ -4767,8 +4757,6 @@ void WebContentsImpl::SystemDragEnded(RenderWidgetHost* source_rwh) {
|
||||
"render_widget_host", source_rwh);
|
||||
if (source_rwh)
|
||||
source_rwh->DragSourceSystemDragEnded();
|
||||
if (browser_plugin_embedder_)
|
||||
browser_plugin_embedder_->SystemDragEnded();
|
||||
}
|
||||
|
||||
void WebContentsImpl::SetClosedByUserGesture(bool value) {
|
||||
|
@ -939,7 +939,6 @@ class CONTENT_EXPORT WebContentsImpl : public WebContents,
|
||||
blink::mojom::FrameVisibility visibility) override;
|
||||
void SendScreenRects() override;
|
||||
TextInputManager* GetTextInputManager() override;
|
||||
bool OnUpdateDragCursor() override;
|
||||
bool IsWidgetForMainFrame(RenderWidgetHostImpl* render_widget_host) override;
|
||||
bool AddDomainInfoToRapporSample(rappor::Sample* sample) override;
|
||||
bool IsShowingContextMenuOnPage() const override;
|
||||
|
@ -375,7 +375,7 @@ enum HistogramValue {
|
||||
WEB_VIEW_INTERNAL_ON_CONSOLE_MESSAGE = 353,
|
||||
WEB_VIEW_INTERNAL_ON_CONTENT_LOAD = 354,
|
||||
WEB_VIEW_INTERNAL_ON_DIALOG = 355,
|
||||
WEB_VIEW_INTERNAL_ON_DROP_LINK = 356,
|
||||
DELETED_WEB_VIEW_INTERNAL_ON_DROP_LINK = 356,
|
||||
WEB_VIEW_INTERNAL_ON_EXIT = 357,
|
||||
WEB_VIEW_INTERNAL_ON_EXIT_FULLSCREEN = 358,
|
||||
WEB_VIEW_INTERNAL_ON_FIND_REPLY = 359,
|
||||
|
@ -46,7 +46,6 @@ class EventMap {
|
||||
events::WEB_VIEW_INTERNAL_ON_CONSOLE_MESSAGE},
|
||||
{webview::kEventContentLoad, events::WEB_VIEW_INTERNAL_ON_CONTENT_LOAD},
|
||||
{webview::kEventDialog, events::WEB_VIEW_INTERNAL_ON_DIALOG},
|
||||
{webview::kEventDropLink, events::WEB_VIEW_INTERNAL_ON_DROP_LINK},
|
||||
{webview::kEventExit, events::WEB_VIEW_INTERNAL_ON_EXIT},
|
||||
{webview::kEventExitFullscreen,
|
||||
events::WEB_VIEW_INTERNAL_ON_EXIT_FULLSCREEN},
|
||||
|
@ -27,7 +27,6 @@ const char kEventConsoleMessage[] = "webViewInternal.onConsoleMessage";
|
||||
const char kEventContentLoad[] = "webViewInternal.onContentLoad";
|
||||
const char kEventContextMenuShow[] = "chromeWebViewInternal.onContextMenuShow";
|
||||
const char kEventDialog[] = "webViewInternal.onDialog";
|
||||
const char kEventDropLink[] = "webViewInternal.onDropLink";
|
||||
const char kEventExit[] = "webViewInternal.onExit";
|
||||
const char kEventExitFullscreen[] = "webViewInternal.onExitFullscreen";
|
||||
const char kEventFindReply[] = "webViewInternal.onFindReply";
|
||||
|
@ -33,7 +33,6 @@ extern const char kEventConsoleMessage[];
|
||||
extern const char kEventContentLoad[];
|
||||
extern const char kEventContextMenuShow[];
|
||||
extern const char kEventDialog[];
|
||||
extern const char kEventDropLink[];
|
||||
extern const char kEventExit[];
|
||||
extern const char kEventExitFullscreen[];
|
||||
extern const char kEventFindReply[];
|
||||
|
@ -466,13 +466,6 @@ void WebViewGuest::DidAttachToEmbedder() {
|
||||
ApplyAttributes(*attach_params());
|
||||
}
|
||||
|
||||
void WebViewGuest::DidDropLink(const GURL& url) {
|
||||
auto args = std::make_unique<base::DictionaryValue>();
|
||||
args->SetString(guest_view::kUrl, url.spec());
|
||||
DispatchEventToView(std::make_unique<GuestViewEvent>(webview::kEventDropLink,
|
||||
std::move(args)));
|
||||
}
|
||||
|
||||
void WebViewGuest::DidInitialize(const base::DictionaryValue& create_params) {
|
||||
script_executor_ = std::make_unique<ScriptExecutor>(web_contents());
|
||||
|
||||
|
@ -183,10 +183,6 @@ class WebViewGuest : public guest_view::GuestView<WebViewGuest> {
|
||||
bool last_unlocked_by_target,
|
||||
base::OnceCallback<void(bool)> callback);
|
||||
|
||||
// TODO(533069): This appears to be dead code following BrowserPlugin removal.
|
||||
// Investigate removing this.
|
||||
void DidDropLink(const GURL& url);
|
||||
|
||||
// GuestViewBase implementation.
|
||||
void CreateWebContents(const base::DictionaryValue& create_params,
|
||||
WebContentsCreatedCallback callback) final;
|
||||
|
@ -72,10 +72,6 @@ WebViewEvents.EVENTS = {
|
||||
fields: ['defaultPromptText', 'messageText', 'messageType', 'url'],
|
||||
handler: 'handleDialogEvent'
|
||||
},
|
||||
'droplink': {
|
||||
evt: CreateEvent('webViewInternal.onDropLink'),
|
||||
fields: ['url']
|
||||
},
|
||||
'exit': {
|
||||
evt: CreateEvent('webViewInternal.onExit'),
|
||||
fields: ['processId', 'reason']
|
||||
|
@ -23768,7 +23768,7 @@ Called by update_extension_histograms.py.-->
|
||||
<int value="353" label="WEB_VIEW_INTERNAL_ON_CONSOLE_MESSAGE"/>
|
||||
<int value="354" label="WEB_VIEW_INTERNAL_ON_CONTENT_LOAD"/>
|
||||
<int value="355" label="WEB_VIEW_INTERNAL_ON_DIALOG"/>
|
||||
<int value="356" label="WEB_VIEW_INTERNAL_ON_DROP_LINK"/>
|
||||
<int value="356" label="DELETED_WEB_VIEW_INTERNAL_ON_DROP_LINK"/>
|
||||
<int value="357" label="WEB_VIEW_INTERNAL_ON_EXIT"/>
|
||||
<int value="358" label="WEB_VIEW_INTERNAL_ON_EXIT_FULLSCREEN"/>
|
||||
<int value="359" label="WEB_VIEW_INTERNAL_ON_FIND_REPLY"/>
|
||||
|
Reference in New Issue
Block a user