You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
#lockdown Nick.Penwarden #rb none ========================== MAJOR FEATURES + CHANGES ========================== Change 3209340 on 2016/11/23 by Ben.Marsh Convert UE4 codebase to an "include what you use" model - where every header just includes the dependencies it needs, rather than every source file including large monolithic headers like Engine.h and UnrealEd.h. Measured full rebuild times around 2x faster using XGE on Windows, and improvements of 25% or more for incremental builds and full rebuilds on most other platforms. * Every header now includes everything it needs to compile. * There's a CoreMinimal.h header that gets you a set of ubiquitous types from Core (eg. FString, FName, TArray, FVector, etc...). Most headers now include this first. * There's a CoreTypes.h header that sets up primitive UE4 types and build macros (int32, PLATFORM_WIN64, etc...). All headers in Core include this first, as does CoreMinimal.h. * Every .cpp file includes its matching .h file first. * This helps validate that each header is including everything it needs to compile. * No engine code includes a monolithic header such as Engine.h or UnrealEd.h any more. * You will get a warning if you try to include one of these from the engine. They still exist for compatibility with game projects and do not produce warnings when included there. * There have only been minor changes to our internal games down to accommodate these changes. The intent is for this to be as seamless as possible. * No engine code explicitly includes a precompiled header any more. * We still use PCHs, but they're force-included on the compiler command line by UnrealBuildTool instead. This lets us tune what they contain without breaking any existing include dependencies. * PCHs are generated by a tool to get a statistical amount of coverage for the source files using it, and I've seeded the new shared PCHs to contain any header included by > 15% of source files. Tool used to generate this transform is at Engine\Source\Programs\IncludeTool. [CL 3209342 by Ben Marsh in Main branch]
275 lines
6.7 KiB
C++
275 lines
6.7 KiB
C++
// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "AndroidWebBrowserWindow.h"
|
|
#include "AndroidWebBrowserDialog.h"
|
|
#include "AndroidWebBrowserWidget.h"
|
|
#include "AndroidApplication.h"
|
|
#include "AndroidWindow.h"
|
|
#include "AndroidJava.h"
|
|
|
|
#include <jni.h>
|
|
|
|
|
|
namespace {
|
|
|
|
static const FString JSGetSourceCommand = TEXT("GetSource");
|
|
static const FString JSMessageGetSourceScript =
|
|
TEXT("document.location = '") + FAndroidJSScripting::JSMessageTag + JSGetSourceCommand +
|
|
TEXT("/' + encodeURIComponent(document.documentElement.innerHTML);");
|
|
|
|
}
|
|
|
|
FAndroidWebBrowserWindow::FAndroidWebBrowserWindow(FString InUrl, TOptional<FString> InContentsToLoad, bool InShowErrorMessage, bool InThumbMouseButtonNavigation, bool InUseTransparency)
|
|
: CurrentUrl(MoveTemp(InUrl))
|
|
, ContentsToLoad(MoveTemp(InContentsToLoad))
|
|
, DocumentState(EWebBrowserDocumentState::NoDocument)
|
|
, ErrorCode(0)
|
|
, Scripting(new FAndroidJSScripting())
|
|
{
|
|
}
|
|
|
|
FAndroidWebBrowserWindow::~FAndroidWebBrowserWindow()
|
|
{
|
|
CloseBrowser(true);
|
|
}
|
|
|
|
void FAndroidWebBrowserWindow::LoadURL(FString NewURL)
|
|
{
|
|
BrowserWidget->LoadURL(NewURL);
|
|
}
|
|
|
|
void FAndroidWebBrowserWindow::LoadString(FString Contents, FString DummyURL)
|
|
{
|
|
BrowserWidget->LoadString(Contents, DummyURL);
|
|
}
|
|
|
|
TSharedRef<SWidget> FAndroidWebBrowserWindow::CreateWidget()
|
|
{
|
|
TSharedRef<SAndroidWebBrowserWidget> BrowserWidgetRef =
|
|
SNew(SAndroidWebBrowserWidget)
|
|
.InitialURL(CurrentUrl)
|
|
.WebBrowserWindow(SharedThis(this));
|
|
|
|
BrowserWidget = BrowserWidgetRef;
|
|
return BrowserWidgetRef;
|
|
}
|
|
|
|
void FAndroidWebBrowserWindow::SetViewportSize(FIntPoint WindowSize, FIntPoint WindowPos)
|
|
{
|
|
}
|
|
|
|
FSlateShaderResource* FAndroidWebBrowserWindow::GetTexture(bool bIsPopup /*= false*/)
|
|
{
|
|
return nullptr;
|
|
}
|
|
|
|
bool FAndroidWebBrowserWindow::IsValid() const
|
|
{
|
|
return false;
|
|
}
|
|
|
|
bool FAndroidWebBrowserWindow::IsInitialized() const
|
|
{
|
|
return true;
|
|
}
|
|
|
|
bool FAndroidWebBrowserWindow::IsClosing() const
|
|
{
|
|
return false;
|
|
}
|
|
|
|
EWebBrowserDocumentState FAndroidWebBrowserWindow::GetDocumentLoadingState() const
|
|
{
|
|
return DocumentState;
|
|
}
|
|
|
|
FString FAndroidWebBrowserWindow::GetTitle() const
|
|
{
|
|
return Title;
|
|
}
|
|
|
|
FString FAndroidWebBrowserWindow::GetUrl() const
|
|
{
|
|
return CurrentUrl;
|
|
}
|
|
|
|
bool FAndroidWebBrowserWindow::OnKeyDown(const FKeyEvent& InKeyEvent)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
bool FAndroidWebBrowserWindow::OnKeyUp(const FKeyEvent& InKeyEvent)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
bool FAndroidWebBrowserWindow::OnKeyChar(const FCharacterEvent& InCharacterEvent)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
FReply FAndroidWebBrowserWindow::OnMouseButtonDown(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent, bool bIsPopup)
|
|
{
|
|
return FReply::Unhandled();
|
|
}
|
|
|
|
FReply FAndroidWebBrowserWindow::OnMouseButtonUp(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent, bool bIsPopup)
|
|
{
|
|
return FReply::Unhandled();
|
|
}
|
|
|
|
FReply FAndroidWebBrowserWindow::OnMouseButtonDoubleClick(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent, bool bIsPopup)
|
|
{
|
|
return FReply::Unhandled();
|
|
}
|
|
|
|
FReply FAndroidWebBrowserWindow::OnMouseMove(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent, bool bIsPopup)
|
|
{
|
|
return FReply::Unhandled();
|
|
}
|
|
|
|
FReply FAndroidWebBrowserWindow::OnMouseWheel(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent, bool bIsPopup)
|
|
{
|
|
return FReply::Unhandled();
|
|
}
|
|
|
|
void FAndroidWebBrowserWindow::OnFocus(bool SetFocus, bool bIsPopup)
|
|
{
|
|
}
|
|
|
|
void FAndroidWebBrowserWindow::OnCaptureLost()
|
|
{
|
|
}
|
|
|
|
bool FAndroidWebBrowserWindow::CanGoBack() const
|
|
{
|
|
return BrowserWidget->CanGoBack();
|
|
}
|
|
|
|
void FAndroidWebBrowserWindow::GoBack()
|
|
{
|
|
BrowserWidget->GoBack();
|
|
}
|
|
|
|
bool FAndroidWebBrowserWindow::CanGoForward() const
|
|
{
|
|
return BrowserWidget->CanGoForward();
|
|
}
|
|
|
|
void FAndroidWebBrowserWindow::GoForward()
|
|
{
|
|
BrowserWidget->GoForward();
|
|
}
|
|
|
|
bool FAndroidWebBrowserWindow::IsLoading() const
|
|
{
|
|
return DocumentState != EWebBrowserDocumentState::Loading;
|
|
}
|
|
|
|
void FAndroidWebBrowserWindow::Reload()
|
|
{
|
|
BrowserWidget->Reload();
|
|
}
|
|
|
|
void FAndroidWebBrowserWindow::StopLoad()
|
|
{
|
|
BrowserWidget->StopLoad();
|
|
}
|
|
|
|
void FAndroidWebBrowserWindow::GetSource(TFunction<void (const FString&)> Callback) const
|
|
{
|
|
//@todo: decide what to do about multiple pending requests
|
|
GetPageSourceCallback.Emplace(Callback);
|
|
|
|
// Ugly hack: Work around the fact that ExecuteJavascript is non-const.
|
|
const_cast<FAndroidWebBrowserWindow*>(this)->ExecuteJavascript(JSMessageGetSourceScript);
|
|
}
|
|
|
|
int FAndroidWebBrowserWindow::GetLoadError()
|
|
{
|
|
return ErrorCode;
|
|
}
|
|
|
|
void FAndroidWebBrowserWindow::NotifyDocumentError(const FString& InCurrentUrl, int InErrorCode)
|
|
{
|
|
if(!CurrentUrl.Equals(InCurrentUrl, ESearchCase::CaseSensitive))
|
|
{
|
|
CurrentUrl = InCurrentUrl;
|
|
UrlChangedEvent.Broadcast(CurrentUrl);
|
|
}
|
|
|
|
ErrorCode = InErrorCode;
|
|
DocumentState = EWebBrowserDocumentState::Error;
|
|
DocumentStateChangedEvent.Broadcast(DocumentState);
|
|
}
|
|
|
|
void FAndroidWebBrowserWindow::NotifyDocumentLoadingStateChange(const FString& InCurrentUrl, bool IsLoading)
|
|
{
|
|
// Ignore a load completed notification if there was an error.
|
|
// For load started, reset any errors from previous page load.
|
|
if (IsLoading || DocumentState != EWebBrowserDocumentState::Error)
|
|
{
|
|
if(!CurrentUrl.Equals(InCurrentUrl, ESearchCase::CaseSensitive))
|
|
{
|
|
CurrentUrl = InCurrentUrl;
|
|
UrlChangedEvent.Broadcast(CurrentUrl);
|
|
}
|
|
|
|
if(!IsLoading && !InCurrentUrl.StartsWith("javascript:"))
|
|
{
|
|
Scripting->PageLoaded(SharedThis(this));
|
|
}
|
|
ErrorCode = 0;
|
|
DocumentState = IsLoading
|
|
? EWebBrowserDocumentState::Loading
|
|
: EWebBrowserDocumentState::Completed;
|
|
DocumentStateChangedEvent.Broadcast(DocumentState);
|
|
}
|
|
|
|
}
|
|
|
|
void FAndroidWebBrowserWindow::SetIsDisabled(bool bValue)
|
|
{
|
|
}
|
|
|
|
TSharedPtr<SWindow> FAndroidWebBrowserWindow::GetParentWindow() const
|
|
{
|
|
return ParentWindow;
|
|
}
|
|
|
|
void FAndroidWebBrowserWindow::SetParentWindow(TSharedPtr<SWindow> Window)
|
|
{
|
|
ParentWindow = Window;
|
|
}
|
|
|
|
void FAndroidWebBrowserWindow::ExecuteJavascript(const FString& Script)
|
|
{
|
|
BrowserWidget->ExecuteJavascript(Script);
|
|
}
|
|
|
|
void FAndroidWebBrowserWindow::CloseBrowser(bool bForce)
|
|
{
|
|
BrowserWidget->Close();
|
|
}
|
|
|
|
bool FAndroidWebBrowserWindow::OnJsMessageReceived(const FString& Command, const TArray<FString>& Params, const FString& Origin)
|
|
{
|
|
if( Command.Equals(JSGetSourceCommand, ESearchCase::CaseSensitive) && GetPageSourceCallback.IsSet() && Params.Num() == 1)
|
|
{
|
|
GetPageSourceCallback.GetValue()(Params[0]);
|
|
GetPageSourceCallback.Reset();
|
|
return true;
|
|
}
|
|
return Scripting->OnJsMessageReceived(Command, Params, Origin);
|
|
}
|
|
|
|
void FAndroidWebBrowserWindow::BindUObject(const FString& Name, UObject* Object, bool bIsPermanent /*= true*/)
|
|
{
|
|
Scripting->BindUObject(Name, Object, bIsPermanent);
|
|
}
|
|
|
|
void FAndroidWebBrowserWindow::UnbindUObject(const FString& Name, UObject* Object /*= nullptr*/, bool bIsPermanent /*= true*/)
|
|
{
|
|
Scripting->UnbindUObject(Name, Object, bIsPermanent);
|
|
}
|