OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "content/browser/pointer_lock_browsertest.h" |
| 6 |
| 7 #include "content/browser/renderer_host/render_widget_host_impl.h" |
| 8 #include "content/browser/renderer_host/render_widget_host_view_mac.h" |
| 9 #include "content/browser/web_contents/web_contents_view_mac.h" |
| 10 |
| 11 namespace content { |
| 12 |
| 13 namespace { |
| 14 |
| 15 class MockRenderWidgetHostView : public RenderWidgetHostViewMac { |
| 16 public: |
| 17 MockRenderWidgetHostView(RenderWidgetHost* host, bool is_guest_view_hack) |
| 18 : RenderWidgetHostViewMac(host, is_guest_view_hack), |
| 19 host_(RenderWidgetHostImpl::From(host)) {} |
| 20 ~MockRenderWidgetHostView() override { |
| 21 if (mouse_locked_) |
| 22 UnlockMouse(); |
| 23 } |
| 24 |
| 25 bool LockMouse() override { |
| 26 mouse_locked_ = true; |
| 27 |
| 28 return true; |
| 29 } |
| 30 |
| 31 void UnlockMouse() override { |
| 32 host_->LostMouseLock(); |
| 33 mouse_locked_ = false; |
| 34 } |
| 35 |
| 36 bool IsMouseLocked() override { return mouse_locked_; } |
| 37 |
| 38 bool HasFocus() const override { return true; } |
| 39 |
| 40 RenderWidgetHostImpl* host_; |
| 41 }; |
| 42 |
| 43 } // namespace |
| 44 |
| 45 void InstallCreateHooksForPointerLockBrowserTests() { |
| 46 WebContentsViewMac::InstallCreateHookForTests( |
| 47 [](RenderWidgetHost* host, |
| 48 bool is_guest_view_hack) -> RenderWidgetHostViewMac* { |
| 49 return new MockRenderWidgetHostView(host, is_guest_view_hack); |
| 50 }); |
| 51 } |
| 52 |
| 53 } // namespace content |
OLD | NEW |