OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_DECLARATIVE_CONTENT_CS
S_CONDITION_TRACKER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_CONTENT_DECLARATIVE_CONTENT_CS
S_CONDITION_TRACKER_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_CONTENT_DECLARATIVE_CONTENT_CS
S_CONDITION_TRACKER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_CONTENT_DECLARATIVE_CONTENT_CS
S_CONDITION_TRACKER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
| 9 #include <memory> |
9 #include <set> | 10 #include <set> |
10 #include <string> | 11 #include <string> |
11 #include <vector> | 12 #include <vector> |
12 | 13 |
13 #include "base/callback.h" | 14 #include "base/callback.h" |
14 #include "base/containers/hash_tables.h" | 15 #include "base/containers/hash_tables.h" |
15 #include "base/macros.h" | 16 #include "base/macros.h" |
16 #include "base/memory/linked_ptr.h" | 17 #include "base/memory/linked_ptr.h" |
17 #include "base/memory/scoped_ptr.h" | |
18 #include "chrome/browser/extensions/api/declarative_content/content_predicate_ev
aluator.h" | 18 #include "chrome/browser/extensions/api/declarative_content/content_predicate_ev
aluator.h" |
19 #include "content/public/browser/notification_observer.h" | 19 #include "content/public/browser/notification_observer.h" |
20 #include "content/public/browser/notification_registrar.h" | 20 #include "content/public/browser/notification_registrar.h" |
21 #include "content/public/browser/web_contents_observer.h" | 21 #include "content/public/browser/web_contents_observer.h" |
22 | 22 |
23 namespace base { | 23 namespace base { |
24 class Value; | 24 class Value; |
25 } | 25 } |
26 | 26 |
27 namespace content { | 27 namespace content { |
28 struct FrameNavigateParams; | 28 struct FrameNavigateParams; |
29 struct LoadCommittedDetails; | 29 struct LoadCommittedDetails; |
30 class RenderProcessHost; | 30 class RenderProcessHost; |
31 class WebContents; | 31 class WebContents; |
32 } | 32 } |
33 | 33 |
34 namespace extensions { | 34 namespace extensions { |
35 | 35 |
36 class Extension; | 36 class Extension; |
37 | 37 |
38 // Tests whether all the specified CSS selectors match on the page. | 38 // Tests whether all the specified CSS selectors match on the page. |
39 class DeclarativeContentCssPredicate : public ContentPredicate { | 39 class DeclarativeContentCssPredicate : public ContentPredicate { |
40 public: | 40 public: |
41 ~DeclarativeContentCssPredicate() override; | 41 ~DeclarativeContentCssPredicate() override; |
42 | 42 |
43 const std::vector<std::string>& css_selectors() const { | 43 const std::vector<std::string>& css_selectors() const { |
44 return css_selectors_; | 44 return css_selectors_; |
45 } | 45 } |
46 | 46 |
47 static scoped_ptr<DeclarativeContentCssPredicate> Create( | 47 static std::unique_ptr<DeclarativeContentCssPredicate> Create( |
48 ContentPredicateEvaluator* evaluator, | 48 ContentPredicateEvaluator* evaluator, |
49 const base::Value& value, | 49 const base::Value& value, |
50 std::string* error); | 50 std::string* error); |
51 | 51 |
52 // ContentPredicate: | 52 // ContentPredicate: |
53 ContentPredicateEvaluator* GetEvaluator() const override; | 53 ContentPredicateEvaluator* GetEvaluator() const override; |
54 | 54 |
55 private: | 55 private: |
56 DeclarativeContentCssPredicate(ContentPredicateEvaluator* evaluator, | 56 DeclarativeContentCssPredicate(ContentPredicateEvaluator* evaluator, |
57 const std::vector<std::string>& css_selectors); | 57 const std::vector<std::string>& css_selectors); |
58 | 58 |
59 // Weak. | 59 // Weak. |
60 ContentPredicateEvaluator* const evaluator_; | 60 ContentPredicateEvaluator* const evaluator_; |
61 std::vector<std::string> css_selectors_; | 61 std::vector<std::string> css_selectors_; |
62 | 62 |
63 DISALLOW_COPY_AND_ASSIGN(DeclarativeContentCssPredicate); | 63 DISALLOW_COPY_AND_ASSIGN(DeclarativeContentCssPredicate); |
64 }; | 64 }; |
65 | 65 |
66 // Supports watching of CSS selectors to across tab contents in a browser | 66 // Supports watching of CSS selectors to across tab contents in a browser |
67 // context, and querying for the matching CSS selectors for a context. | 67 // context, and querying for the matching CSS selectors for a context. |
68 class DeclarativeContentCssConditionTracker | 68 class DeclarativeContentCssConditionTracker |
69 : public ContentPredicateEvaluator, | 69 : public ContentPredicateEvaluator, |
70 public content::NotificationObserver { | 70 public content::NotificationObserver { |
71 public: | 71 public: |
72 explicit DeclarativeContentCssConditionTracker(Delegate* delegate); | 72 explicit DeclarativeContentCssConditionTracker(Delegate* delegate); |
73 ~DeclarativeContentCssConditionTracker() override; | 73 ~DeclarativeContentCssConditionTracker() override; |
74 | 74 |
75 // ContentPredicateEvaluator: | 75 // ContentPredicateEvaluator: |
76 std::string GetPredicateApiAttributeName() const override; | 76 std::string GetPredicateApiAttributeName() const override; |
77 scoped_ptr<const ContentPredicate> CreatePredicate( | 77 std::unique_ptr<const ContentPredicate> CreatePredicate( |
78 const Extension* extension, | 78 const Extension* extension, |
79 const base::Value& value, | 79 const base::Value& value, |
80 std::string* error) override; | 80 std::string* error) override; |
81 void TrackPredicates( | 81 void TrackPredicates( |
82 const std::map<const void*, std::vector<const ContentPredicate*>>& | 82 const std::map<const void*, std::vector<const ContentPredicate*>>& |
83 predicates) override; | 83 predicates) override; |
84 void StopTrackingPredicates( | 84 void StopTrackingPredicates( |
85 const std::vector<const void*>& predicate_groups) override; | 85 const std::vector<const void*>& predicate_groups) override; |
86 void TrackForWebContents(content::WebContents* contents) override; | 86 void TrackForWebContents(content::WebContents* contents) override; |
87 void OnWebContentsNavigation( | 87 void OnWebContentsNavigation( |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 | 167 |
168 // Manages our notification registrations. | 168 // Manages our notification registrations. |
169 content::NotificationRegistrar registrar_; | 169 content::NotificationRegistrar registrar_; |
170 | 170 |
171 DISALLOW_COPY_AND_ASSIGN(DeclarativeContentCssConditionTracker); | 171 DISALLOW_COPY_AND_ASSIGN(DeclarativeContentCssConditionTracker); |
172 }; | 172 }; |
173 | 173 |
174 } // namespace extensions | 174 } // namespace extensions |
175 | 175 |
176 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_CONTENT_DECLARATIVE_CONTENT
_CSS_CONDITION_TRACKER_H_ | 176 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_CONTENT_DECLARATIVE_CONTENT
_CSS_CONDITION_TRACKER_H_ |
OLD | NEW |