Index: chrome/browser/extensions/extension_user_script_loader.h |
diff --git a/chrome/browser/extensions/shared_user_script_master.h b/chrome/browser/extensions/extension_user_script_loader.h |
similarity index 32% |
copy from chrome/browser/extensions/shared_user_script_master.h |
copy to chrome/browser/extensions/extension_user_script_loader.h |
index bd20bb7062bee34755f0ea9bff580bea07881b7f..06db56af0bc4417d74d8d0ec9ce0cba989ba9850 100644 |
--- a/chrome/browser/extensions/shared_user_script_master.h |
+++ b/chrome/browser/extensions/extension_user_script_loader.h |
@@ -2,15 +2,16 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#ifndef CHROME_BROWSER_EXTENSIONS_SHARED_USER_SCRIPT_MASTER_H_ |
-#define CHROME_BROWSER_EXTENSIONS_SHARED_USER_SCRIPT_MASTER_H_ |
+#ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_USER_SCRIPT_LOADER_H_ |
+#define CHROME_BROWSER_EXTENSIONS_EXTENSION_USER_SCRIPT_LOADER_H_ |
-#include <set> |
- |
-#include "base/scoped_observer.h" |
+#include "base/memory/shared_memory.h" |
#include "chrome/browser/extensions/user_script_loader.h" |
+#include "content/public/browser/notification_observer.h" |
+#include "content/public/browser/notification_registrar.h" |
#include "extensions/browser/extension_registry_observer.h" |
#include "extensions/common/extension.h" |
+#include "extensions/common/extension_set.h" |
#include "extensions/common/user_script.h" |
namespace content { |
@@ -21,44 +22,53 @@ class Profile; |
namespace extensions { |
+class ContentVerifier; |
class ExtensionRegistry; |
-// Manages statically-defined user scripts for all extensions. Owns a |
-// UserScriptLoader to which file loading and shared memory management |
-// operations are delegated. |
-class SharedUserScriptMaster : public ExtensionRegistryObserver { |
+// UserScriptLoader for extensions. |
+class ExtensionUserScriptLoader : public UserScriptLoader, |
+ public ExtensionRegistryObserver { |
public: |
- explicit SharedUserScriptMaster(Profile* profile); |
- ~SharedUserScriptMaster() override; |
- |
- // Provides access to loader state method: scripts_ready(). |
- bool scripts_ready() const { return loader_.scripts_ready(); } |
+ ExtensionUserScriptLoader(Profile* profile, |
+ const ConsumerID& consumer_id, |
+ bool listen_for_extension_system_loaded); |
+ ~ExtensionUserScriptLoader() override; |
private: |
+ // UserScriptLoader implementation. |
+ void UpdateConsumersInfo() override; |
+ bool ready() override; |
+ ContentVerifier* GetContentVerifier() override; |
+ LoadUserScriptsFunctionCallback GetLoadUserScriptsFunction() override; |
+ static bool LoadScriptContent(const ConsumerID& consumer_id, |
Fady Samuel
2014/12/22 21:48:46
Move this above // UserScriptLoader implementation
Xi Han
2014/12/22 22:58:59
Moved.
|
+ UserScript::File* script_file, |
+ const SubstitutionMap* localization_messages, |
+ scoped_refptr<ContentVerifier> verifier); |
+ void SendUpdate(content::RenderProcessHost* process, |
+ base::SharedMemoryHandle handle_for_process, |
+ const std::set<ConsumerID>& changed_consumers) override; |
+ |
// ExtensionRegistryObserver implementation. |
- void OnExtensionLoaded(content::BrowserContext* browser_context, |
- const Extension* extension) override; |
void OnExtensionUnloaded(content::BrowserContext* browser_context, |
const Extension* extension, |
UnloadedExtensionInfo::Reason reason) override; |
- // Gets an extension's scripts' metadata; i.e., gets a list of UserScript |
- // objects that contains script info, but not the contents of the scripts. |
- const std::set<UserScript> GetScriptsMetadata(const Extension* extension); |
+ // Initiates script load when we have been waiting for the extension system |
+ // to be ready. |
+ void OnExtensionSystemReady(); |
- // Script loader that handles loading contents of scripts into shared memory |
- // and notifying renderers of scripts in shared memory. |
- UserScriptLoader loader_; |
- |
- // The profile for which the scripts managed here are installed. |
- Profile* profile_; |
+ // If the extensions service has finished loading its initial set of |
+ // extensions. |
+ bool extension_system_ready_; |
ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> |
extension_registry_observer_; |
- DISALLOW_COPY_AND_ASSIGN(SharedUserScriptMaster); |
+ base::WeakPtrFactory<ExtensionUserScriptLoader> weak_factory_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(ExtensionUserScriptLoader); |
}; |
} // namespace extensions |
-#endif // CHROME_BROWSER_EXTENSIONS_SHARED_USER_SCRIPT_MASTER_H_ |
+#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_USER_SCRIPT_LOADER_H_ |