Joe Downing | 190f4ac | 2018-04-17 22:00:27 | [diff] [blame] | 1 | // Copyright 2018 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/keyboard_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 | bool g_window_has_focus = false; |
| 16 | |
| 17 | class TestRenderWidgetHostView : public RenderWidgetHostViewMac { |
| 18 | public: |
| 19 | TestRenderWidgetHostView(RenderWidgetHost* host, bool is_guest_view_hack) |
| 20 | : RenderWidgetHostViewMac(host, is_guest_view_hack) {} |
| 21 | ~TestRenderWidgetHostView() override {} |
| 22 | |
Lucas Furukawa Gadani | 95fc361 | 2019-04-05 22:33:49 | [diff] [blame] | 23 | bool HasFocus() override { return g_window_has_focus; } |
Joe Downing | 190f4ac | 2018-04-17 22:00:27 | [diff] [blame] | 24 | }; |
| 25 | } |
| 26 | |
| 27 | void SetWindowFocusForKeyboardLockBrowserTests(bool is_focused) { |
| 28 | g_window_has_focus = is_focused; |
| 29 | } |
| 30 | |
| 31 | void InstallCreateHooksForKeyboardLockBrowserTests() { |
| 32 | WebContentsViewMac::InstallCreateHookForTests( |
| 33 | [](RenderWidgetHost* host, |
| 34 | bool is_guest_view_hack) -> RenderWidgetHostViewMac* { |
| 35 | return new TestRenderWidgetHostView(host, is_guest_view_hack); |
| 36 | }); |
| 37 | } |
| 38 | |
Lucas Furukawa Gadani | 95fc361 | 2019-04-05 22:33:49 | [diff] [blame] | 39 | } // namespace content |