Late to the party but for future references and if someone stumbles on to this one
DECLARE_LOG_CATEGORY_EXTERN(LogBrowserVerbose, Verbose, All);
/**
* Extending UE4's Web Browser component to add up page source functionality
* Makes use of WebBrowserWidget
*/
UCLASS()
class EXTENDEDBROWSER_API UExtendedBrowser : public UWebBrowser
{
GENERATED_BODY()
public:
class SWebBrowser;
/** Gets called after extracting Page Source */
UFUNCTION(BlueprintCallable)
void ProcessSource(const FString& content) {}
/** Widget event for extended browser gets called automatically when GetPageSource() returns*/
UPROPERTY(BlueprintAssignable, Category = "PageSource")
FBrowserSourceDelegate OnPageSource;
/**
* BlueprintCallable Asynchronous Page Source function
* Asynchronously calls OnPageSource and Process Source with contents of page
*/
UFUNCTION(BlueprintCallable)
void GetPageSource()
{
TFunction<void(const FString& content)>fp = [this](const FString& content) {
ProcessSource(content);
OnPageSource.Broadcast(content);
PRINTLOG(LogBrowserVerbose,content);
};
WebBrowserWidget->GetSource(fp);
}
};
UCLASS()
class EXTENDEDBROWSER_API ULoginBrowserUI : public UUserWidget
{
GENERATED_BODY()
public:
/** Extended Web Browser Widget with functionality to get page source */
UPROPERTY(EditAnywhere,BlueprintReadWrite,meta = (BindWidget))
UExtendedBrowser* WebbrowserComp;
public:
void NativeConstruct() override;
/** OnSucessful FBLogin Delegate */
UPROPERTY(BlueprintAssignable, BlueprintCallable)
FBrowserSourceDelegate OnPageSource;
};