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.

juce_WebBrowserComponent.h 5.0KB

9 years ago
9 years ago
9 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2015 - ROLI 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. /** This callback occurs when the browser attempts to load a URL in a new window.
  76. This won't actually load the window but gives you a chance to either launch a
  77. new window yourself or just load the URL into the current window with goToURL().
  78. */
  79. virtual void newWindowAttemptingToLoad (const String& newURL);
  80. //==============================================================================
  81. /** @internal */
  82. void paint (Graphics&) override;
  83. /** @internal */
  84. void resized() override;
  85. /** @internal */
  86. void parentHierarchyChanged() override;
  87. /** @internal */
  88. void visibilityChanged() override;
  89. /** @internal */
  90. void focusGained (FocusChangeType) override;
  91. private:
  92. //==============================================================================
  93. class Pimpl;
  94. Pimpl* browser;
  95. bool blankPageShown, unloadPageWhenBrowserIsHidden;
  96. String lastURL;
  97. StringArray lastHeaders;
  98. MemoryBlock lastPostData;
  99. void reloadLastURL();
  100. void checkWindowAssociation();
  101. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (WebBrowserComponent)
  102. };
  103. #endif
  104. #endif // JUCE_WEBBROWSERCOMPONENT_H_INCLUDED