• 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_BROWSER_DELEGATE_H_
6 #define CEF_LIBCEF_BROWSER_CHROME_BROWSER_DELEGATE_H_
7 #pragma once
8 
9 #include <memory>
10 
11 #include "base/memory/scoped_refptr.h"
12 #include "content/public/browser/web_contents_delegate.h"
13 
14 class Browser;
15 
16 namespace cef {
17 
18 // Delegate for the chrome Browser object. Lifespan is controlled by the Browser
19 // object. See the ChromeBrowserDelegate documentation for additional details.
20 // Only accessed on the UI thread.
21 class BrowserDelegate : public content::WebContentsDelegate {
22  public:
23   // Opaque ref-counted base class for CEF-specific parameters passed via
24   // Browser::CreateParams::cef_params and possibly shared by multiple Browser
25   // instances.
26   class CreateParams : public base::RefCounted<CreateParams> {
27    public:
~CreateParams()28     virtual ~CreateParams() {}
29   };
30 
31   // Called from the Browser constructor to create a new delegate.
32   static std::unique_ptr<BrowserDelegate> Create(
33       Browser* browser,
34       scoped_refptr<CreateParams> cef_params);
35 
~BrowserDelegate()36   ~BrowserDelegate() override {}
37 
38   // Called immediately after |new_contents| is created.
39   virtual void OnWebContentsCreated(content::WebContents* new_contents) = 0;
40 
41   // Add or remove ownership of the WebContents.
42   virtual void SetAsDelegate(content::WebContents* web_contents,
43                              bool set_delegate) = 0;
44 };
45 
46 }  // namespace cef
47 
48 #endif  // CEF_LIBCEF_BROWSER_CHROME_BROWSER_DELEGATE_H_
49