• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2020 The Chromium Embedded Framework 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 CEF_LIBCEF_BROWSER_CHROME_CHROME_BROWSER_CONTEXT_H_
6 #define CEF_LIBCEF_BROWSER_CHROME_CHROME_BROWSER_CONTEXT_H_
7 #pragma once
8 
9 #include "libcef/browser/browser_context.h"
10 
11 #include "base/memory/weak_ptr.h"
12 #include "chrome/browser/profiles/profile_manager.h"
13 
14 // See CefBrowserContext documentation for usage. Only accessed on the UI thread
15 // unless otherwise indicated.
16 class ChromeBrowserContext : public CefBrowserContext {
17  public:
18   explicit ChromeBrowserContext(const CefRequestContextSettings& settings);
19 
20   void InitializeAsync(base::OnceClosure initialized_cb);
21 
22   // CefBrowserContext overrides.
23   content::BrowserContext* AsBrowserContext() override;
24   Profile* AsProfile() override;
25   bool IsInitialized() const override;
26   void StoreOrTriggerInitCallback(base::OnceClosure callback) override;
27   void Shutdown() override;
28 
29  private:
30   ~ChromeBrowserContext() override;
31 
32   void ProfileCreated(Profile* profile, Profile::CreateStatus status);
33 
34   base::OnceClosure initialized_cb_;
35   Profile* profile_ = nullptr;
36   bool should_destroy_ = false;
37 
38   std::vector<base::OnceClosure> init_callbacks_;
39 
40   base::WeakPtrFactory<ChromeBrowserContext> weak_ptr_factory_;
41 
42   DISALLOW_COPY_AND_ASSIGN(ChromeBrowserContext);
43 };
44 
45 #endif  // CEF_LIBCEF_BROWSER_CHROME_CHROME_BROWSER_CONTEXT_H_
46