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