29#if JUCE_WEB_BROWSER || DOXYGEN
45class JUCE_API WebBrowserComponent :
public Component
59 explicit WebBrowserComponent (
bool unloadPageWhenBrowserIsHidden =
true);
62 ~WebBrowserComponent()
override;
74 void goToURL (
const String& url,
75 const StringArray* headers =
nullptr,
76 const MemoryBlock* postData =
nullptr);
91 static void clearCookies();
101 virtual bool pageAboutToLoad (
const String& newURL) {
ignoreUnused (newURL);
return true; }
104 virtual void pageFinishedLoading (
const String& url) {
ignoreUnused (url); }
116 virtual bool pageLoadHadNetworkError (
const String& errorInfo) {
ignoreUnused (errorInfo);
return true; }
121 virtual void windowCloseRequest() {}
127 virtual void newWindowAttemptingToLoad (
const String& newURL) {
ignoreUnused (newURL); }
131 void paint (Graphics&)
override;
133 void resized()
override;
135 void parentHierarchyChanged()
override;
137 void visibilityChanged()
override;
139 void focusGained (FocusChangeType)
override;
145 friend class WindowsWebView2WebBrowserComponent;
148 struct ConstructWithoutPimpl
150 explicit ConstructWithoutPimpl (
bool unloadOnHide) : unloadWhenHidden (unloadOnHide) {}
151 const bool unloadWhenHidden;
153 explicit WebBrowserComponent (ConstructWithoutPimpl);
157 std::unique_ptr<Pimpl> browser;
158 bool blankPageShown =
false, unloadPageWhenHidden;
160 StringArray lastHeaders;
161 MemoryBlock lastPostData;
163 void reloadLastURL();
164 void checkWindowAssociation();
185 JUCE_NODISCARD WebView2Preferences withDLLLocation (
const File& location)
const {
return with (&WebView2Preferences::dllLocation, location); }
188 WebView2Preferences withUserDataFolder (
const File& folder)
const {
return with (&WebView2Preferences::userDataFolder, folder); }
193 JUCE_NODISCARD WebView2Preferences withStatusBarDisabled()
const {
return with (&WebView2Preferences::disableStatusBar,
true); }
198 JUCE_NODISCARD WebView2Preferences withBuiltInErrorPageDisabled()
const {
return with (&WebView2Preferences::disableBuiltInErrorPage,
true); }
205 JUCE_NODISCARD WebView2Preferences withBackgroundColour (
const Colour& colour)
const
208 jassert (colour.isOpaque() || colour.isTransparent());
210 return with (&WebView2Preferences::backgroundColour, colour);
214 File getDLLLocation()
const {
return dllLocation; }
215 File getUserDataFolder()
const {
return userDataFolder; }
216 bool getIsStatusBarDisabled()
const noexcept {
return disableStatusBar; }
217 bool getIsBuiltInErrorPageDisabled()
const noexcept {
return disableBuiltInErrorPage; }
218 Colour getBackgroundColour()
const {
return backgroundColour; }
222 template <
typename Member,
typename Item>
223 WebView2Preferences with (Member&& member, Item&& item)
const
225 auto options = *
this;
226 options.*member = std::forward<Item> (item);
231 File dllLocation, userDataFolder;
232 bool disableStatusBar =
false, disableBuiltInErrorPage =
false;
233 Colour backgroundColour = Colours::white;
253class WindowsWebView2WebBrowserComponent :
public WebBrowserComponent
270 WindowsWebView2WebBrowserComponent (
bool unloadPageWhenBrowserIsHidden =
true,
271 const WebView2Preferences& preferences = {});
275 explicit WindowsWebView2WebBrowserComponent (
bool unloadPageWhenBrowserIsHidden =
true,
276 const File& dllLocation = {},
277 const File& userDataFolder = {})
278 : WindowsWebView2WebBrowserComponent (unloadPageWhenBrowserIsHidden,
279 WebView2Preferences().withDLLLocation (dllLocation)
280 .withUserDataFolder (userDataFolder))
#define noexcept
Definition DistrhoDefines.h:72
virtual ASIOError stop()=0
#define JUCE_NODISCARD
Definition juce_CompilerSupport.h:108
#define JUCE_API
Definition juce_StandardHeader.h:152
Definition carla_juce.cpp:31
void ignoreUnused(Types &&...) noexcept
Definition juce_MathsFunctions.h:333
#define const
Definition zconf.h:137