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

content / web_test / renderer / fake_subresource_filter.h [blame]

// Copyright 2016 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_RENDERER_FAKE_SUBRESOURCE_FILTER_H_
#define CONTENT_WEB_TEST_RENDERER_FAKE_SUBRESOURCE_FILTER_H_

#include <string>
#include <vector>

#include "third_party/blink/public/platform/web_document_subresource_filter.h"
#include "third_party/blink/public/platform/web_url_request.h"

namespace blink {
class WebURL;
}  // namespace blink

namespace content {

class FakeSubresourceFilter : public blink::WebDocumentSubresourceFilter {
 public:
  explicit FakeSubresourceFilter(
      std::vector<std::string> disallowed_path_suffixes,
      bool block_resources);
  ~FakeSubresourceFilter() override;

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

  // blink::WebDocumentSubresourceFilter:
  LoadPolicy GetLoadPolicy(const blink::WebURL& resource_url,
                           blink::mojom::RequestContextType) override;
  LoadPolicy GetLoadPolicyForWebSocketConnect(
      const blink::WebURL& url) override;
  LoadPolicy GetLoadPolicyForWebTransportConnect(
      const blink::WebURL& url) override;
  void ReportDisallowedLoad() override;
  bool ShouldLogToConsole() override;

 private:
  LoadPolicy GetLoadPolicyImpl(const blink::WebURL& url);

  const std::vector<std::string> disallowed_path_suffixes_;
  const bool block_subresources_;
};

}  // namespace content

#endif  // CONTENT_WEB_TEST_RENDERER_FAKE_SUBRESOURCE_FILTER_H_