| Index: extensions/browser/api/declarative_net_request/rules_monitor.h
|
| diff --git a/extensions/browser/api/declarative_net_request/rules_monitor.h b/extensions/browser/api/declarative_net_request/rules_monitor.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..78276cb044bddf3552eb97de3656937331871081
|
| --- /dev/null
|
| +++ b/extensions/browser/api/declarative_net_request/rules_monitor.h
|
| @@ -0,0 +1,68 @@
|
| +// Copyright 2017 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 EXTENSIONS_BROWSER_API_DECLARATIVE_NET_REQUEST_RULES_MONITOR_H_
|
| +#define EXTENSIONS_BROWSER_API_DECLARATIVE_NET_REQUEST_RULES_MONITOR_H_
|
| +
|
| +#include "base/macros.h"
|
| +#include "base/scoped_observer.h"
|
| +#include "extensions/browser/extension_registry_observer.h"
|
| +
|
| +namespace content {
|
| +class BrowserContext;
|
| +}
|
| +
|
| +namespace base {
|
| +class SequencedTaskRunner;
|
| +}
|
| +
|
| +namespace extensions {
|
| +class InfoMap;
|
| +
|
| +namespace declarative_net_request {
|
| +
|
| +// Lives on the UI thread. TODO take care of incognito.
|
| +// Owned by ExtensionSystem.
|
| +class RulesMonitor : public ExtensionRegistryObserver {
|
| + public:
|
| + // TODO if needed change to Profile.
|
| + explicit RulesMonitor(content::BrowserContext* browser_context,
|
| + base::SequencedTaskRunner* task_runner,
|
| + InfoMap* info_map);
|
| + ~RulesMonitor() override;
|
| +
|
| + private:
|
| + void OnExtensionLoaded(content::BrowserContext* browser_context,
|
| + const Extension* extension) override;
|
| +
|
| + void OnExtensionUnloaded(content::BrowserContext* browser_context,
|
| + const Extension* extension,
|
| + UnloadedExtensionReason reason) override;
|
| +
|
| + // TODO listen to OnExtensionUninstalled to clear persisted ruleset for
|
| + // unpacked extensions? Won't be needed for packed extensions since the
|
| + // extension directory will be deleted.
|
| +
|
| + // TODO do we need to store browser context?
|
| + content::BrowserContext* browser_context_;
|
| + ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver>
|
| + registry_observer_;
|
| +
|
| + // Weak. Owned by ExtensionService. The events above are propogated through
|
| + // the ExtensionService, which means this weak reference is safe to use.
|
| + base::SequencedTaskRunner* file_task_runner_;
|
| +
|
| + // Weak. Owned by ExtensionSystem, which also owns us. We use it in the
|
| + // OnExtension* events, which means the ExtensionService hasn't been shut down
|
| + // which means the ExtensionSystem hasn't been shutdown. Hence this is safe to
|
| + // use.
|
| + InfoMap* info_map_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(RulesMonitor);
|
| +};
|
| +
|
| +} // namespace declarative_net_request
|
| +} // namespace extensions
|
| +
|
| +#endif // EXTENSIONS_BROWSER_API_DECLARATIVE_NET_REQUEST_RULES_MONITOR_H_
|
|
|