Extending SWebBrowser

Hello all,

I’m trying to extend the SWebBrowser in C++, more specifically the UWebBrowser that can be used in blueprints. What I’m trying to accomplish is being able to call the “ExecuteJavascript” function found in the SWebBrowser. I’ve tried to essentially copy over the UWebBrowser to another class and to just add the ExecuteJavascript function but because UWebBrowser is a plugin.

Currently the issue is it’s saying SWebBrowser is undefined which is the biggest issue followed by “SNew” not being defined.

MyWebBrowser.h

// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "Components/Widget.h"
#include "Runtime/WebBrowser/Public/SWebBrowser.h"
#include "Runtime/Slate/Public/SlateBasics.h"
#include "MyWebBrowser.generated.h"

/**
 * 
 */
UCLASS()
class MY_API UMYWebBrowser : public UWidget
{
	GENERATED_UCLASS_BODY()

public:

	/**
	* Load the specified URL
	*
	* @param NewURL New URL to load
	*/
	UFUNCTION(BlueprintCallable, Category = "Web Browser")
		void LoadURL(FString NewURL);

	/**
	* Load a string as data to create a web page
	*
	* @param Contents String to load
	* @param DummyURL Dummy URL for the page
	*/
	UFUNCTION(BlueprintCallable, Category = "Web Browser")
		void LoadString(FString Contents, FString DummyURL);

	/**
	* Get the current title of the web page
	*/
	UFUNCTION(BlueprintCallable, Category = "Web Browser")
		FText GetTitleText() const;

public:

	// UWidget interface
	virtual void SynchronizeProperties() override;
	// End of UWidget interface

	virtual void ReleaseSlateResources(bool bReleaseChildren) override;

#if WITH_EDITOR
	virtual const FText GetPaletteCategory() override;
#endif

protected:
	UPROPERTY(EditAnywhere, Category = Appearance)
		FString InitialURL;

	UPROPERTY(EditAnywhere, Category = Appearance)
		bool bSupportsTransparency;

protected:
	TSharedPtr<class SWebBrowser> WebBrowserWidget;

protected:
	// UWidget interface
	virtual TSharedRef<SWidget> RebuildWidget() override;
	// End of UWidget interface
	
	
	
	
};

MyWebBrowser.cpp

// Fill out your copyright notice in the Description page of Project Settings.

#include "MyWebBrowser.h"


#define LOCTEXT_NAMESPACE "MyWebBrowser"

/////////////////////////////////////////////////////
// UMYWebBrowser

UMYWebBrowser::UMYWebBrowser(const FObjectInitializer& ObjectInitializer)
	: Super(ObjectInitializer)
{
	bIsVariable = true;
}

void UMYWebBrowser::LoadURL(FString NewURL)
{
	if (WebBrowserWidget.IsValid())
	{
		return WebBrowserWidget->LoadURL(NewURL);
	}
}

void UMYWebBrowser::LoadString(FString Contents, FString DummyURL)
{
	if (WebBrowserWidget.IsValid())
	{
		return WebBrowserWidget->LoadString(Contents, DummyURL);
	}
}

FText UMYWebBrowser::GetTitleText() const
{
	if (WebBrowserWidget.IsValid())
	{
		return WebBrowserWidget->GetTitleText();
	}

	return FText::GetEmpty();
}

void UMYWebBrowser::ReleaseSlateResources(bool bReleaseChildren)
{
	Super::ReleaseSlateResources(bReleaseChildren);

	WebBrowserWidget.Reset();
}

TSharedRef<SWidget> UMYWebBrowser::RebuildWidget()
{
	if (IsDesignTime())
	{
		return BuildDesignTimeWidget(SNew(SBox)
			.HAlign(HAlign_Center)
			.VAlign(VAlign_Center)
			[
				SNew(STextBlock)
				.Text(LOCTEXT("IDWeb Browser", "IDWeb Browser"))
			]);
	}
	else
	{
		WebBrowserWidget = SNew(SWebBrowser)
			.InitialURL(InitialURL)
			.ShowControls(false)
			.SupportsTransparency(bSupportsTransparency);

		return WebBrowserWidget.ToSharedRef();
	}
}

void UMYWebBrowser::SynchronizeProperties()
{
	Super::SynchronizeProperties();

	if (WebBrowserWidget.IsValid())
	{

	}
}

#if WITH_EDITOR

const FText UMYWebBrowser::GetPaletteCategory()
{
	return LOCTEXT("Experimental", "Experimental");
}

#endif

/////////////////////////////////////////////////////

#undef LOCTEXT_NAMESPACE

Have you tried including SWebBrowser.h in the .cpp file?
#include “SWebBrowser.h”