| 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 "chrome/browser/chrome_notification_types.h" | 9 #include "chrome/browser/chrome_notification_types.h" |
| 10 #include "chrome/browser/extensions/api/declarative_content/content_constants.h" | 10 #include "chrome/browser/extensions/api/declarative_content/content_constants.h" |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 | 157 |
| 158 ChromeContentRulesRegistry::ContentRule::~ContentRule() {} | 158 ChromeContentRulesRegistry::ContentRule::~ContentRule() {} |
| 159 | 159 |
| 160 scoped_ptr<const ChromeContentRulesRegistry::ContentRule> | 160 scoped_ptr<const ChromeContentRulesRegistry::ContentRule> |
| 161 ChromeContentRulesRegistry::CreateRule( | 161 ChromeContentRulesRegistry::CreateRule( |
| 162 const Extension* extension, | 162 const Extension* extension, |
| 163 const std::map<std::string, ContentPredicateFactory*>& predicate_factories, | 163 const std::map<std::string, ContentPredicateFactory*>& predicate_factories, |
| 164 const api::events::Rule& api_rule, | 164 const api::events::Rule& api_rule, |
| 165 std::string* error) { | 165 std::string* error) { |
| 166 std::vector<scoped_ptr<const ContentCondition>> conditions; | 166 std::vector<scoped_ptr<const ContentCondition>> conditions; |
| 167 for (const linked_ptr<base::Value>& value : api_rule.conditions) { | 167 for (const scoped_ptr<base::Value>& value : api_rule.conditions) { |
| 168 conditions.push_back( | 168 conditions.push_back( |
| 169 CreateContentCondition(extension, predicate_factories, *value, error)); | 169 CreateContentCondition(extension, predicate_factories, *value, error)); |
| 170 if (!error->empty()) | 170 if (!error->empty()) |
| 171 return scoped_ptr<ContentRule>(); | 171 return scoped_ptr<ContentRule>(); |
| 172 } | 172 } |
| 173 | 173 |
| 174 std::vector<scoped_ptr<const ContentAction>> actions; | 174 std::vector<scoped_ptr<const ContentAction>> actions; |
| 175 for (const linked_ptr<base::Value>& value : api_rule.actions) { | 175 for (const scoped_ptr<base::Value>& value : api_rule.actions) { |
| 176 actions.push_back(ContentAction::Create(browser_context(), extension, | 176 actions.push_back(ContentAction::Create(browser_context(), extension, |
| 177 *value, error)); | 177 *value, error)); |
| 178 if (!error->empty()) | 178 if (!error->empty()) |
| 179 return scoped_ptr<ContentRule>(); | 179 return scoped_ptr<ContentRule>(); |
| 180 } | 180 } |
| 181 | 181 |
| 182 // Note: |api_rule| may contain tags, but these are ignored. | 182 // Note: |api_rule| may contain tags, but these are ignored. |
| 183 | 183 |
| 184 return make_scoped_ptr(new ContentRule(extension, std::move(conditions), | 184 return make_scoped_ptr(new ContentRule(extension, std::move(conditions), |
| 185 std::move(actions), | 185 std::move(actions), |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 size_t count = 0; | 421 size_t count = 0; |
| 422 for (const auto& web_contents_rules_pair : active_rules_) | 422 for (const auto& web_contents_rules_pair : active_rules_) |
| 423 count += web_contents_rules_pair.second.size(); | 423 count += web_contents_rules_pair.second.size(); |
| 424 return count; | 424 return count; |
| 425 } | 425 } |
| 426 | 426 |
| 427 ChromeContentRulesRegistry::~ChromeContentRulesRegistry() { | 427 ChromeContentRulesRegistry::~ChromeContentRulesRegistry() { |
| 428 } | 428 } |
| 429 | 429 |
| 430 } // namespace extensions | 430 } // namespace extensions |
| OLD | NEW |