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..d9ecd0fd6f303bcfee695eb846f2abf832bee8be |
| --- /dev/null |
| +++ b/chrome/browser/extensions/declarative_user_script_master.h |
| @@ -0,0 +1,78 @@ |
| +// Copyright (c) 2014 The Chromium Authors. All rights reserved. |
|
Devlin
2014/07/30 21:20:38
nit: we don't use (c) anymore (I don't know why, b
Mark Dittmer
2014/07/31 18:37:33
Done.
|
| +// 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 "base/scoped_observer.h" |
|
Devlin
2014/07/30 21:20:38
unused?
Mark Dittmer
2014/07/31 18:37:33
Done.
|
| +#include "chrome/browser/extensions/user_script_master.h" |
| +#include "content/public/browser/notification_observer.h" |
| +#include "content/public/browser/notification_registrar.h" |
| +#include "extensions/common/extension.h" |
| + |
| +class Profile; |
| + |
| +namespace extensions { |
| + |
| +class DeclarativeUserScriptMaster : public UserScriptMaster, |
| + public content::NotificationObserver { |
| + public: |
| + DeclarativeUserScriptMaster(Profile* profile, |
| + const ExtensionId& extension_id); |
| + virtual ~DeclarativeUserScriptMaster(); |
| + |
| + // content::NotificationObserver implementation. |
| + virtual void Observe(int type, |
|
Devlin
2014/07/30 21:20:38
Let's make this private.
Mark Dittmer
2014/07/31 18:37:33
Done.
|
| + const content::NotificationSource& source, |
| + const content::NotificationDetails& details) OVERRIDE; |
| + |
| + // 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(); |
| + |
| + // Start loading scripts into shared memory region. |
|
Devlin
2014/07/30 21:20:38
Replace this comment with just UserScriptMaster im
Mark Dittmer
2014/07/31 18:37:33
Done.
|
| + virtual void StartLoad() OVERRIDE; |
| + |
| + private: |
| + // Reset UserScriptMaster::pending_load_ based on our data. |
| + void ResetPendingLoad() { |
|
Devlin
2014/07/30 21:20:38
This and ResetPendingLoadData should probably both
Mark Dittmer
2014/07/31 18:37:33
Done.
|
| + pending_load_ = (clear_scripts_ || scripts_to_add_.size() > 0 || |
| + scripts_to_remove_.size() > 0); |
| + } |
| + |
| + // Reset data upon which UserScriptMaster::pending_load_ depends. |
| + void ResetPendingLoadData() { |
| + scripts_to_add_.clear(); |
| + scripts_to_remove_.clear(); |
| + clear_scripts_ = false; |
| + } |
| + |
| + // 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_; |
| + |
| + // Manages our notification registrations. |
| + content::NotificationRegistrar registrar_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(DeclarativeUserScriptMaster); |
| +}; |
| + |
| +} // namespace extensions |
| + |
| +#endif // CHROME_BROWSER_EXTENSIONS_DECLARATIVE_USER_SCRIPT_MASTER_H_ |