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 #include "chrome/browser/extensions/api/declarative_content/declarative_content_
css_condition_tracker.h" | 5 #include "chrome/browser/extensions/api/declarative_content/declarative_content_
css_condition_tracker.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 DeletePerWebContentsTracker, | 227 DeletePerWebContentsTracker, |
228 base::Unretained(this)))); | 228 base::Unretained(this)))); |
229 // Note: the condition is always false until we receive OnWatchedPageChange, | 229 // Note: the condition is always false until we receive OnWatchedPageChange, |
230 // so there's no need to evaluate it here. | 230 // so there's no need to evaluate it here. |
231 } | 231 } |
232 | 232 |
233 void DeclarativeContentCssConditionTracker::OnWebContentsNavigation( | 233 void DeclarativeContentCssConditionTracker::OnWebContentsNavigation( |
234 content::WebContents* contents, | 234 content::WebContents* contents, |
235 const content::LoadCommittedDetails& details, | 235 const content::LoadCommittedDetails& details, |
236 const content::FrameNavigateParams& params) { | 236 const content::FrameNavigateParams& params) { |
237 DCHECK(ContainsKey(per_web_contents_tracker_, contents)); | 237 DCHECK(base::ContainsKey(per_web_contents_tracker_, contents)); |
238 per_web_contents_tracker_[contents]->OnWebContentsNavigation(details, params); | 238 per_web_contents_tracker_[contents]->OnWebContentsNavigation(details, params); |
239 } | 239 } |
240 | 240 |
241 bool DeclarativeContentCssConditionTracker::EvaluatePredicate( | 241 bool DeclarativeContentCssConditionTracker::EvaluatePredicate( |
242 const ContentPredicate* predicate, | 242 const ContentPredicate* predicate, |
243 content::WebContents* tab) const { | 243 content::WebContents* tab) const { |
244 DCHECK_EQ(this, predicate->GetEvaluator()); | 244 DCHECK_EQ(this, predicate->GetEvaluator()); |
245 const DeclarativeContentCssPredicate* typed_predicate = | 245 const DeclarativeContentCssPredicate* typed_predicate = |
246 static_cast<const DeclarativeContentCssPredicate*>(predicate); | 246 static_cast<const DeclarativeContentCssPredicate*>(predicate); |
247 auto loc = per_web_contents_tracker_.find(tab); | 247 auto loc = per_web_contents_tracker_.find(tab); |
248 DCHECK(loc != per_web_contents_tracker_.end()); | 248 DCHECK(loc != per_web_contents_tracker_.end()); |
249 const base::hash_set<std::string>& matching_css_selectors = | 249 const base::hash_set<std::string>& matching_css_selectors = |
250 loc->second->matching_css_selectors(); | 250 loc->second->matching_css_selectors(); |
251 for (const std::string& predicate_css_selector : | 251 for (const std::string& predicate_css_selector : |
252 typed_predicate->css_selectors()) { | 252 typed_predicate->css_selectors()) { |
253 if (!ContainsKey(matching_css_selectors, predicate_css_selector)) | 253 if (!base::ContainsKey(matching_css_selectors, predicate_css_selector)) |
254 return false; | 254 return false; |
255 } | 255 } |
256 | 256 |
257 return true; | 257 return true; |
258 } | 258 } |
259 | 259 |
260 void DeclarativeContentCssConditionTracker::Observe( | 260 void DeclarativeContentCssConditionTracker::Observe( |
261 int type, | 261 int type, |
262 const content::NotificationSource& source, | 262 const content::NotificationSource& source, |
263 const content::NotificationDetails& details) { | 263 const content::NotificationDetails& details) { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 content::RenderProcessHost* process, | 297 content::RenderProcessHost* process, |
298 std::vector<std::string> watched_css_selectors) { | 298 std::vector<std::string> watched_css_selectors) { |
299 if (delegate_->ShouldManageConditionsForBrowserContext( | 299 if (delegate_->ShouldManageConditionsForBrowserContext( |
300 process->GetBrowserContext())) { | 300 process->GetBrowserContext())) { |
301 process->Send(new ExtensionMsg_WatchPages(watched_css_selectors)); | 301 process->Send(new ExtensionMsg_WatchPages(watched_css_selectors)); |
302 } | 302 } |
303 } | 303 } |
304 | 304 |
305 void DeclarativeContentCssConditionTracker::DeletePerWebContentsTracker( | 305 void DeclarativeContentCssConditionTracker::DeletePerWebContentsTracker( |
306 content::WebContents* contents) { | 306 content::WebContents* contents) { |
307 DCHECK(ContainsKey(per_web_contents_tracker_, contents)); | 307 DCHECK(base::ContainsKey(per_web_contents_tracker_, contents)); |
308 per_web_contents_tracker_.erase(contents); | 308 per_web_contents_tracker_.erase(contents); |
309 } | 309 } |
310 | 310 |
311 } // namespace extensions | 311 } // namespace extensions |
OLD | NEW |