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_MASTER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_DECLARATIVE_USER_SCRIPT_MASTER_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_DECLARATIVE_USER_SCRIPT_MASTER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_DECLARATIVE_USER_SCRIPT_MASTER_H_ |
7 | 7 |
8 #include "base/scoped_observer.h" | 8 #include "base/scoped_observer.h" |
9 #include "chrome/browser/extensions/user_script_loader.h" | 9 #include "chrome/browser/extensions/extension_user_script_loader.h" |
10 #include "extensions/browser/extension_registry_observer.h" | 10 #include "extensions/common/consumer_id.h" |
11 #include "extensions/common/extension.h" | |
12 | 11 |
13 class Profile; | 12 class Profile; |
14 | 13 |
15 namespace extensions { | 14 namespace extensions { |
16 | 15 |
17 class ExtensionRegistry; | |
18 class UserScript; | 16 class UserScript; |
19 | 17 |
20 // Manages declarative user scripts for a single extension. Owns a | 18 // Manages declarative user scripts for a single extension. Owns a |
21 // UserScriptLoader to which file loading and shared memory management | 19 // UserScriptLoader to which file loading and shared memory management |
22 // operations are delegated, and provides an interface for adding, removing, | 20 // operations are delegated, and provides an interface for adding, removing, |
23 // and clearing scripts. | 21 // and clearing scripts. |
24 class DeclarativeUserScriptMaster : public ExtensionRegistryObserver { | 22 class DeclarativeUserScriptMaster { |
25 public: | 23 public: |
26 DeclarativeUserScriptMaster(Profile* profile, | 24 DeclarativeUserScriptMaster(Profile* profile, const ConsumerID& id); |
27 const ExtensionId& extension_id); | 25 virtual ~DeclarativeUserScriptMaster(); |
Devlin
2015/01/21 23:25:20
Nothing inherits this, right? We can make it a no
Xi Han
2015/01/22 17:19:36
Done.
| |
28 ~DeclarativeUserScriptMaster() override; | |
29 | 26 |
30 // Adds script to shared memory region. This may not happen right away if a | 27 // Adds script to shared memory region. This may not happen right away if a |
31 // script load is in progress. | 28 // script load is in progress. |
32 void AddScript(const UserScript& script); | 29 void AddScript(const UserScript& script); |
33 | 30 |
34 // Removes script from shared memory region. This may not happen right away if | 31 // Removes script from shared memory region. This may not happen right away if |
35 // a script load is in progress. | 32 // a script load is in progress. |
36 void RemoveScript(const UserScript& script); | 33 void RemoveScript(const UserScript& script); |
37 | 34 |
38 // Removes all scripts from shared memory region. This may not happen right | 35 // Removes all scripts from shared memory region. This may not happen right |
39 // away if a script load is in progress. | 36 // away if a script load is in progress. |
40 void ClearScripts(); | 37 void ClearScripts(); |
41 | 38 |
42 const ExtensionId& extension_id() const { return extension_id_; } | 39 const ConsumerID& consumer_id() const { return consumer_id_; } |
43 | 40 |
44 private: | 41 private: |
45 // ExtensionRegistryObserver implementation. | 42 // ID of consumer that owns scripts that this component manages. |
46 void OnExtensionUnloaded(content::BrowserContext* browser_context, | 43 ConsumerID consumer_id_; |
47 const Extension* extension, | |
48 UnloadedExtensionInfo::Reason reason) override; | |
49 | |
50 // ID of extension that owns scripts that this component manages. | |
51 ExtensionId extension_id_; | |
52 | 44 |
53 // Script loader that handles loading contents of scripts into shared memory | 45 // Script loader that handles loading contents of scripts into shared memory |
54 // and notifying renderers of script updates. | 46 // and notifying renderers of script updates. |
55 UserScriptLoader loader_; | 47 ExtensionUserScriptLoader loader_; |
56 | |
57 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> | |
58 extension_registry_observer_; | |
59 | 48 |
60 DISALLOW_COPY_AND_ASSIGN(DeclarativeUserScriptMaster); | 49 DISALLOW_COPY_AND_ASSIGN(DeclarativeUserScriptMaster); |
61 }; | 50 }; |
62 | 51 |
63 } // namespace extensions | 52 } // namespace extensions |
64 | 53 |
65 #endif // CHROME_BROWSER_EXTENSIONS_DECLARATIVE_USER_SCRIPT_MASTER_H_ | 54 #endif // CHROME_BROWSER_EXTENSIONS_DECLARATIVE_USER_SCRIPT_MASTER_H_ |
OLD | NEW |