// Copyright 2022 The Chromium Embedded Framework Authors. // Portions copyright 2020 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "cef/libcef/browser/alloy/dialogs/alloy_javascript_dialog_manager_delegate.h" #include "base/logging.h" #include "cef/libcef/browser/browser_host_base.h" namespace { class AlloyJavaScriptTabModalDialogManagerDelegateDesktop : public JavaScriptTabModalDialogManagerDelegateDesktop { public: explicit AlloyJavaScriptTabModalDialogManagerDelegateDesktop( content::WebContents* web_contents) : JavaScriptTabModalDialogManagerDelegateDesktop(web_contents), web_contents_(web_contents) {} AlloyJavaScriptTabModalDialogManagerDelegateDesktop( const AlloyJavaScriptTabModalDialogManagerDelegateDesktop&) = delete; AlloyJavaScriptTabModalDialogManagerDelegateDesktop& operator=( const AlloyJavaScriptTabModalDialogManagerDelegateDesktop&) = delete; // javascript_dialogs::TabModalDialogManagerDelegate methods: void WillRunDialog() override {} void DidCloseDialog() override {} void SetTabNeedsAttention(bool attention) override {} bool IsWebContentsForemost() override { if (auto browser = CefBrowserHostBase::GetBrowserForContents(web_contents_)) { return browser->IsVisible(); } return false; } bool IsApp() override { return false; } private: // The WebContents for the tab over which the dialog will be modal. This may // be different from the WebContents that requested the dialog, such as with // Chrome app s. raw_ptr web_contents_; }; } // namespace std::unique_ptr CreateAlloyJavaScriptTabModalDialogManagerDelegateDesktop( content::WebContents* web_contents) { return std::make_unique( web_contents); }