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

Unified Diff: content/browser/pointer_lock_browsertest_mac.mm

Issue 2592243002: Perform direct routing of mouse events when the pointer is locked. (Closed)
Patch Set: transform event, add tests Created 3 years, 10 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
Index: content/browser/pointer_lock_browsertest_mac.mm
diff --git a/content/browser/pointer_lock_browsertest_mac.mm b/content/browser/pointer_lock_browsertest_mac.mm
new file mode 100644
index 0000000000000000000000000000000000000000..a8b334ca4a62d9d021857eb8dce490464a6debe3
--- /dev/null
+++ b/content/browser/pointer_lock_browsertest_mac.mm
@@ -0,0 +1,53 @@
+// Copyright 2017 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.
+
+#include "content/browser/pointer_lock_browsertest.h"
+
+#include "content/browser/renderer_host/render_widget_host_impl.h"
+#include "content/browser/renderer_host/render_widget_host_view_mac.h"
+#include "content/browser/web_contents/web_contents_view_mac.h"
+
+namespace content {
+
+namespace {
+
+class MockRenderWidgetHostView : public RenderWidgetHostViewMac {
+ public:
+ MockRenderWidgetHostView(RenderWidgetHost* host, bool is_guest_view_hack)
+ : RenderWidgetHostViewMac(host, is_guest_view_hack),
+ host_(RenderWidgetHostImpl::From(host)) {}
+ ~MockRenderWidgetHostView() override {
+ if (mouse_locked_)
+ UnlockMouse();
+ }
+
+ bool LockMouse() override {
+ mouse_locked_ = true;
+
+ return true;
+ }
+
+ void UnlockMouse() override {
+ host_->LostMouseLock();
+ mouse_locked_ = false;
+ }
+
+ bool IsMouseLocked() override { return mouse_locked_; }
+
+ bool HasFocus() const override { return true; }
+
+ RenderWidgetHostImpl* host_;
+};
+
+} // namespace
+
+void InstallCreateHooksForPointerLockBrowserTests() {
+ WebContentsViewMac::InstallCreateHookForTests(
+ [](RenderWidgetHost* host,
+ bool is_guest_view_hack) -> RenderWidgetHostViewMac* {
+ return new MockRenderWidgetHostView(host, is_guest_view_hack);
+ });
+}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698