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

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

Issue 11414230: Declarative Web Request: firstPartyForCookiesUrl (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More checks and one more unit test Created 7 years, 11 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
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 <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 // TODO(battre) Consider making the URLMatcher an owner of the 53 // TODO(battre) Consider making the URLMatcher an owner of the
54 // URLMatcherConditionSet and only pass a pointer to URLMatcherConditionSet 54 // URLMatcherConditionSet and only pass a pointer to URLMatcherConditionSet
55 // in url_matcher_condition_set(). This saves some copying in 55 // in url_matcher_condition_set(). This saves some copying in
56 // WebRequestConditionSet::GetURLMatcherConditionSets. 56 // WebRequestConditionSet::GetURLMatcherConditionSets.
57 class WebRequestCondition { 57 class WebRequestCondition {
58 public: 58 public:
59 typedef DeclarativeWebRequestData MatchData; 59 typedef DeclarativeWebRequestData MatchData;
60 60
61 WebRequestCondition( 61 WebRequestCondition(
62 scoped_refptr<URLMatcherConditionSet> url_matcher_conditions, 62 scoped_refptr<URLMatcherConditionSet> url_matcher_conditions,
63 scoped_refptr<URLMatcherConditionSet> first_party_url_matcher_conditions,
63 const WebRequestConditionAttributes& condition_attributes); 64 const WebRequestConditionAttributes& condition_attributes);
64 ~WebRequestCondition(); 65 ~WebRequestCondition();
65 66
66 // Factory method that instantiates a WebRequestCondition according to 67 // Factory method that instantiates a WebRequestCondition according to
67 // the description |condition| passed by the extension API. 68 // the description |condition| passed by the extension API. Two factories
69 // should be passed. The first factory should be from the matcher for the URL
70 // of a request, the second factory should be from the matcher for the first
71 // party for cookies URL.
68 static scoped_ptr<WebRequestCondition> Create( 72 static scoped_ptr<WebRequestCondition> Create(
69 URLMatcherConditionFactory* url_matcher_condition_factory, 73 const std::vector<URLMatcherConditionFactory*>&
74 url_matcher_condition_factories,
70 const base::Value& condition, 75 const base::Value& condition,
71 std::string* error); 76 std::string* error);
72 77
73 // Returns whether the request matches this condition. |url_matches| lists 78 // Returns whether the request matches this condition. |url_matches| lists
74 // the IDs that match the request's URL. 79 // the IDs that match their corresponding URLs.
75 bool IsFulfilled(const std::set<URLMatcherConditionSet::ID> &url_matches, 80 bool IsFulfilled(
76 const DeclarativeWebRequestData& request_data) const; 81 const std::set<URLMatcherConditionSet::ID>& url_matches,
82 const DeclarativeWebRequestData& request_data) const;
77 83
78 // True if this condition has a url filter. 84 // If the Condition needs to be filtered by some URLMatcherConditionSets,
79 bool has_url_matcher_condition_set() const { 85 // append them to this argument. With |index| 0 this returns the condition
80 return url_matcher_conditions_ != NULL; 86 // set for the request's URL, and returns 1. With |index| 1 this returns the
81 } 87 // set for the "1st party for cookies" URL and returns -1. For all other
82 88 // values of |index| does nothing and returns -1.
83 // If this Condition has a url filter, appends it to |condition_sets|. 89 int GetURLMatcherConditionSets(
84 void GetURLMatcherConditionSets( 90 URLMatcherConditionSet::Vector* condition_sets,
85 URLMatcherConditionSet::Vector* condition_sets) const { 91 int index) const;
86 if (url_matcher_conditions_)
87 condition_sets->push_back(url_matcher_conditions_);
88 }
89 92
90 // Returns the condition attributes checked by this condition. 93 // Returns the condition attributes checked by this condition.
91 const WebRequestConditionAttributes condition_attributes() const { 94 const WebRequestConditionAttributes condition_attributes() const {
92 return condition_attributes_; 95 return condition_attributes_;
93 } 96 }
94 97
95 // Returns a bit vector representing extensions::RequestStage. The bit vector 98 // Returns a bit vector representing extensions::RequestStage. The bit vector
96 // contains a 1 for each request stage during which the condition can be 99 // contains a 1 for each request stage during which the condition can be
97 // tested. 100 // tested.
98 int stages() const { return applicable_request_stages_; } 101 int stages() const { return applicable_request_stages_; }
99 102
100 private: 103 private:
101 // Represents the 'url' attribute of this condition. If NULL, then there was 104 // URL attributes of this condition.
102 // no 'url' attribute in this condition.
103 scoped_refptr<URLMatcherConditionSet> url_matcher_conditions_; 105 scoped_refptr<URLMatcherConditionSet> url_matcher_conditions_;
106 scoped_refptr<URLMatcherConditionSet> first_party_url_matcher_conditions_;
104 107
105 // All non-UrlFilter attributes of this condition. 108 // All non-UrlFilter attributes of this condition.
106 WebRequestConditionAttributes condition_attributes_; 109 WebRequestConditionAttributes condition_attributes_;
107 110
108 // Bit vector indicating all RequestStage during which all 111 // Bit vector indicating all RequestStage during which all
109 // |condition_attributes_| can be evaluated. 112 // |condition_attributes_| can be evaluated.
110 int applicable_request_stages_; 113 int applicable_request_stages_;
111 114
112 DISALLOW_COPY_AND_ASSIGN(WebRequestCondition); 115 DISALLOW_COPY_AND_ASSIGN(WebRequestCondition);
113 }; 116 };
114 117
115 typedef DeclarativeConditionSet<WebRequestCondition> WebRequestConditionSet; 118 typedef DeclarativeConditionSet<WebRequestCondition> WebRequestConditionSet;
116 119
117 } // namespace extensions 120 } // namespace extensions
118 121
119 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_WEBREQUEST_WEBREQUEST_CONDI TION_H_ 122 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_WEBREQUEST_WEBREQUEST_CONDI TION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698