| 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..161a7db20119c7406cd79b6ac4222642dcb5b354 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,21 +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 {
|
| + 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);
|
| +
|
| + // 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);
|
| };
|
|
|
|
|