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. //==============================================================================
  22. /**
  23. A component that displays an embedded web browser.
  24. The browser itself will be platform-dependent. On the Mac, probably Safari, on
  25. Windows, probably IE.
  26. */
  27. class JUCE_API WebBrowserComponent : public Component
  28. {
  29. public:
  30. //==============================================================================
  31. /** Creates a WebBrowserComponent.
  32. Once it's created and visible, send the browser to a URL using goToURL().
  33. @param unloadPageWhenBrowserIsHidden if this is true, then when the browser
  34. component is taken offscreen, it'll clear the current page
  35. and replace it with a blank page - this can be handy to stop
  36. the browser using resources in the background when it's not
  37. actually being used.
  38. */
  39. explicit WebBrowserComponent (bool unloadPageWhenBrowserIsHidden = true);
  40. /** Destructor. */
  41. ~WebBrowserComponent();
  42. //==============================================================================
  43. /** Sends the browser to a particular URL.
  44. @param url the URL to go to.
  45. @param headers an optional set of parameters to put in the HTTP header. If
  46. you supply this, it should be a set of string in the form
  47. "HeaderKey: HeaderValue"
  48. @param postData an optional block of data that will be attached to the HTTP
  49. POST request
  50. */
  51. void goToURL (const String& url,
  52. const StringArray* headers = nullptr,
  53. const MemoryBlock* postData = nullptr);
  54. /** Stops the current page loading.
  55. */
  56. void stop();
  57. /** Sends the browser back one page.
  58. */
  59. void goBack();
  60. /** Sends the browser forward one page.
  61. */
  62. void goForward();
  63. /** Refreshes the browser.
  64. */
  65. void refresh();
  66. //==============================================================================
  67. /** This callback is called when the browser is about to navigate
  68. to a new location.
  69. You can override this method to perform some action when the user
  70. tries to go to a particular URL. To allow the operation to carry on,
  71. return true, or return false to stop the navigation happening.
  72. */
  73. virtual bool pageAboutToLoad (const String& newURL);
  74. /** This callback happens when the browser has finished loading a page. */
  75. virtual void pageFinishedLoading (const String& url);
  76. //==============================================================================
  77. /** @internal */
  78. void paint (Graphics& g);
  79. /** @internal */
  80. void resized();
  81. /** @internal */
  82. void parentHierarchyChanged();
  83. /** @internal */
  84. void visibilityChanged();
  85. private:
  86. //==============================================================================
  87. class Pimpl;
  88. Pimpl* 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__