Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(753)

Side by Side Diff: chrome/browser/extensions/api/declarative/rules_registry.h

Issue 52743002: Declarative rules should be removed on uninstalling, not unloading (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rewritten and rebased off https://codereview.chromium.org/64093010/ Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #ifndef CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_RULES_REGISTRY_H__ 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_RULES_REGISTRY_H__
6 #define CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_RULES_REGISTRY_H__ 6 #define CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_RULES_REGISTRY_H__
7 7
8 #include "chrome/browser/extensions/api/declarative/rules_registry.h" 8 #include "chrome/browser/extensions/api/declarative/rules_registry.h"
9 9
10 #include <map> 10 #include <map>
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 // 113 //
114 // The returned rules are stored in |out|. Ownership is passed to the caller. 114 // The returned rules are stored in |out|. Ownership is passed to the caller.
115 void GetRules(const std::string& extension_id, 115 void GetRules(const std::string& extension_id,
116 const std::vector<std::string>& rule_identifiers, 116 const std::vector<std::string>& rule_identifiers,
117 std::vector<linked_ptr<RulesRegistry::Rule> >* out); 117 std::vector<linked_ptr<RulesRegistry::Rule> >* out);
118 118
119 // Same as GetRules but returns all rules owned by |extension_id|. 119 // Same as GetRules but returns all rules owned by |extension_id|.
120 void GetAllRules(const std::string& extension_id, 120 void GetAllRules(const std::string& extension_id,
121 std::vector<linked_ptr<RulesRegistry::Rule> >* out); 121 std::vector<linked_ptr<RulesRegistry::Rule> >* out);
122 122
123 // Called to notify the RulesRegistry that an extension has been unloaded 123 // Called to notify the RulesRegistry that the extension availability has
124 // and all rules of this extension need to be removed. 124 // changed, so that the registry can update which rules are active.
125 void OnExtensionUnloaded(const std::string& extension_id); 125 void OnExtensionUnloaded(const std::string& extension_id);
126 void OnExtensionUninstalled(const std::string& extension_id);
127 void OnExtensionLoaded(const std::string& extension_id);
126 128
127 // Returns the number of entries in used_rule_identifiers_ for leak detection. 129 // Returns the number of entries in used_rule_identifiers_ for leak detection.
128 // Every ExtensionId counts as one entry, even if it contains no rules. 130 // Every ExtensionId counts as one entry, even if it contains no rules.
129 size_t GetNumberOfUsedRuleIdentifiersForTesting() const; 131 size_t GetNumberOfUsedRuleIdentifiersForTesting() const;
130 132
131 // Returns the RulesCacheDelegate. This is used for testing. 133 // Returns the RulesCacheDelegate. This is used for testing.
132 RulesCacheDelegate* rules_cache_delegate_for_testing() const { 134 RulesCacheDelegate* rules_cache_delegate_for_testing() const {
133 return cache_delegate_.get(); 135 return cache_delegate_.get();
134 } 136 }
135 137
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 // NOT_SCHEDULED_FOR_PROCESSING. 208 // NOT_SCHEDULED_FOR_PROCESSING.
207 void MaybeProcessChangedRules(const std::string& extension_id); 209 void MaybeProcessChangedRules(const std::string& extension_id);
208 210
209 void MarkReady(base::Time storage_init_time); 211 void MarkReady(base::Time storage_init_time);
210 212
211 // Deserialize the rules from the given Value object and add them to the 213 // Deserialize the rules from the given Value object and add them to the
212 // RulesRegistry. 214 // RulesRegistry.
213 void DeserializeAndAddRules(const std::string& extension_id, 215 void DeserializeAndAddRules(const std::string& extension_id,
214 scoped_ptr<base::Value> rules); 216 scoped_ptr<base::Value> rules);
215 217
218 // These functions are responsible for removing rules from RulesRegistry
219 // storage (as opposed to the storage of the inheriting registries, handled by
Jeffrey Yasskin 2013/11/20 05:55:28 This isn't clear. Maybe "These functions remove ru
vabr (Chromium) 2013/11/20 17:46:07 I was also unhappy about the naming. However, fol
220 // Remove(All)RulesImpl).
221 void CommitRemoveRules(const std::string& extension_id,
222 const std::vector<std::string>& rule_identifiers);
223 void CommitRemoveAllRules(const std::string& extension_id);
224
216 // The profile to which this rules registry belongs. 225 // The profile to which this rules registry belongs.
217 Profile* profile_; 226 Profile* profile_;
218 227
219 // The ID of the thread on which the rules registry lives. 228 // The ID of the thread on which the rules registry lives.
220 const content::BrowserThread::ID owner_thread_; 229 const content::BrowserThread::ID owner_thread_;
221 230
222 // The name of the event with which rules are registered. 231 // The name of the event with which rules are registered.
223 const std::string event_name_; 232 const std::string event_name_;
224 233
225 // The key that identifies the context in which these rules apply. 234 // The key that identifies the context in which these rules apply.
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 typedef std::map<ExtensionId, std::set<RuleIdentifier> > RuleIdentifiersMap; 286 typedef std::map<ExtensionId, std::set<RuleIdentifier> > RuleIdentifiersMap;
278 RuleIdentifiersMap used_rule_identifiers_; 287 RuleIdentifiersMap used_rule_identifiers_;
279 int last_generated_rule_identifier_id_; 288 int last_generated_rule_identifier_id_;
280 289
281 DISALLOW_COPY_AND_ASSIGN(RulesRegistry); 290 DISALLOW_COPY_AND_ASSIGN(RulesRegistry);
282 }; 291 };
283 292
284 } // namespace extensions 293 } // namespace extensions
285 294
286 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_RULES_REGISTRY_H__ 295 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_RULES_REGISTRY_H__
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698