[email protected] | 6b54fda | 2014-07-22 02:13:47 | [diff] [blame] | 1 | // Copyright 2014 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_CHROME_PROCESS_MANAGER_DELEGATE_H_ |
| 6 | #define CHROME_BROWSER_EXTENSIONS_CHROME_PROCESS_MANAGER_DELEGATE_H_ |
| 7 | |
| 8 | #include "base/compiler_specific.h" |
| 9 | #include "base/macros.h" |
Evan Stade | e55e6b9 | 2019-07-25 18:59:22 | [diff] [blame] | 10 | #include "chrome/browser/ui/browser_list_observer.h" |
[email protected] | 6b54fda | 2014-07-22 02:13:47 | [diff] [blame] | 11 | #include "content/public/browser/notification_observer.h" |
| 12 | #include "content/public/browser/notification_registrar.h" |
| 13 | #include "extensions/browser/process_manager_delegate.h" |
| 14 | |
| 15 | class Browser; |
| 16 | class Profile; |
| 17 | |
| 18 | namespace extensions { |
| 19 | |
| 20 | // Support for ProcessManager. Controls cases where Chrome wishes to disallow |
| 21 | // extension background pages or defer their creation. |
| 22 | class ChromeProcessManagerDelegate : public ProcessManagerDelegate, |
Evan Stade | e55e6b9 | 2019-07-25 18:59:22 | [diff] [blame] | 23 | public content::NotificationObserver, |
| 24 | public BrowserListObserver { |
[email protected] | 6b54fda | 2014-07-22 02:13:47 | [diff] [blame] | 25 | public: |
| 26 | ChromeProcessManagerDelegate(); |
dcheng | ae36a4a | 2014-10-21 12:36:36 | [diff] [blame] | 27 | ~ChromeProcessManagerDelegate() override; |
[email protected] | 6b54fda | 2014-07-22 02:13:47 | [diff] [blame] | 28 | |
Evan Stade | e55e6b9 | 2019-07-25 18:59:22 | [diff] [blame] | 29 | // ProcessManagerDelegate: |
achuith | d3da4f0 | 2017-03-23 20:05:29 | [diff] [blame] | 30 | bool AreBackgroundPagesAllowedForContext( |
| 31 | content::BrowserContext* context) const override; |
| 32 | bool IsExtensionBackgroundPageAllowed( |
| 33 | content::BrowserContext* context, |
| 34 | const Extension& extension) const override; |
dcheng | ae36a4a | 2014-10-21 12:36:36 | [diff] [blame] | 35 | bool DeferCreatingStartupBackgroundHosts( |
mostynb | a15bee1 | 2014-10-04 00:40:32 | [diff] [blame] | 36 | content::BrowserContext* context) const override; |
[email protected] | 6b54fda | 2014-07-22 02:13:47 | [diff] [blame] | 37 | |
Evan Stade | e55e6b9 | 2019-07-25 18:59:22 | [diff] [blame] | 38 | // content::NotificationObserver: |
dcheng | ae36a4a | 2014-10-21 12:36:36 | [diff] [blame] | 39 | void Observe(int type, |
| 40 | const content::NotificationSource& source, |
| 41 | const content::NotificationDetails& details) override; |
[email protected] | 6b54fda | 2014-07-22 02:13:47 | [diff] [blame] | 42 | |
Evan Stade | e55e6b9 | 2019-07-25 18:59:22 | [diff] [blame] | 43 | // BrowserListObserver: |
| 44 | void OnBrowserAdded(Browser* browser) override; |
| 45 | |
[email protected] | 6b54fda | 2014-07-22 02:13:47 | [diff] [blame] | 46 | private: |
| 47 | // Notification handlers. |
[email protected] | 6b54fda | 2014-07-22 02:13:47 | [diff] [blame] | 48 | void OnProfileCreated(Profile* profile); |
[email protected] | 9602db4 | 2014-07-25 05:24:37 | [diff] [blame] | 49 | void OnProfileDestroyed(Profile* profile); |
[email protected] | 6b54fda | 2014-07-22 02:13:47 | [diff] [blame] | 50 | |
| 51 | content::NotificationRegistrar registrar_; |
| 52 | |
| 53 | DISALLOW_COPY_AND_ASSIGN(ChromeProcessManagerDelegate); |
| 54 | }; |
| 55 | |
| 56 | } // namespace extensions |
| 57 | |
| 58 | #endif // CHROME_BROWSER_EXTENSIONS_CHROME_PROCESS_MANAGER_DELEGATE_H_ |