summaryrefslogtreecommitdiffstats
path: root/chromium/content/browser/keyboard_lock_browsertest_mac.mm
blob: 58218c24b227f78a4fc0d8abed3ec79ea6dfc800 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Copyright 2018 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/keyboard_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 {

bool g_window_has_focus = false;

class TestRenderWidgetHostView : public RenderWidgetHostViewMac {
 public:
  TestRenderWidgetHostView(RenderWidgetHost* host)
      : RenderWidgetHostViewMac(host) {}
  ~TestRenderWidgetHostView() override {}

  bool HasFocus() override { return g_window_has_focus; }
};
}

void SetWindowFocusForKeyboardLockBrowserTests(bool is_focused) {
  g_window_has_focus = is_focused;
}

void InstallCreateHooksForKeyboardLockBrowserTests() {
  WebContentsViewMac::InstallCreateHookForTests(
      [](RenderWidgetHost* host) -> RenderWidgetHostViewMac* {
        return new TestRenderWidgetHostView(host);
      });
}

}  // namespace content