blob: 5f743f404cd6612f19b475bf165caebd8c734449 [file] [log] [blame]
Joe Downing190f4ac2018-04-17 22:00:271// 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
11namespace content {
12
13namespace {
14
15bool g_window_has_focus = false;
16
17class 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 Gadani95fc3612019-04-05 22:33:4923 bool HasFocus() override { return g_window_has_focus; }
Joe Downing190f4ac2018-04-17 22:00:2724};
25}
26
27void SetWindowFocusForKeyboardLockBrowserTests(bool is_focused) {
28 g_window_has_focus = is_focused;
29}
30
31void 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 Gadani95fc3612019-04-05 22:33:4939} // namespace content