chromium/third_party/blink/public/common/safe_url_pattern.h

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

#ifndef THIRD_PARTY_BLINK_PUBLIC_COMMON_SAFE_URL_PATTERN_H_
#define THIRD_PARTY_BLINK_PUBLIC_COMMON_SAFE_URL_PATTERN_H_

#include <vector>

#include "third_party/blink/public/common/common_export.h"
#include "third_party/liburlpattern/pattern.h"

namespace blink {

struct BLINK_COMMON_EXPORT SafeUrlPatternOptions {};

// SafeUrlPattern is a reduced version of URLPattern.
// It is used in both the browser process and the renderer process, and it does
// not allow a user-defined regular expression due to a security concern.
//
// To proceed the URLPattern matching, the user of the structure needs to
// set up their own `liburlpattern::Pattern`.
//
// `GetOptions` in
// third_party/blink/renderer/core/url_pattern/url_pattern_component.cc is
// a good example of how to set up `liburlpattern::Options` for
// each field. `SafeUrlPatternOptions::ignore_case` is provided for that
// purpose.
struct BLINK_COMMON_EXPORT SafeUrlPattern {};

BLINK_COMMON_EXPORT bool operator==(const SafeUrlPattern& left,
                                    const SafeUrlPattern& right);

BLINK_COMMON_EXPORT bool operator==(const SafeUrlPatternOptions& left,
                                    const SafeUrlPatternOptions& right);

}  // namespace blink

#endif  // THIRD_PARTY_BLINK_PUBLIC_COMMON_SAFE_URL_PATTERN_H_