Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

129 lines
4.6KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2013 - Raw Material Software Ltd.
  5. Permission is granted to use this software under the terms of either:
  6. a) the GPL v2 (or any later version)
  7. b) the Affero GPL v3
  8. Details of these licenses can be found at: www.gnu.org/licenses
  9. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  10. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  11. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  12. ------------------------------------------------------------------------------
  13. To release a closed-source product which uses JUCE, commercial licenses are
  14. available: visit www.juce.com for more information.
  15. ==============================================================================
  16. */
  17. #ifndef JUCE_WEBBROWSERCOMPONENT_H_INCLUDED
  18. #define JUCE_WEBBROWSERCOMPONENT_H_INCLUDED
  19. #if JUCE_WEB_BROWSER || DOXYGEN
  20. //==============================================================================
  21. /**
  22. A component that displays an embedded web browser.
  23. The browser itself will be platform-dependent. On the Mac, probably Safari, on
  24. Windows, probably IE.
  25. */
  26. class JUCE_API WebBrowserComponent : public Component
  27. {
  28. public:
  29. //==============================================================================
  30. /** Creates a WebBrowserComponent.
  31. Once it's created and visible, send the browser to a URL using goToURL().
  32. @param unloadPageWhenBrowserIsHidden if this is true, then when the browser
  33. component is taken offscreen, it'll clear the current page
  34. and replace it with a blank page - this can be handy to stop
  35. the browser using resources in the background when it's not
  36. actually being used.
  37. */
  38. explicit WebBrowserComponent (bool unloadPageWhenBrowserIsHidden = true);
  39. /** Destructor. */
  40. ~WebBrowserComponent();
  41. //==============================================================================
  42. /** Sends the browser to a particular URL.
  43. @param url the URL to go to.
  44. @param headers an optional set of parameters to put in the HTTP header. If
  45. you supply this, it should be a set of string in the form
  46. "HeaderKey: HeaderValue"
  47. @param postData an optional block of data that will be attached to the HTTP
  48. POST request
  49. */
  50. void goToURL (const String& url,
  51. const StringArray* headers = nullptr,
  52. const MemoryBlock* postData = nullptr);
  53. /** Stops the current page loading. */
  54. void stop();
  55. /** Sends the browser back one page. */
  56. void goBack();
  57. /** Sends the browser forward one page. */
  58. void goForward();
  59. /** Refreshes the browser. */
  60. void refresh();
  61. //==============================================================================
  62. /** This callback is called when the browser is about to navigate
  63. to a new location.
  64. You can override this method to perform some action when the user
  65. tries to go to a particular URL. To allow the operation to carry on,
  66. return true, or return false to stop the navigation happening.
  67. */
  68. virtual bool pageAboutToLoad (const String& newURL);
  69. /** This callback happens when the browser has finished loading a page. */
  70. virtual void pageFinishedLoading (const String& url);
  71. /** This callback occurs when a script or other activity in the browser asks for
  72. the window to be closed.
  73. */
  74. virtual void windowCloseRequest();
  75. //==============================================================================
  76. /** @internal */
  77. void paint (Graphics&) override;
  78. /** @internal */
  79. void resized() override;
  80. /** @internal */
  81. void parentHierarchyChanged() override;
  82. /** @internal */
  83. void visibilityChanged() override;
  84. private:
  85. //==============================================================================
  86. class Pimpl;
  87. Pimpl* browser;
  88. bool blankPageShown, unloadPageWhenBrowserIsHidden;
  89. String lastURL;
  90. StringArray lastHeaders;
  91. MemoryBlock lastPostData;
  92. void reloadLastURL();
  93. void checkWindowAssociation();
  94. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (WebBrowserComponent)
  95. };
  96. #endif
  97. #endif // JUCE_WEBBROWSERCOMPONENT_H_INCLUDED