1 // Copyright 2019 The Chromium 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 CHROME_BROWSER_UI_ASH_ARC_CUSTOM_TAB_MODAL_DIALOG_HOST_H_ 6 #define CHROME_BROWSER_UI_ASH_ARC_CUSTOM_TAB_MODAL_DIALOG_HOST_H_ 7 8 #include <memory> 9 10 #include "base/macros.h" 11 #include "components/web_modal/web_contents_modal_dialog_host.h" 12 #include "components/web_modal/web_contents_modal_dialog_manager_delegate.h" 13 #include "ui/gfx/native_widget_types.h" 14 15 namespace arc { 16 class CustomTab; 17 } // namespace arc 18 19 namespace contents { 20 class WebContents; 21 } // namespace contents 22 23 namespace gfx { 24 class Point; 25 class Size; 26 } // namespace gfx 27 28 namespace web_modal { 29 class ModalDialogHostObserver; 30 } // namespace web_modal 31 32 // Implements a WebContentsModalDialogHost for an ARC Custom Tab. This allows a 33 // web contents modal dialog to be drawn in the ARC Custom Tab. 34 // The WebContents hosted by this object must outlive it. 35 class ArcCustomTabModalDialogHost 36 : public web_modal::WebContentsModalDialogHost, 37 public web_modal::WebContentsModalDialogManagerDelegate { 38 public: 39 ArcCustomTabModalDialogHost(std::unique_ptr<arc::CustomTab> custom_tab, 40 content::WebContents* web_contents); 41 ~ArcCustomTabModalDialogHost() override = 0; 42 43 // web_modal::WebContentsModalDialogManagerDelegate: 44 web_modal::WebContentsModalDialogHost* GetWebContentsModalDialogHost() 45 override; 46 47 // web_modal::WebContentsModalDialogHost: 48 gfx::NativeView GetHostView() const override; 49 gfx::Point GetDialogPosition(const gfx::Size& size) override; 50 gfx::Size GetMaximumDialogSize() override; 51 void AddObserver(web_modal::ModalDialogHostObserver* observer) override; 52 void RemoveObserver(web_modal::ModalDialogHostObserver* observer) override; 53 54 protected: 55 std::unique_ptr<arc::CustomTab> custom_tab_; 56 content::WebContents* web_contents_; 57 58 DISALLOW_COPY_AND_ASSIGN(ArcCustomTabModalDialogHost); 59 }; 60 61 #endif // CHROME_BROWSER_UI_ASH_ARC_CUSTOM_TAB_MODAL_DIALOG_HOST_H_ 62