OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_DECLARATIVE_USER_SCRIPT_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_DECLARATIVE_USER_SCRIPT_MANAGER_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_DECLARATIVE_USER_SCRIPT_MANAGER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_DECLARATIVE_USER_SCRIPT_MANAGER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/memory/linked_ptr.h" | 11 #include "base/memory/linked_ptr.h" |
12 #include "extensions/common/consumer.h" | |
12 | 13 |
13 class Profile; | 14 class Profile; |
14 | 15 |
15 namespace extensions { | 16 namespace extensions { |
16 class DeclarativeUserScriptMaster; | 17 class DeclarativeUserScriptMaster; |
17 | 18 |
18 // Manages a set of DeclarativeUserScriptMaster objects for script injections. | 19 // Manages a set of DeclarativeUserScriptMaster objects for script injections. |
19 class DeclarativeUserScriptManager { | 20 class DeclarativeUserScriptManager { |
20 public: | 21 public: |
21 explicit DeclarativeUserScriptManager(Profile* profile); | 22 explicit DeclarativeUserScriptManager(Profile* profile); |
22 ~DeclarativeUserScriptManager(); | 23 ~DeclarativeUserScriptManager(); |
23 | 24 |
24 // Get the user script master for declarative scripts; if one does not exist, | 25 // Gets the user script master for declarative scripts by the given |
25 // a new object will be created. | 26 // ConsumerID; if one does not exist, a new object will be created. |
26 DeclarativeUserScriptMaster* GetDeclarativeUserScriptMasterByID( | 27 linked_ptr<DeclarativeUserScriptMaster> GetDeclarativeUserScriptMasterByID( |
Devlin
2015/01/14 16:45:08
Again, no linked_ptr (assume this goes for all Dec
Xi Han
2015/01/14 23:46:02
Updated.
| |
27 const std::string& id); | 28 const ConsumerID& id); |
28 | 29 |
29 private: | 30 private: |
30 using UserScriptMasterMap = | 31 using UserScriptMasterMap = |
31 std::map<std::string, linked_ptr<DeclarativeUserScriptMaster>>; | 32 std::map<ConsumerID, linked_ptr<DeclarativeUserScriptMaster>>; |
32 | 33 |
33 // A map of DeclarativeUserScriptMasters for ids; each master is lazily | 34 // Creates a DeclarativeUserScriptMaster object. |
34 // initialized. | 35 linked_ptr<DeclarativeUserScriptMaster> CreateDeclarativeUserScriptMaster( |
36 const ConsumerID& consumer_id); | |
37 | |
38 // A map of DeclarativeUserScriptMasters for ConsumerIDs; each master | |
39 // is lazily initialized. | |
35 UserScriptMasterMap declarative_user_script_masters_; | 40 UserScriptMasterMap declarative_user_script_masters_; |
36 | 41 |
37 Profile* profile_; | 42 Profile* profile_; |
38 | 43 |
39 DISALLOW_COPY_AND_ASSIGN(DeclarativeUserScriptManager); | 44 DISALLOW_COPY_AND_ASSIGN(DeclarativeUserScriptManager); |
40 }; | 45 }; |
41 | 46 |
42 } // extensions | 47 } // namespace extensions |
43 | 48 |
44 #endif // CHROME_BROWSER_EXTENSIONS_DECLARATIVE_USER_SCRIPT_MANAGER_H_ | 49 #endif // CHROME_BROWSER_EXTENSIONS_DECLARATIVE_USER_SCRIPT_MANAGER_H_ |
OLD | NEW |