tab_modal_dialog_manager_delegate.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // Copyright 2020 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. #ifndef COMPONENTS_JAVASCRIPT_DIALOGS_TAB_MODAL_DIALOG_MANAGER_DELEGATE_H_
  5. #define COMPONENTS_JAVASCRIPT_DIALOGS_TAB_MODAL_DIALOG_MANAGER_DELEGATE_H_
  6. #include <string>
  7. #include "base/callback_forward.h"
  8. #include "base/memory/weak_ptr.h"
  9. #include "content/public/browser/javascript_dialog_manager.h"
  10. namespace javascript_dialogs {
  11. class TabModalDialogView;
  12. // This interface provides platform-specific controller functionality to
  13. // TabModalDialogManager.
  14. class TabModalDialogManagerDelegate {
  15. public:
  16. virtual ~TabModalDialogManagerDelegate() = default;
  17. // Factory function for creating a tab modal view.
  18. virtual base::WeakPtr<TabModalDialogView> CreateNewDialog(
  19. content::WebContents* alerting_web_contents,
  20. const std::u16string& title,
  21. content::JavaScriptDialogType dialog_type,
  22. const std::u16string& message_text,
  23. const std::u16string& default_prompt_text,
  24. content::JavaScriptDialogManager::DialogClosedCallback dialog_callback,
  25. base::OnceClosure dialog_closed_callback) = 0;
  26. // Called when a dialog is about to be shown.
  27. virtual void WillRunDialog() = 0;
  28. // Called when a dialog has been hidden.
  29. virtual void DidCloseDialog() = 0;
  30. // Called when a tab should indicate to the user that it needs attention, such
  31. // as when an alert fires from a background tab.
  32. virtual void SetTabNeedsAttention(bool attention) = 0;
  33. // Should return true if the web contents is foremost (i.e. the active tab in
  34. // the active browser window).
  35. virtual bool IsWebContentsForemost() = 0;
  36. // Should return true if this web contents is an app window, such as a PWA.
  37. virtual bool IsApp() = 0;
  38. };
  39. } // namespace javascript_dialogs
  40. #endif // COMPONENTS_JAVASCRIPT_DIALOGS_TAB_MODAL_DIALOG_MANAGER_DELEGATE_H_