Skip to content

Commit

Permalink
Merge becb14d into fe98124
Browse files Browse the repository at this point in the history
  • Loading branch information
amaitland authored Jun 13, 2019
2 parents fe98124 + becb14d commit 01dea3f
Show file tree
Hide file tree
Showing 87 changed files with 1,168 additions and 1,453 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace CefSharp
bool JavascriptAsyncMethodHandler::Execute(const CefString& name, CefRefPtr<CefV8Value> object, const CefV8ValueList& arguments, CefRefPtr<CefV8Value>& retval, CefString& exception)
{
auto context = CefV8Context::GetCurrentContext();
auto browser = context->GetBrowser();
auto frame = context->GetFrame();

CefRefPtr<CefV8Value> promiseData;
CefRefPtr<CefV8Exception> promiseException;
Expand Down Expand Up @@ -59,13 +59,12 @@ namespace CefSharp
SerializeV8Object(arguments[i], params, i, _callbackRegistry);
}

SetInt64(argList, 0, context->GetFrame()->GetIdentifier());
SetInt64(argList, 1, _objectId);
SetInt64(argList, 2, callbackId);
argList->SetString(3, name);
argList->SetList(4, params);
SetInt64(argList, 0, _objectId);
SetInt64(argList, 1, callbackId);
argList->SetString(2, name);
argList->SetList(3, params);

browser->SendProcessMessage(CefProcessId::PID_BROWSER, request);
frame->SendProcessMessage(CefProcessId::PID_BROWSER, request);

return true;
}
Expand Down
53 changes: 22 additions & 31 deletions CefSharp.BrowserSubprocess.Core/CefAppUnmanagedWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ namespace CefSharp
};

// CefRenderProcessHandler
void CefAppUnmanagedWrapper::OnBrowserCreated(CefRefPtr<CefBrowser> browser)
void CefAppUnmanagedWrapper::OnBrowserCreated(CefRefPtr<CefBrowser> browser, CefRefPtr<CefDictionaryValue> extraInfo)
{
auto wrapper = gcnew CefBrowserWrapper(browser);
_onBrowserCreated->Invoke(wrapper);
Expand Down Expand Up @@ -123,9 +123,7 @@ namespace CefSharp
//have been created
auto contextCreatedMessage = CefProcessMessage::Create(kOnContextCreatedRequest);

SetInt64(contextCreatedMessage->GetArgumentList(), 0, frame->GetIdentifier());

browser->SendProcessMessage(CefProcessId::PID_BROWSER, contextCreatedMessage);
frame->SendProcessMessage(CefProcessId::PID_BROWSER, contextCreatedMessage);
};

void CefAppUnmanagedWrapper::OnContextReleased(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, CefRefPtr<CefV8Context> context)
Expand All @@ -141,9 +139,7 @@ namespace CefSharp

auto contextReleasedMessage = CefProcessMessage::Create(kOnContextReleasedRequest);

SetInt64(contextReleasedMessage->GetArgumentList(), 0, frame->GetIdentifier());

browser->SendProcessMessage(CefProcessId::PID_BROWSER, contextReleasedMessage);
frame->SendProcessMessage(CefProcessId::PID_BROWSER, contextReleasedMessage);

auto browserWrapper = FindBrowserWrapper(browser->GetIdentifier());

Expand Down Expand Up @@ -172,19 +168,16 @@ namespace CefSharp
auto focusedNodeChangedMessage = CefProcessMessage::Create(kOnFocusedNodeChanged);
auto list = focusedNodeChangedMessage->GetArgumentList();

// Needed in the browser process to get the frame.
SetInt64(list, 0, frame->GetIdentifier());

// The node will be empty if an element loses focus but another one
// doesn't gain focus. Only transfer information if the node is an
// element.
if (node != nullptr && node->IsElement())
{
// True when a node exists, false if it doesn't.
list->SetBool(1, true);
list->SetBool(0, true);

// Store the tag name.
list->SetString(2, node->GetElementTagName());
list->SetString(1, node->GetElementTagName());

// Transfer the attributes in a Dictionary.
auto attributes = CefDictionaryValue::Create();
Expand All @@ -195,24 +188,22 @@ namespace CefSharp
attributes->SetString(iter.first, iter.second);
}

list->SetDictionary(3, attributes);
list->SetDictionary(2, attributes);
}
else
{
list->SetBool(1, false);
list->SetBool(0, false);
}

browser->SendProcessMessage(CefProcessId::PID_BROWSER, focusedNodeChangedMessage);
frame->SendProcessMessage(CefProcessId::PID_BROWSER, focusedNodeChangedMessage);
}

