Chromium Code Reviews| Index: chrome/browser/extensions/shared_user_script_master.h |
| diff --git a/chrome/browser/extensions/shared_user_script_master.h b/chrome/browser/extensions/shared_user_script_master.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..7baed0df64d27e35f1a80a31a2c16c8b554c86d8 |
| --- /dev/null |
| +++ b/chrome/browser/extensions/shared_user_script_master.h |
| @@ -0,0 +1,96 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// 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_ |
| + |
| +#include <set> |
| + |
| +#include "base/scoped_observer.h" |
| +#include "chrome/browser/extensions/user_script_master.h" |
| +#include "content/public/browser/notification_observer.h" |
| +#include "content/public/browser/notification_registrar.h" |
| +#include "extensions/browser/extension_registry.h" |
| +#include "extensions/browser/extension_registry_observer.h" |
| +#include "extensions/common/extension.h" |
| + |
| +namespace content { |
| + |
|
Devlin
2014/07/31 20:32:24
namespace content {
class BrowserContext;
}
|
| +class BrowserContext; |
| + |
| +} // namespace content |
| + |
| +class Profile; |
| + |
| +namespace extensions { |
| + |
| +class SharedUserScriptMaster : public UserScriptMaster, |
| + public ExtensionRegistryObserver { |
| + public: |
| + explicit SharedUserScriptMaster(Profile* profile); |
| + virtual ~SharedUserScriptMaster(); |
| + |
| + // ExtensionRegistryObserver implementation. |
| + virtual void OnExtensionLoaded(content::BrowserContext* browser_context, |
|
Devlin
2014/07/31 20:32:24
private
|
| + const Extension* extension) OVERRIDE; |
| + virtual void OnExtensionUnloaded( |
| + content::BrowserContext* browser_context, |
| + const Extension* extension, |
| + UnloadedExtensionInfo::Reason reason) OVERRIDE; |
| + |
| + // UserScriptMaster implementation. |
| + virtual void StartLoad() OVERRIDE; |
| + |
| + protected: |
| + // UserScriptMaster implementation. |
|
Devlin
2014/07/31 20:32:24
private
|
| + virtual void AcquireUserScripts(scoped_ptr<UserScriptList> scripts) OVERRIDE; |
| + virtual ExtensionsInfo GetExtensionsInfo() OVERRIDE; |
| + virtual std::set<ExtensionId> GetAddedExtensions() OVERRIDE; |
| + virtual std::set<ExtensionId> GetAllManagedExtensions() OVERRIDE; |
| + virtual std::set<ExtensionId> GetChangedExtensions() OVERRIDE; |
| + virtual void ResetChangedExtensions() OVERRIDE; |
| + |
| + private: |
| + void OnExtensionSystemReady(); |
|
Devlin
2014/07/31 20:32:24
comment
|
| + |
| + // Attempt to initiate a load of scripts. May need to signal a pending load if |
| + // a load is already in progress. |
| + void AttemptLoad(); |
| + |
| + bool is_loading() const { |
| + // Ownership of |user_scripts_| is passed to the file thread when loading. |
| + return user_scripts_.get() == NULL; |
| + } |
| + |
| + // List of scripts from currently-installed extensions we should load. |
| + scoped_ptr<UserScriptList> user_scripts_; |
| + |
| + // The IDs of the extensions which have changed since the last update sent to |
| + // the renderer. |
| + std::set<ExtensionId> changed_extensions_; |
| + |
| + // The mutually-exclusive sets of extensions that were added or removed since |
| + // the last script load. |
| + std::set<ExtensionId> added_extensions_; |
| + std::set<ExtensionId> removed_extensions_; |
| + |
| + // Maps extension info needed for localization to an extension ID. |
| + ExtensionsInfo extensions_info_; |
| + |
| + // If the extensions service has finished loading its initial set of |
| + // extensions. |
| + bool extensions_service_ready_; |
| + |
| + base::WeakPtrFactory<SharedUserScriptMaster> weak_factory_; |
| + |
| + // Listen to extension load, unloaded notifications. |
| + ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> |
| + extension_registry_observer_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(SharedUserScriptMaster); |
| +}; |
| + |
| +} // namespace extensions |
| + |
| +#endif // CHROME_BROWSER_EXTENSIONS_SHARED_USER_SCRIPT_MASTER_H_ |