Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(184)

Unified Diff: components/subresource_filter/core/common/url_pattern.h

Issue 2098233002: Implement matching of URL patterns. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ruleset
Patch Set: Fix another cast warning. Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/subresource_filter/core/common/url_pattern.h
diff --git a/components/subresource_filter/core/common/url_pattern.h b/components/subresource_filter/core/common/url_pattern.h
new file mode 100644
index 0000000000000000000000000000000000000000..f49b5ea610bbaa26a9bfeb98187a23762cdc9f1c
--- /dev/null
+++ b/components/subresource_filter/core/common/url_pattern.h
@@ -0,0 +1,53 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_SUBRESOURCE_FILTER_CORE_COMMON_URL_PATTERN_H_
+#define COMPONENTS_SUBRESOURCE_FILTER_CORE_COMMON_URL_PATTERN_H_
+
+#include "base/macros.h"
+#include "base/strings/string_piece.h"
+#include "components/subresource_filter/core/common/proto/rules.pb.h"
+
+namespace subresource_filter {
+
+namespace flat {
+struct UrlRule; // The FlatBuffers version of UrlRule.
+}
+
+// The structure used to mirror a URL pattern regardless of the representation
+// of the UrlRule that owns it.
+struct UrlPattern {
+ UrlPattern();
+
+ // Creates a |url_pattern| of a certain |type|.
+ UrlPattern(base::StringPiece url_pattern,
+ proto::UrlPatternType type = proto::URL_PATTERN_TYPE_WILDCARDED);
+
+ // Creates a WILDCARDED |url_pattern| with the specified anchors.
+ UrlPattern(base::StringPiece url_pattern,
+ proto::AnchorType anchor_left,
+ proto::AnchorType anchor_right);
+
+ // The following constructors create UrlPattern from one of the UrlRule
+ // representations. The passed in |rule| must outlive the created instance.
+ explicit UrlPattern(const flat::UrlRule& rule);
+ explicit UrlPattern(const proto::UrlRule& rule);
+
+ ~UrlPattern();
+
+ proto::UrlPatternType type = proto::URL_PATTERN_TYPE_UNSPECIFIED;
+ base::StringPiece url_pattern;
+
+ proto::AnchorType anchor_left = proto::ANCHOR_TYPE_NONE;
+ proto::AnchorType anchor_right = proto::ANCHOR_TYPE_NONE;
+
+ bool match_case = false;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(UrlPattern);
+};
+
+} // namespace subresource_filter
+
+#endif // COMPONENTS_SUBRESOURCE_FILTER_CORE_COMMON_URL_PATTERN_H_
« no previous file with comments | « components/subresource_filter/core/common/BUILD.gn ('k') | components/subresource_filter/core/common/url_pattern.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698