| 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 #include "chrome/browser/extensions/api/declarative_content/chrome_content_rules
_registry.h" | 5 #include "chrome/browser/extensions/api/declarative_content/chrome_content_rules
_registry.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 // We rely on active_rules_ to have a key-value pair for |contents| to know | 125 // We rely on active_rules_ to have a key-value pair for |contents| to know |
| 126 // which WebContents we are working with. | 126 // which WebContents we are working with. |
| 127 active_rules_[contents] = std::set<const ContentRule*>(); | 127 active_rules_[contents] = std::set<const ContentRule*>(); |
| 128 | 128 |
| 129 EvaluationScope evaluation_scope(this); | 129 EvaluationScope evaluation_scope(this); |
| 130 for (const std::unique_ptr<ContentPredicateEvaluator>& evaluator : | 130 for (const std::unique_ptr<ContentPredicateEvaluator>& evaluator : |
| 131 evaluators_) | 131 evaluators_) |
| 132 evaluator->TrackForWebContents(contents); | 132 evaluator->TrackForWebContents(contents); |
| 133 } | 133 } |
| 134 | 134 |
| 135 void ChromeContentRulesRegistry::DidNavigateMainFrame( | 135 void ChromeContentRulesRegistry::DidFinishNavigation( |
| 136 content::WebContents* contents, | 136 content::WebContents* contents, |
| 137 const content::LoadCommittedDetails& details, | 137 content::NavigationHandle* navigation_handle) { |
| 138 const content::FrameNavigateParams& params) { | |
| 139 if (base::ContainsKey(active_rules_, contents)) { | 138 if (base::ContainsKey(active_rules_, contents)) { |
| 140 EvaluationScope evaluation_scope(this); | 139 EvaluationScope evaluation_scope(this); |
| 141 for (const std::unique_ptr<ContentPredicateEvaluator>& evaluator : | 140 for (const std::unique_ptr<ContentPredicateEvaluator>& evaluator : |
| 142 evaluators_) | 141 evaluators_) |
| 143 evaluator->OnWebContentsNavigation(contents, details, params); | 142 evaluator->OnWebContentsNavigation(contents, navigation_handle); |
| 144 } | 143 } |
| 145 } | 144 } |
| 146 | 145 |
| 147 ChromeContentRulesRegistry::ContentRule::ContentRule( | 146 ChromeContentRulesRegistry::ContentRule::ContentRule( |
| 148 const Extension* extension, | 147 const Extension* extension, |
| 149 std::vector<std::unique_ptr<const ContentCondition>> conditions, | 148 std::vector<std::unique_ptr<const ContentCondition>> conditions, |
| 150 std::vector<std::unique_ptr<const ContentAction>> actions, | 149 std::vector<std::unique_ptr<const ContentAction>> actions, |
| 151 int priority) | 150 int priority) |
| 152 : extension(extension), | 151 : extension(extension), |
| 153 conditions(std::move(conditions)), | 152 conditions(std::move(conditions)), |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 size_t count = 0; | 421 size_t count = 0; |
| 423 for (const auto& web_contents_rules_pair : active_rules_) | 422 for (const auto& web_contents_rules_pair : active_rules_) |
| 424 count += web_contents_rules_pair.second.size(); | 423 count += web_contents_rules_pair.second.size(); |
| 425 return count; | 424 return count; |
| 426 } | 425 } |
| 427 | 426 |
| 428 ChromeContentRulesRegistry::~ChromeContentRulesRegistry() { | 427 ChromeContentRulesRegistry::~ChromeContentRulesRegistry() { |
| 429 } | 428 } |
| 430 | 429 |
| 431 } // namespace extensions | 430 } // namespace extensions |
| OLD | NEW |