| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_WEBREQUEST_WEBREQUEST_CONDITIO
N_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_WEBREQUEST_WEBREQUEST_CONDITIO
N_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_WEBREQUEST_WEBREQUEST_CONDITIO
N_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_WEBREQUEST_WEBREQUEST_CONDITIO
N_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/memory/linked_ptr.h" | 12 #include "base/memory/linked_ptr.h" |
| 13 #include "chrome/browser/extensions/api/declarative_webrequest/webrequest_condit
ion_attribute.h" | 13 #include "chrome/browser/extensions/api/declarative_webrequest/webrequest_condit
ion_attribute.h" |
| 14 #include "chrome/browser/extensions/api/declarative_webrequest/webrequest_rule.h
" | 14 #include "chrome/browser/extensions/api/declarative_webrequest/webrequest_rule.h
" |
| 15 #include "chrome/common/extensions/matcher/url_matcher.h" | 15 #include "chrome/common/extensions/matcher/url_matcher.h" |
| 16 | 16 |
| 17 namespace base { |
| 18 class Value; |
| 19 } |
| 20 |
| 17 namespace extensions { | 21 namespace extensions { |
| 18 | 22 |
| 19 // Representation of a condition in the Declarative WebRequest API. A condition | 23 // Representation of a condition in the Declarative WebRequest API. A condition |
| 20 // consists of several attributes. Each of these attributes needs to be | 24 // consists of several attributes. Each of these attributes needs to be |
| 21 // fulfilled in order for the condition to be fulfilled. | 25 // fulfilled in order for the condition to be fulfilled. |
| 22 // | 26 // |
| 23 // We distinguish between two types of conditions: | 27 // We distinguish between two types of conditions: |
| 24 // - URL Matcher conditions are conditions that test the URL of a request. | 28 // - URL Matcher conditions are conditions that test the URL of a request. |
| 25 // These are treated separately because we use a URLMatcher to efficiently | 29 // These are treated separately because we use a URLMatcher to efficiently |
| 26 // test many of these conditions in parallel by using some advanced | 30 // test many of these conditions in parallel by using some advanced |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 int applicable_request_stages_; | 90 int applicable_request_stages_; |
| 87 | 91 |
| 88 DISALLOW_COPY_AND_ASSIGN(WebRequestCondition); | 92 DISALLOW_COPY_AND_ASSIGN(WebRequestCondition); |
| 89 }; | 93 }; |
| 90 | 94 |
| 91 // This class stores a set of conditions that may be part of a WebRequestRule. | 95 // This class stores a set of conditions that may be part of a WebRequestRule. |
| 92 // If any condition is fulfilled, the WebRequestActions of the WebRequestRule | 96 // If any condition is fulfilled, the WebRequestActions of the WebRequestRule |
| 93 // can be triggered. | 97 // can be triggered. |
| 94 class WebRequestConditionSet { | 98 class WebRequestConditionSet { |
| 95 public: | 99 public: |
| 96 typedef std::vector<linked_ptr<json_schema_compiler::any::Any> > AnyVector; | 100 typedef std::vector<linked_ptr<base::Value> > AnyVector; |
| 97 typedef std::vector<linked_ptr<WebRequestCondition> > Conditions; | 101 typedef std::vector<linked_ptr<WebRequestCondition> > Conditions; |
| 98 | 102 |
| 99 explicit WebRequestConditionSet(const Conditions& conditions); | 103 explicit WebRequestConditionSet(const Conditions& conditions); |
| 100 ~WebRequestConditionSet(); | 104 ~WebRequestConditionSet(); |
| 101 | 105 |
| 102 // Factory method that creates an WebRequestConditionSet according to the JSON | 106 // Factory method that creates an WebRequestConditionSet according to the JSON |
| 103 // array |conditions| passed by the extension API. | 107 // array |conditions| passed by the extension API. |
| 104 // Sets |error| and returns NULL in case of an error. | 108 // Sets |error| and returns NULL in case of an error. |
| 105 static scoped_ptr<WebRequestConditionSet> Create( | 109 static scoped_ptr<WebRequestConditionSet> Create( |
| 106 URLMatcherConditionFactory* url_matcher_condition_factory, | 110 URLMatcherConditionFactory* url_matcher_condition_factory, |
| (...skipping 23 matching lines...) Expand all Loading... |
| 130 typedef std::map<URLMatcherConditionSet::ID, WebRequestCondition*> | 134 typedef std::map<URLMatcherConditionSet::ID, WebRequestCondition*> |
| 131 MatchTriggers; | 135 MatchTriggers; |
| 132 MatchTriggers match_triggers_; | 136 MatchTriggers match_triggers_; |
| 133 | 137 |
| 134 DISALLOW_COPY_AND_ASSIGN(WebRequestConditionSet); | 138 DISALLOW_COPY_AND_ASSIGN(WebRequestConditionSet); |
| 135 }; | 139 }; |
| 136 | 140 |
| 137 } // namespace extensions | 141 } // namespace extensions |
| 138 | 142 |
| 139 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_WEBREQUEST_WEBREQUEST_CONDI
TION_H_ | 143 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_WEBREQUEST_WEBREQUEST_CONDI
TION_H_ |
| OLD | NEW |