| Index: extensions/browser/api/declarative_net_request/matcher_util.h
|
| diff --git a/extensions/browser/api/declarative_net_request/matcher_util.h b/extensions/browser/api/declarative_net_request/matcher_util.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..f3137b32878ab047041422928702dd789143eba9
|
| --- /dev/null
|
| +++ b/extensions/browser/api/declarative_net_request/matcher_util.h
|
| @@ -0,0 +1,83 @@
|
| +// Copyright 2017 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 EXTENSIONS_BROWSER_API_DECLARATIVE_NET_REQUEST_MATCHER_UTIL_H_
|
| +#define EXTENSIONS_BROWSER_API_DECLARATIVE_NET_REQUEST_MATCHER_UTIL_H_
|
| +
|
| +#include <memory>
|
| +#include "components/subresource_filter/core/common/url_pattern_index.h"
|
| +#include "content/public/browser/browser_thread.h"
|
| +#include "extensions/common/api/declarative_net_request/constants.h"
|
| +
|
| +namespace net {
|
| +class URLRequest;
|
| +}
|
| +
|
| +namespace base {
|
| +class MemoryMappedFile;
|
| +class FilePath;
|
| +}
|
| +
|
| +class GURL;
|
| +
|
| +namespace url {
|
| +class Origin;
|
| +}
|
| +
|
| +namespace extensions {
|
| +class InfoMap;
|
| +
|
| +namespace declarative_net_request {
|
| +
|
| +namespace flat {
|
| +struct ExtensionIndexedRuleset;
|
| +struct ExtensionRuleMetadata;
|
| +}
|
| +
|
| +// This is created on the file thread and used on the IO thread. However,
|
| +// there are no thread safety issues since this is only accessed on a single
|
| +// thread at a time.
|
| +class ExtensionIndexedRulesetMatcher {
|
| + public:
|
| + // We should ensure that the buffer passed has been verified.
|
| + explicit ExtensionIndexedRulesetMatcher(
|
| + std::unique_ptr<base::MemoryMappedFile,
|
| + content::BrowserThread::DeleteOnFileThread> ruleset_file);
|
| +
|
| + bool ShouldBlockRequest(const GURL& url,
|
| + const url::Origin& first_party_origin,
|
| + ElementType element_type,
|
| + bool is_third_party);
|
| +
|
| + private:
|
| + using UrlPatternIndexMatcher = subresource_filter::UrlPatternIndexMatcher;
|
| + using ExtensionRuleMetadataList =
|
| + flatbuffers::Vector<flatbuffers::Offset<flat::ExtensionRuleMetadata>>;
|
| +
|
| + // This owns the actual buffer. Are there any potential issues of using
|
| + // DeleteOnFileThread.
|
| + std::unique_ptr<base::MemoryMappedFile,
|
| + content::BrowserThread::DeleteOnFileThread>
|
| + ruleset_file_;
|
| + const flat::ExtensionIndexedRuleset* root_;
|
| + const UrlPatternIndexMatcher blacklist_matcher_;
|
| + const UrlPatternIndexMatcher whitelist_matcher_;
|
| + const UrlPatternIndexMatcher redirect_matcher_;
|
| + const ExtensionRuleMetadataList* extension_metdata_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(ExtensionIndexedRulesetMatcher);
|
| +};
|
| +
|
| +std::unique_ptr<ExtensionIndexedRulesetMatcher>
|
| +CreateVerifiedExtensionIndexedRulesetMatcher(
|
| + const base::FilePath& indexed_ruleset_path);
|
| +
|
| +bool ShouldBlockRequest(void* BrowserContext,
|
| + const InfoMap* info_map,
|
| + net::URLRequest* request);
|
| +
|
| +} // namespace declarative_net_request
|
| +} // namespace extensions
|
| +
|
| +#endif // EXTENSIONS_BROWSER_API_DECLARATIVE_NET_REQUEST_MATCHER_UTIL_H_
|
|
|