Chromium Code Reviews| Index: chrome/browser/extensions/declarative_user_script_master.h |
| diff --git a/chrome/browser/extensions/declarative_user_script_master.h b/chrome/browser/extensions/declarative_user_script_master.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..5f306099f168860a3ee748807e3496f237d47968 |
| --- /dev/null |
| +++ b/chrome/browser/extensions/declarative_user_script_master.h |
| @@ -0,0 +1,84 @@ |
| +// 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_DECLARATIVE_USER_SCRIPT_MASTER_H_ |
| +#define CHROME_BROWSER_EXTENSIONS_DECLARATIVE_USER_SCRIPT_MASTER_H_ |
| + |
| +#include <set> |
| + |
| +#include "chrome/browser/extensions/user_script_master.h" |
| +#include "extensions/common/extension.h" |
| + |
| +class Profile; |
| + |
| +namespace extensions { |
| + |
| +class DeclarativeUserScriptMaster : public UserScriptMaster { |
| + public: |
| + DeclarativeUserScriptMaster(Profile* profile, |
| + const ExtensionId& extension_id); |
| + virtual ~DeclarativeUserScriptMaster(); |
| + |
| + // Add script to shared memory region. This may not happen right away if a |
| + // script load is in progress. |
| + void AddScript(const UserScript& script); |
| + |
| + // Remove script from shared memory region. This may not happen right away if |
| + // a script load is in progress. |
| + void RemoveScript(const UserScript& script); |
| + |
| + // Remove all scripts from shared memory region. This may not happen right |
| + // away if a script load is in progress. |
| + void ClearScripts(); |
| + |
| + // UserScriptMaster implementation. |
|
Devlin
2014/07/31 20:32:24
make this private.
|
| + virtual void StartLoad() OVERRIDE; |
| + |
| + protected: |
| + // UserScriptMaster implementation. |
|
Devlin
2014/07/31 20:32:24
Make all of these 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: |
| + // Attempt to initiate a load of scripts. May need to signal a pending load if |
| + // a load is already in progress. |
| + void AttemptLoad(); |
| + |
| + // Reset UserScriptMaster::pending_load_ based on our data. |
|
Devlin
2014/07/31 20:32:24
Prefer: "Signal a pending load if any scripts have
|
| + void MaybeSignalPendingLoad(); |
| + |
| + 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_; |
| + |
| + // Set containing only the extension we manage. This is passed to the base |
| + // class in several different contexts. |
| + std::set<ExtensionId> owner_extension_as_set_; |
| + |
| + // Scripts to be added next time the memory region reloads. |
| + std::set<UserScript> scripts_to_add_; |
| + |
| + // Scripts to be removed next time the memory region reloads. |
| + std::set<UserScript> scripts_to_remove_; |
| + |
| + // Indicator variable: clear list of scripts on next reload. |
| + bool clear_scripts_; |
| + |
| + // Maps extension info needed for localization to an extension ID. |
| + ExtensionsInfo extensions_info_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(DeclarativeUserScriptMaster); |
| +}; |
| + |
| +} // namespace extensions |
| + |
| +#endif // CHROME_BROWSER_EXTENSIONS_DECLARATIVE_USER_SCRIPT_MASTER_H_ |