Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Side by Side Diff: chrome/browser/extensions/api/declarative_content/declarative_content_css_condition_tracker.h

Issue 2668003004: Convert extensions::TabHelper to use the new navigation callbacks. (Closed)
Patch Set: update Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <memory>
10 #include <set> 10 #include <set>
11 #include <string> 11 #include <string>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/callback.h" 14 #include "base/callback.h"
15 #include "base/containers/hash_tables.h" 15 #include "base/containers/hash_tables.h"
16 #include "base/macros.h" 16 #include "base/macros.h"
17 #include "base/memory/linked_ptr.h" 17 #include "base/memory/linked_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 {
28 struct FrameNavigateParams;
29 struct LoadCommittedDetails;
30 class RenderProcessHost;
31 class WebContents;
32 }
33
34 namespace extensions { 27 namespace extensions {
35 28
36 class Extension; 29 class Extension;
37 30
38 // Tests whether all the specified CSS selectors match on the page. 31 // Tests whether all the specified CSS selectors match on the page.
39 class DeclarativeContentCssPredicate : public ContentPredicate { 32 class DeclarativeContentCssPredicate : public ContentPredicate {
40 public: 33 public:
41 ~DeclarativeContentCssPredicate() override; 34 ~DeclarativeContentCssPredicate() override;
42 35
43 const std::vector<std::string>& css_selectors() const { 36 const std::vector<std::string>& css_selectors() const {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 const base::Value& value, 72 const base::Value& value,
80 std::string* error) override; 73 std::string* error) override;
81 void TrackPredicates( 74 void TrackPredicates(
82 const std::map<const void*, std::vector<const ContentPredicate*>>& 75 const std::map<const void*, std::vector<const ContentPredicate*>>&
83 predicates) override; 76 predicates) override;
84 void StopTrackingPredicates( 77 void StopTrackingPredicates(
85 const std::vector<const void*>& predicate_groups) override; 78 const std::vector<const void*>& predicate_groups) override;
86 void TrackForWebContents(content::WebContents* contents) override; 79 void TrackForWebContents(content::WebContents* contents) override;
87 void OnWebContentsNavigation( 80 void OnWebContentsNavigation(
88 content::WebContents* contents, 81 content::WebContents* contents,
89 const content::LoadCommittedDetails& details, 82 content::NavigationHandle* navigation_handle) override;
90 const content::FrameNavigateParams& params) override;
91 bool EvaluatePredicate(const ContentPredicate* predicate, 83 bool EvaluatePredicate(const ContentPredicate* predicate,
92 content::WebContents* tab) const override; 84 content::WebContents* tab) const override;
93 85
94 private: 86 private:
95 // Monitors CSS selector matching state on one WebContents. 87 // Monitors CSS selector matching state on one WebContents.
96 class PerWebContentsTracker : public content::WebContentsObserver { 88 class PerWebContentsTracker : public content::WebContentsObserver {
97 public: 89 public:
98 using RequestEvaluationCallback = 90 using RequestEvaluationCallback =
99 base::Callback<void(content::WebContents*)>; 91 base::Callback<void(content::WebContents*)>;
100 using WebContentsDestroyedCallback = 92 using WebContentsDestroyedCallback =
101 base::Callback<void(content::WebContents*)>; 93 base::Callback<void(content::WebContents*)>;
102 94
103 PerWebContentsTracker( 95 PerWebContentsTracker(
104 content::WebContents* contents, 96 content::WebContents* contents,
105 const RequestEvaluationCallback& request_evaluation, 97 const RequestEvaluationCallback& request_evaluation,
106 const WebContentsDestroyedCallback& web_contents_destroyed); 98 const WebContentsDestroyedCallback& web_contents_destroyed);
107 ~PerWebContentsTracker() override; 99 ~PerWebContentsTracker() override;
108 100
109 void OnWebContentsNavigation(const content::LoadCommittedDetails& details, 101 void OnWebContentsNavigation(content::NavigationHandle* navigation_handle);
110 const content::FrameNavigateParams& params);
111 102
112 const base::hash_set<std::string>& matching_css_selectors() const { 103 const base::hash_set<std::string>& matching_css_selectors() const {
113 return matching_css_selectors_; 104 return matching_css_selectors_;
114 } 105 }
115 106
116 private: 107 private:
117 // content::WebContentsObserver overrides. 108 // content::WebContentsObserver overrides.
118 bool OnMessageReceived(const IPC::Message& message) override; 109 bool OnMessageReceived(const IPC::Message& message) override;
119 void WebContentsDestroyed() override; 110 void WebContentsDestroyed() override;
120 111
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 158
168 // Manages our notification registrations. 159 // Manages our notification registrations.
169 content::NotificationRegistrar registrar_; 160 content::NotificationRegistrar registrar_;
170 161
171 DISALLOW_COPY_AND_ASSIGN(DeclarativeContentCssConditionTracker); 162 DISALLOW_COPY_AND_ASSIGN(DeclarativeContentCssConditionTracker);
172 }; 163 };
173 164
174 } // namespace extensions 165 } // namespace extensions
175 166
176 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_CONTENT_DECLARATIVE_CONTENT _CSS_CONDITION_TRACKER_H_ 167 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_CONTENT_DECLARATIVE_CONTENT _CSS_CONDITION_TRACKER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698