blob: 17f06b86a384fcd497cc54fa8bd359a77428139c [file] [log] [blame]
// 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_CHROME_PROCESS_MANAGER_DELEGATE_H_
#define CHROME_BROWSER_EXTENSIONS_CHROME_PROCESS_MANAGER_DELEGATE_H_
#include "base/compiler_specific.h"
#include "base/macros.h"
#include "base/scoped_observer.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager_observer.h"
#include "chrome/browser/profiles/profile_observer.h"
#include "chrome/browser/ui/browser_list_observer.h"
#include "extensions/browser/process_manager_delegate.h"
class Browser;
class Profile;
namespace extensions {
// Support for ProcessManager. Controls cases where Chrome wishes to disallow
// extension background pages or defer their creation.
class ChromeProcessManagerDelegate : public ProcessManagerDelegate,
public BrowserListObserver,
public ProfileManagerObserver,
public ProfileObserver {
public:
ChromeProcessManagerDelegate();
~ChromeProcessManagerDelegate() override;
// ProcessManagerDelegate:
bool AreBackgroundPagesAllowedForContext(
content::BrowserContext* context) const override;
bool IsExtensionBackgroundPageAllowed(
content::BrowserContext* context,
const Extension& extension) const override;
bool DeferCreatingStartupBackgroundHosts(
content::BrowserContext* context) const override;
// BrowserListObserver:
void OnBrowserAdded(Browser* browser) override;
// ProfileManagerObserver:
void OnProfileAdded(Profile* profile) override;
// ProfileObserver:
void OnOffTheRecordProfileCreated(Profile* off_the_record_profile) override;
void OnProfileWillBeDestroyed(Profile* profile) override;
private:
ScopedObserver<Profile, ProfileObserver> observed_profiles_{this};
DISALLOW_COPY_AND_ASSIGN(ChromeProcessManagerDelegate);
};
} // namespace extensions
#endif // CHROME_BROWSER_EXTENSIONS_CHROME_PROCESS_MANAGER_DELEGATE_H_