void CefAppUnmanagedWrapper::OnUncaughtException(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, CefRefPtr<CefV8Context> context, CefRefPtr<CefV8Exception> exception, CefRefPtr<CefV8StackTrace> stackTrace)
{
auto uncaughtExceptionMessage = CefProcessMessage::Create(kOnUncaughtException);
auto list = uncaughtExceptionMessage->GetArgumentList();

// Needed in the browser process to get the frame.
SetInt64(list, 0, frame->GetIdentifier());
list->SetString(1, exception->GetMessage());
list->SetString(0, exception->GetMessage());

auto frames = CefListValue::Create();
for (auto i = 0; i < stackTrace->GetFrameCount(); i++)
Expand All @@ -228,9 +219,9 @@ namespace CefSharp
frames->SetList(i, frame);
}

list->SetList(2, frames);
list->SetList(1, frames);

browser->SendProcessMessage(CefProcessId::PID_BROWSER, uncaughtExceptionMessage);
frame->SendProcessMessage(CefProcessId::PID_BROWSER, uncaughtExceptionMessage);
}

JavascriptRootObjectWrapper^ CefAppUnmanagedWrapper::GetJsRootObjectWrapper(int browserId, int64 frameId)
Expand Down Expand Up @@ -269,7 +260,7 @@ namespace CefSharp
return wrapper;
}

bool CefAppUnmanagedWrapper::OnProcessMessageReceived(CefRefPtr<CefBrowser> browser, CefProcessId sourceProcessId, CefRefPtr<CefProcessMessage> message)
bool CefAppUnmanagedWrapper::OnProcessMessageReceived(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, CefProcessId sourceProcessId, CefRefPtr<CefProcessMessage> message)
{
auto handled = false;
auto name = message->GetName();
Expand Down Expand Up @@ -313,7 +304,7 @@ namespace CefSharp
responseArgList->SetBool(0, false);
SetInt64(responseArgList, 1, callbackId);
responseArgList->SetString(2, StringUtils::ToNative(errorMessage));
browser->SendProcessMessage(sourceProcessId, response);
frame->SendProcessMessage(sourceProcessId, response);

return true;
}
Expand All @@ -336,7 +327,7 @@ namespace CefSharp
}

//both messages have the frameId stored at 0 and callbackId stored at index 1
auto frameId = GetInt64(argList, 0);
auto frameId = frame->GetIdentifier();
int64 callbackId = GetInt64(argList, 1);

if (name == kEvaluateJavascriptRequest)
Expand Down Expand Up @@ -471,14 +462,14 @@ namespace CefSharp
{
responseArgList->SetString(2, errorMessage);
}
browser->SendProcessMessage(sourceProcessId, response);
frame->SendProcessMessage(sourceProcessId, response);

