Skip to content

Commit

Permalink
Merge pull request cefsharp#693 from cefsharp/cef/2171
Browse files Browse the repository at this point in the history
Cef 2171 - Upgrade to Chromium 39
  • Loading branch information
amaitland committed Jan 20, 2015
2 parents b17807e + 72270b1 commit 6acb2b2
Show file tree
Hide file tree
Showing 81 changed files with 1,460 additions and 811 deletions.
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="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\cef.sdk.3.2062.1898\build\cef.sdk.props" Condition="Exists('..\packages\cef.sdk.3.2062.1898\build\cef.sdk.props')" />
<Import Project="..\packages\cef.sdk.3.2171.1949\build\cef.sdk.props" Condition="Exists('..\packages\cef.sdk.3.2171.1949\build\cef.sdk.props')" />
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
Expand Down Expand Up @@ -66,7 +66,7 @@
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros">
<NuGetPackageImportStamp>598202e1</NuGetPackageImportStamp>
<NuGetPackageImportStamp>03744085</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
Expand Down Expand Up @@ -198,6 +198,6 @@
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\cef.sdk.3.2062.1898\build\cef.sdk.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\cef.sdk.3.2062.1898\build\cef.sdk.props'))" />
<Error Condition="!Exists('..\packages\cef.sdk.3.2171.1949\build\cef.sdk.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\cef.sdk.3.2171.1949\build\cef.sdk.props'))" />
</Target>
</Project>
54 changes: 50 additions & 4 deletions CefSharp.BrowserSubprocess.Core/JavascriptMethodHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,63 @@ namespace CefSharp
parameter[i] = TypeUtils::ConvertFromCef(arguments[i]);
}

auto response = _method->Invoke(parameter);
try
{
auto response = _method->Invoke(parameter);

retval = TypeUtils::ConvertToCef(response->Result, nullptr);
if(!response->Success)
retval = ConvertToCefObject(response->Result);
if (!response->Success)
{
exception = StringUtils::ToNative(response->Message);
}
}
catch (Exception^ ex)
{
exception = StringUtils::ToNative(response->Message);
exception = StringUtils::ToNative(ex->Message);
}

//NOTE: Return true otherwise exception is ignored
return true;
}

CefRefPtr<CefV8Value> ConvertToCefObject(Object^ obj)
{
if (obj == nullptr)
{
return CefV8Value::CreateNull();
}

auto type = obj->GetType();

if (type == JavascriptObject::typeid)
{
JavascriptObject^ javascriptObject = (JavascriptObject^)obj;
CefRefPtr<CefV8Value> cefObject = CefV8Value::CreateObject(NULL);

for (int i = 0; i < javascriptObject->Properties->Count; i++)
{
auto prop = javascriptObject->Properties[i];

if(prop->IsComplexType)
{
auto v8Value = ConvertToCefObject(prop->JsObject);

cefObject->SetValue(StringUtils::ToNative(prop->JavascriptName), v8Value, CefV8Value::PropertyAttribute::V8_PROPERTY_ATTRIBUTE_NONE);
}
else
{
auto v8Value = TypeUtils::ConvertToCef(prop->PropertyValue, nullptr);

cefObject->SetValue(StringUtils::ToNative(prop->JavascriptName), v8Value, CefV8Value::PropertyAttribute::V8_PROPERTY_ATTRIBUTE_NONE);
}
}

return cefObject;
}

return TypeUtils::ConvertToCef(obj, nullptr);
}

IMPLEMENT_REFCOUNTING(JavascriptMethodHandler)
};
}
14 changes: 3 additions & 11 deletions CefSharp.BrowserSubprocess.Core/TypeUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,6 @@ namespace CefSharp
throw gcnew Exception(String::Format("Cannot convert '{0}' object from CLR to CEF.", type->FullName));
}

System::String^ stdToString(const std::string& s)
{
return gcnew System::String(s.c_str());
}

