single_web_contents_dialog_manager.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. // Copyright 2014 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_WEB_MODAL_SINGLE_WEB_CONTENTS_DIALOG_MANAGER_H_
  5. #define COMPONENTS_WEB_MODAL_SINGLE_WEB_CONTENTS_DIALOG_MANAGER_H_
  6. #include "ui/gfx/native_widget_types.h"
  7. namespace content {
  8. class WebContents;
  9. } // namespace content
  10. namespace web_modal {
  11. class WebContentsModalDialogHost;
  12. // Interface from SingleWebContentsDialogManager to
  13. // WebContentsModalDialogManager.
  14. class SingleWebContentsDialogManagerDelegate {
  15. public:
  16. SingleWebContentsDialogManagerDelegate() {}
  17. SingleWebContentsDialogManagerDelegate(
  18. const SingleWebContentsDialogManagerDelegate&) = delete;
  19. SingleWebContentsDialogManagerDelegate& operator=(
  20. const SingleWebContentsDialogManagerDelegate&) = delete;
  21. virtual ~SingleWebContentsDialogManagerDelegate() {}
  22. virtual content::WebContents* GetWebContents() const = 0;
  23. // Notify the delegate that the dialog is closing. The native
  24. // manager will be deleted before the end of this call.
  25. virtual void WillClose(gfx::NativeWindow dialog) = 0;
  26. };
  27. // Provides an interface for platform-specific UI implementation for the web
  28. // contents modal dialog. Each object will manage a single dialog window
  29. // during its lifecycle.
  30. //
  31. // Implementation classes should accept a dialog window at construction time
  32. // and register to be notified when the dialog is closing, so that it can
  33. // notify its delegate (WillClose method).
  34. class SingleWebContentsDialogManager {
  35. public:
  36. SingleWebContentsDialogManager(const SingleWebContentsDialogManager&) =
  37. delete;
  38. SingleWebContentsDialogManager& operator=(
  39. const SingleWebContentsDialogManager&) = delete;
  40. virtual ~SingleWebContentsDialogManager() {}
  41. // Makes the web contents modal dialog visible. Only one web contents modal
  42. // dialog is shown at a time per tab.
  43. virtual void Show() = 0;
  44. // Hides the web contents modal dialog without closing it.
  45. virtual void Hide() = 0;
  46. // Closes the web contents modal dialog.
  47. // If this method causes a WillClose() call to the delegate, the manager
  48. // will be deleted at the close of that invocation.
  49. virtual void Close() = 0;
  50. // Sets focus on the web contents modal dialog.
  51. virtual void Focus() = 0;
  52. // Runs a pulse animation for the web contents modal dialog.
  53. virtual void Pulse() = 0;
  54. // Called when the host view for the dialog has changed.
  55. virtual void HostChanged(WebContentsModalDialogHost* new_host) = 0;
  56. // Return the dialog under management by this object.
  57. virtual gfx::NativeWindow dialog() = 0;
  58. protected:
  59. SingleWebContentsDialogManager() {}
  60. };
  61. } // namespace web_modal
  62. #endif // COMPONENTS_WEB_MODAL_SINGLE_WEB_CONTENTS_DIALOG_MANAGER_H_