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_CONTENT_RULES_REGISTRY
_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_CONTENT_CONTENT_RULES_REGISTRY
_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_CONTENT_CONTENT_RULES_REGISTRY
_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_CONTENT_CONTENT_RULES_REGISTRY
_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/memory/linked_ptr.h" | 13 #include "base/memory/linked_ptr.h" |
14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
16 #include "base/time/time.h" | 16 #include "base/time/time.h" |
17 #include "chrome/browser/extensions/api/declarative/declarative_rule.h" | 17 #include "chrome/browser/extensions/api/declarative/declarative_rule.h" |
18 #include "chrome/browser/extensions/api/declarative/rules_registry.h" | 18 #include "chrome/browser/extensions/api/declarative/rules_registry.h" |
19 #include "chrome/browser/extensions/api/declarative_content/content_action.h" | 19 #include "chrome/browser/extensions/api/declarative_content/content_action.h" |
20 #include "chrome/browser/extensions/api/declarative_content/content_condition.h" | 20 #include "chrome/browser/extensions/api/declarative_content/content_condition.h" |
21 #include "components/url_matcher/url_matcher.h" | 21 #include "components/url_matcher/url_matcher.h" |
22 #include "content/public/browser/notification_observer.h" | 22 #include "content/public/browser/notification_observer.h" |
23 #include "content/public/browser/notification_registrar.h" | 23 #include "content/public/browser/notification_registrar.h" |
24 #include "extensions/browser/info_map.h" | 24 #include "extensions/browser/info_map.h" |
25 | 25 |
26 class Profile; | |
27 class ContentPermissions; | 26 class ContentPermissions; |
28 | 27 |
29 namespace content { | 28 namespace content { |
| 29 class BrowserContext; |
30 class RenderProcessHost; | 30 class RenderProcessHost; |
31 class WebContents; | 31 class WebContents; |
32 struct FrameNavigateParams; | 32 struct FrameNavigateParams; |
33 struct LoadCommittedDetails; | 33 struct LoadCommittedDetails; |
34 } | 34 } |
35 | 35 |
36 namespace extension_web_request_api_helpers { | 36 namespace extension_web_request_api_helpers { |
37 struct EventResponseDelta; | 37 struct EventResponseDelta; |
38 } | 38 } |
39 | 39 |
(...skipping 17 matching lines...) Expand all Loading... |
57 // ContentRuleActions. | 57 // ContentRuleActions. |
58 // | 58 // |
59 // The evaluation of URL related condition attributes (host_suffix, path_prefix) | 59 // The evaluation of URL related condition attributes (host_suffix, path_prefix) |
60 // is delegated to a URLMatcher, because this is capable of evaluating many | 60 // is delegated to a URLMatcher, because this is capable of evaluating many |
61 // of such URL related condition attributes in parallel. | 61 // of such URL related condition attributes in parallel. |
62 class ContentRulesRegistry : public RulesRegistry, | 62 class ContentRulesRegistry : public RulesRegistry, |
63 public content::NotificationObserver { | 63 public content::NotificationObserver { |
64 public: | 64 public: |
65 // For testing, |ui_part| can be NULL. In that case it constructs the | 65 // For testing, |ui_part| can be NULL. In that case it constructs the |
66 // registry with storage functionality suspended. | 66 // registry with storage functionality suspended. |
67 ContentRulesRegistry(Profile* profile, RulesCacheDelegate* cache_delegate); | 67 ContentRulesRegistry(content::BrowserContext* browser_context, |
| 68 RulesCacheDelegate* cache_delegate); |
68 | 69 |
69 // Applies all content rules given an update (CSS match change or | 70 // Applies all content rules given an update (CSS match change or |
70 // page navigation, for now) from the renderer. | 71 // page navigation, for now) from the renderer. |
71 void Apply(content::WebContents* contents, | 72 void Apply(content::WebContents* contents, |
72 const std::vector<std::string>& matching_css_selectors); | 73 const std::vector<std::string>& matching_css_selectors); |
73 | 74 |
74 // Applies all content rules given that a tab was just navigated. | 75 // Applies all content rules given that a tab was just navigated. |
75 void DidNavigateMainFrame(content::WebContents* tab, | 76 void DidNavigateMainFrame(content::WebContents* tab, |
76 const content::LoadCommittedDetails& details, | 77 const content::LoadCommittedDetails& details, |
77 const content::FrameNavigateParams& params); | 78 const content::FrameNavigateParams& params); |
(...skipping 24 matching lines...) Expand all Loading... |
102 const std::string& extension_id) const; | 103 const std::string& extension_id) const; |
103 | 104 |
104 private: | 105 private: |
105 friend class DeclarativeContentRulesRegistryTest; | 106 friend class DeclarativeContentRulesRegistryTest; |
106 | 107 |
107 std::set<ContentRule*> | 108 std::set<ContentRule*> |
108 GetMatches(const RendererContentMatchData& renderer_data) const; | 109 GetMatches(const RendererContentMatchData& renderer_data) const; |
109 | 110 |
110 // Scans the rules for the set of conditions they're watching. If the set has | 111 // Scans the rules for the set of conditions they're watching. If the set has |
111 // changed, calls InstructRenderProcess() for each RenderProcessHost in the | 112 // changed, calls InstructRenderProcess() for each RenderProcessHost in the |
112 // current profile. | 113 // current browser_context. |
113 void UpdateConditionCache(); | 114 void UpdateConditionCache(); |
114 | 115 |
115 // Tells a renderer what page attributes to watch for using an | 116 // Tells a renderer what page attributes to watch for using an |
116 // ExtensionMsg_WatchPages. | 117 // ExtensionMsg_WatchPages. |
117 void InstructRenderProcess(content::RenderProcessHost* process); | 118 void InstructRenderProcess(content::RenderProcessHost* process); |
118 | 119 |
119 typedef std::map<url_matcher::URLMatcherConditionSet::ID, ContentRule*> | 120 typedef std::map<url_matcher::URLMatcherConditionSet::ID, ContentRule*> |
120 URLMatcherIdToRule; | 121 URLMatcherIdToRule; |
121 typedef std::map<ContentRule::GlobalRuleId, linked_ptr<ContentRule> > | 122 typedef std::map<ContentRule::GlobalRuleId, linked_ptr<ContentRule> > |
122 RulesMap; | 123 RulesMap; |
(...skipping 18 matching lines...) Expand all Loading... |
141 content::NotificationRegistrar registrar_; | 142 content::NotificationRegistrar registrar_; |
142 | 143 |
143 scoped_refptr<InfoMap> extension_info_map_; | 144 scoped_refptr<InfoMap> extension_info_map_; |
144 | 145 |
145 DISALLOW_COPY_AND_ASSIGN(ContentRulesRegistry); | 146 DISALLOW_COPY_AND_ASSIGN(ContentRulesRegistry); |
146 }; | 147 }; |
147 | 148 |
148 } // namespace extensions | 149 } // namespace extensions |
149 | 150 |
150 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_CONTENT_CONTENT_RULES_REGIS
TRY_H_ | 151 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_CONTENT_CONTENT_RULES_REGIS
TRY_H_ |
OLD | NEW |