• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2019 The Chromium Embedded Framework Authors. All rights
2 // reserved. Use of this source code is governed by a BSD-style license that
3 // can be found in the LICENSE file.
4 
5 #ifndef CEF_LIBCEF_BROWSER_WEB_CONTENTS_DIALOG_HELPER_H_
6 #define CEF_LIBCEF_BROWSER_WEB_CONTENTS_DIALOG_HELPER_H_
7 #pragma once
8 
9 #include "base/callback_forward.h"
10 #include "base/memory/weak_ptr.h"
11 #include "base/observer_list.h"
12 #include "components/web_modal/modal_dialog_host.h"
13 #include "components/web_modal/web_contents_modal_dialog_host.h"
14 #include "components/web_modal/web_contents_modal_dialog_manager_delegate.h"
15 
16 class CefBrowserPlatformDelegate;
17 
18 class CefWebContentsDialogHelper
19     : public web_modal::WebContentsModalDialogManagerDelegate,
20       public web_modal::WebContentsModalDialogHost {
21  public:
22   CefWebContentsDialogHelper(content::WebContents* web_contents,
23                              CefBrowserPlatformDelegate* browser_delegate);
24 
25   base::RepeatingClosure GetBoundsChangedCallback();
26 
27   // web_modal::WebContentsModalDialogManagerDelegate methods:
28   bool IsWebContentsVisible(content::WebContents* web_contents) override;
29   web_modal::WebContentsModalDialogHost* GetWebContentsModalDialogHost()
30       override;
31 
32   // web_modal::WebContentsModalDialogHost methods:
33   gfx::NativeView GetHostView() const override;
34   gfx::Point GetDialogPosition(const gfx::Size& size) override;
35   gfx::Size GetMaximumDialogSize() override;
36   void AddObserver(web_modal::ModalDialogHostObserver* observer) override;
37   void RemoveObserver(web_modal::ModalDialogHostObserver* observer) override;
38 
39  private:
40   void OnBoundsChanged();
41 
42   CefBrowserPlatformDelegate* const browser_delegate_;
43 
44   // Used to notify WebContentsModalDialog.
45   base::ObserverList<web_modal::ModalDialogHostObserver>::Unchecked
46       observer_list_;
47 
48   base::WeakPtrFactory<CefWebContentsDialogHelper> weak_factory_;
49 };
50 
51 #endif  // CEF_LIBCEF_BROWSER_WEB_CONTENTS_DIALOG_HELPER_H_
52