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

content / web_test / browser / web_test_storage_access_manager.h [blame]

// Copyright 2020 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_WEB_TEST_BROWSER_WEB_TEST_STORAGE_ACCESS_MANAGER_H_
#define CONTENT_WEB_TEST_BROWSER_WEB_TEST_STORAGE_ACCESS_MANAGER_H_

#include <stddef.h>

#include "base/containers/id_map.h"
#include "base/functional/callback_forward.h"
#include "base/memory/raw_ptr.h"
#include "base/synchronization/lock.h"
#include "components/content_settings/core/common/content_settings.h"
#include "mojo/public/cpp/bindings/receiver_set.h"
#include "third_party/blink/public/mojom/storage_access/storage_access_automation.mojom.h"

namespace content {

class BrowserContext;

class WebTestStorageAccessManager
    : public blink::test::mojom::StorageAccessAutomation {
 public:
  explicit WebTestStorageAccessManager(BrowserContext* browser_context);

  WebTestStorageAccessManager(const WebTestStorageAccessManager&) = delete;
  WebTestStorageAccessManager& operator=(const WebTestStorageAccessManager&) =
      delete;

  ~WebTestStorageAccessManager() override;

  // blink::test::mojom::StorageAccessAutomation
  void SetStorageAccess(
      const std::string& origin,
      const std::string& embedding_origin,
      const bool blocked,
      blink::test::mojom::StorageAccessAutomation::SetStorageAccessCallback)
      override;

  void Bind(mojo::PendingReceiver<blink::test::mojom::StorageAccessAutomation>
                receiver);

 private:
  raw_ref<BrowserContext> browser_context_;

  mojo::ReceiverSet<blink::test::mojom::StorageAccessAutomation> receivers_;
};

}  // namespace content

#endif  // CONTENT_WEB_TEST_BROWSER_WEB_TEST_STORAGE_ACCESS_MANAGER_H_