blob: 803e62cd23505f97b4b0fb82d299773aeb76f571 [file] [log] [blame]
Devlin Cronin4d5fbc92019-07-01 19:11:351// Copyright 2019 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_BROWSER_WINDOW_HELPER_H_
6#define CHROME_BROWSER_EXTENSIONS_EXTENSION_BROWSER_WINDOW_HELPER_H_
7
8#include "base/macros.h"
9#include "base/scoped_observer.h"
Evan Stade75872a62019-09-06 21:17:3810#include "extensions/browser/extension_registry.h"
Devlin Cronin4d5fbc92019-07-01 19:11:3511#include "extensions/browser/extension_registry_observer.h"
12
13class Browser;
14
15namespace extensions {
16
17// A helper object for extensions-related management for Browser* objects.
18class ExtensionBrowserWindowHelper : public ExtensionRegistryObserver {
19 public:
20 // Note: |browser| must outlive this object.
21 explicit ExtensionBrowserWindowHelper(Browser* browser);
22 ~ExtensionBrowserWindowHelper() override;
23
24 private:
25 // ExtensionRegistryObserver:
26 void OnExtensionLoaded(content::BrowserContext* browser_context,
27 const Extension* extension) override;
28 void OnExtensionUnloaded(content::BrowserContext* browser_context,
29 const Extension* extension,
30 UnloadedExtensionReason reason) override;
31
32 // Closes any tabs owned by the extension with the given |extension_id| and
33 // unmutes others if necessary.
34 void CleanUpTabsOnUnload(const ExtensionId& extension_id);
35
36 // The associated browser. Must outlive this object.
37 Browser* const browser_ = nullptr;
38
39 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver>
Evan Stade75872a62019-09-06 21:17:3840 registry_observer_{this};
Devlin Cronin4d5fbc92019-07-01 19:11:3541
42 DISALLOW_COPY_AND_ASSIGN(ExtensionBrowserWindowHelper);
43};
44
45} // namespace extensions
46
47#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_BROWSER_WINDOW_HELPER_H_