2020-07-04 04:51:17 +02:00
|
|
|
// Copyright 2020 The Chromium Embedded Framework 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 CEF_LIBCEF_BROWSER_CHROME_CHROME_BROWSER_CONTEXT_H_
|
|
|
|
#define CEF_LIBCEF_BROWSER_CHROME_CHROME_BROWSER_CONTEXT_H_
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "libcef/browser/browser_context.h"
|
|
|
|
|
2021-04-07 00:09:45 +02:00
|
|
|
#include "base/memory/weak_ptr.h"
|
|
|
|
#include "chrome/browser/profiles/profile_manager.h"
|
2021-07-23 21:55:22 +02:00
|
|
|
#include "chrome/browser/profiles/profile_observer.h"
|
|
|
|
|
|
|
|
class ScopedProfileKeepAlive;
|
2021-04-07 00:09:45 +02:00
|
|
|
|
2020-07-04 04:51:17 +02:00
|
|
|
// See CefBrowserContext documentation for usage. Only accessed on the UI thread
|
|
|
|
// unless otherwise indicated.
|
2021-07-23 21:55:22 +02:00
|
|
|
class ChromeBrowserContext : public CefBrowserContext, public ProfileObserver {
|
2020-07-04 04:51:17 +02:00
|
|
|
public:
|
|
|
|
explicit ChromeBrowserContext(const CefRequestContextSettings& settings);
|
|
|
|
|
2021-12-06 21:40:25 +01:00
|
|
|
ChromeBrowserContext(const ChromeBrowserContext&) = delete;
|
|
|
|
ChromeBrowserContext& operator=(const ChromeBrowserContext&) = delete;
|
|
|
|
|
2021-04-07 00:09:45 +02:00
|
|
|
void InitializeAsync(base::OnceClosure initialized_cb);
|
|
|
|
|
2020-07-04 04:51:17 +02:00
|
|
|
// CefBrowserContext overrides.
|
|
|
|
content::BrowserContext* AsBrowserContext() override;
|
|
|
|
Profile* AsProfile() override;
|
2021-04-15 01:28:22 +02:00
|
|
|
bool IsInitialized() const override;
|
|
|
|
void StoreOrTriggerInitCallback(base::OnceClosure callback) override;
|
2020-07-04 04:51:17 +02:00
|
|
|
void Shutdown() override;
|
|
|
|
|
2021-07-23 21:55:22 +02:00
|
|
|
// ProfileObserver overrides.
|
|
|
|
void OnProfileWillBeDestroyed(Profile* profile) override;
|
|
|
|
|
2020-07-04 04:51:17 +02:00
|
|
|
private:
|
|
|
|
~ChromeBrowserContext() override;
|
|
|
|
|
2022-09-26 21:30:45 +02:00
|
|
|
void ProfileCreated(Profile::CreateStatus status, Profile* profile);
|
2021-04-07 00:09:45 +02:00
|
|
|
|
|
|
|
base::OnceClosure initialized_cb_;
|
2020-07-04 04:51:17 +02:00
|
|
|
Profile* profile_ = nullptr;
|
2021-04-07 00:09:45 +02:00
|
|
|
bool should_destroy_ = false;
|
|
|
|
|
2021-07-23 21:55:22 +02:00
|
|
|
bool destroyed_ = false;
|
|
|
|
std::unique_ptr<ScopedProfileKeepAlive> profile_keep_alive_;
|
|
|
|
|
2021-04-15 01:28:22 +02:00
|
|
|
std::vector<base::OnceClosure> init_callbacks_;
|
|
|
|
|
2021-04-07 00:09:45 +02:00
|
|
|
base::WeakPtrFactory<ChromeBrowserContext> weak_ptr_factory_;
|
2020-07-04 04:51:17 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // CEF_LIBCEF_BROWSER_CHROME_CHROME_BROWSER_CONTEXT_H_
|