| 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_with_cache.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 "chrome/browser/extensions/extension_info_map.h" | 21 #include "chrome/browser/extensions/extension_info_map.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/common/matcher/url_matcher.h" | 24 #include "extensions/common/matcher/url_matcher.h" |
| 25 | 25 |
| 26 class Profile; | 26 class Profile; |
| 27 class ContentPermissions; | 27 class ContentPermissions; |
| 28 | 28 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 52 // | 52 // |
| 53 // Here is the high level overview of this functionality: | 53 // Here is the high level overview of this functionality: |
| 54 // | 54 // |
| 55 // RulesRegistry::Rule consists of Conditions and Actions, these are | 55 // RulesRegistry::Rule consists of Conditions and Actions, these are |
| 56 // represented as a ContentRule with ContentConditions and | 56 // represented as a ContentRule with ContentConditions and |
| 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 RulesRegistryWithCache, | 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( | 67 ContentRulesRegistry(Profile* profile, |
| 68 Profile* profile, | 68 scoped_ptr<RulesCacheDelegate>* ui_part); |
| 69 scoped_ptr<RulesRegistryWithCache::RuleStorageOnUI>* ui_part); | |
| 70 | 69 |
| 71 // Applies all content rules given an update (CSS match change or | 70 // Applies all content rules given an update (CSS match change or |
| 72 // page navigation, for now) from the renderer. | 71 // page navigation, for now) from the renderer. |
| 73 void Apply(content::WebContents* contents, | 72 void Apply(content::WebContents* contents, |
| 74 const std::vector<std::string>& matching_css_selectors); | 73 const std::vector<std::string>& matching_css_selectors); |
| 75 | 74 |
| 76 // Applies all content rules given that a tab was just navigated. | 75 // Applies all content rules given that a tab was just navigated. |
| 77 void DidNavigateMainFrame(content::WebContents* tab, | 76 void DidNavigateMainFrame(content::WebContents* tab, |
| 78 const content::LoadCommittedDetails& details, | 77 const content::LoadCommittedDetails& details, |
| 79 const content::FrameNavigateParams& params); | 78 const content::FrameNavigateParams& params); |
| 80 | 79 |
| 81 // Implementation of RulesRegistryWithCache: | 80 // Implementation of RulesRegistry: |
| 82 virtual std::string AddRulesImpl( | 81 virtual std::string AddRulesImpl( |
| 83 const std::string& extension_id, | 82 const std::string& extension_id, |
| 84 const std::vector<linked_ptr<RulesRegistry::Rule> >& rules) OVERRIDE; | 83 const std::vector<linked_ptr<RulesRegistry::Rule> >& rules) OVERRIDE; |
| 85 virtual std::string RemoveRulesImpl( | 84 virtual std::string RemoveRulesImpl( |
| 86 const std::string& extension_id, | 85 const std::string& extension_id, |
| 87 const std::vector<std::string>& rule_identifiers) OVERRIDE; | 86 const std::vector<std::string>& rule_identifiers) OVERRIDE; |
| 88 virtual std::string RemoveAllRulesImpl( | 87 virtual std::string RemoveAllRulesImpl( |
| 89 const std::string& extension_id) OVERRIDE; | 88 const std::string& extension_id) OVERRIDE; |
| 90 | 89 |
| 91 // content::NotificationObserver implementation. | 90 // content::NotificationObserver implementation. |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 content::NotificationRegistrar registrar_; | 143 content::NotificationRegistrar registrar_; |
| 145 | 144 |
| 146 scoped_refptr<ExtensionInfoMap> extension_info_map_; | 145 scoped_refptr<ExtensionInfoMap> extension_info_map_; |
| 147 | 146 |
| 148 DISALLOW_COPY_AND_ASSIGN(ContentRulesRegistry); | 147 DISALLOW_COPY_AND_ASSIGN(ContentRulesRegistry); |
| 149 }; | 148 }; |
| 150 | 149 |
| 151 } // namespace extensions | 150 } // namespace extensions |
| 152 | 151 |
| 153 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_CONTENT_CONTENT_RULES_REGIS
TRY_H_ | 152 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_CONTENT_CONTENT_RULES_REGIS
TRY_H_ |
| OLD | NEW |