| Index: chrome/browser/extensions/api/declarative_webrequest/webrequest_rules_checker.h
|
| diff --git a/chrome/browser/extensions/api/declarative_webrequest/webrequest_rules_checker.h b/chrome/browser/extensions/api/declarative_webrequest/webrequest_rules_checker.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..88b2d5258d953c0d82381e26ca264112f33dfc70
|
| --- /dev/null
|
| +++ b/chrome/browser/extensions/api/declarative_webrequest/webrequest_rules_checker.h
|
| @@ -0,0 +1,53 @@
|
| +// Copyright (c) 2013 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 CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_WEBREQUEST_WEBREQUEST_RULES_CHECKER_H_
|
| +#define CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_WEBREQUEST_WEBREQUEST_RULES_CHECKER_H_
|
| +
|
| +#include <string>
|
| +
|
| +#include "base/basictypes.h"
|
| +#include "base/gtest_prod_util.h"
|
| +#include "chrome/browser/extensions/api/declarative_webrequest/webrequest_action.h"
|
| +#include "chrome/browser/extensions/api/declarative_webrequest/webrequest_condition.h"
|
| +#include "chrome/browser/extensions/api/declarative_webrequest/webrequest_rules_registry.h"
|
| +
|
| +namespace extensions {
|
| +
|
| +class Extension;
|
| +
|
| +// This class encapsulates rules consistency checks for Declarative WebRequest.
|
| +class WebRequestRulesChecker {
|
| + public:
|
| + explicit WebRequestRulesChecker(const Extension* extension);
|
| + WebRequestRule::ConsistencyChecker GetChecker();
|
| +
|
| + private:
|
| + FRIEND_TEST_ALL_PREFIXES(WebRequestRulesCheckerTest, StageChecker);
|
| + FRIEND_TEST_ALL_PREFIXES(WebRequestRulesCheckerTest, HostPermissionsChecker);
|
| +
|
| + // This budles all checkers and is returned by GetChecker. Returns true in
|
| + // case of consistency and MUST set |error| otherwise.
|
| + bool Checker(const WebRequestConditionSet* conditions,
|
| + const WebRequestActionSet* actions,
|
| + std::string* error);
|
| +
|
| + // Check that the |extension| has host permissions for all URLs if actions
|
| + // requiring them are present.
|
| + bool HostPermissionsChecker(const WebRequestActionSet* actions,
|
| + std::string* error);
|
| + // Check that every action is applicable in the same request stage as at
|
| + // least one condition.
|
| + static bool StageChecker(const WebRequestConditionSet* conditions,
|
| + const WebRequestActionSet* actions,
|
| + std::string* error);
|
| +
|
| + const Extension* const extension_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(WebRequestRulesChecker);
|
| +};
|
| +
|
| +} // namespace extensions
|
| +
|
| +#endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_WEBREQUEST_WEBREQUEST_RULES_CHECKER_H_
|
|
|