Chromium Code Reviews| Index: chrome/browser/extensions/declarative_user_script_manager.h |
| diff --git a/chrome/browser/extensions/declarative_user_script_manager.h b/chrome/browser/extensions/declarative_user_script_manager.h |
| index ba50ce2014ab063d19ebe888a507b05424561e56..23a05caf06d154d00562e1b6ee6f9f79e81d0db2 100644 |
| --- a/chrome/browser/extensions/declarative_user_script_manager.h |
| +++ b/chrome/browser/extensions/declarative_user_script_manager.h |
| @@ -9,6 +9,7 @@ |
| #include "base/macros.h" |
| #include "base/memory/linked_ptr.h" |
| +#include "extensions/common/consumer.h" |
| class Profile; |
| @@ -21,24 +22,53 @@ class DeclarativeUserScriptManager { |
| explicit DeclarativeUserScriptManager(Profile* profile); |
| ~DeclarativeUserScriptManager(); |
| - // Get the user script master for declarative scripts; if one does not exist, |
| - // a new object will be created. |
| + // Get the user script master for declarative scripts by the given id; |
| + // if one does not exist, a new object will be created. |
| DeclarativeUserScriptMaster* GetDeclarativeUserScriptMasterByID( |
| const std::string& id); |
| private: |
| + // TODO(hanxi): add RulesRegistryID to the RulesRegistryKey. |
| + struct RulesRegistryKey { |
| + explicit RulesRegistryKey(const std::string& host_id) : host_id(host_id) {} |
| + bool operator<(const RulesRegistryKey& key) const { |
| + return host_id.compare(key.host_id) < 0; |
| + } |
| + |
| + std::string host_id; |
| + }; |
| + |
| + using RulesRegistryKeyToIDMap = std::map<RulesRegistryKey, ConsumerID>; |
|
Fady Samuel
2015/01/08 16:12:59
Make this std::map<RulesRegistry, linked_ptr<Consu
Xi Han
2015/01/08 20:54:11
Done. Also move the keys conversion part to Consum
|
| using UserScriptMasterMap = |
| - std::map<std::string, linked_ptr<DeclarativeUserScriptMaster>>; |
| + std::map<ConsumerID, linked_ptr<DeclarativeUserScriptMaster>>; |
| + |
| + // Get next available instance ID. |
| + int GetNextID(); |
| + |
| + // Get the user script master for declarative scripts by the given ConsumerID. |
| + DeclarativeUserScriptMaster* GetDeclarativeUserScriptMasterByID( |
| + const ConsumerID& id); |
| + |
| + // Create a DeclarativeUserScriptMaster object. |
| + DeclarativeUserScriptMaster* CreateDeclarativeUserScriptMaster( |
| + const ConsumerID& consumer_id); |
| - // A map of DeclarativeUserScriptMasters for ids; each master is lazily |
| - // initialized. |
| + // A map of ConsumerIDs for the given rules registry ids. |
| + // Different types of input ids will define their own maps to store the |
| + // mappings from ids to ConsumerIDs. |
| + RulesRegistryKeyToIDMap rules_registry_key_to_id_map_; |
| + |
| + // A map of DeclarativeUserScriptMasters for ConsumerIDs; |
| + // each master is lazily initialized. |
| UserScriptMasterMap declarative_user_script_masters_; |
| Profile* profile_; |
| + int current_instance_id_; |
| + |
| DISALLOW_COPY_AND_ASSIGN(DeclarativeUserScriptManager); |
| }; |
| -} // extensions |
| +} // namespace extensions |
| #endif // CHROME_BROWSER_EXTENSIONS_DECLARATIVE_USER_SCRIPT_MANAGER_H_ |