Object^ TypeUtils::ConvertFromCef(CefRefPtr<CefV8Value> obj)
{
if (obj->IsNull() || obj->IsUndefined())
Expand Down Expand Up @@ -210,18 +205,15 @@ namespace CefSharp
int objLength = keys.size();
if (objLength > 0)
{
Dictionary<String^, Object^>^ result = gcnew Dictionary<String^, Object^>();
auto result = gcnew Dictionary<String^, Object^>();

for (int i = 0; i < objLength; i++)
{
std::string p_key = keys[i].ToString();
String^ p_keyStr = stdToString(p_key);
String^ p_keyStr = StringUtils::ToClr(keys[i].ToString());

if ((obj->HasValue(keys[i])) && (!p_keyStr->StartsWith("__")))
{
CefRefPtr<CefV8Value> data;

data = obj->GetValue(keys[i]);
CefRefPtr<CefV8Value> data = obj->GetValue(keys[i]);
if (data != nullptr)
{
Object^ p_data = TypeUtils::ConvertFromCef(data);
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="3.2062.1898" targetFramework="Native" />
<package id="cef.sdk" version="3.2171.1949" targetFramework="Native" />
</packages>
2 changes: 1 addition & 1 deletion CefSharp.BrowserSubprocess/CefRenderProcess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace CefSharp.BrowserSubprocess
{
[CallbackBehavior(ConcurrencyMode = ConcurrencyMode.Multiple)]
[CallbackBehavior(ConcurrencyMode = ConcurrencyMode.Multiple, IncludeExceptionDetailInFaults=true)]
public class CefRenderProcess : CefSubProcess, IRenderProcess
{
private int? parentBrowserId;
Expand Down
44 changes: 15 additions & 29 deletions CefSharp.Core/Cef.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,15 +146,6 @@ namespace CefSharp
CefMainArgs main_args;
CefRefPtr<CefSharpApp> app(new CefSharpApp(cefSettings));

int exitCode = CefExecuteProcess(main_args, app.get(), NULL);

if (exitCode >= 0)
{
// Something went "wrong", but it may also be caused in the case where we are the secondary process, so we
// can't really throw exceptions or anything like that.
return false;
}

success = CefInitialize(main_args, *(cefSettings->_cefSettings), app.get(), NULL);
app->CompleteSchemeRegistrations();
_initialized = success;
Expand All @@ -173,17 +164,16 @@ namespace CefSharp
/// <return>Returns false if the CookieManager is not available; otherwise, true.</return>
static bool VisitAllCookies(ICookieVisitor^ visitor)
{
CefRefPtr<CookieVisitor> cookieVisitor = new CookieVisitor(visitor);
CefRefPtr<CefCookieManager> manager = CefCookieManager::GetGlobalManager();

if (manager != nullptr)
{
return manager->VisitAllCookies(static_cast<CefRefPtr<CefCookieVisitor>>(cookieVisitor));
}
else
if (manager == nullptr)
{
return false;
}

CefRefPtr<CookieVisitor> cookieVisitor = new CookieVisitor(visitor);

return manager->VisitAllCookies(cookieVisitor);
}

/// <summary>Visits a subset of the cookies. The results are filtered by the given url scheme, host, domain and path.
Expand All @@ -195,18 +185,16 @@ namespace CefSharp
/// <return>Returns false if the CookieManager is not available; otherwise, true.</return>
static bool VisitUrlCookies(String^ url, bool includeHttpOnly, ICookieVisitor^ visitor)
{
CefRefPtr<CookieVisitor> cookieVisitor = new CookieVisitor(visitor);
CefRefPtr<CefCookieManager> manager = CefCookieManager::GetGlobalManager();

if (manager != nullptr)
{
return manager->VisitUrlCookies(StringUtils::ToNative(url), includeHttpOnly,
static_cast<CefRefPtr<CefCookieVisitor>>(cookieVisitor));
}
else
if (manager == nullptr)
{
return false;
}

CefRefPtr<CookieVisitor> cookieVisitor = new CookieVisitor(visitor);

return manager->VisitUrlCookies(StringUtils::ToNative(url), includeHttpOnly, cookieVisitor);
}

/// <summary>Sets a CefSharp Cookie. This function expects each attribute to be well-formed. It will check for disallowed
Expand Down Expand Up @@ -305,14 +293,12 @@ namespace CefSharp
{
CefRefPtr<CefCookieManager> manager = CefCookieManager::GetGlobalManager();

if (manager != nullptr)
{
return manager->SetStoragePath(StringUtils::ToNative(path), persistSessionCookies);
}
else
if (manager == nullptr)
{
return false;
}

return manager->SetStoragePath(StringUtils::ToNative(path), persistSessionCookies);
}

/// <summary> Flush the backing store (if any) to disk and execute the specified |handler| on the IO thread when done. Returns </summary>
Expand All @@ -327,9 +313,9 @@ namespace CefSharp
return false;
}

auto wrapper = new CompletionHandler(handler);
CefRefPtr<CefCompletionCallback> wrapper = new CompletionHandler(handler);

return manager->FlushStore(static_cast<CefRefPtr<CefCompletionCallback>>(wrapper));
return manager->FlushStore(wrapper);
}

/// <summary>Shuts down CefSharp and the underlying CEF infrastructure. This method is safe to call multiple times; it will only
Expand Down
14 changes: 9 additions & 5 deletions CefSharp.Core/CefSharp.Core.vcxproj
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="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\cef.sdk.3.2062.1898\build\cef.sdk.props" Condition="Exists('..\packages\cef.sdk.3.2062.1898\build\cef.sdk.props')" />
<Import Project="..\packages\cef.sdk.3.2171.1949\build\cef.sdk.props" Condition="Exists('..\packages\cef.sdk.3.2171.1949\build\cef.sdk.props')" />
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
Expand Down Expand Up @@ -66,7 +66,7 @@
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>11.0.51106.1</_ProjectFileVersion>
<NuGetPackageImportStamp>3c9e3304</NuGetPackageImportStamp>
<NuGetPackageImportStamp>6edfce21</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<OutDir>bin\$(Configuration)\</OutDir>
Expand Down Expand Up @@ -217,13 +217,14 @@
</ItemGroup>
<ItemGroup>
<ClCompile Include="AssemblyInfo.cpp" />
<ClCompile Include="Internals\CefWebPluginInfoWrapper.cpp" />
<ClCompile Include="Internals\CefContextMenuParamsWrapper.cpp" />
<ClCompile Include="Internals\ClientAdapter.cpp" />
<ClCompile Include="Internals\CompletionHandler.cpp" />
<ClCompile Include="Internals\CookieVisitor.cpp" />
<ClCompile Include="Internals\CefRequestWrapper.cpp" />
<ClCompile Include="Internals\DownloadAdapter.cpp" />
<ClCompile Include="Internals\StringVisitor.cpp" />
<ClCompile Include="NativeMethodWrapper.cpp" />
<ClCompile Include="SchemeHandlerResponse.cpp" />
<ClCompile Include="SchemeHandlerWrapper.cpp" />
<ClCompile Include="Stdafx.cpp">
Expand All @@ -239,6 +240,7 @@
<ClInclude Include="BrowserSettings.h" />
<ClInclude Include="Cef.h" />
<ClInclude Include="Internals\AutoLock.h" />
<ClInclude Include="Internals\CefContextMenuParamsWrapper.h" />
<ClInclude Include="Internals\CefDragDataWrapper.h" />
<ClInclude Include="Internals\CompletionHandler.h" />
<ClInclude Include="Internals\DownloadAdapter.h" />
Expand All @@ -249,6 +251,9 @@
<ClInclude Include="Internals\MCefRefPtr.h" />
<ClInclude Include="Internals\RenderClientAdapter.h" />
<ClInclude Include="Internals\StringVisitor.h" />
<ClInclude Include="Internals\TypeConversion.h" />
<ClInclude Include="NativeMethodWrapper.h" />
<ClInclude Include="PaintElementType.h" />
<ClInclude Include="MouseButtonType.h" />
<ClInclude Include="ManagedCefBrowserAdapter.h" />
<ClInclude Include="CefSettings.h" />
Expand All @@ -258,7 +263,6 @@
<ClInclude Include="Internals\StringUtils.h" />
<ClInclude Include="Internals\StreamAdapter.h" />
<ClInclude Include="vcclr_local.h" />
<ClInclude Include="Internals\CefWebPluginInfoWrapper.h" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\CefSharp\CefSharp.csproj">
Expand All @@ -279,6 +283,6 @@
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\cef.sdk.3.2062.1898\build\cef.sdk.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\cef.sdk.3.2062.1898\build\cef.sdk.props'))" />
<Error Condition="!Exists('..\packages\cef.sdk.3.2171.1949\build\cef.sdk.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\cef.sdk.3.2171.1949\build\cef.sdk.props'))" />
</Target>
</Project>
24 changes: 18 additions & 6 deletions CefSharp.Core/CefSharp.Core.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@
<ClCompile Include="SchemeHandlerResponse.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Internals\CefWebPluginInfoWrapper.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Internals\StringVisitor.cpp">
<Filter>Source Files</Filter>
</ClCompile>
Expand All @@ -50,6 +47,12 @@
<ClCompile Include="Internals\CompletionHandler.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Internals\CefContextMenuParamsWrapper.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="NativeMethodWrapper.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="vcclr_local.h">
Expand Down Expand Up @@ -91,6 +94,9 @@
<ClInclude Include="MouseButtonType.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="PaintElementType.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Internals\RenderClientAdapter.h">
<Filter>Header Files</Filter>
</ClInclude>
Expand All @@ -106,9 +112,6 @@
<ClInclude Include="CefSettings.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Internals\CefWebPluginInfoWrapper.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Internals\StringVisitor.h">
<Filter>Header Files</Filter>
</ClInclude>
Expand All @@ -118,9 +121,18 @@
<ClInclude Include="Internals\AutoLock.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Internals\CefContextMenuParamsWrapper.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Internals\CefDragDataWrapper.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="NativeMethodWrapper.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Internals\TypeConversion.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
Expand Down
Loading

0 comments on commit 6acb2b2

Please sign in to comment.