| 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/content_rules_regist
ry.h" | 5 #include "chrome/browser/extensions/api/declarative_content/content_rules_regist
ry.h" |
| 6 | 6 |
| 7 #include "chrome/browser/chrome_notification_types.h" | 7 #include "chrome/browser/chrome_notification_types.h" |
| 8 #include "chrome/browser/extensions/api/declarative_content/content_action.h" | 8 #include "chrome/browser/extensions/api/declarative_content/content_action.h" |
| 9 #include "chrome/browser/extensions/api/declarative_content/content_condition.h" | 9 #include "chrome/browser/extensions/api/declarative_content/content_condition.h" |
| 10 #include "chrome/browser/extensions/api/declarative_content/content_constants.h" | 10 #include "chrome/browser/extensions/api/declarative_content/content_constants.h" |
| 11 #include "chrome/browser/extensions/extension_service.h" | |
| 12 #include "chrome/browser/extensions/extension_tab_util.h" | 11 #include "chrome/browser/extensions/extension_tab_util.h" |
| 13 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
| 14 #include "content/public/browser/navigation_details.h" | 13 #include "content/public/browser/navigation_details.h" |
| 15 #include "content/public/browser/notification_service.h" | 14 #include "content/public/browser/notification_service.h" |
| 16 #include "content/public/browser/notification_source.h" | 15 #include "content/public/browser/notification_source.h" |
| 17 #include "content/public/browser/render_process_host.h" | 16 #include "content/public/browser/render_process_host.h" |
| 18 #include "content/public/browser/web_contents.h" | 17 #include "content/public/browser/web_contents.h" |
| 18 #include "extensions/browser/extension_registry.h" |
| 19 #include "extensions/browser/extension_system.h" | 19 #include "extensions/browser/extension_system.h" |
| 20 #include "extensions/common/extension_messages.h" | 20 #include "extensions/common/extension_messages.h" |
| 21 | 21 |
| 22 using url_matcher::URLMatcherConditionSet; | 22 using url_matcher::URLMatcherConditionSet; |
| 23 | 23 |
| 24 namespace extensions { | 24 namespace extensions { |
| 25 | 25 |
| 26 ContentRulesRegistry::ContentRulesRegistry(Profile* profile, | 26 ContentRulesRegistry::ContentRulesRegistry(Profile* profile, |
| 27 RulesCacheDelegate* cache_delegate) | 27 RulesCacheDelegate* cache_delegate) |
| 28 : RulesRegistry(profile, | 28 : RulesRegistry(profile, |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 ContentRule* rule = rule_iter->second; | 131 ContentRule* rule = rule_iter->second; |
| 132 if (rule->conditions().IsFulfilled(*url_match, renderer_data)) | 132 if (rule->conditions().IsFulfilled(*url_match, renderer_data)) |
| 133 result.insert(rule); | 133 result.insert(rule); |
| 134 } | 134 } |
| 135 return result; | 135 return result; |
| 136 } | 136 } |
| 137 | 137 |
| 138 std::string ContentRulesRegistry::AddRulesImpl( | 138 std::string ContentRulesRegistry::AddRulesImpl( |
| 139 const std::string& extension_id, | 139 const std::string& extension_id, |
| 140 const std::vector<linked_ptr<RulesRegistry::Rule> >& rules) { | 140 const std::vector<linked_ptr<RulesRegistry::Rule> >& rules) { |
| 141 ExtensionService* service = | 141 const Extension* extension = |
| 142 ExtensionSystem::Get(profile())->extension_service(); | 142 ExtensionRegistry::Get(profile()) |
| 143 const Extension* extension = service->GetInstalledExtension(extension_id); | 143 ->GetExtensionById(extension_id, ExtensionRegistry::EVERYTHING); |
| 144 DCHECK(extension) << "Must have extension with id " << extension_id; | 144 DCHECK(extension) << "Must have extension with id " << extension_id; |
| 145 | 145 |
| 146 base::Time extension_installation_time = | 146 base::Time extension_installation_time = |
| 147 GetExtensionInstallationTime(extension_id); | 147 GetExtensionInstallationTime(extension_id); |
| 148 | 148 |
| 149 std::string error; | 149 std::string error; |
| 150 RulesMap new_content_rules; | 150 RulesMap new_content_rules; |
| 151 | 151 |
| 152 for (std::vector<linked_ptr<RulesRegistry::Rule> >::const_iterator rule = | 152 for (std::vector<linked_ptr<RulesRegistry::Rule> >::const_iterator rule = |
| 153 rules.begin(); rule != rules.end(); ++rule) { | 153 rules.begin(); rule != rules.end(); ++rule) { |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 | 312 |
| 313 base::Time ContentRulesRegistry::GetExtensionInstallationTime( | 313 base::Time ContentRulesRegistry::GetExtensionInstallationTime( |
| 314 const std::string& extension_id) const { | 314 const std::string& extension_id) const { |
| 315 if (!extension_info_map_.get()) // May be NULL during testing. | 315 if (!extension_info_map_.get()) // May be NULL during testing. |
| 316 return base::Time(); | 316 return base::Time(); |
| 317 | 317 |
| 318 return extension_info_map_->GetInstallTime(extension_id); | 318 return extension_info_map_->GetInstallTime(extension_id); |
| 319 } | 319 } |
| 320 | 320 |
| 321 } // namespace extensions | 321 } // namespace extensions |
| OLD | NEW |