| 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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 std::vector<std::unique_ptr<const ContentAction>> actions; | 173 std::vector<std::unique_ptr<const ContentAction>> actions; |
| 174 for (const std::unique_ptr<base::Value>& value : api_rule.actions) { | 174 for (const std::unique_ptr<base::Value>& value : api_rule.actions) { |
| 175 actions.push_back(ContentAction::Create(browser_context(), extension, | 175 actions.push_back(ContentAction::Create(browser_context(), extension, |
| 176 *value, error)); | 176 *value, error)); |
| 177 if (!error->empty()) | 177 if (!error->empty()) |
| 178 return std::unique_ptr<ContentRule>(); | 178 return std::unique_ptr<ContentRule>(); |
| 179 } | 179 } |
| 180 | 180 |
| 181 // Note: |api_rule| may contain tags, but these are ignored. | 181 // Note: |api_rule| may contain tags, but these are ignored. |
| 182 | 182 |
| 183 return base::WrapUnique(new ContentRule(extension, std::move(conditions), | 183 return base::MakeUnique<ContentRule>(extension, std::move(conditions), |
| 184 std::move(actions), | 184 std::move(actions), *api_rule.priority); |
| 185 *api_rule.priority)); | |
| 186 } | 185 } |
| 187 | 186 |
| 188 bool ChromeContentRulesRegistry::ManagingRulesForBrowserContext( | 187 bool ChromeContentRulesRegistry::ManagingRulesForBrowserContext( |
| 189 content::BrowserContext* context) { | 188 content::BrowserContext* context) { |
| 190 // Manage both the normal context and incognito contexts associated with it. | 189 // Manage both the normal context and incognito contexts associated with it. |
| 191 return Profile::FromBrowserContext(context)->GetOriginalProfile() == | 190 return Profile::FromBrowserContext(context)->GetOriginalProfile() == |
| 192 Profile::FromBrowserContext(browser_context()); | 191 Profile::FromBrowserContext(browser_context()); |
| 193 } | 192 } |
| 194 | 193 |
| 195 // static | 194 // static |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 423 size_t count = 0; | 422 size_t count = 0; |
| 424 for (const auto& web_contents_rules_pair : active_rules_) | 423 for (const auto& web_contents_rules_pair : active_rules_) |
| 425 count += web_contents_rules_pair.second.size(); | 424 count += web_contents_rules_pair.second.size(); |
| 426 return count; | 425 return count; |
| 427 } | 426 } |
| 428 | 427 |
| 429 ChromeContentRulesRegistry::~ChromeContentRulesRegistry() { | 428 ChromeContentRulesRegistry::~ChromeContentRulesRegistry() { |
| 430 } | 429 } |
| 431 | 430 |
| 432 } // namespace extensions | 431 } // namespace extensions |
| OLD | NEW |