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
   39
   40
   41
   42
   43
   44
   45

content / public / test / update_user_activation_state_interceptor.h [blame]

// Copyright 2024 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CONTENT_PUBLIC_TEST_UPDATE_USER_ACTIVATION_STATE_INTERCEPTOR_H_
#define CONTENT_PUBLIC_TEST_UPDATE_USER_ACTIVATION_STATE_INTERCEPTOR_H_

#include "base/functional/callback_forward.h"
#include "mojo/public/cpp/bindings/associated_receiver.h"
#include "mojo/public/cpp/test_support/test_utils.h"
#include "third_party/blink/public/mojom/frame/frame.mojom-test-utils.h"

namespace content {

class RenderFrameHost;

class UpdateUserActivationStateInterceptor
    : public blink::mojom::LocalFrameHostInterceptorForTesting {
 public:
  explicit UpdateUserActivationStateInterceptor(
      content::RenderFrameHost* render_frame_host);
  UpdateUserActivationStateInterceptor(
      const UpdateUserActivationStateInterceptor&) = delete;
  UpdateUserActivationStateInterceptor& operator=(
      const UpdateUserActivationStateInterceptor&) = delete;
  ~UpdateUserActivationStateInterceptor() override;

  void set_quit_handler(base::OnceClosure handler);
  bool update_user_activation_state() { return update_user_activation_state_; }

  blink::mojom::LocalFrameHost* GetForwardingInterface() override;
  void UpdateUserActivationState(
      blink::mojom::UserActivationUpdateType update_type,
      blink::mojom::UserActivationNotificationType notification_type) override;

 private:
  mojo::test::ScopedSwapImplForTesting<blink::mojom::LocalFrameHost>
      swapped_impl_;
  base::OnceClosure quit_handler_;
  bool update_user_activation_state_ = false;
};

}  // namespace content

#endif  // CONTENT_PUBLIC_TEST_UPDATE_USER_ACTIVATION_STATE_INTERCEPTOR_H_