forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DNR: Introduce IndexedRule to store parsed JSON rules.
r489421 added the schema for specifying JSON rules for the Declarative Net Request API. This CL introduces IndexedRule to store the parsed JSON rules. In a subsequent CL, this structure will aid in the conversion to a flatbuffer UrlRule as specified by the url_pattern_index component. Doc=http://go/declarative-net-request (Internal only) BUG=696822 Change-Id: I87b55c0266eafddf521bccb3f7d11757f47c2d7b Reviewed-on: https://chromium-review.googlesource.com/577287 Commit-Queue: Karan Bhatia <karandeepb@chromium.org> Reviewed-by: Istiaque Ahmed <lazyboy@chromium.org> Reviewed-by: Pavel Kalinnikov <pkalinnikov@chromium.org> Cr-Commit-Position: refs/heads/master@{#492824}
- Loading branch information
Karan Bhatia
authored and
Commit Bot
committed
Aug 9, 2017
1 parent
8cb8c81
commit 9356edc
Showing
8 changed files
with
819 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# 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. | ||
|
||
source_set("declarative_net_request") { | ||
sources = [ | ||
"constants.h", | ||
"indexed_rule.cc", | ||
"indexed_rule.h", | ||
] | ||
|
||
public_deps = [ | ||
"//components/url_pattern_index", | ||
] | ||
|
||
deps = [ | ||
"//base", | ||
"//extensions/common", | ||
"//extensions/common/api", | ||
"//url", | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
include_rules = [ | ||
"+components/url_pattern_index", | ||
] |
38 changes: 38 additions & 0 deletions
38
extensions/browser/api/declarative_net_request/constants.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// 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_CONSTANTS_H_ | ||
#define EXTENSIONS_BROWSER_API_DECLARATIVE_NET_REQUEST_CONSTANTS_H_ | ||
|
||
namespace extensions { | ||
namespace declarative_net_request { | ||
|
||
// The result of parsing a JSON rule provided by an extension. | ||
enum class ParseResult { | ||
SUCCESS, | ||
ERROR_RESOURCE_TYPE_DUPLICATED, | ||
ERROR_EMPTY_REDIRECT_RULE_PRIORITY, | ||
ERROR_EMPTY_REDIRECT_URL, | ||
ERROR_INVALID_RULE_ID, | ||
ERROR_INVALID_REDIRECT_RULE_PRIORITY, | ||
ERROR_NO_APPLICABLE_RESOURCE_TYPES, | ||
ERROR_EMPTY_DOMAINS_LIST, | ||
ERROR_EMPTY_RESOURCE_TYPES_LIST, | ||
ERROR_EMPTY_URL_FILTER, | ||
ERROR_INVALID_REDIRECT_URL, | ||
}; | ||
|
||
// Minimum valid value of a declarative rule ID. | ||
constexpr int kMinValidID = 1; | ||
|
||
// Minimum valid value of a declarative rule priority. | ||
constexpr int kMinValidPriority = 1; | ||
|
||
// Default priority used for rules when the priority is not explicity provided | ||
// by an extension. | ||
constexpr int kDefaultPriority = 1; | ||
} // namespace declarative_net_request | ||
} // namespace extensions | ||
|
||
#endif // EXTENSIONS_BROWSER_API_DECLARATIVE_NET_REQUEST_CONSTANTS_H_ |
Oops, something went wrong.