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
   46
   47
   48
   49
   50
   51
   52
   53
   54
   55
   56

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

// Copyright 2022 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_PERMISSIONS_TEST_UTILS_H_
#define CONTENT_PUBLIC_TEST_PERMISSIONS_TEST_UTILS_H_

#include <optional>

#include "content/public/browser/permission_controller.h"
#include "third_party/blink/public/mojom/permissions/permission_status.mojom.h"

namespace blink {
enum class PermissionType;
}

namespace url {
class Origin;
}

namespace content {

// A helper method that gives access to
// content/browser/PermissionControllerImpl::SetOverrideForDevTools to //content
// embedders in tests.
void SetPermissionControllerOverrideForDevTools(
    PermissionController* permission_controller,
    const std::optional<url::Origin>& origin,
    blink::PermissionType permission,
    const blink::mojom::PermissionStatus& status);

// A helper method that gives access to
// content/browser/PermissionControllerImpl::AddNotifyListenerObserver to
// //content embedders in tests.
void AddNotifyListenerObserver(PermissionController* permission_controller,
                               base::RepeatingClosure callback);

// A helper method that gives access to
// content/browser/PermissionControllerImpl::SubscribeToPermissionStatusChange
// to
// //content embedders in tests.
//
// PermissionController::UnsubscribeFromPermissionStatusChange can be used to
// unsubscribe.
PermissionController::SubscriptionId SubscribeToPermissionStatusChange(
    PermissionController* permission_controller,
    blink::PermissionType permission,
    RenderProcessHost* render_process_host,
    RenderFrameHost* render_frame_host,
    const GURL& requesting_origin,
    bool should_include_device_status,
    const base::RepeatingCallback<void(PermissionStatus)>& callback);

}  // namespace content

#endif  // CONTENT_PUBLIC_TEST_PERMISSIONS_TEST_UTILS_H_