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

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

Issue 14358004: Almost all actions in Declarative Web Request require all_urls host permissions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Now with error messages Created 7 years, 7 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) 2013 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_RULES_CH ECKER_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_WEBREQUEST_WEBREQUEST_RULES_CH ECKER_H_
7
8 #include <string>
9
10 #include "base/basictypes.h"
11 #include "base/gtest_prod_util.h"
12 #include "chrome/browser/extensions/api/declarative_webrequest/webrequest_action .h"
13 #include "chrome/browser/extensions/api/declarative_webrequest/webrequest_condit ion.h"
14 #include "chrome/browser/extensions/api/declarative_webrequest/webrequest_rules_ registry.h"
15
16 namespace extensions {
17
18 class Extension;
19
20 // This class encapsulates rules consistency checks for Declarative WebRequest.
21 class WebRequestRulesChecker {
22 public:
23 explicit WebRequestRulesChecker(const Extension* extension);
24 WebRequestRule::ConsistencyChecker GetChecker();
25
26 private:
27 FRIEND_TEST_ALL_PREFIXES(WebRequestRulesCheckerTest, StageChecker);
28 FRIEND_TEST_ALL_PREFIXES(WebRequestRulesCheckerTest, HostPermissionsChecker);
29
30 // This budles all checkers and is returned by GetChecker. Returns true in
31 // case of consistency and MUST set |error| otherwise.
32 bool Checker(const WebRequestConditionSet* conditions,
33 const WebRequestActionSet* actions,
34 std::string* error);
35
36 // Check that the |extension| has host permissions for all URLs if actions
37 // requiring them are present.
38 bool HostPermissionsChecker(const WebRequestActionSet* actions,
39 std::string* error);
40 // Check that every action is applicable in the same request stage as at
41 // least one condition.
42 static bool StageChecker(const WebRequestConditionSet* conditions,
43 const WebRequestActionSet* actions,
44 std::string* error);
45
46 const Extension* const extension_;
47
48 DISALLOW_COPY_AND_ASSIGN(WebRequestRulesChecker);
49 };
50
51 } // namespace extensions
52
53 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_WEBREQUEST_WEBREQUEST_RULES _CHECKER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698