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