| 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 #include "extensions/common/watched_pages_recipient.h" |
| 25 | 26 |
| 26 class Profile; | 27 class Profile; |
| 27 class ContentPermissions; | 28 class ContentPermissions; |
| 28 | 29 |
| 29 namespace content { | 30 namespace content { |
| 30 class RenderProcessHost; | 31 class RenderProcessHost; |
| 31 class WebContents; | 32 class WebContents; |
| 32 struct FrameNavigateParams; | 33 struct FrameNavigateParams; |
| 33 struct LoadCommittedDetails; | 34 struct LoadCommittedDetails; |
| 34 } | 35 } |
| (...skipping 22 matching lines...) Expand all Loading... |
| 57 // ContentRuleActions. | 58 // ContentRuleActions. |
| 58 // | 59 // |
| 59 // The evaluation of URL related condition attributes (host_suffix, path_prefix) | 60 // The evaluation of URL related condition attributes (host_suffix, path_prefix) |
| 60 // is delegated to a URLMatcher, because this is capable of evaluating many | 61 // is delegated to a URLMatcher, because this is capable of evaluating many |
| 61 // of such URL related condition attributes in parallel. | 62 // of such URL related condition attributes in parallel. |
| 62 class ContentRulesRegistry : public RulesRegistry, | 63 class ContentRulesRegistry : public RulesRegistry, |
| 63 public content::NotificationObserver { | 64 public content::NotificationObserver { |
| 64 public: | 65 public: |
| 65 // For testing, |ui_part| can be NULL. In that case it constructs the | 66 // For testing, |ui_part| can be NULL. In that case it constructs the |
| 66 // registry with storage functionality suspended. | 67 // registry with storage functionality suspended. |
| 67 ContentRulesRegistry(Profile* profile, RulesCacheDelegate* cache_delegate); | 68 ContentRulesRegistry(Profile* profile, |
| 69 const std::string& event_name, |
| 70 const WatchedPagesRecipient watched_pages_recipient, |
| 71 RulesCacheDelegate* cache_delegate); |
| 68 | 72 |
| 69 // Applies all content rules given an update (CSS match change or | 73 // Applies all content rules given an update (CSS match change or |
| 70 // page navigation, for now) from the renderer. | 74 // page navigation, for now) from the renderer. |
| 71 void Apply(content::WebContents* contents, | 75 void Apply(content::WebContents* contents, |
| 72 const std::vector<std::string>& matching_css_selectors); | 76 const std::vector<std::string>& matching_css_selectors); |
| 73 | 77 |
| 74 // Applies all content rules given that a tab was just navigated. | 78 // Applies all content rules given that a tab was just navigated. |
| 75 void DidNavigateMainFrame(content::WebContents* tab, | 79 void DidNavigateMainFrame(content::WebContents* tab, |
| 76 const content::LoadCommittedDetails& details, | 80 const content::LoadCommittedDetails& details, |
| 77 const content::FrameNavigateParams& params); | 81 const content::FrameNavigateParams& params); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 // Maps tab_id to the set of rules that match on that tab. This | 134 // Maps tab_id to the set of rules that match on that tab. This |
| 131 // lets us call Revert as appropriate. | 135 // lets us call Revert as appropriate. |
| 132 std::map<int, std::set<ContentRule*> > active_rules_; | 136 std::map<int, std::set<ContentRule*> > active_rules_; |
| 133 | 137 |
| 134 // Matches URLs for the page_url condition. | 138 // Matches URLs for the page_url condition. |
| 135 url_matcher::URLMatcher url_matcher_; | 139 url_matcher::URLMatcher url_matcher_; |
| 136 | 140 |
| 137 // All CSS selectors any rule's conditions watch for. | 141 // All CSS selectors any rule's conditions watch for. |
| 138 std::vector<std::string> watched_css_selectors_; | 142 std::vector<std::string> watched_css_selectors_; |
| 139 | 143 |
| 144 WatchedPagesRecipient watched_pages_recipient_; |
| 145 |
| 140 // Manages our notification registrations. | 146 // Manages our notification registrations. |
| 141 content::NotificationRegistrar registrar_; | 147 content::NotificationRegistrar registrar_; |
| 142 | 148 |
| 143 scoped_refptr<InfoMap> extension_info_map_; | 149 scoped_refptr<InfoMap> extension_info_map_; |
| 144 | 150 |
| 145 DISALLOW_COPY_AND_ASSIGN(ContentRulesRegistry); | 151 DISALLOW_COPY_AND_ASSIGN(ContentRulesRegistry); |
| 146 }; | 152 }; |
| 147 | 153 |
| 154 // Map from event_name to registry pointer. |
| 155 typedef std::map<std::string, ContentRulesRegistry*> ContentRulesRegistryMap; |
| 156 |
| 148 } // namespace extensions | 157 } // namespace extensions |
| 149 | 158 |
| 150 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_CONTENT_CONTENT_RULES_REGIS
TRY_H_ | 159 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_CONTENT_CONTENT_RULES_REGIS
TRY_H_ |
| OLD | NEW |