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..787db748e1dcca1ebd4c2b1770f2db621bd779ef 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,56 @@ 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>; |
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); |
- // A map of DeclarativeUserScriptMasters for ids; each master is lazily |
- // initialized. |
+ // Given an input id, generate and return a ConsumerID. |
+ ConsumerID* GenerateConsumerID(const std::string& id); |
Fady Samuel
2015/01/07 19:19:40
Return scoped_ptr<ConsumerID> to avoid accidentall
Xi Han
2015/01/07 20:28:42
Good point, but I realize this function hasn't bee
|
+ |
+ // Create a DeclarativeUserScriptMaster object. |
+ DeclarativeUserScriptMaster* CreateDeclarativeUserScriptMaster( |
+ const ConsumerID& consumer_id); |
+ |
+ // 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_ |