handled = true;
}
else if (name == kJavascriptCallbackDestroyRequest)
{
auto jsCallbackId = GetInt64(argList, 0);
auto frameId = GetInt64(argList, 1);
auto frameId = frame->GetIdentifier();
JavascriptRootObjectWrapper^ rootObjectWrapper;
browserWrapper->JavascriptRootObjectWrappers->TryGetValue(frameId, rootObjectWrapper);
if (rootObjectWrapper != nullptr && rootObjectWrapper->CallbackRegistry != nullptr)
Expand Down Expand Up @@ -517,10 +508,10 @@ namespace CefSharp
}
else
{
auto browserId = argList->GetInt(1);
auto frameId = GetInt64(argList, 2);
auto callbackId = GetInt64(argList, 3);
auto javascriptObjects = DeserializeJsObjects(argList, 4);
auto browserId = browser->GetIdentifier();
auto frameId = frame->GetIdentifier();
auto callbackId = GetInt64(argList, 1);
auto javascriptObjects = DeserializeJsObjects(argList, 2);

//Caching of JavascriptObjects
//TODO: JSB Should caching be configurable? On a per object basis?
Expand Down Expand Up @@ -594,7 +585,7 @@ namespace CefSharp

args->SetList(0, boundObjects);

browser->SendProcessMessage(CefProcessId::PID_BROWSER, msg);
frame->SendProcessMessage(CefProcessId::PID_BROWSER, msg);
}
}
finally
Expand All @@ -609,7 +600,7 @@ namespace CefSharp
}
else if (name == kJavascriptAsyncMethodCallResponse)
{
auto frameId = GetInt64(argList, 0);
auto frameId = frame->GetIdentifier();
auto callbackId = GetInt64(argList, 1);

JavascriptRootObjectWrapper^ rootObjectWrapper;
Expand Down
4 changes: 2 additions & 2 deletions CefSharp.BrowserSubprocess.Core/CefAppUnmanagedWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ namespace CefSharp
JavascriptRootObjectWrapper^ GetJsRootObjectWrapper(int browserId, int64 frameId);

virtual DECL CefRefPtr<CefRenderProcessHandler> GetRenderProcessHandler() OVERRIDE;
virtual DECL void OnBrowserCreated(CefRefPtr<CefBrowser> browser) OVERRIDE;
virtual DECL void OnBrowserCreated(CefRefPtr<CefBrowser> browser, CefRefPtr<CefDictionaryValue> extraInfo) OVERRIDE;
virtual DECL void OnBrowserDestroyed(CefRefPtr<CefBrowser> browser) OVERRIDE;
virtual DECL void OnContextCreated(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, CefRefPtr<CefV8Context> context) OVERRIDE;
virtual DECL void OnContextReleased(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, CefRefPtr<CefV8Context> context) OVERRIDE;
virtual DECL bool OnProcessMessageReceived(CefRefPtr<CefBrowser> browser, CefProcessId sourceProcessId, CefRefPtr<CefProcessMessage> message) OVERRIDE;
virtual DECL bool OnProcessMessageReceived(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, CefProcessId sourceProcessId, CefRefPtr<CefProcessMessage> message) OVERRIDE;
virtual DECL void OnRenderThreadCreated(CefRefPtr<CefListValue> extraInfo) OVERRIDE;
virtual DECL void OnWebKitInitialized() OVERRIDE;
virtual DECL void OnRegisterCustomSchemes(CefRawPtr<CefSchemeRegistrar> registrar) OVERRIDE;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\cef.sdk.74.1.13\build\cef.sdk.props" Condition="Exists('..\packages\cef.sdk.74.1.13\build\cef.sdk.props')" />
<Import Project="..\packages\cef.sdk.75.0.3\build\cef.sdk.props" Condition="Exists('..\packages\cef.sdk.75.0.3\build\cef.sdk.props')" />
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ namespace CefSharp
auto context = CefV8Context::GetCurrentContext();
if (context.get())
{
auto browser = context->GetBrowser();
auto frame = context->GetFrame();

if (context.get() && context->Enter())
{
Expand All @@ -53,18 +53,16 @@ namespace CefSharp
auto request = CefProcessMessage::Create(kJavascriptMessageReceived);
auto argList = request->GetArgumentList();

SetInt64(argList, 0, context->GetFrame()->GetIdentifier());

auto params = CefListValue::Create();
SerializeV8Object(arguments[0], params, 0, _javascriptCallbackRegistry);

//We're only interested in the first param
if (params->GetSize() > 0)
{
argList->SetValue(1, params->GetValue(0));
argList->SetValue(0, params->GetValue(0));
}

browser->SendProcessMessage(CefProcessId::PID_BROWSER, request);
frame->SendProcessMessage(CefProcessId::PID_BROWSER, request);

retval = CefV8Value::CreateNull();
}
Expand Down
58 changes: 33 additions & 25 deletions CefSharp.BrowserSubprocess.Core/RegisterBoundObjectHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ namespace CefSharp
if (cachedObjects->Count == objectCount && ignoreCache == false)
{
auto frame = context->GetFrame();

if (frame.get())
{
if (Object::ReferenceEquals(_browserWrapper, nullptr))
Expand Down Expand Up @@ -268,45 +269,52 @@ namespace CefSharp
response->SetValue("Message", CefV8Value::CreateString("OK"), CefV8Value::PropertyAttribute::V8_PROPERTY_ATTRIBUTE_READONLY);
callback->Success(response);

NotifyObjectBound(browser, objectNamesWithBoundStatus);
NotifyObjectBound(frame, objectNamesWithBoundStatus);
}
}

}
else
{
//Obtain a callbackId then send off the Request for objects
auto callbackId = _callbackRegistry->SaveMethodCallback(callback);
auto frame = context->GetFrame();
if (frame.get())
{
//Obtain a callbackId then send off the Request for objects
auto callbackId = _callbackRegistry->SaveMethodCallback(callback);

argList->SetInt(0, browser->GetIdentifier());
SetInt64(argList, 1, context->GetFrame()->GetIdentifier());
SetInt64(argList, 2, callbackId);
argList->SetList(3, params);
SetInt64(argList, 0, callbackId);
argList->SetList(1, params);

browser->SendProcessMessage(CefProcessId::PID_BROWSER, request);
frame->SendProcessMessage(CefProcessId::PID_BROWSER, request);
}
}
}
else
{
//Objects already bound or ignore cache
auto frame = context->GetFrame();

//Response object has no Accessor or Interceptor
auto response = CefV8Value::CreateObject(NULL, NULL);
if (frame.get())
{
//Objects already bound or ignore cache

//Objects already bound so we immediately resolve the Promise
response->SetValue("Success", CefV8Value::CreateBool(false), CefV8Value::PropertyAttribute::V8_PROPERTY_ATTRIBUTE_READONLY);
response->SetValue("Count", CefV8Value::CreateInt(0), CefV8Value::PropertyAttribute::V8_PROPERTY_ATTRIBUTE_READONLY);
response->SetValue("Message", CefV8Value::CreateString("Object(s) already bound"), CefV8Value::PropertyAttribute::V8_PROPERTY_ATTRIBUTE_READONLY);
//Response object has no Accessor or Interceptor
auto response = CefV8Value::CreateObject(NULL, NULL);

CefV8ValueList returnArgs;
returnArgs.push_back(response);
//If all the requested objects are bound then we immediately execute resolve
//with Success true and Count of 0
resolve->ExecuteFunctionWithContext(context, nullptr, returnArgs);
//Objects already bound so we immediately resolve the Promise
response->SetValue("Success", CefV8Value::CreateBool(false), CefV8Value::PropertyAttribute::V8_PROPERTY_ATTRIBUTE_READONLY);
response->SetValue("Count", CefV8Value::CreateInt(0), CefV8Value::PropertyAttribute::V8_PROPERTY_ATTRIBUTE_READONLY);
response->SetValue("Message", CefV8Value::CreateString("Object(s) already bound"), CefV8Value::PropertyAttribute::V8_PROPERTY_ATTRIBUTE_READONLY);

if (notifyIfAlreadyBound)
{
NotifyObjectBound(browser, objectNamesWithBoundStatus);
CefV8ValueList returnArgs;
returnArgs.push_back(response);
//If all the requested objects are bound then we immediately execute resolve
//with Success true and Count of 0
resolve->ExecuteFunctionWithContext(context, nullptr, returnArgs);

if (notifyIfAlreadyBound)
{
NotifyObjectBound(frame, objectNamesWithBoundStatus);
}
}
}
}
Expand All @@ -331,7 +339,7 @@ namespace CefSharp
}

