| Index: content/browser/web_contents/web_contents_impl.cc
|
| diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
|
| index bfdda50f69c982a5208572a106e7b34157cfed2d..e683b9d16bd3ce530d0e62d1e33981852ba9cd48 100644
|
| --- a/content/browser/web_contents/web_contents_impl.cc
|
| +++ b/content/browser/web_contents/web_contents_impl.cc
|
| @@ -416,6 +416,7 @@ WebContentsImpl::WebContentsImpl(BrowserContext* browser_context)
|
| bluetooth_connected_device_count_(0),
|
| virtual_keyboard_requested_(false),
|
| page_scale_factor_is_one_(true),
|
| + mouse_lock_widget_(nullptr),
|
| loading_weak_factory_(this),
|
| weak_factory_(this) {
|
| frame_tree_.SetFrameRemoveListener(
|
| @@ -1694,6 +1695,9 @@ void WebContentsImpl::RenderWidgetDeleted(
|
| if (fullscreen_widget_had_focus_at_shutdown_)
|
| view_->RestoreFocus();
|
| }
|
| +
|
| + if (mouse_lock_widget_ == render_widget_host)
|
| + mouse_lock_widget_ = nullptr;
|
| }
|
|
|
| void WebContentsImpl::RenderWidgetGotFocus(
|
| @@ -1890,20 +1894,32 @@ void WebContentsImpl::RequestToLockMouse(
|
| RenderWidgetHostImpl* render_widget_host,
|
| bool user_gesture,
|
| bool last_unlocked_by_target) {
|
| - if (render_widget_host != GetRenderViewHost()->GetWidget()) {
|
| + if (mouse_lock_widget_) {
|
| render_widget_host->GotResponseToLockMouseRequest(false);
|
| return;
|
| }
|
|
|
| - if (delegate_)
|
| + bool widget_in_frame_tree = false;
|
| + for (FrameTreeNode* node : frame_tree_.Nodes()) {
|
| + if (node->current_frame_host()->GetRenderWidgetHost() ==
|
| + render_widget_host) {
|
| + widget_in_frame_tree = true;
|
| + break;
|
| + }
|
| + }
|
| +
|
| + if (widget_in_frame_tree && delegate_) {
|
| + mouse_lock_widget_ = render_widget_host;
|
| delegate_->RequestToLockMouse(this, user_gesture, last_unlocked_by_target);
|
| - else
|
| - GotResponseToLockMouseRequest(false);
|
| + } else {
|
| + render_widget_host->GotResponseToLockMouseRequest(false);
|
| + }
|
| }
|
|
|
| void WebContentsImpl::LostMouseLock(RenderWidgetHostImpl* render_widget_host) {
|
| - if (!RenderViewHostImpl::From(render_widget_host))
|
| - return;
|
| + CHECK(mouse_lock_widget_);
|
| + mouse_lock_widget_->SendMouseLockLost();
|
| + mouse_lock_widget_ = nullptr;
|
|
|
| if (delegate_)
|
| delegate_->LostMouseLock();
|
| @@ -2958,10 +2974,9 @@ bool WebContentsImpl::GotResponseToLockMouseRequest(bool allowed) {
|
| if (GetBrowserPluginGuest())
|
| return GetBrowserPluginGuest()->LockMouse(allowed);
|
|
|
| - return GetRenderViewHost()
|
| - ? GetRenderViewHost()->GetWidget()->GotResponseToLockMouseRequest(
|
| - allowed)
|
| - : false;
|
| + if (mouse_lock_widget_)
|
| + return mouse_lock_widget_->GotResponseToLockMouseRequest(allowed);
|
| + return false;
|
| }
|
|
|
| bool WebContentsImpl::HasOpener() const {
|
|
|