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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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((*it)->extension_id(), |
| 87 base::Time(), |
| 88 &apply_info); |
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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 std::string error; | 153 std::string error; |
150 RulesMap new_content_rules; | 154 RulesMap new_content_rules; |
151 | 155 |
152 for (std::vector<linked_ptr<RulesRegistry::Rule> >::const_iterator rule = | 156 for (std::vector<linked_ptr<RulesRegistry::Rule> >::const_iterator rule = |
153 rules.begin(); rule != rules.end(); ++rule) { | 157 rules.begin(); rule != rules.end(); ++rule) { |
154 ContentRule::GlobalRuleId rule_id(extension_id, *(*rule)->id); | 158 ContentRule::GlobalRuleId rule_id(extension_id, *(*rule)->id); |
155 DCHECK(content_rules_.find(rule_id) == content_rules_.end()); | 159 DCHECK(content_rules_.find(rule_id) == content_rules_.end()); |
156 | 160 |
157 scoped_ptr<ContentRule> content_rule( | 161 scoped_ptr<ContentRule> content_rule( |
158 ContentRule::Create(url_matcher_.condition_factory(), | 162 ContentRule::Create(url_matcher_.condition_factory(), |
| 163 profile(), |
159 extension, | 164 extension, |
160 extension_installation_time, | 165 extension_installation_time, |
161 *rule, | 166 *rule, |
162 ContentRule::ConsistencyChecker(), | 167 ContentRule::ConsistencyChecker(), |
163 &error)); | 168 &error)); |
164 if (!error.empty()) { | 169 if (!error.empty()) { |
165 // Clean up temporary condition sets created during rule creation. | 170 // Clean up temporary condition sets created during rule creation. |
166 url_matcher_.ClearUnusedConditionSets(); | 171 url_matcher_.ClearUnusedConditionSets(); |
167 return error; | 172 return error; |
168 } | 173 } |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 | 317 |
313 base::Time ContentRulesRegistry::GetExtensionInstallationTime( | 318 base::Time ContentRulesRegistry::GetExtensionInstallationTime( |
314 const std::string& extension_id) const { | 319 const std::string& extension_id) const { |
315 if (!extension_info_map_.get()) // May be NULL during testing. | 320 if (!extension_info_map_.get()) // May be NULL during testing. |
316 return base::Time(); | 321 return base::Time(); |
317 | 322 |
318 return extension_info_map_->GetInstallTime(extension_id); | 323 return extension_info_map_->GetInstallTime(extension_id); |
319 } | 324 } |
320 | 325 |
321 } // namespace extensions | 326 } // namespace extensions |
OLD | NEW |