private:
void NotifyObjectBound(const CefRefPtr<CefBrowser> browser, List<Tuple<String^, bool, bool>^>^ objectNamesWithBoundStatus)
void NotifyObjectBound(const CefRefPtr<CefFrame> frame, List<Tuple<String^, bool, bool>^>^ objectNamesWithBoundStatus)
{
//Send message notifying Browser Process of which objects were bound
//We do this after the objects have been created in the V8Context to gurantee
Expand All @@ -358,7 +366,7 @@ namespace CefSharp

args->SetList(0, boundObjects);

browser->SendProcessMessage(CefProcessId::PID_BROWSER, msg);
frame->SendProcessMessage(CefProcessId::PID_BROWSER, msg);
}


Expand Down
8 changes: 4 additions & 4 deletions CefSharp.BrowserSubprocess.Core/Resource.rc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
1 VERSIONINFO
FILEVERSION 74.1.130
PRODUCTVERSION 74.1.130
FILEVERSION 75.0.30
PRODUCTVERSION 75.0.30
FILEFLAGSMASK 0x17L
#ifdef _DEBUG
FILEFLAGS 0x1L
Expand All @@ -16,10 +16,10 @@ BEGIN
BLOCK "040904b0"
BEGIN
VALUE "FileDescription", "CefSharp.BrowserSubprocess.Core"
VALUE "FileVersion", "74.1.130"
VALUE "FileVersion", "75.0.30"
VALUE "LegalCopyright", "Copyright © 2019 The CefSharp Authors"
VALUE "ProductName", "CefSharp"
VALUE "ProductVersion", "74.1.130"
VALUE "ProductVersion", "75.0.30"
END
END
BLOCK "VarFileInfo"
Expand Down
2 changes: 1 addition & 1 deletion CefSharp.BrowserSubprocess.Core/packages.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="cef.sdk" version="74.1.13" targetFramework="native" />
<package id="cef.sdk" version="75.0.3" targetFramework="native" />
</packages>
2 changes: 1 addition & 1 deletion CefSharp.BrowserSubprocess/app.manifest
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
xmlns:asmv3="urn:schemas-microsoft-com:asm.v3"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<assemblyIdentity version="74.1.130.0" name="CefSharp.BrowserSubprocess.app" />
<assemblyIdentity version="75.0.30.0" name="CefSharp.BrowserSubprocess.app" />
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
Expand Down
Loading

0 comments on commit 01dea3f

Please sign in to comment.