| 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" |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 std::set<ContentRule*> matching_rules = GetMatches(renderer_data); | 73 std::set<ContentRule*> matching_rules = GetMatches(renderer_data); |
| 74 if (matching_rules.empty() && !ContainsKey(active_rules_, tab_id)) | 74 if (matching_rules.empty() && !ContainsKey(active_rules_, tab_id)) |
| 75 return; | 75 return; |
| 76 | 76 |
| 77 std::set<ContentRule*>& prev_matching_rules = active_rules_[tab_id]; | 77 std::set<ContentRule*>& prev_matching_rules = active_rules_[tab_id]; |
| 78 ContentAction::ApplyInfo apply_info = { | 78 ContentAction::ApplyInfo apply_info = { |
| 79 profile(), contents | 79 profile(), contents |
| 80 }; | 80 }; |
| 81 for (std::set<ContentRule*>::const_iterator it = matching_rules.begin(); | 81 for (std::set<ContentRule*>::const_iterator it = matching_rules.begin(); |
| 82 it != matching_rules.end(); ++it) { | 82 it != matching_rules.end(); ++it) { |
| 83 if (!ContainsKey(prev_matching_rules, *it)) | 83 if (!ContainsKey(prev_matching_rules, *it)) { |
| 84 (*it)->actions().Apply((*it)->extension_id(), base::Time(), &apply_info); | 84 (*it)->actions().Apply((*it)->extension_id(), base::Time(), &apply_info); |
| 85 } else { |
| 86 (*it)->actions().Reapply( |
| 87 (*it)->extension_id(), base::Time(), &apply_info); |
| 88 } |
| 85 } | 89 } |
| 86 for (std::set<ContentRule*>::const_iterator it = prev_matching_rules.begin(); | 90 for (std::set<ContentRule*>::const_iterator it = prev_matching_rules.begin(); |
| 87 it != prev_matching_rules.end(); ++it) { | 91 it != prev_matching_rules.end(); ++it) { |
| 88 if (!ContainsKey(matching_rules, *it)) | 92 if (!ContainsKey(matching_rules, *it)) |
| 89 (*it)->actions().Revert((*it)->extension_id(), base::Time(), &apply_info); | 93 (*it)->actions().Revert((*it)->extension_id(), base::Time(), &apply_info); |
| 90 } | 94 } |
| 91 | 95 |
| 92 if (matching_rules.empty()) | 96 if (matching_rules.empty()) |
| 93 active_rules_.erase(tab_id); | 97 active_rules_.erase(tab_id); |
| 94 else | 98 else |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 | 316 |
| 313 base::Time ContentRulesRegistry::GetExtensionInstallationTime( | 317 base::Time ContentRulesRegistry::GetExtensionInstallationTime( |
| 314 const std::string& extension_id) const { | 318 const std::string& extension_id) const { |
| 315 if (!extension_info_map_.get()) // May be NULL during testing. | 319 if (!extension_info_map_.get()) // May be NULL during testing. |
| 316 return base::Time(); | 320 return base::Time(); |
| 317 | 321 |
| 318 return extension_info_map_->GetInstallTime(extension_id); | 322 return extension_info_map_->GetInstallTime(extension_id); |
| 319 } | 323 } |
| 320 | 324 |
| 321 } // namespace extensions | 325 } // namespace extensions |
| OLD | NEW |