Files
UnrealEngineUWP/Engine/Source/Programs/UnrealCEFSubProcess/Private/UnrealCEFSubProcessRemoteScripting.cpp

392 lines
12 KiB
C++
Raw Normal View History

// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.
#include "UnrealCEFSubProcessRemoteScripting.h"
Copying //UE4/Dev-Build to //UE4/Dev-Main (Source: //UE4/Dev-Build @ 3209340) #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]
2016-11-23 15:48:37 -05:00
#include "UnrealCEFSubProcess.h"
#include "UnrealCEFSubProcessRemoteMethodHandler.h"
#if WITH_CEF3
CefRefPtr<CefV8Value> FUnrealCEFSubProcessRemoteScripting::CefToV8(CefRefPtr<CefDictionaryValue> Dictionary)
{
// Custom types are encoded inside dictionary values with a $type and a $value property
if ( Dictionary->GetType("$type") == VTYPE_STRING)
{
FString Type = WCHAR_TO_TCHAR(Dictionary->GetString("$type").ToWString().c_str());
if ( Type == "struct" && Dictionary->GetType("$value") == VTYPE_DICTIONARY)
{
return CefToPlainV8Object(Dictionary->GetDictionary("$value"));
}
if ( Type == "uobject" && Dictionary->GetType("$id") == VTYPE_STRING && Dictionary->GetType("$methods") == VTYPE_LIST)
{
FGuid Guid;
if (FGuid::Parse(WCHAR_TO_TCHAR(Dictionary->GetString("$id").ToWString().c_str()), Guid))
{
CefRefPtr<CefListValue> Methods = Dictionary->GetList("$methods");
return CreateUObjectProxy(Guid, Methods);
}
}
}
return CefToPlainV8Object(Dictionary);
}
CefRefPtr<CefV8Value> FUnrealCEFSubProcessRemoteScripting::CreateUObjectProxy(FGuid ObjectId, CefRefPtr<CefListValue> Methods)
{
CefRefPtr<CefV8Context> Context = CefV8Context::GetCurrentContext();
CefRefPtr<CefBrowser> Browser = Context->GetBrowser();
#if PLATFORM_LINUX
CefRefPtr<CefV8Value> Result = CefV8Value::CreateObject(nullptr);
#else
Copying //UE4/Portal-Staging to //UE4/Dev-Main (Source: //UE4/Portal-Staging @ 3592606) #rb none #lockdown Nick.Penwarden ============================ MAJOR FEATURES & CHANGES ============================ Change 3520569 by Leigh.Swift Adding chunkdb support to BPS installer as a chunk source for installations. Chunk db filenames are provided on the installer configuration struct, and will be used to load chunks needed for the installation. Chunk db source shares a chunk store with the cloud source. Adding message pump implementation for installer which can be used to surface events or messages to handlers added to the installer. Currently just takes chunk source events for losing access to the chunkdb files. Adding concept of new runtime requirements and callback for unavailable chunks to chunk source base API. Chained chunk source cascades broadcasted unavailable chunks down to other sources as new requirements. #jira OPP-7191: Add chunkdb source support to BPS Adding support for passing chunkdb files to created installers. Storing chunkdb filenames used for installation in pending manifest so they can be re-used when resuming. Exposing chunkdb source events to UI as warning triangle. #jira OPP-7191: Add chunkdb source support to BPS Change 3508964 by Wes.Fudala CL# 3431076 - Upgrade Win32, Win64, and Mac to latest CEF branch 3071. Adds browser support for foreign language character input via IME. #jira OPP-4400 Non-Roman characters from an IME cannot be typed into CEF based views Change 3506884 by Leigh.Swift #jira OPP-6981: Make sign-in screen a web page WebBrowser: Adding support to WebBrowser module for implementing custom protocol/scheme handlers. Currently works for CEF integration only. WebBrowser: Adding support to override the user-agent version string when initialising the web browser module. PortalBuild: Additionally shipping the contents of /Portal/Content/Web with full launchers. Portal: Adding web content for sign in, background, and web test pages. Portal: Added a high version number setup for WebBrowser when running debug so that latest code always gets latest websites. Portal: Removing old slate sign in screens, and associated code. Portal: Adding bIsThirdParty bool to some AccountService functions to allow to handle not yet having information about account types returned from the backend to deside if an account can be used with a password sign in. Portal: Removing unnecessary use of email in the AccountService::AutoSignIn API. Portal: Replacing old logging in overlay with a 'ShowLongProcessOverlay' API for systems that still use that (e.g. vault cach location select, waiting room). Portal: UI: Adding a null state to sign in router so resources can be cleaned up. Portal: UI: Adding web states for all screens on sign in router. Portal: DebugTools: Adding a web developer section, with a refresh all browsers button to help with web iteration. Portal: DebugTools: Fixing all test JS to use lowercased api calls. Portal: Implementing new client:// scheme handler for WebBrowser which local pages will use. Portal: RememberMe: Exposing additional user info, LastName and whether the account can auth with a password. Portal: Temporary dynamic background image implementation and javascript bridge. Portal: Sign in screen is now driven by a web page, and javascript API. Portal: UIRouter: Improved handling of redirects and tracking of state changes via redirects. Change 3471216 by Leigh.Swift Extending BPT VerifyChunks mode to check manifests are loadable and do not reference broken data, and also to output bad files to a text file passed in on commandline. Change 3469441 by Richard.Fawcett Add support for disc icon to packaging game ISO #jira OPP-7311: Implement icon file for disc Change 3468243 by Wes.Fudala Adds support for branding windows installers. #jira OPP-7190: Create game bootstrap msi (Windows) Change 3456485 by Richard.Fawcett Create new C# wrapper around BuildPatchTool to call the (as yet unimplemented) PackageChunks mode. Implement new tool mode in PortalPublishingTool which takes game name and build version, finds manifest files, and executes BuildPatchTool for each platform, with the option to restrict to a single platform via the commandline. Build script changes to allow the Package Chunks job to be called from Electric Commander. This includes refactoring the setup of PortalPublishingTool to a new node which the package chunks job, and the existing build diff job depend on. #jira OPP-7193: Create 'package chunks' job Change 3446665 by Jacob.Hedges CL# 3430618 - Added App Installation, Engine Installation, and Plugin Installation test suites. Create Social gadget for interacting with the social panel. Added Portal Automation Helper that exposes the UIRouter, and changed existing tests and Screens to utilize URI navigation. Added various metadata tags. #jira OPP-7155 #jira QAENG-1075 #jira QAENG-1076 #jira QAENG-1079 #jira QAENG-1080 Change 3420598 by Richard.Fawcett Use Prerequisite Ids to track which prerequisistes have been installed on a user's system. #jira OPP-6007: Upgrade prereq installer so that it checks versions instead of file hashes - Part 1 Change 3410773 by Richard.Fawcett Implement project-specific retention periods for automated cleanup routines. Additional changes: * Remove VerifyManifestFilenames as it makes no sense for manifest filenames to have to conform to a specific pattern now that we have randomized manifest filenames. * Add support for detecting build versions from Win32 manifest files by tweaking regex. * DeleteUnreferencedManifestsFromCDN: Avoid parsing version strings when we're not in SimulateCDN mode as we're only interested in the result if we're filtering "old" manifests by CL (i.e. simulating) rather than having the date of real files from the folder. * Add -SkipProd flag to periodic rocket cleanup to enable us to run operations that only touch gamedev. This aids debugging as prod environment is firewalled from developer workstations. Change 3377027 by Leigh.Swift #jira OPP-6911: Launcher.Install.Stats Changes Adding specific process timers for each stage that we want to time, replacing any individual logic. Verifier no longer needs to provide the TimeSpentPaused output, since it is now given knowledge of pause state via external dependancy, it doesn't need to be responsible for providing the pause timer. Rearranging Launcher.Build.Stats analytics events according to new spec and desires. Also cleaning up some GLog->UE_LOG. Change 3374573 by Jacob.Hedges Copying //Tasks/Portal/Dev-UIAutomation to Dev-Main (//Portal/Dev-Main) Added new functional testsuite for the launcher, including metadata tags for relevant elements Added new functionality to ID and Path searches for the automation driver to start the search from a specified element Changed selective download components to utilize SCheckBox instead of SButton #jira OPP-6973 [CL 3592632 by Antony Carter in Main branch]
2017-08-17 06:28:58 -04:00
CefRefPtr<CefV8Value> Result = CefV8Value::CreateObject(nullptr, nullptr);
#endif
CefRefPtr<FUnrealCEFSubProcessRemoteObject> Remote = new FUnrealCEFSubProcessRemoteObject(this, Browser, ObjectId);
for (size_t I=0; I < Methods->GetSize(); ++I)
{
CefString MethodName = Methods->GetString(I);
CefRefPtr<CefV8Value> FunctionProxy = CefV8Value::CreateFunction(MethodName, new FUnrealCEFSubProcessRemoteMethodHandler(Remote, MethodName));
Result->SetValue(MethodName, FunctionProxy, static_cast<CefV8Value::PropertyAttribute>(V8_PROPERTY_ATTRIBUTE_DONTDELETE | V8_PROPERTY_ATTRIBUTE_READONLY ));
}
Result->SetValue("$id", CefV8Value::CreateString(TCHAR_TO_WCHAR(*ObjectId.ToString(EGuidFormats::Digits))), static_cast<CefV8Value::PropertyAttribute>(V8_PROPERTY_ATTRIBUTE_DONTDELETE | V8_PROPERTY_ATTRIBUTE_READONLY | V8_PROPERTY_ATTRIBUTE_DONTENUM));
return Result;
}
CefRefPtr<CefV8Value> FUnrealCEFSubProcessRemoteScripting::CefToPlainV8Object(CefRefPtr<CefDictionaryValue> Dictionary)
{
#if PLATFORM_LINUX
CefRefPtr<CefV8Value> Result = CefV8Value::CreateObject(nullptr);
#else
Copying //UE4/Portal-Staging to //UE4/Dev-Main (Source: //UE4/Portal-Staging @ 3592606) #rb none #lockdown Nick.Penwarden ============================ MAJOR FEATURES & CHANGES ============================ Change 3520569 by Leigh.Swift Adding chunkdb support to BPS installer as a chunk source for installations. Chunk db filenames are provided on the installer configuration struct, and will be used to load chunks needed for the installation. Chunk db source shares a chunk store with the cloud source. Adding message pump implementation for installer which can be used to surface events or messages to handlers added to the installer. Currently just takes chunk source events for losing access to the chunkdb files. Adding concept of new runtime requirements and callback for unavailable chunks to chunk source base API. Chained chunk source cascades broadcasted unavailable chunks down to other sources as new requirements. #jira OPP-7191: Add chunkdb source support to BPS Adding support for passing chunkdb files to created installers. Storing chunkdb filenames used for installation in pending manifest so they can be re-used when resuming. Exposing chunkdb source events to UI as warning triangle. #jira OPP-7191: Add chunkdb source support to BPS Change 3508964 by Wes.Fudala CL# 3431076 - Upgrade Win32, Win64, and Mac to latest CEF branch 3071. Adds browser support for foreign language character input via IME. #jira OPP-4400 Non-Roman characters from an IME cannot be typed into CEF based views Change 3506884 by Leigh.Swift #jira OPP-6981: Make sign-in screen a web page WebBrowser: Adding support to WebBrowser module for implementing custom protocol/scheme handlers. Currently works for CEF integration only. WebBrowser: Adding support to override the user-agent version string when initialising the web browser module. PortalBuild: Additionally shipping the contents of /Portal/Content/Web with full launchers. Portal: Adding web content for sign in, background, and web test pages. Portal: Added a high version number setup for WebBrowser when running debug so that latest code always gets latest websites. Portal: Removing old slate sign in screens, and associated code. Portal: Adding bIsThirdParty bool to some AccountService functions to allow to handle not yet having information about account types returned from the backend to deside if an account can be used with a password sign in. Portal: Removing unnecessary use of email in the AccountService::AutoSignIn API. Portal: Replacing old logging in overlay with a 'ShowLongProcessOverlay' API for systems that still use that (e.g. vault cach location select, waiting room). Portal: UI: Adding a null state to sign in router so resources can be cleaned up. Portal: UI: Adding web states for all screens on sign in router. Portal: DebugTools: Adding a web developer section, with a refresh all browsers button to help with web iteration. Portal: DebugTools: Fixing all test JS to use lowercased api calls. Portal: Implementing new client:// scheme handler for WebBrowser which local pages will use. Portal: RememberMe: Exposing additional user info, LastName and whether the account can auth with a password. Portal: Temporary dynamic background image implementation and javascript bridge. Portal: Sign in screen is now driven by a web page, and javascript API. Portal: UIRouter: Improved handling of redirects and tracking of state changes via redirects. Change 3471216 by Leigh.Swift Extending BPT VerifyChunks mode to check manifests are loadable and do not reference broken data, and also to output bad files to a text file passed in on commandline. Change 3469441 by Richard.Fawcett Add support for disc icon to packaging game ISO #jira OPP-7311: Implement icon file for disc Change 3468243 by Wes.Fudala Adds support for branding windows installers. #jira OPP-7190: Create game bootstrap msi (Windows) Change 3456485 by Richard.Fawcett Create new C# wrapper around BuildPatchTool to call the (as yet unimplemented) PackageChunks mode. Implement new tool mode in PortalPublishingTool which takes game name and build version, finds manifest files, and executes BuildPatchTool for each platform, with the option to restrict to a single platform via the commandline. Build script changes to allow the Package Chunks job to be called from Electric Commander. This includes refactoring the setup of PortalPublishingTool to a new node which the package chunks job, and the existing build diff job depend on. #jira OPP-7193: Create 'package chunks' job Change 3446665 by Jacob.Hedges CL# 3430618 - Added App Installation, Engine Installation, and Plugin Installation test suites. Create Social gadget for interacting with the social panel. Added Portal Automation Helper that exposes the UIRouter, and changed existing tests and Screens to utilize URI navigation. Added various metadata tags. #jira OPP-7155 #jira QAENG-1075 #jira QAENG-1076 #jira QAENG-1079 #jira QAENG-1080 Change 3420598 by Richard.Fawcett Use Prerequisite Ids to track which prerequisistes have been installed on a user's system. #jira OPP-6007: Upgrade prereq installer so that it checks versions instead of file hashes - Part 1 Change 3410773 by Richard.Fawcett Implement project-specific retention periods for automated cleanup routines. Additional changes: * Remove VerifyManifestFilenames as it makes no sense for manifest filenames to have to conform to a specific pattern now that we have randomized manifest filenames. * Add support for detecting build versions from Win32 manifest files by tweaking regex. * DeleteUnreferencedManifestsFromCDN: Avoid parsing version strings when we're not in SimulateCDN mode as we're only interested in the result if we're filtering "old" manifests by CL (i.e. simulating) rather than having the date of real files from the folder. * Add -SkipProd flag to periodic rocket cleanup to enable us to run operations that only touch gamedev. This aids debugging as prod environment is firewalled from developer workstations. Change 3377027 by Leigh.Swift #jira OPP-6911: Launcher.Install.Stats Changes Adding specific process timers for each stage that we want to time, replacing any individual logic. Verifier no longer needs to provide the TimeSpentPaused output, since it is now given knowledge of pause state via external dependancy, it doesn't need to be responsible for providing the pause timer. Rearranging Launcher.Build.Stats analytics events according to new spec and desires. Also cleaning up some GLog->UE_LOG. Change 3374573 by Jacob.Hedges Copying //Tasks/Portal/Dev-UIAutomation to Dev-Main (//Portal/Dev-Main) Added new functional testsuite for the launcher, including metadata tags for relevant elements Added new functionality to ID and Path searches for the automation driver to start the search from a specified element Changed selective download components to utilize SCheckBox instead of SButton #jira OPP-6973 [CL 3592632 by Antony Carter in Main branch]
2017-08-17 06:28:58 -04:00
CefRefPtr<CefV8Value> Result = CefV8Value::CreateObject(nullptr, nullptr);
#endif
CefDictionaryValue::KeyList Keys;
Dictionary->GetKeys(Keys);
for (CefString Key : Keys)
{
Result->SetValue(Key, CefToV8(Dictionary, Key), V8_PROPERTY_ATTRIBUTE_NONE);
}
return Result;
}
CefRefPtr<CefV8Value> FUnrealCEFSubProcessRemoteScripting::CefToV8(CefRefPtr<CefListValue> List)
{
CefRefPtr<CefV8Value> Result = CefV8Value::CreateArray(List->GetSize());
for (size_t i = 0; i < List->GetSize(); ++i)
{
Result->SetValue(i, CefToV8(List, i));
}
return Result;
}
void FUnrealCEFSubProcessRemoteScripting::CefToV8Arglist(CefRefPtr<CefListValue> List, CefV8ValueList& Values)
{
for (size_t i = 0; i < List->GetSize(); ++i)
{
Values.push_back(CefToV8(List, i));
}
}
CefRefPtr<CefListValue> FUnrealCEFSubProcessRemoteScripting::V8ArrayToCef(const CefV8ValueList& Values)
{
CefRefPtr<CefListValue> Result = CefListValue::Create();
for (size_t I = 0; I < Values.size(); ++I)
{
V8ToCef(Result, nullptr, I, Values[I]);
}
return Result;
}
CefRefPtr<CefListValue> FUnrealCEFSubProcessRemoteScripting::V8ArrayToCef(CefRefPtr<CefV8Value> Array)
{
CefRefPtr<CefListValue> Result = CefListValue::Create();
if (Array->IsArray())
{
for (int I = 0; I < Array->GetArrayLength(); ++I)
{
V8ToCef(Result, Array, I, Array->GetValue(I));
}
}
return Result;
}
CefRefPtr<CefDictionaryValue> FUnrealCEFSubProcessRemoteScripting::V8ObjectToCef(CefRefPtr<CefV8Value> Object)
{
CefRefPtr<CefDictionaryValue> Result = CefDictionaryValue::Create();
if (Object->IsObject())
{
std::vector<CefString> Keys;
Object->GetKeys(Keys);
for (CefString Key : Keys)
{
V8ToCef(Result, Object, Key, Object->GetValue(Key));
}
}
return Result;
}
CefRefPtr<CefDictionaryValue> FUnrealCEFSubProcessRemoteScripting::V8FunctionToCef(CefRefPtr<CefV8Value> Object, CefRefPtr<CefV8Value> Function)
{
CefRefPtr<CefDictionaryValue> Result = CefDictionaryValue::Create();
FGuid Guid = CallbackRegistry.FindOrAdd(CefV8Context::GetCurrentContext(), Object, Function);
Result->SetString("$type", "callback");
Result->SetString("$id", TCHAR_TO_WCHAR(*Guid.ToString(EGuidFormats::Digits)));
Result->SetString("$name", Function->GetFunctionName());
return Result;
}
bool FUnrealCEFSubProcessRemoteScripting::HandleExecuteJSFunctionMessage(CefRefPtr<CefListValue> MessageArguments)
{
FGuid Guid;
// Message arguments are CallbackGuid, FunctionArguments, bIsError
if (MessageArguments->GetSize() != 3
|| MessageArguments->GetType(0) != VTYPE_STRING
|| MessageArguments->GetType(1) != VTYPE_LIST
|| MessageArguments->GetType(2) != VTYPE_BOOL)
{
// Wrong message argument types or count
return false;
}
if (!FGuid::Parse(FString(WCHAR_TO_TCHAR(MessageArguments->GetString(0).ToWString().c_str())), Guid))
{
// Invalid GUID
return false;
}
if (!CallbackRegistry.Contains(Guid))
{
// Unknown callback id
return false;
}
auto Callback = CallbackRegistry[Guid];
{
ScopedV8Context ContextScope(Callback.Context);
bool bIsErrorCallback = MessageArguments->GetBool(2);
CefRefPtr<CefV8Value> Function = bIsErrorCallback?Callback.OnError:Callback.Function;
if (!Function.get())
{
// Either invalid entry or no error handler
return false;
}
CefV8ValueList FunctionArguments;
CefToV8Arglist(MessageArguments->GetList(1), FunctionArguments);
CefRefPtr<CefV8Value> Retval = Function->ExecuteFunction(Callback.Object, FunctionArguments);
if (!Retval.get())
{
// Function call resulted in an error
return false;
}
// Remove callback if it's a one-shot callback and successful.
if (Callback.bOneShot)
{
CallbackRegistry.Remove(Guid);
}
return true;
}
}
bool FUnrealCEFSubProcessRemoteScripting::HandleSetValueMessage(CefRefPtr<CefBrowser> Browser, CefRefPtr<CefListValue> MessageArguments)
{
CefRefPtr<CefFrame> MainFrame = Browser->GetMainFrame();
CefRefPtr<CefV8Context> Context = MainFrame->GetV8Context();
ScopedV8Context ContextScope(Context);
CefRefPtr<CefV8Value> RootObject = Context->GetGlobal()->GetValue("ue");
if (!RootObject.get())
{
// The root object should always be created on context creation.
return false;
}
for (size_t I = 0; I < MessageArguments->GetSize(); I++)
{
if (MessageArguments->GetType(I) != VTYPE_DICTIONARY)
{
return false;
}
CefRefPtr<CefDictionaryValue> Argument = MessageArguments->GetDictionary(I);
if (Argument->GetType("name") != VTYPE_STRING
|| Argument->GetType("value") != VTYPE_DICTIONARY
|| Argument->GetType("permanent") != VTYPE_BOOL)
{
// Wrong message argument types or count
return false;
}
CefString Name = Argument->GetString("name");
CefRefPtr<CefDictionaryValue> CefValue = Argument->GetDictionary("value");
bool bPermanent = Argument->GetBool("permanent");
if (bPermanent)
{
int32 BrowserID = Browser->GetIdentifier();
CefRefPtr<CefDictionaryValue> Bindings;
if (PermanentBindings.Contains(BrowserID))
{
Bindings = PermanentBindings[BrowserID];
}
else
{
Bindings = CefDictionaryValue::Create();
PermanentBindings.Add(BrowserID, Bindings);
}
Bindings->SetDictionary(Name, CefValue);
}
CefRefPtr<CefV8Value> Value = CefToV8(CefValue);
RootObject->SetValue(Name, Value, V8_PROPERTY_ATTRIBUTE_NONE);
}
return true;
}
bool FUnrealCEFSubProcessRemoteScripting::HandleDeleteValueMessage(CefRefPtr<CefBrowser> Browser, CefRefPtr<CefListValue> MessageArguments)
{
CefRefPtr<CefFrame> MainFrame = Browser->GetMainFrame();
CefRefPtr<CefV8Context> Context = MainFrame->GetV8Context();
ScopedV8Context ContextScope(Context);
CefRefPtr<CefV8Value> RootObject = Context->GetGlobal()->GetValue("ue");
if (!RootObject.get())
{
// The root object should always be created on context creation.
return false;
}
for (size_t I = 0; I < MessageArguments->GetSize(); I++)
{
if (MessageArguments->GetType(I) != VTYPE_DICTIONARY)
{
return false;
}
CefRefPtr<CefDictionaryValue> Argument = MessageArguments->GetDictionary(I);
if (Argument->GetType("name") != VTYPE_STRING
|| Argument->GetType("id") != VTYPE_STRING
|| Argument->GetType("permanent") != VTYPE_BOOL)
{
// Wrong message argument types or count
return false;
}
CefString Name = Argument->GetString("name");
CefString Id = Argument->GetString("id");
bool bPermanent = Argument->GetBool("permanent");
FGuid Guid;
if (!FGuid::Parse(WCHAR_TO_TCHAR(Id.ToWString().c_str()), Guid))
{
return false;
}
if (bPermanent)
{
int32 BrowserID = Browser->GetIdentifier();
CefRefPtr<CefDictionaryValue> Bindings;
if (PermanentBindings.Contains(BrowserID))
{
Bindings = PermanentBindings[BrowserID];
if (!Bindings->HasKey(Name))
{
return false;
}
if (Guid.IsValid())
{
CefRefPtr<CefDictionaryValue> CefValue = Bindings->GetDictionary(Name);
if (CefValue.get() && CefValue->GetString("$id") != Id)
{
return false;
}
}
Bindings->Remove(Name);
}
}
if (!RootObject->HasValue(Name))
{
return false;
}
if (Guid.IsValid())
{
CefRefPtr<CefV8Value> Value = RootObject->GetValue(Name);
if (!Value->HasValue("$id") || !Value->GetValue("$id")->IsString() || Value->GetValue("$id")->GetStringValue() != Id)
{
return false;
}
}
RootObject->DeleteValue(Name);
}
return true;
}
bool FUnrealCEFSubProcessRemoteScripting::OnProcessMessageReceived(CefRefPtr<CefBrowser> Browser,
CefProcessId SourceProcess,
CefRefPtr<CefProcessMessage> Message)
{
bool Result = false;
FString MessageName = WCHAR_TO_TCHAR(Message->GetName().ToWString().c_str());
if (MessageName == TEXT("UE::ExecuteJSFunction"))
{
Result = HandleExecuteJSFunctionMessage(Message->GetArgumentList());
}
else if (MessageName == TEXT("UE::SetValue"))
{
Result = HandleSetValueMessage(Browser, Message->GetArgumentList());
}
else if (MessageName == TEXT("UE::DeleteValue"))
{
Result = HandleDeleteValueMessage(Browser, Message->GetArgumentList());
}
return Result;
}
void FUnrealCEFSubProcessRemoteScripting::OnContextCreated(CefRefPtr<CefBrowser> Browser, CefRefPtr<CefFrame> Frame, CefRefPtr<CefV8Context> Context)
{
ScopedV8Context ContextScope(Context);
CefRefPtr<CefV8Value> Global = Context->GetGlobal();
if ( !Global->HasValue("ue") )
{
#if PLATFORM_LINUX
Global->SetValue("ue", CefV8Value::CreateObject(nullptr), V8_PROPERTY_ATTRIBUTE_DONTDELETE);
#else
Copying //UE4/Portal-Staging to //UE4/Dev-Main (Source: //UE4/Portal-Staging @ 3592606) #rb none #lockdown Nick.Penwarden ============================ MAJOR FEATURES & CHANGES ============================ Change 3520569 by Leigh.Swift Adding chunkdb support to BPS installer as a chunk source for installations. Chunk db filenames are provided on the installer configuration struct, and will be used to load chunks needed for the installation. Chunk db source shares a chunk store with the cloud source. Adding message pump implementation for installer which can be used to surface events or messages to handlers added to the installer. Currently just takes chunk source events for losing access to the chunkdb files. Adding concept of new runtime requirements and callback for unavailable chunks to chunk source base API. Chained chunk source cascades broadcasted unavailable chunks down to other sources as new requirements. #jira OPP-7191: Add chunkdb source support to BPS Adding support for passing chunkdb files to created installers. Storing chunkdb filenames used for installation in pending manifest so they can be re-used when resuming. Exposing chunkdb source events to UI as warning triangle. #jira OPP-7191: Add chunkdb source support to BPS Change 3508964 by Wes.Fudala CL# 3431076 - Upgrade Win32, Win64, and Mac to latest CEF branch 3071. Adds browser support for foreign language character input via IME. #jira OPP-4400 Non-Roman characters from an IME cannot be typed into CEF based views Change 3506884 by Leigh.Swift #jira OPP-6981: Make sign-in screen a web page WebBrowser: Adding support to WebBrowser module for implementing custom protocol/scheme handlers. Currently works for CEF integration only. WebBrowser: Adding support to override the user-agent version string when initialising the web browser module. PortalBuild: Additionally shipping the contents of /Portal/Content/Web with full launchers. Portal: Adding web content for sign in, background, and web test pages. Portal: Added a high version number setup for WebBrowser when running debug so that latest code always gets latest websites. Portal: Removing old slate sign in screens, and associated code. Portal: Adding bIsThirdParty bool to some AccountService functions to allow to handle not yet having information about account types returned from the backend to deside if an account can be used with a password sign in. Portal: Removing unnecessary use of email in the AccountService::AutoSignIn API. Portal: Replacing old logging in overlay with a 'ShowLongProcessOverlay' API for systems that still use that (e.g. vault cach location select, waiting room). Portal: UI: Adding a null state to sign in router so resources can be cleaned up. Portal: UI: Adding web states for all screens on sign in router. Portal: DebugTools: Adding a web developer section, with a refresh all browsers button to help with web iteration. Portal: DebugTools: Fixing all test JS to use lowercased api calls. Portal: Implementing new client:// scheme handler for WebBrowser which local pages will use. Portal: RememberMe: Exposing additional user info, LastName and whether the account can auth with a password. Portal: Temporary dynamic background image implementation and javascript bridge. Portal: Sign in screen is now driven by a web page, and javascript API. Portal: UIRouter: Improved handling of redirects and tracking of state changes via redirects. Change 3471216 by Leigh.Swift Extending BPT VerifyChunks mode to check manifests are loadable and do not reference broken data, and also to output bad files to a text file passed in on commandline. Change 3469441 by Richard.Fawcett Add support for disc icon to packaging game ISO #jira OPP-7311: Implement icon file for disc Change 3468243 by Wes.Fudala Adds support for branding windows installers. #jira OPP-7190: Create game bootstrap msi (Windows) Change 3456485 by Richard.Fawcett Create new C# wrapper around BuildPatchTool to call the (as yet unimplemented) PackageChunks mode. Implement new tool mode in PortalPublishingTool which takes game name and build version, finds manifest files, and executes BuildPatchTool for each platform, with the option to restrict to a single platform via the commandline. Build script changes to allow the Package Chunks job to be called from Electric Commander. This includes refactoring the setup of PortalPublishingTool to a new node which the package chunks job, and the existing build diff job depend on. #jira OPP-7193: Create 'package chunks' job Change 3446665 by Jacob.Hedges CL# 3430618 - Added App Installation, Engine Installation, and Plugin Installation test suites. Create Social gadget for interacting with the social panel. Added Portal Automation Helper that exposes the UIRouter, and changed existing tests and Screens to utilize URI navigation. Added various metadata tags. #jira OPP-7155 #jira QAENG-1075 #jira QAENG-1076 #jira QAENG-1079 #jira QAENG-1080 Change 3420598 by Richard.Fawcett Use Prerequisite Ids to track which prerequisistes have been installed on a user's system. #jira OPP-6007: Upgrade prereq installer so that it checks versions instead of file hashes - Part 1 Change 3410773 by Richard.Fawcett Implement project-specific retention periods for automated cleanup routines. Additional changes: * Remove VerifyManifestFilenames as it makes no sense for manifest filenames to have to conform to a specific pattern now that we have randomized manifest filenames. * Add support for detecting build versions from Win32 manifest files by tweaking regex. * DeleteUnreferencedManifestsFromCDN: Avoid parsing version strings when we're not in SimulateCDN mode as we're only interested in the result if we're filtering "old" manifests by CL (i.e. simulating) rather than having the date of real files from the folder. * Add -SkipProd flag to periodic rocket cleanup to enable us to run operations that only touch gamedev. This aids debugging as prod environment is firewalled from developer workstations. Change 3377027 by Leigh.Swift #jira OPP-6911: Launcher.Install.Stats Changes Adding specific process timers for each stage that we want to time, replacing any individual logic. Verifier no longer needs to provide the TimeSpentPaused output, since it is now given knowledge of pause state via external dependancy, it doesn't need to be responsible for providing the pause timer. Rearranging Launcher.Build.Stats analytics events according to new spec and desires. Also cleaning up some GLog->UE_LOG. Change 3374573 by Jacob.Hedges Copying //Tasks/Portal/Dev-UIAutomation to Dev-Main (//Portal/Dev-Main) Added new functional testsuite for the launcher, including metadata tags for relevant elements Added new functionality to ID and Path searches for the automation driver to start the search from a specified element Changed selective download components to utilize SCheckBox instead of SButton #jira OPP-6973 [CL 3592632 by Antony Carter in Main branch]
2017-08-17 06:28:58 -04:00
Global->SetValue("ue", CefV8Value::CreateObject(nullptr, nullptr), V8_PROPERTY_ATTRIBUTE_DONTDELETE);
#endif
}
CefRefPtr<CefV8Value> RootObject = Context->GetGlobal()->GetValue("ue");
int32 BrowserID = Browser->GetIdentifier();
if (PermanentBindings.Contains(BrowserID))
{
CefRefPtr<CefDictionaryValue> Bindings = PermanentBindings[BrowserID];
CefDictionaryValue::KeyList Keys;
Bindings->GetKeys(Keys);
for (CefString Key : Keys)
{
CefRefPtr<CefV8Value> Value = CefToV8(Bindings->GetDictionary(Key));
RootObject->SetValue(Key, Value, V8_PROPERTY_ATTRIBUTE_NONE);
}
}
}
void FUnrealCEFSubProcessRemoteScripting::OnContextReleased(CefRefPtr<CefBrowser> Browser, CefRefPtr<CefFrame> Frame, CefRefPtr<CefV8Context> Context)
{
// Invalidate JS functions that were created in the context being released.
CallbackRegistry.RemoveByContext(Context);
}
void FUnrealCEFSubProcessRemoteScripting::InitPermanentBindings(int32 BrowserID, CefRefPtr<CefDictionaryValue> Values)
{
// The CefDictionary in PermanentBindings needs to be writable, so we'll copy the Values argument before saving it.
PermanentBindings.Add(BrowserID, Values->Copy(true));
}
#endif