Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(531)

Unified Diff: content/browser/web_contents/web_contents_impl.cc

Issue 2112923002: Fix crash when destroying a RenderWidgetHost that holds the pointer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/web_contents/web_contents_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 83636c498e21924031004d0b7494365916e97e02..9b445c8815676eb6171b6d95b893621abf2a7478 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -1707,8 +1707,7 @@ void WebContentsImpl::RenderWidgetDeleted(
view_->RestoreFocus();
}
- if (mouse_lock_widget_ == render_widget_host)
- mouse_lock_widget_ = nullptr;
+ CHECK(mouse_lock_widget_ != render_widget_host);
}
void WebContentsImpl::RenderWidgetGotFocus(
@@ -1897,12 +1896,19 @@ blink::WebDisplayMode WebContentsImpl::GetDisplayMode(
void WebContentsImpl::RequestToLockMouse(
RenderWidgetHostImpl* render_widget_host,
bool user_gesture,
- bool last_unlocked_by_target) {
+ bool last_unlocked_by_target,
+ bool privileged) {
if (mouse_lock_widget_) {
render_widget_host->GotResponseToLockMouseRequest(false);
return;
}
+ if (privileged) {
+ mouse_lock_widget_ = render_widget_host;
+ render_widget_host->GotResponseToLockMouseRequest(true);
+ return;
+ }
+
bool widget_in_frame_tree = false;
for (FrameTreeNode* node : frame_tree_.Nodes()) {
if (node->current_frame_host()->GetRenderWidgetHost() ==
@@ -1929,6 +1935,14 @@ void WebContentsImpl::LostMouseLock(RenderWidgetHostImpl* render_widget_host) {
delegate_->LostMouseLock();
}
+bool WebContentsImpl::HasMouseLock(RenderWidgetHostImpl* render_widget_host) {
+ // To verify if the mouse is locked, the mouse_lock_widget_ needs to be
+ // assigned to the widget that requested the mouse lock, and the top-level
+ // platform RenderWidgetHostView needs to hold the mouse lock from the OS.
+ return mouse_lock_widget_ == render_widget_host &&
+ GetTopLevelRenderWidgetHostView()->IsMouseLocked();
+}
+
void WebContentsImpl::ForwardCompositorProto(
RenderWidgetHostImpl* render_widget_host,
const std::vector<uint8_t>& proto) {
@@ -2986,8 +3000,11 @@ bool WebContentsImpl::GotResponseToLockMouseRequest(bool allowed) {
if (GetBrowserPluginGuest())
return GetBrowserPluginGuest()->LockMouse(allowed);
- if (mouse_lock_widget_)
- return mouse_lock_widget_->GotResponseToLockMouseRequest(allowed);
+ if (mouse_lock_widget_ &&
+ mouse_lock_widget_->GotResponseToLockMouseRequest(allowed))
+ return true;
+
+ mouse_lock_widget_ = nullptr;
return false;
}
« no previous file with comments | « content/browser/web_contents/web_contents_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698