OLD | NEW |
---|---|
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2014 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 EXTENSIONS_BROWSER_API_DECLARATIVE_CONTENT_CONTENT_RULES_REGISTRY_H__ | 5 #ifndef EXTENSIONS_BROWSER_API_DECLARATIVE_CONTENT_CONTENT_RULES_REGISTRY_H__ |
6 #define EXTENSIONS_BROWSER_API_DECLARATIVE_CONTENT_CONTENT_RULES_REGISTRY_H__ | 6 #define EXTENSIONS_BROWSER_API_DECLARATIVE_CONTENT_CONTENT_RULES_REGISTRY_H__ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "content/public/browser/browser_thread.h" | 10 #include "content/public/browser/browser_thread.h" |
11 #include "extensions/browser/api/declarative/rules_registry.h" | 11 #include "extensions/browser/api/declarative/rules_registry.h" |
12 | 12 |
13 namespace content { | 13 namespace content { |
14 class BrowserContext; | 14 class BrowserContext; |
15 class WebContents; | 15 class WebContents; |
16 struct FrameNavigateParams; | 16 struct FrameNavigateParams; |
17 struct LoadCommittedDetails; | 17 struct LoadCommittedDetails; |
18 } | 18 } |
19 | 19 |
20 namespace extensions { | 20 namespace extensions { |
21 | 21 |
22 // This class acts as an //extensions-side interface for ContentRulesRegistry | 22 // This class acts as an //extensions-side interface for ContentRulesRegistry |
23 // to allow RulesRegistryService to be moved to //extensions. | 23 // to allow RulesRegistryService to be moved to //extensions. |
24 // TODO(wjmaclean): Remove this once ContentRulesRegistry moves to | 24 // TODO(wjmaclean): Remove this once ContentRulesRegistry moves to |
25 // //extensions. | 25 // //extensions. |
26 // | |
27 // Note: when dealing with WebContents associated with OffTheRecord contexts, | |
28 // functions on this interface must be invoked for BOTH the Original and | |
29 // OffTheRecord ContentRulesRegistry instances. This is necessary because the | |
30 // Original ContentRulesRegistry instance handles spanning-mode incognito | |
31 // extensions. | |
26 class ContentRulesRegistry : public RulesRegistry { | 32 class ContentRulesRegistry : public RulesRegistry { |
27 public: | 33 public: |
28 ContentRulesRegistry(content::BrowserContext* browser_context, | 34 ContentRulesRegistry(content::BrowserContext* browser_context, |
29 const std::string& event_name, | 35 const std::string& event_name, |
30 content::BrowserThread::ID owner_thread, | 36 content::BrowserThread::ID owner_thread, |
31 RulesCacheDelegate* cache_delegate, | 37 RulesCacheDelegate* cache_delegate, |
32 int rules_registry_id) | 38 int rules_registry_id) |
33 : RulesRegistry(browser_context, | 39 : RulesRegistry(browser_context, |
34 event_name, | 40 event_name, |
35 owner_thread, | 41 owner_thread, |
36 cache_delegate, | 42 cache_delegate, |
37 rules_registry_id) {} | 43 rules_registry_id) {} |
38 | 44 |
39 // Applies all content rules given an update (CSS match change or | 45 // Notifies the registry that it should evaluate rules for |contents|. |
40 // page navigation, for now) from the renderer. | 46 virtual void MonitorWebContentsForRuleEvaluation( |
41 virtual void Apply( | 47 content::WebContents* contents) = 0; |
42 content::WebContents* contents, | |
43 const std::vector<std::string>& matching_css_selectors) = 0; | |
44 | 48 |
45 // Applies all content rules given that a tab was just navigated. | 49 // Applies all content rules given that a tab was just navigated. |
46 virtual void DidNavigateMainFrame( | 50 virtual void DidNavigateMainFrame( |
47 content::WebContents* tab, | 51 content::WebContents* tab, |
48 const content::LoadCommittedDetails& details, | 52 const content::LoadCommittedDetails& details, |
49 const content::FrameNavigateParams& params) = 0; | 53 const content::FrameNavigateParams& params) = 0; |
50 | 54 |
51 // Applies all content rules given that a tab was just navigated on the | |
52 // original context. Only invoked on the OffTheRecord registry instance. | |
53 virtual void DidNavigateMainFrameOfOriginalContext( | |
Mike Wittman
2015/06/09 02:37:35
I coalesced this back into DidNavigateMainFrame si
| |
54 content::WebContents* tab, | |
55 const content::LoadCommittedDetails& details, | |
56 const content::FrameNavigateParams& params) = 0; | |
57 | |
58 protected: | 55 protected: |
59 ~ContentRulesRegistry() override {} | 56 ~ContentRulesRegistry() override {} |
60 | 57 |
61 private: | 58 private: |
62 DISALLOW_COPY_AND_ASSIGN(ContentRulesRegistry); | 59 DISALLOW_COPY_AND_ASSIGN(ContentRulesRegistry); |
63 }; | 60 }; |
64 | 61 |
65 } // namespace extensions | 62 } // namespace extensions |
66 | 63 |
67 #endif // EXTENSIONS_BROWSER_API_DECLARATIVE_CONTENT_CONTENT_RULES_REGISTRY_H__ | 64 #endif // EXTENSIONS_BROWSER_API_DECLARATIVE_CONTENT_CONTENT_RULES_REGISTRY_H__ |
OLD | NEW |