46 using completionHandlerFunc = std::function<void(
const char* result)>;
53 IWebView(
bool opaque =
true,
bool enableDevTools =
false,
const char* customUrlScheme =
"");
56 void* OpenWebView(
void* pParent,
float x,
float y,
float w,
float h,
float scale = 1.0f);
58 void HideWebView(
bool hide);
70 void LoadFile(
const char* fileName,
const char* bundleID =
"");
137 std::unique_ptr<IWebViewImpl> mpImpl;
139 bool mEnableDevTools =
false;
140 WDL_String mCustomUrlScheme;
IPlug logging a.k.a tracing functionality.
IWebView is a base interface for hosting a platform web view inside an IPlug plug-in's UI.
virtual bool OnCanDownloadMIMEType(const char *mimeType)
Override to filter MIME types that should be downloaded.
void EnableInteraction(bool enable)
Sets whether the webview is interactive.
void EvaluateJavaScript(const char *scriptStr, completionHandlerFunc func=nullptr)
Runs some JavaScript in the webview.
virtual bool OnCanNavigateToURL(const char *url)
Override to filter URLs.
void EnableScroll(bool enable)
Enable scrolling on the webview.
void LoadFile(const char *fileName, const char *bundleID="")
Load a file on disk into the web view.
virtual void OnDownloadedFile(const char *path)
Override to handle file download success.
const char * GetCustomUrlScheme() const
Returns the custom URL scheme, if set.
virtual void OnFailedToDownloadFile(const char *path)
Override to handle file download failure.
void LoadHTML(const char *html)
Load an HTML string into the webview.
void SetCustomUrlScheme(const char *customUrlScheme)
Used to set the URL scheme after the IWebView has been contstructed;.
bool IsOpaque() const
True if the webview was configured opaque.
virtual void OnWebContentLoaded()
Called after navigation instructions have been exectued and e.g.
void LoadURL(const char *url)
Instruct the webview to load an external URL.
virtual void OnGetLocalDownloadPathForFile(const char *fileName, WDL_String &localPath)
Override to download the file to a specific location other than e.g.
void SetWebViewBounds(float x, float y, float w, float h, float scale=1.)
Set the bounds of the webview in the parent window.
virtual void OnWebViewReady()
Called when the web view is ready to receive navigation instructions.
void SetEnableDevTools(bool enable)
Used to toggle devtools after the IWebView has been contstructed.
void GetWebRoot(WDL_String &path) const
Fills the path where web content is being served from, when LoadFile() is used.
virtual void OnMessageFromWebView(const char *json)
When a script in the web view posts a message, it will arrive as a UTF8 json string here.
void ReloadPageContent()
Trigger a reload of the webview's content.
virtual void OnReceivedData(size_t numBytesReceived, size_t totalNumBytes)
Override to handle file download progress.
IWebView(bool opaque=true, bool enableDevTools=false, const char *customUrlScheme="")
Constructs an IWebView.
bool GetEnableDevTools() const
Are developer tools enabled on this webview.