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_CONTENT_CHROME_CONTENT_RULES_R
EGISTRY_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_CONTENT_CHROME_CONTENT_RULES_R
EGISTRY_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_CONTENT_CHROME_CONTENT_RULES_R
EGISTRY_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_CONTENT_CHROME_CONTENT_RULES_R
EGISTRY_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 class URLRequest; | 43 class URLRequest; |
44 } | 44 } |
45 | 45 |
46 namespace extensions { | 46 namespace extensions { |
47 | 47 |
48 // The ChromeContentRulesRegistry is responsible for managing | 48 // The ChromeContentRulesRegistry is responsible for managing |
49 // the internal representation of rules for the Declarative Content API. | 49 // the internal representation of rules for the Declarative Content API. |
50 // | 50 // |
51 // Here is the high level overview of this functionality: | 51 // Here is the high level overview of this functionality: |
52 // | 52 // |
53 // core_api::events::Rule consists of conditions and actions, these are | 53 // api::events::Rule consists of conditions and actions, these are |
54 // represented as a ContentRule with ContentConditions and ContentRuleActions. | 54 // represented as a ContentRule with ContentConditions and ContentRuleActions. |
55 // | 55 // |
56 // The evaluation of URL related condition attributes (host_suffix, path_prefix) | 56 // The evaluation of URL related condition attributes (host_suffix, path_prefix) |
57 // is delegated to a URLMatcher, because this is capable of evaluating many | 57 // is delegated to a URLMatcher, because this is capable of evaluating many |
58 // of such URL related condition attributes in parallel. | 58 // of such URL related condition attributes in parallel. |
59 // | 59 // |
60 // A note on incognito support: separate instances of ChromeContentRulesRegistry | 60 // A note on incognito support: separate instances of ChromeContentRulesRegistry |
61 // are created for incognito and non-incognito contexts. The incognito instance, | 61 // are created for incognito and non-incognito contexts. The incognito instance, |
62 // however, is only responsible for applying rules registered by the incognito | 62 // however, is only responsible for applying rules registered by the incognito |
63 // side of split-mode extensions to incognito tabs. The non-incognito instance | 63 // side of split-mode extensions to incognito tabs. The non-incognito instance |
(...skipping 13 matching lines...) Expand all Loading... |
77 void MonitorWebContentsForRuleEvaluation( | 77 void MonitorWebContentsForRuleEvaluation( |
78 content::WebContents* contents) override; | 78 content::WebContents* contents) override; |
79 void DidNavigateMainFrame( | 79 void DidNavigateMainFrame( |
80 content::WebContents* tab, | 80 content::WebContents* tab, |
81 const content::LoadCommittedDetails& details, | 81 const content::LoadCommittedDetails& details, |
82 const content::FrameNavigateParams& params) override; | 82 const content::FrameNavigateParams& params) override; |
83 | 83 |
84 // RulesRegistry: | 84 // RulesRegistry: |
85 std::string AddRulesImpl( | 85 std::string AddRulesImpl( |
86 const std::string& extension_id, | 86 const std::string& extension_id, |
87 const std::vector<linked_ptr<core_api::events::Rule>>& rules) override; | 87 const std::vector<linked_ptr<api::events::Rule>>& rules) override; |
88 std::string RemoveRulesImpl( | 88 std::string RemoveRulesImpl( |
89 const std::string& extension_id, | 89 const std::string& extension_id, |
90 const std::vector<std::string>& rule_identifiers) override; | 90 const std::vector<std::string>& rule_identifiers) override; |
91 std::string RemoveAllRulesImpl(const std::string& extension_id) override; | 91 std::string RemoveAllRulesImpl(const std::string& extension_id) override; |
92 | 92 |
93 // content::NotificationObserver: | 93 // content::NotificationObserver: |
94 void Observe(int type, | 94 void Observe(int type, |
95 const content::NotificationSource& source, | 95 const content::NotificationSource& source, |
96 const content::NotificationDetails& details) override; | 96 const content::NotificationDetails& details) override; |
97 | 97 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 IGNORE_REQUESTS // Ignore. | 149 IGNORE_REQUESTS // Ignore. |
150 }; | 150 }; |
151 | 151 |
152 class EvaluationScope; | 152 class EvaluationScope; |
153 | 153 |
154 // Creates a ContentRule for |extension| given a json definition. The format | 154 // Creates a ContentRule for |extension| given a json definition. The format |
155 // of each condition and action's json is up to the specific ContentCondition | 155 // of each condition and action's json is up to the specific ContentCondition |
156 // and ContentAction. |extension| may be NULL in tests. If |error| is empty, | 156 // and ContentAction. |extension| may be NULL in tests. If |error| is empty, |
157 // the translation was successful and the returned rule is internally | 157 // the translation was successful and the returned rule is internally |
158 // consistent. | 158 // consistent. |
159 scoped_ptr<const ContentRule> CreateRule( | 159 scoped_ptr<const ContentRule> CreateRule(const Extension* extension, |
160 const Extension* extension, | 160 const api::events::Rule& api_rule, |
161 const core_api::events::Rule& api_rule, | 161 std::string* error); |
162 std::string* error); | |
163 | 162 |
164 // True if this object is managing the rules for |context|. | 163 // True if this object is managing the rules for |context|. |
165 bool ManagingRulesForBrowserContext(content::BrowserContext* context); | 164 bool ManagingRulesForBrowserContext(content::BrowserContext* context); |
166 | 165 |
167 std::set<const ContentRule*> GetMatches( | 166 std::set<const ContentRule*> GetMatches( |
168 const RendererContentMatchData& renderer_data, | 167 const RendererContentMatchData& renderer_data, |
169 bool is_incognito_renderer) const; | 168 bool is_incognito_renderer) const; |
170 | 169 |
171 // Updates the condition evaluator with the current watched CSS selectors. | 170 // Updates the condition evaluator with the current watched CSS selectors. |
172 void UpdateCssSelectorsFromRules(); | 171 void UpdateCssSelectorsFromRules(); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 | 214 |
216 // Manages our notification registrations. | 215 // Manages our notification registrations. |
217 content::NotificationRegistrar registrar_; | 216 content::NotificationRegistrar registrar_; |
218 | 217 |
219 DISALLOW_COPY_AND_ASSIGN(ChromeContentRulesRegistry); | 218 DISALLOW_COPY_AND_ASSIGN(ChromeContentRulesRegistry); |
220 }; | 219 }; |
221 | 220 |
222 } // namespace extensions | 221 } // namespace extensions |
223 | 222 |
224 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_CONTENT_CHROME_CONTENT_RULE
S_REGISTRY_H_ | 223 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_CONTENT_CHROME_CONTENT_RULE
S_REGISTRY_H_ |
OLD | NEW |