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

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

Issue 11569007: Refactoring how conditions without URL attributes are handled. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Triggers back in ConditionSet Created 8 years 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_RULES_RE GISTRY_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_WEBREQUEST_WEBREQUEST_RULES_RE GISTRY_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_WEBREQUEST_WEBREQUEST_RULES_RE GISTRY_H_ 6 #define CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_WEBREQUEST_WEBREQUEST_RULES_RE GISTRY_H_
7 7
8 #include <list> 8 #include <list>
9 #include <map> 9 #include <map>
10 #include <set> 10 #include <set>
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 // "http://www.example.com/query/" has any matches, and the URLMatcher 61 // "http://www.example.com/query/" has any matches, and the URLMatcher
62 // will respond with the URLMatcherConditionSet::ID. We can map this 62 // will respond with the URLMatcherConditionSet::ID. We can map this
63 // to the WebRequestRule and check whether also the other conditions (in this 63 // to the WebRequestRule and check whether also the other conditions (in this
64 // example 'scheme': 'http') are fulfilled. 64 // example 'scheme': 'http') are fulfilled.
65 class WebRequestRulesRegistry : public RulesRegistryWithCache { 65 class WebRequestRulesRegistry : public RulesRegistryWithCache {
66 public: 66 public:
67 WebRequestRulesRegistry(Profile* profile, Delegate* delegate); 67 WebRequestRulesRegistry(Profile* profile, Delegate* delegate);
68 68
69 // TODO(battre): This will become an implementation detail, because we need 69 // TODO(battre): This will become an implementation detail, because we need
70 // a way to also execute the actions of the rules. 70 // a way to also execute the actions of the rules.
71 std::set<WebRequestRule::GlobalRuleId> GetMatches( 71 std::set<const WebRequestRule*> GetMatches(
72 const WebRequestRule::RequestData& request_data); 72 const WebRequestRule::RequestData& request_data);
73 73
74 // Returns which modifications should be executed on the network request 74 // Returns which modifications should be executed on the network request
75 // according to the rules registered in this registry. 75 // according to the rules registered in this registry.
76 std::list<LinkedPtrEventResponseDelta> CreateDeltas( 76 std::list<LinkedPtrEventResponseDelta> CreateDeltas(
77 const ExtensionInfoMap* extension_info_map, 77 const ExtensionInfoMap* extension_info_map,
78 const WebRequestRule::RequestData& request_data, 78 const WebRequestRule::RequestData& request_data,
79 bool crosses_incognito); 79 bool crosses_incognito);
80 80
81 // Implementation of RulesRegistryWithCache: 81 // Implementation of RulesRegistryWithCache:
(...skipping 11 matching lines...) Expand all
93 bool IsEmpty() const; 93 bool IsEmpty() const;
94 94
95 protected: 95 protected:
96 virtual ~WebRequestRulesRegistry(); 96 virtual ~WebRequestRulesRegistry();
97 97
98 // Virtual for testing: 98 // Virtual for testing:
99 virtual base::Time GetExtensionInstallationTime( 99 virtual base::Time GetExtensionInstallationTime(
100 const std::string& extension_id) const; 100 const std::string& extension_id) const;
101 virtual void ClearCacheOnNavigation(); 101 virtual void ClearCacheOnNavigation();
102 102
103 const std::set<const WebRequestRule*>&
104 rules_with_untriggered_conditions_for_test() const {
105 return rules_with_untriggered_conditions_;
106 }
107
103 private: 108 private:
104 typedef std::map<URLMatcherConditionSet::ID, WebRequestRule*> RuleTriggers; 109 typedef std::map<URLMatcherConditionSet::ID, WebRequestRule*> RuleTriggers;
105 typedef std::map<WebRequestRule::GlobalRuleId, linked_ptr<WebRequestRule> > 110 typedef std::map<WebRequestRule::GlobalRuleId, linked_ptr<WebRequestRule> >
106 RulesMap; 111 RulesMap;
107 112
108 // Map that tells us which WebRequestRule may match under the condition that 113 // Map that tells us which WebRequestRule may match under the condition that
109 // the URLMatcherConditionSet::ID was returned by the |url_matcher_|. 114 // the URLMatcherConditionSet::ID was returned by the |url_matcher_|.
110 RuleTriggers rule_triggers_; 115 RuleTriggers rule_triggers_;
111 116
117 // These rules contain condition sets with conditions without URL attributes.
118 // Such conditions are not triggered by URL matcher, so we need to test them
119 // separately.
120 std::set<const WebRequestRule*> rules_with_untriggered_conditions_;
121
112 RulesMap webrequest_rules_; 122 RulesMap webrequest_rules_;
113 123
114 URLMatcher url_matcher_; 124 URLMatcher url_matcher_;
115 125
116 scoped_refptr<ExtensionInfoMap> extension_info_map_; 126 scoped_refptr<ExtensionInfoMap> extension_info_map_;
117 }; 127 };
118 128
119 } // namespace extensions 129 } // namespace extensions
120 130
121 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_WEBREQUEST_WEBREQUEST_RULES _REGISTRY_H_ 131 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_WEBREQUEST_WEBREQUEST_RULES _REGISTRY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698