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

Side by Side Diff: chrome/browser/extensions/api/declarative_webrequest/webrequest_rule.h

Issue 9820003: Implementation of beginning of Declarative Web Request API backend (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed comments Created 8 years, 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_WEBREQUEST_WEBREQUEST_RULE_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_WEBREQUEST_WEBREQUEST_RULE_H_
7 #pragma once
8
9 #include <vector>
10
11 #include "base/compiler_specific.h"
12 #include "chrome/browser/extensions/api/declarative/rules_registry.h"
13
14 namespace extensions {
15 class URLMatcherConditionFactory;
16 class WebRequestConditionCollection;
17 class WebRequestActionCollection;
18 }
19
20 namespace extensions {
21
22 // Representation of a rule of the declarative Web Request API
23 class WebRequestRule {
24 public:
25 typedef std::string ExtensionId;
26 typedef std::string RuleId;
27 typedef std::pair<ExtensionId, RuleId> GlobalRuleId;
28
29 WebRequestRule(const GlobalRuleId& id,
30 scoped_ptr<WebRequestConditionCollection> conditions,
31 scoped_ptr<WebRequestActionCollection> actions);
32 virtual ~WebRequestRule();
33
34 const GlobalRuleId& id() const { return id_; }
35
36 const WebRequestConditionCollection& conditions_collection() const {
37 return *conditions_;
38 }
39
40 const WebRequestActionCollection& actions() const {
41 return *actions_;
42 }
43
44 // If |error| is empty, the translation was successful and the returned
45 // rule is internally consistent.
46 static scoped_ptr<WebRequestRule> Create(
47 URLMatcherConditionFactory* url_matcher_condition_factory,
48 const std::string& extension_id,
49 linked_ptr<RulesRegistry::Rule> rule,
50 std::string* error);
51
52 private:
53 // Checks whether the set of |conditions| and |actions| are consistent,
54 // meaning for example that we do not allow combining an |action| that needs
55 // to be executed before the |condition| can be fulfilled.
56 // Returns true in case of consistency and MUST set |error| otherwise.
57 static bool CheckConsistency(WebRequestConditionCollection* conditions,
58 WebRequestActionCollection* actions,
59 std::string* error);
60
61 GlobalRuleId id_;
62 scoped_ptr<WebRequestConditionCollection> conditions_;
63 scoped_ptr<WebRequestActionCollection> actions_;
64
65 DISALLOW_COPY_AND_ASSIGN(WebRequestRule);
66 };
67
68 } // namespace extensions
69
70 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_WEBREQUEST_WEBREQUEST_RULE_ H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698