mirror of
https://github.com/cefsharp/CefSharp.git
synced 2026-12-06 04:00:07 +00:00
Merge branch 'master' of https://github.com/Bodekaer/CefSharp
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
SET ThisScriptsDirectory=%~dp0
|
||||
SET PowerShellScriptPath=%ThisScriptsDirectory%Build.ps1
|
||||
PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& {Start-Process PowerShell -ArgumentList '-NoProfile -ExecutionPolicy Bypass -File ""%PowerShellScriptPath%""' -Verb RunAs}";
|
||||
+3
-2
@@ -18,7 +18,7 @@ Thanks for your interest in contributing to the project! Please follow these sim
|
||||
`CefSharp` simply takes the building blocks provided by `Cef` and attempts to provide a usable '.Net' implementation.
|
||||
The upstream [`CEF` forum](http://magpcss.org/ceforum/) is a valuable resource, if your issues seems fairly low level, then please conduct some research before posting.
|
||||
|
||||
It maybe helpful to run the `cefclient` application and compare output with `CefSharp`. The `WinForms` and `WPF` versions use two different rendering modes, `WPF` uses Offscreen Rendering (`OSR`).
|
||||
It maybe helpful to run the `cefclient` application and compare output with `CefSharp`. The `WinForms` and `WPF` versions use two different rendering modes, `WPF` uses Offscreen Rendering (`OSR`). `OffScreen` also uses `OSR` mode.
|
||||
|
||||
- Download **Test App** from http://cefbuilds.com
|
||||
- To compare with WPF run `cefclient --multi-threaded-message-loop --off-screen-rendering-enabled`
|
||||
@@ -44,6 +44,7 @@ Your bug report should **always follow this template**:
|
||||
|
||||
- **What is the expected output? What do you see instead?**
|
||||
- **What steps will reproduce the problem?**
|
||||
- **Are you using `WinForms`, `WPF` or `OffScreen`?**
|
||||
- **What version of the product are you using? On what operating system? x86 or x64?**
|
||||
- What version are you using? Nuget? CI Nuget? build from a branch? If so which branch?
|
||||
- Win7, Win 8, etc?
|
||||
@@ -84,4 +85,4 @@ Pull requests are **awesome**. If you're looking to raise a PR for something whi
|
||||
- Max number of columns are 132, please format your code accordingly
|
||||
- Please don't add #Regions to the code
|
||||
- When adding new files, please prepend the standard license disclaimer (just copy and paste from another source file)
|
||||
- Do your best to follow these guidelines but don't be afraid to make mistakes when trying to apply them. We are all novices in the beginning.
|
||||
- Do your best to follow these guidelines but don't be afraid to make mistakes when trying to apply them. We are all novices in the beginning.
|
||||
|
||||
@@ -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.2171.1972\build\cef.sdk.props" Condition="Exists('..\packages\cef.sdk.3.2171.1972\build\cef.sdk.props')" />
|
||||
<Import Project="..\packages\cef.sdk.3.2171.1979\build\cef.sdk.props" Condition="Exists('..\packages\cef.sdk.3.2171.1979\build\cef.sdk.props')" />
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
@@ -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>03744085</NuGetPackageImportStamp>
|
||||
<NuGetPackageImportStamp>4664bbc5</NuGetPackageImportStamp>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
@@ -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.2171.1972\build\cef.sdk.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\cef.sdk.3.2171.1972\build\cef.sdk.props'))" />
|
||||
<Error Condition="!Exists('..\packages\cef.sdk.3.2171.1979\build\cef.sdk.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\cef.sdk.3.2171.1979\build\cef.sdk.props'))" />
|
||||
</Target>
|
||||
</Project>
|
||||
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="cef.sdk" version="3.2171.1972" targetFramework="Native" />
|
||||
<package id="cef.sdk" version="3.2171.1979" targetFramework="Native" />
|
||||
</packages>
|
||||
@@ -71,13 +71,15 @@ namespace CefSharp
|
||||
|
||||
public ref class BrowserSettings
|
||||
{
|
||||
private:
|
||||
bool _isFinalized;
|
||||
internal:
|
||||
CefBrowserSettings* _browserSettings;
|
||||
|
||||
public:
|
||||
BrowserSettings() : _browserSettings(new CefBrowserSettings()) { }
|
||||
!BrowserSettings() { delete _browserSettings; }
|
||||
~BrowserSettings() { delete _browserSettings; }
|
||||
BrowserSettings() : _browserSettings(new CefBrowserSettings()), _isFinalized(false) { }
|
||||
!BrowserSettings() { delete _browserSettings; _isFinalized = true; }
|
||||
~BrowserSettings() { if (!_isFinalized) this->!BrowserSettings(); }
|
||||
|
||||
// CefBrowserSettings is private causing whole field to be private
|
||||
// exposing void* as a workaround
|
||||
|
||||
+99
-1
@@ -7,6 +7,7 @@
|
||||
#include <msclr/lock.h>
|
||||
#include <include/cef_version.h>
|
||||
#include <include/cef_runnable.h>
|
||||
#include <include/cef_origin_whitelist.h>
|
||||
|
||||
#include "Internals/CefSharpApp.h"
|
||||
#include "Internals/CookieVisitor.h"
|
||||
@@ -168,6 +169,94 @@ namespace CefSharp
|
||||
return success;
|
||||
}
|
||||
|
||||
/// <summary>Add an entry to the cross-origin whitelist.</summary>
|
||||
/// <param name="sourceOrigin">The origin allowed to be accessed by the target protocol/domain.</param>
|
||||
/// <param name="targetProtocol">The target protocol allowed to access the source origin.</param>
|
||||
/// <param name="targetDomain">The optional target domain allowed to access the source origin.</param>
|
||||
/// <param name="allowTargetSubdomains">If set to true would allow a blah.example.com if the
|
||||
/// <paramref name="targetDomain/> was set to example.com
|
||||
/// </param>
|
||||
/// <remarks>
|
||||
/// The same-origin policy restricts how scripts hosted from different origins
|
||||
/// (scheme + domain + port) can communicate. By default, scripts can only access
|
||||
/// resources with the same origin. Scripts hosted on the HTTP and HTTPS schemes
|
||||
/// (but no other schemes) can use the "Access-Control-Allow-Origin" header to
|
||||
/// allow cross-origin requests. For example, https://source.example.com can make
|
||||
/// XMLHttpRequest requests on http://target.example.com if the
|
||||
/// http://target.example.com request returns an "Access-Control-Allow-Origin:
|
||||
/// https://source.example.com" response header.
|
||||
//
|
||||
/// Scripts in separate frames or iframes and hosted from the same protocol and
|
||||
/// domain suffix can execute cross-origin JavaScript if both pages set the
|
||||
/// document.domain value to the same domain suffix. For example,
|
||||
/// scheme://foo.example.com and scheme://bar.example.com can communicate using
|
||||
/// JavaScript if both domains set document.domain="example.com".
|
||||
//
|
||||
/// This method is used to allow access to origins that would otherwise violate
|
||||
/// the same-origin policy. Scripts hosted underneath the fully qualified
|
||||
/// <paramref name="sourceOrigin"/> URL (like http://www.example.com) will be allowed access to
|
||||
/// all resources hosted on the specified <paramref name="targetProtocol"/> and <paramref name="targetDomain"/>.
|
||||
/// If <paramref name="targetDomain"/> is non-empty and <paramref name="allowTargetSubdomains"/> if false only
|
||||
/// exact domain matches will be allowed. If <paramref name="targetDomain"/> contains a top-
|
||||
/// level domain component (like "example.com") and <paramref name="allowTargetSubdomains"/> is
|
||||
/// true sub-domain matches will be allowed. If <paramref name="targetDomain"/> is empty and
|
||||
/// <paramref name="<paramref name="allowTargetSubdomains"/>"/> if true all domains and IP addresses will be
|
||||
/// allowed.
|
||||
//
|
||||
/// This method cannot be used to bypass the restrictions on local or display
|
||||
/// isolated schemes. See the comments on <see cref="CefCustomScheme"/> for more
|
||||
/// information.
|
||||
///
|
||||
/// This function may be called on any thread. Returns false if <paramref name="sourceOrigin"/>
|
||||
/// is invalid or the whitelist cannot be accessed.
|
||||
/// </remarks>
|
||||
static bool AddCrossOriginWhitelistEntry(
|
||||
String^ sourceOrigin,
|
||||
String^ targetProtocol,
|
||||
String^ targetDomain,
|
||||
bool allowTargetSubdomains)
|
||||
{
|
||||
return CefAddCrossOriginWhitelistEntry(
|
||||
StringUtils::ToNative(sourceOrigin),
|
||||
StringUtils::ToNative(targetProtocol),
|
||||
StringUtils::ToNative(targetDomain),
|
||||
allowTargetSubdomains);
|
||||
}
|
||||
|
||||
/// <summary>Remove entry from cross-origin whitelist</summary>
|
||||
/// <param name="sourceOrigin">The origin allowed to be accessed by the target protocol/domain.</param>
|
||||
/// <param name="targetProtocol">The target protocol allowed to access the source origin.</param>
|
||||
/// <param name="targetDomain">The optional target domain allowed to access the source origin.</param>
|
||||
/// <param name="allowTargetSubdomains">If set to true would allow a blah.example.com if the
|
||||
/// <paramref name="targetDomain/> was set to example.com
|
||||
/// </param>
|
||||
/// <remarks>
|
||||
/// Remove an entry from the cross-origin access whitelist. Returns false if
|
||||
/// <paramref name="sourceOrigin"/> is invalid or the whitelist cannot be accessed.
|
||||
/// </remarks>
|
||||
static bool RemoveCrossOriginWhitelistEntry(String^ sourceOrigin,
|
||||
String^ targetProtocol,
|
||||
String^ targetDomain,
|
||||
bool allowTargetSubdomains)
|
||||
|
||||
{
|
||||
return CefRemoveCrossOriginWhitelistEntry(
|
||||
StringUtils::ToNative(sourceOrigin),
|
||||
StringUtils::ToNative(targetProtocol),
|
||||
StringUtils::ToNative(targetDomain),
|
||||
allowTargetSubdomains);
|
||||
}
|
||||
|
||||
/// <summary>Remove all entries from the cross-origin access whitelist.</summary>
|
||||
/// <remarks>
|
||||
/// Remove all entries from the cross-origin access whitelist. Returns false if
|
||||
/// the whitelist cannot be accessed.
|
||||
/// </remarks>
|
||||
static bool ClearCrossOriginWhitelist()
|
||||
{
|
||||
return CefClearCrossOriginWhitelist();
|
||||
}
|
||||
|
||||
/// <summary>Visits all cookies using the provided Cookie Visitor. The returned cookies are sorted by longest path, then by earliest creation date.</summary>
|
||||
/// <param name="visitor">A user-provided Cookie Visitor implementation.</param>
|
||||
/// <return>Returns false if the CookieManager is not available; otherwise, true.</return>
|
||||
@@ -258,9 +347,9 @@ namespace CefSharp
|
||||
/// characters (e.g. the ';' character is disallowed within the cookie value attribute) and will return false without setting
|
||||
/// the cookie if such characters are found.</summary>
|
||||
/// <param name="url">The cookie URL</param>
|
||||
/// <param name="domain">The cookie domain.</param>
|
||||
/// <param name="name">The cookie name.</param>
|
||||
/// <param name="value">The cookie value.</param>
|
||||
/// <param name="domain">The cookie domain.</param>
|
||||
/// <param name="expires">The DateTime when the cookie will be treated as expired.</param>
|
||||
/// <return>false if the cookie cannot be set (e.g. if illegal charecters such as ';' are used); otherwise true.</return>
|
||||
static bool SetCookie(String^ url, String^ domain, String^ name, String^ value, DateTime expires)
|
||||
@@ -348,5 +437,14 @@ namespace CefSharp
|
||||
IsInitialized = false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clear all registered scheme handler factories.
|
||||
/// </summary>
|
||||
/// <return>Returns false on error.</return>
|
||||
static bool ClearSchemeHandlerFactories()
|
||||
{
|
||||
return CefClearSchemeHandlerFactories();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -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.2171.1972\build\cef.sdk.props" Condition="Exists('..\packages\cef.sdk.3.2171.1972\build\cef.sdk.props')" />
|
||||
<Import Project="..\packages\cef.sdk.3.2171.1979\build\cef.sdk.props" Condition="Exists('..\packages\cef.sdk.3.2171.1979\build\cef.sdk.props')" />
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
@@ -66,7 +66,7 @@
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup>
|
||||
<_ProjectFileVersion>11.0.51106.1</_ProjectFileVersion>
|
||||
<NuGetPackageImportStamp>6edfce21</NuGetPackageImportStamp>
|
||||
<NuGetPackageImportStamp>84bd8e6a</NuGetPackageImportStamp>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<OutDir>bin\$(Configuration)\</OutDir>
|
||||
@@ -225,6 +225,7 @@
|
||||
<ClCompile Include="Internals\DownloadAdapter.cpp" />
|
||||
<ClCompile Include="Internals\StringVisitor.cpp" />
|
||||
<ClCompile Include="NativeMethodWrapper.cpp" />
|
||||
<ClCompile Include="SchemeHandlerFactoryWrapper.cpp" />
|
||||
<ClCompile Include="SchemeHandlerResponse.cpp" />
|
||||
<ClCompile Include="SchemeHandlerWrapper.cpp" />
|
||||
<ClCompile Include="Stdafx.cpp">
|
||||
@@ -257,6 +258,7 @@
|
||||
<ClInclude Include="MouseButtonType.h" />
|
||||
<ClInclude Include="ManagedCefBrowserAdapter.h" />
|
||||
<ClInclude Include="CefSettings.h" />
|
||||
<ClInclude Include="SchemeHandlerFactoryWrapper.h" />
|
||||
<ClInclude Include="SchemeHandlerResponse.h" />
|
||||
<ClInclude Include="SchemeHandlerWrapper.h" />
|
||||
<ClInclude Include="Stdafx.h" />
|
||||
@@ -283,6 +285,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.2171.1972\build\cef.sdk.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\cef.sdk.3.2171.1972\build\cef.sdk.props'))" />
|
||||
<Error Condition="!Exists('..\packages\cef.sdk.3.2171.1979\build\cef.sdk.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\cef.sdk.3.2171.1979\build\cef.sdk.props'))" />
|
||||
</Target>
|
||||
</Project>
|
||||
@@ -53,6 +53,9 @@
|
||||
<ClCompile Include="NativeMethodWrapper.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="SchemeHandlerFactoryWrapper.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="vcclr_local.h">
|
||||
@@ -133,6 +136,9 @@
|
||||
<ClInclude Include="Internals\TypeConversion.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="SchemeHandlerFactoryWrapper.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
|
||||
@@ -41,6 +41,24 @@ namespace CefSharp
|
||||
virtual property bool IsFragment;
|
||||
virtual property bool IsLink;
|
||||
|
||||
///
|
||||
// Create a new CefDragData object.
|
||||
///
|
||||
/*--cef()--*/
|
||||
static CefDragDataWrapper^ Create()
|
||||
{
|
||||
CefRefPtr<CefDragData> cefDragData = CefDragData::Create();
|
||||
return gcnew CefDragDataWrapper(cefDragData);
|
||||
}
|
||||
|
||||
virtual property CefRefPtr<CefDragData>* InternalDragData
|
||||
{
|
||||
CefRefPtr<CefDragData>* get()
|
||||
{
|
||||
return new CefRefPtr<CefDragData>(_wrappedDragData.get());
|
||||
}
|
||||
}
|
||||
|
||||
//TODO: Vector is a pointer, so can potentially be updated (items may be possibly removed)
|
||||
virtual property IList<String^>^ FileNames
|
||||
{
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "include/cef_app.h"
|
||||
#include "CefSettings.h"
|
||||
#include "SchemeHandlerWrapper.h"
|
||||
#include "SchemeHandlerFactoryWrapper.h"
|
||||
|
||||
namespace CefSharp
|
||||
{
|
||||
@@ -56,7 +57,7 @@ namespace CefSharp
|
||||
// when the process is shutting down.
|
||||
|
||||
// TOOD: Consider adding error handling here. But where do we report any errors that may have occurred?
|
||||
registrar->AddCustomScheme(StringUtils::ToNative(cefCustomScheme->SchemeName), cefCustomScheme->IsStandard, false, false);
|
||||
registrar->AddCustomScheme(StringUtils::ToNative(cefCustomScheme->SchemeName), cefCustomScheme->IsStandard, cefCustomScheme->IsLocal, cefCustomScheme->IsDisplayIsolated);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -569,5 +569,32 @@ namespace CefSharp
|
||||
|
||||
return handler->OnDragEnter(_browserControl, dragDataWrapper, (CefSharp::DragOperationsMask)mask);
|
||||
}
|
||||
|
||||
bool ClientAdapter::OnRequestGeolocationPermission(CefRefPtr<CefBrowser> browser, const CefString& requesting_url, int request_id, CefRefPtr<CefGeolocationCallback> callback)
|
||||
{
|
||||
IGeolocationHandler^ handler = _browserControl->GeolocationHandler;
|
||||
if (handler == nullptr)
|
||||
{
|
||||
// Default deny, as CEF does.
|
||||
return false;
|
||||
}
|
||||
|
||||
if (handler->OnRequestGeolocationPermission(_browserControl, StringUtils::ToClr(requesting_url), request_id))
|
||||
{
|
||||
callback->Continue(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void ClientAdapter::OnCancelGeolocationPermission(CefRefPtr<CefBrowser> browser, const CefString& requesting_url, int request_id)
|
||||
{
|
||||
IGeolocationHandler^ handler = _browserControl->GeolocationHandler;
|
||||
if (handler != nullptr)
|
||||
{
|
||||
handler->OnCancelGeolocationPermission(_browserControl, StringUtils::ToClr(requesting_url), request_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,8 +15,6 @@ using namespace System;
|
||||
|
||||
namespace CefSharp
|
||||
{
|
||||
ref class ManagedCefBrowserAdapter;
|
||||
|
||||
namespace Internals
|
||||
{
|
||||
private class ClientAdapter : public CefClient,
|
||||
@@ -29,7 +27,8 @@ namespace CefSharp
|
||||
public CefKeyboardHandler,
|
||||
public CefJSDialogHandler,
|
||||
public CefDialogHandler,
|
||||
public CefDragHandler
|
||||
public CefDragHandler,
|
||||
public CefGeolocationHandler
|
||||
{
|
||||
private:
|
||||
CriticalSection _syncRoot;
|
||||
@@ -75,6 +74,7 @@ namespace CefSharp
|
||||
virtual CefRefPtr<CefJSDialogHandler> GetJSDialogHandler() OVERRIDE{ return this; }
|
||||
virtual CefRefPtr<CefDialogHandler> GetDialogHandler() OVERRIDE{ return this; }
|
||||
virtual CefRefPtr<CefDragHandler> GetDragHandler() OVERRIDE{ return this; }
|
||||
virtual CefRefPtr<CefGeolocationHandler> GetGeolocationHandler() OVERRIDE{ return this; }
|
||||
|
||||
// CefLifeSpanHandler
|
||||
virtual DECL bool OnBeforePopup(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame,
|
||||
@@ -136,6 +136,11 @@ namespace CefSharp
|
||||
//CefDragHandler
|
||||
virtual DECL bool OnDragEnter(CefRefPtr<CefBrowser> browser, CefRefPtr<CefDragData> dragData, DragOperationsMask mask) OVERRIDE;
|
||||
|
||||
//CefGeolocationHandler
|
||||
virtual DECL bool OnRequestGeolocationPermission(CefRefPtr<CefBrowser> browser, const CefString& requesting_url, int request_id,
|
||||
CefRefPtr<CefGeolocationCallback> callback) OVERRIDE;
|
||||
virtual DECL void OnCancelGeolocationPermission(CefRefPtr<CefBrowser> browser, const CefString& requesting_url, int request_id) OVERRIDE;
|
||||
|
||||
IMPLEMENT_REFCOUNTING(ClientAdapter);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -39,12 +39,12 @@ namespace CefSharp
|
||||
_renderWebBrowser = nullptr;
|
||||
_webBrowserInternal = nullptr;
|
||||
|
||||
DisposeBitmapInfo(_mainBitmapInfo);
|
||||
ReleaseBitmapHandlers(_mainBitmapInfo);
|
||||
|
||||
delete _mainBitmapInfo;
|
||||
_mainBitmapInfo = nullptr;
|
||||
|
||||
DisposeBitmapInfo(_popupBitmapInfo);
|
||||
ReleaseBitmapHandlers(_popupBitmapInfo);
|
||||
|
||||
delete _popupBitmapInfo;
|
||||
_popupBitmapInfo = nullptr;
|
||||
@@ -92,14 +92,54 @@ namespace CefSharp
|
||||
|
||||
lock l(bitmapInfo->BitmapLock);
|
||||
|
||||
auto fileMappingHandle = (HANDLE)bitmapInfo->FileMappingHandle;
|
||||
if(bitmapInfo->DirtyRectSupport)
|
||||
{
|
||||
//NOTE: According to https://bitbucket.org/chromiumembedded/branches-2171-cef3/commits/ce984ddff3268a50cf9967487327e1257015b98c
|
||||
// There is only one rect now that's a union of all dirty regions. API Still passes in a vector
|
||||
|
||||
CefRect r = dirtyRects.front();
|
||||
bitmapInfo->DirtyRect = CefDirtyRect(r.x, r.y, r.width, r.height);
|
||||
}
|
||||
|
||||
auto backBufferHandle = (HANDLE)bitmapInfo->BackBufferHandle;
|
||||
|
||||
SetBufferHelper(bitmapInfo, width, height, &fileMappingHandle,
|
||||
&backBufferHandle, buffer);
|
||||
if (backBufferHandle == NULL || bitmapInfo->Width != width || bitmapInfo->Height != height)
|
||||
{
|
||||
int pixels = width * height;
|
||||
int numberOfBytes = pixels * bitmapInfo->BytesPerPixel;
|
||||
auto fileMappingHandle = (HANDLE)bitmapInfo->FileMappingHandle;
|
||||
|
||||
bitmapInfo->FileMappingHandle = (IntPtr)fileMappingHandle;
|
||||
bitmapInfo->BackBufferHandle = (IntPtr)backBufferHandle;
|
||||
//Clear the reference to Bitmap so a new one is created by InvokeRenderAsync
|
||||
bitmapInfo->ClearBitmap();
|
||||
|
||||
//Release the current handles (if not null)
|
||||
ReleaseBitmapHandlers(bitmapInfo);
|
||||
|
||||
// Create new fileMappingHandle
|
||||
fileMappingHandle = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, numberOfBytes, NULL);
|
||||
if (fileMappingHandle == NULL)
|
||||
{
|
||||
// TODO: Consider doing something more sensible here, since the browser will be very badly broken if this
|
||||
// TODO: method call fails.
|
||||
return;
|
||||
}
|
||||
|
||||
backBufferHandle = MapViewOfFile(fileMappingHandle, FILE_MAP_ALL_ACCESS, 0, 0, numberOfBytes);
|
||||
if (backBufferHandle == NULL)
|
||||
{
|
||||
// TODO: Consider doing something more sensible here, since the browser will be very badly broken if this
|
||||
// TODO: method call fails.
|
||||
return;
|
||||
}
|
||||
|
||||
bitmapInfo->FileMappingHandle = (IntPtr)fileMappingHandle;
|
||||
bitmapInfo->BackBufferHandle = (IntPtr)backBufferHandle;
|
||||
bitmapInfo->Width = width;
|
||||
bitmapInfo->Height = height;
|
||||
bitmapInfo->NumberOfBytes = numberOfBytes;
|
||||
}
|
||||
|
||||
CopyMemory(backBufferHandle, (void*)buffer, bitmapInfo->NumberOfBytes);
|
||||
|
||||
_renderWebBrowser->InvokeRenderAsync(bitmapInfo);
|
||||
};
|
||||
@@ -111,67 +151,24 @@ namespace CefSharp
|
||||
};
|
||||
|
||||
private:
|
||||
void SetBufferHelper(BitmapInfo^ bitmapInfo, int newWidth, int newHeight,
|
||||
HANDLE* fileMappingHandle, HANDLE* backBufferHandle, const void* buffer)
|
||||
{
|
||||
int pixels = newWidth * newHeight;
|
||||
int numberOfBytes = pixels * bitmapInfo->BytesPerPixel;
|
||||
|
||||
if (*backBufferHandle == NULL ||
|
||||
bitmapInfo->Width != newWidth ||
|
||||
bitmapInfo->Height != newHeight)
|
||||
{
|
||||
//Clear the reference to Bitmap so a new one is created by InvokeRenderAsync
|
||||
bitmapInfo->ClearBitmap();
|
||||
|
||||
//Release the current handles (if not null)
|
||||
ReleaseBitmapHandlers(backBufferHandle, fileMappingHandle);
|
||||
|
||||
// Create new fileMappingHandle
|
||||
*fileMappingHandle = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, numberOfBytes, NULL);
|
||||
if (*fileMappingHandle == NULL)
|
||||
{
|
||||
// TODO: Consider doing something more sensible here, since the browser will be very badly broken if this
|
||||
// TODO: method call fails.
|
||||
return;
|
||||
}
|
||||
|
||||
*backBufferHandle = MapViewOfFile(*fileMappingHandle, FILE_MAP_ALL_ACCESS, 0, 0, numberOfBytes);
|
||||
if (*backBufferHandle == NULL)
|
||||
{
|
||||
// TODO: Consider doing something more sensible here, since the browser will be very badly broken if this
|
||||
// TODO: method call fails.
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
bitmapInfo->Width = newWidth;
|
||||
bitmapInfo->Height = newHeight;
|
||||
|
||||
CopyMemory(*backBufferHandle, (void*)buffer, numberOfBytes);
|
||||
};
|
||||
|
||||
void ReleaseBitmapHandlers(HANDLE* backBufferHandle, HANDLE* fileMappingHandle)
|
||||
{
|
||||
if (*backBufferHandle != NULL)
|
||||
{
|
||||
UnmapViewOfFile(*backBufferHandle);
|
||||
*backBufferHandle = NULL;
|
||||
}
|
||||
|
||||
if (*fileMappingHandle != NULL)
|
||||
{
|
||||
CloseHandle(*fileMappingHandle);
|
||||
*fileMappingHandle = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void DisposeBitmapInfo(BitmapInfo^ bitmapInfo)
|
||||
void ReleaseBitmapHandlers(BitmapInfo^ bitmapInfo)
|
||||
{
|
||||
auto backBufferHandle = (HANDLE)bitmapInfo->BackBufferHandle;
|
||||
auto fileMappingHandle = (HANDLE)bitmapInfo->FileMappingHandle;
|
||||
|
||||
ReleaseBitmapHandlers(&backBufferHandle, &fileMappingHandle);
|
||||
if (backBufferHandle != NULL)
|
||||
{
|
||||
UnmapViewOfFile(backBufferHandle);
|
||||
backBufferHandle = NULL;
|
||||
bitmapInfo->BackBufferHandle = IntPtr::Zero;
|
||||
}
|
||||
|
||||
if (fileMappingHandle != NULL)
|
||||
{
|
||||
CloseHandle(fileMappingHandle);
|
||||
fileMappingHandle = NULL;
|
||||
bitmapInfo->FileMappingHandle = IntPtr::Zero;
|
||||
}
|
||||
}
|
||||
|
||||
IMPLEMENT_REFCOUNTING(RenderClientAdapter)
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace CefSharp
|
||||
{
|
||||
StreamAdapter::~StreamAdapter()
|
||||
{
|
||||
_stream->Close();
|
||||
//Remove the reference to the stream, must be kept open as it might be reused for subsiquent requests (e.g. refresh).
|
||||
_stream = nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,11 @@ namespace CefSharp
|
||||
|
||||
public:
|
||||
virtual ~StreamAdapter();
|
||||
StreamAdapter(Stream^ stream) : _stream(stream) { }
|
||||
StreamAdapter(Stream^ stream) : _stream(stream)
|
||||
{
|
||||
//Reset stream position
|
||||
stream->Position = 0;
|
||||
}
|
||||
|
||||
virtual size_t Read(void* ptr, size_t size, size_t n);
|
||||
virtual int Seek(int64 offset, int whence);
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "MouseButtonType.h"
|
||||
#include "PaintElementType.h"
|
||||
#include "Internals/ClientAdapter.h"
|
||||
#include "Internals/CefDragDataWrapper.h"
|
||||
#include "Internals/RenderClientAdapter.h"
|
||||
#include "Internals/MCefRefPtr.h"
|
||||
#include "Internals/StringVisitor.h"
|
||||
@@ -34,7 +35,9 @@ namespace CefSharp
|
||||
Close(true);
|
||||
|
||||
_clientAdapter = nullptr;
|
||||
if (_browserProcessServiceHost != nullptr)
|
||||
|
||||
// Guard managed only member derefs by isDisposing:
|
||||
if (isDisposing && _browserProcessServiceHost != nullptr)
|
||||
{
|
||||
_browserProcessServiceHost->Close();
|
||||
_browserProcessServiceHost = nullptr;
|
||||
@@ -669,5 +672,55 @@ namespace CefSharp
|
||||
browser->GetHost()->AddWordToDictionary(wordNative);
|
||||
}
|
||||
}
|
||||
|
||||
CefMouseEvent GetCefMouseEvent(MouseEvent^ mouseEvent)
|
||||
{
|
||||
CefMouseEvent cefMouseEvent;
|
||||
cefMouseEvent.x = mouseEvent->X;
|
||||
cefMouseEvent.y = mouseEvent->Y;
|
||||
cefMouseEvent.modifiers = (uint32)mouseEvent->Modifiers;
|
||||
return cefMouseEvent;
|
||||
}
|
||||
|
||||
void OnDragTargetDragEnter(CefDragDataWrapper^ dragData, MouseEvent^ mouseEvent, DragOperationsMask allowedOperations)
|
||||
{
|
||||
auto browser = _clientAdapter->GetCefBrowser();
|
||||
|
||||
if (browser != nullptr)
|
||||
{
|
||||
dragData->ResetFileContents(); // Recommended by documentation to reset before calling DragEnter
|
||||
browser->GetHost()->DragTargetDragEnter(*dragData->InternalDragData, GetCefMouseEvent(mouseEvent), (CefBrowserHost::DragOperationsMask) allowedOperations);
|
||||
}
|
||||
}
|
||||
|
||||
void OnDragTargetDragOver(MouseEvent^ mouseEvent, DragOperationsMask allowedOperations)
|
||||
{
|
||||
auto browser = _clientAdapter->GetCefBrowser();
|
||||
|
||||
if (browser != nullptr)
|
||||
{
|
||||
browser->GetHost()->DragTargetDragOver(GetCefMouseEvent(mouseEvent), (CefBrowserHost::DragOperationsMask) allowedOperations);
|
||||
}
|
||||
}
|
||||
|
||||
void OnDragTargetDragLeave()
|
||||
{
|
||||
auto browser = _clientAdapter->GetCefBrowser();
|
||||
|
||||
if (browser != nullptr)
|
||||
{
|
||||
browser->GetHost()->DragTargetDragLeave();
|
||||
}
|
||||
}
|
||||
|
||||
void OnDragTargetDragDrop(MouseEvent^ mouseEvent)
|
||||
{
|
||||
auto browser = _clientAdapter->GetCefBrowser();
|
||||
|
||||
if (browser != nullptr)
|
||||
{
|
||||
browser->GetHost()->DragTargetDrop(GetCefMouseEvent(mouseEvent));
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
// Copyright © 2010-2014 The CefSharp Authors. All rights reserved.
|
||||
//
|
||||
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
#include "Stdafx.h"
|
||||
#include "SchemeHandlerFactoryWrapper.h"
|
||||
|
||||
using namespace System::Runtime::InteropServices;
|
||||
using namespace System::IO;
|
||||
|
||||
namespace CefSharp
|
||||
{
|
||||
CefRefPtr<CefResourceHandler> SchemeHandlerFactoryWrapper::Create(
|
||||
CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
const CefString& scheme_name,
|
||||
CefRefPtr<CefRequest> request)
|
||||
{
|
||||
ISchemeHandler^ handler = _factory->Create();
|
||||
CefRefPtr<SchemeHandlerWrapper> wrapper = new SchemeHandlerWrapper(handler);
|
||||
return static_cast<CefRefPtr<CefResourceHandler>>(wrapper);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
// Copyright © 2010-2014 The CefSharp Authors. All rights reserved.
|
||||
//
|
||||
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Stdafx.h"
|
||||
#include "include/cef_scheme.h"
|
||||
#include "Internals/AutoLock.h"
|
||||
|
||||
using namespace System;
|
||||
using namespace System::IO;
|
||||
using namespace System::Collections::Specialized;
|
||||
|
||||
namespace CefSharp
|
||||
{
|
||||
class SchemeHandlerFactoryWrapper : public CefSchemeHandlerFactory
|
||||
{
|
||||
gcroot<ISchemeHandlerFactory^> _factory;
|
||||
|
||||
public:
|
||||
SchemeHandlerFactoryWrapper(ISchemeHandlerFactory^ factory)
|
||||
: _factory(factory) {}
|
||||
|
||||
virtual CefRefPtr<CefResourceHandler> Create(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, const CefString& scheme_name, CefRefPtr<CefRequest> request);
|
||||
|
||||
IMPLEMENT_REFCOUNTING(SchemeHandlerFactoryWrapper);
|
||||
};
|
||||
}
|
||||
@@ -142,15 +142,4 @@ namespace CefSharp
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
CefRefPtr<CefResourceHandler> SchemeHandlerFactoryWrapper::Create(
|
||||
CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
const CefString& scheme_name,
|
||||
CefRefPtr<CefRequest> request)
|
||||
{
|
||||
ISchemeHandler^ handler = _factory->Create();
|
||||
CefRefPtr<SchemeHandlerWrapper> wrapper = new SchemeHandlerWrapper(handler);
|
||||
return static_cast<CefRefPtr<CefResourceHandler>>(wrapper);
|
||||
}
|
||||
}
|
||||
@@ -49,17 +49,4 @@ namespace CefSharp
|
||||
|
||||
IMPLEMENT_REFCOUNTING(SchemeHandlerWrapper);
|
||||
};
|
||||
|
||||
class SchemeHandlerFactoryWrapper : public CefSchemeHandlerFactory
|
||||
{
|
||||
gcroot<ISchemeHandlerFactory^> _factory;
|
||||
|
||||
public:
|
||||
SchemeHandlerFactoryWrapper(ISchemeHandlerFactory^ factory)
|
||||
: _factory(factory) {}
|
||||
|
||||
virtual CefRefPtr<CefResourceHandler> Create(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, const CefString& scheme_name, CefRefPtr<CefRequest> request);
|
||||
|
||||
IMPLEMENT_REFCOUNTING(SchemeHandlerFactoryWrapper);
|
||||
};
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="cef.sdk" version="3.2171.1972" targetFramework="Native" />
|
||||
<package id="cef.sdk" version="3.2171.1979" targetFramework="Native" />
|
||||
</packages>
|
||||
@@ -15,12 +15,28 @@ namespace CefSharp.Example
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
// Set Google API keys, used for Geolocation requests sans GPS. See http://www.chromium.org/developers/how-tos/api-keys
|
||||
// Environment.SetEnvironmentVariable("GOOGLE_API_KEY", "");
|
||||
// Environment.SetEnvironmentVariable("GOOGLE_DEFAULT_CLIENT_ID", "");
|
||||
// Environment.SetEnvironmentVariable("GOOGLE_DEFAULT_CLIENT_SECRET", "");
|
||||
|
||||
//Chromium Command Line args
|
||||
//http://peter.sh/experiments/chromium-command-line-switches/
|
||||
//NOTE: Note all relevant in relation to `CefSharp`, use for reference purposes only.
|
||||
|
||||
var settings = new CefSettings();
|
||||
settings.RemoteDebuggingPort = 8088;
|
||||
//settings.CefCommandLineArgs.Add("renderer-process-limit", "1");
|
||||
//settings.CefCommandLineArgs.Add("renderer-startup-dialog", "renderer-startup-dialog");
|
||||
//settings.CefCommandLineArgs.Add("disable-gpu", "1");
|
||||
//settings.CefCommandLineArgs.Add("disable-gpu-vsync", "1");
|
||||
//settings.CefCommandLineArgs.Add("enable-media-stream", "1"); //Enable WebRTC
|
||||
//settings.CefCommandLineArgs.Add("no-proxy-server", "1"); //Don't use a proxy server, always make direct connections. Overrides any other proxy server flags that are passed.
|
||||
|
||||
//Disables the DirectWrite font rendering system on windows.
|
||||
//Possibly useful when experiencing blury fonts.
|
||||
//settings.CefCommandLineArgs.Add("disable-direct-write", "1");
|
||||
|
||||
settings.LogSeverity = LogSeverity.Verbose;
|
||||
|
||||
if (DebuggingSubProcess)
|
||||
|
||||
@@ -14,6 +14,11 @@
|
||||
<option>one</option>
|
||||
<option>two</option>
|
||||
</select>
|
||||
<select style="float: right">
|
||||
<option selected>testRight</option>
|
||||
<option>three</option>
|
||||
<option>four</option>
|
||||
</select>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
@@ -13,7 +13,7 @@
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<TargetFrameworkProfile>
|
||||
</TargetFrameworkProfile>
|
||||
<NuGetPackageImportStamp>320b0b24</NuGetPackageImportStamp>
|
||||
<NuGetPackageImportStamp>793b99d4</NuGetPackageImportStamp>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
@@ -94,9 +94,9 @@
|
||||
<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.redist.x64.3.2171.1972\build\cef.redist.x64.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\cef.redist.x64.3.2171.1972\build\cef.redist.x64.targets'))" />
|
||||
<Error Condition="!Exists('..\packages\cef.redist.x86.3.2171.1972\build\cef.redist.x86.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\cef.redist.x86.3.2171.1972\build\cef.redist.x86.targets'))" />
|
||||
<Error Condition="!Exists('..\packages\cef.redist.x64.3.2171.1979\build\cef.redist.x64.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\cef.redist.x64.3.2171.1979\build\cef.redist.x64.targets'))" />
|
||||
<Error Condition="!Exists('..\packages\cef.redist.x86.3.2171.1979\build\cef.redist.x86.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\cef.redist.x86.3.2171.1979\build\cef.redist.x86.targets'))" />
|
||||
</Target>
|
||||
<Import Project="..\packages\cef.redist.x64.3.2171.1972\build\cef.redist.x64.targets" Condition="Exists('..\packages\cef.redist.x64.3.2171.1972\build\cef.redist.x64.targets')" />
|
||||
<Import Project="..\packages\cef.redist.x86.3.2171.1972\build\cef.redist.x86.targets" Condition="Exists('..\packages\cef.redist.x86.3.2171.1972\build\cef.redist.x86.targets')" />
|
||||
<Import Project="..\packages\cef.redist.x64.3.2171.1979\build\cef.redist.x64.targets" Condition="Exists('..\packages\cef.redist.x64.3.2171.1979\build\cef.redist.x64.targets')" />
|
||||
<Import Project="..\packages\cef.redist.x86.3.2171.1979\build\cef.redist.x86.targets" Condition="Exists('..\packages\cef.redist.x86.3.2171.1979\build\cef.redist.x86.targets')" />
|
||||
</Project>
|
||||
@@ -29,22 +29,24 @@ namespace CefSharp.OffScreen.Example
|
||||
CefExample.Init();
|
||||
|
||||
// Create the offscreen Chromium browser.
|
||||
browser = new ChromiumWebBrowser(testUrl);
|
||||
|
||||
// An event that is fired when the first page is finished loading.
|
||||
// This returns to us from another thread.
|
||||
if (captureFirstRenderedImage)
|
||||
using (browser = new ChromiumWebBrowser(testUrl))
|
||||
{
|
||||
browser.ResourceHandler.RegisterHandler(testUrl, ResourceHandler.FromString("<html><body><h1>CefSharp OffScreen</h1></body></html>"));
|
||||
browser.ScreenshotAsync().ContinueWith(DisplayBitmap);
|
||||
}
|
||||
else
|
||||
{
|
||||
browser.FrameLoadEnd += BrowserFrameLoadEnd;
|
||||
}
|
||||
|
||||
// We have to wait for something, otherwise the process will exit too soon.
|
||||
Console.ReadKey();
|
||||
// An event that is fired when the first page is finished loading.
|
||||
// This returns to us from another thread.
|
||||
if (captureFirstRenderedImage)
|
||||
{
|
||||
browser.ResourceHandler.RegisterHandler(testUrl, ResourceHandler.FromString("<html><body><h1>CefSharp OffScreen</h1></body></html>"));
|
||||
browser.ScreenshotAsync().ContinueWith(DisplayBitmap);
|
||||
}
|
||||
else
|
||||
{
|
||||
browser.FrameLoadEnd += BrowserFrameLoadEnd;
|
||||
}
|
||||
|
||||
// We have to wait for something, otherwise the process will exit too soon.
|
||||
Console.ReadKey();
|
||||
}
|
||||
|
||||
// Clean up Chromium objects. You need to call this in your application otherwise
|
||||
// you will get a crash when closing.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="cef.redist.x64" version="3.2171.1972" targetFramework="net45" />
|
||||
<package id="cef.redist.x86" version="3.2171.1972" targetFramework="net45" />
|
||||
<package id="cef.redist.x64" version="3.2171.1979" targetFramework="net45" />
|
||||
<package id="cef.redist.x86" version="3.2171.1979" targetFramework="net45" />
|
||||
</packages>
|
||||
@@ -44,34 +44,74 @@ namespace CefSharp.OffScreen
|
||||
/// <param name="browserSettings">The browser settings to use. If null, the default settings are used.</param>
|
||||
public ChromiumWebBrowser(string address, BrowserSettings browserSettings = null)
|
||||
{
|
||||
if (!Cef.IsInitialized && !Cef.Initialize())
|
||||
{
|
||||
throw new InvalidOperationException("Cef::Initialize() failed");
|
||||
}
|
||||
|
||||
ResourceHandler = new DefaultResourceHandler();
|
||||
|
||||
Cef.AddDisposable(this);
|
||||
Address = address;
|
||||
|
||||
managedCefBrowserAdapter = new ManagedCefBrowserAdapter(this, true);
|
||||
managedCefBrowserAdapter.CreateOffscreenBrowser(IntPtr.Zero, browserSettings ?? new BrowserSettings(), address);
|
||||
}
|
||||
|
||||
~ChromiumWebBrowser()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
// Don't reference handlers any longer:
|
||||
ResourceHandler = null;
|
||||
JsDialogHandler = null;
|
||||
DialogHandler = null;
|
||||
DownloadHandler = null;
|
||||
KeyboardHandler = null;
|
||||
LifeSpanHandler = null;
|
||||
MenuHandler = null;
|
||||
FocusHandler = null;
|
||||
RequestHandler = null;
|
||||
DragHandler = null;
|
||||
GeolocationHandler = null;
|
||||
|
||||
// Don't reference event listeners any longer:
|
||||
LoadError = null;
|
||||
FrameLoadStart = null;
|
||||
FrameLoadEnd = null;
|
||||
ConsoleMessage = null;
|
||||
BrowserInitialized = null;
|
||||
StatusMessage = null;
|
||||
NavStateChanged = null;
|
||||
|
||||
Cef.RemoveDisposable(this);
|
||||
|
||||
if (bitmap != null)
|
||||
if (disposing)
|
||||
{
|
||||
bitmap.Dispose();
|
||||
bitmap = null;
|
||||
}
|
||||
if (bitmap != null)
|
||||
{
|
||||
bitmap.Dispose();
|
||||
bitmap = null;
|
||||
}
|
||||
|
||||
if (managedCefBrowserAdapter != null)
|
||||
{
|
||||
if (!managedCefBrowserAdapter.IsDisposed)
|
||||
managedCefBrowserAdapter.Dispose();
|
||||
managedCefBrowserAdapter = null;
|
||||
if (managedCefBrowserAdapter != null)
|
||||
{
|
||||
if (!managedCefBrowserAdapter.IsDisposed)
|
||||
{
|
||||
managedCefBrowserAdapter.Dispose();
|
||||
}
|
||||
managedCefBrowserAdapter = null;
|
||||
}
|
||||
}
|
||||
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -168,6 +208,7 @@ namespace CefSharp.OffScreen
|
||||
public IRequestHandler RequestHandler { get; set; }
|
||||
public IDragHandler DragHandler { get; set; }
|
||||
public IResourceHandler ResourceHandler { get; set; }
|
||||
public IGeolocationHandler GeolocationHandler { get; set; }
|
||||
|
||||
public event EventHandler<LoadErrorEventArgs> LoadError;
|
||||
public event EventHandler<FrameLoadStartEventArgs> FrameLoadStart;
|
||||
@@ -197,7 +238,7 @@ namespace CefSharp.OffScreen
|
||||
managedCefBrowserAdapter.AddWordToDictionary(word);
|
||||
}
|
||||
|
||||
public string Address { get; set; }
|
||||
public string Address { get; private set; }
|
||||
|
||||
public bool CanGoBack { get; private set; }
|
||||
|
||||
@@ -343,7 +384,7 @@ namespace CefSharp.OffScreen
|
||||
public BitmapInfo CreateBitmapInfo(bool isPopup)
|
||||
{
|
||||
//The bitmap buffer is 32 BPP
|
||||
return new GdiBitmapInfo { IsPopup = isPopup, BytesPerPixel = 4, BitmapLock = bitmapLock };
|
||||
return new GdiBitmapInfo { IsPopup = isPopup, BitmapLock = bitmapLock };
|
||||
}
|
||||
|
||||
void IRenderWebBrowser.InvokeRenderAsync(BitmapInfo bitmapInfo)
|
||||
|
||||
@@ -8,7 +8,17 @@ namespace CefSharp.OffScreen
|
||||
{
|
||||
public class GdiBitmapInfo : BitmapInfo
|
||||
{
|
||||
public bool IsCleared { get; set; }
|
||||
public bool IsCleared { get; private set; }
|
||||
|
||||
public GdiBitmapInfo()
|
||||
{
|
||||
BytesPerPixel = 4;
|
||||
}
|
||||
|
||||
public override bool CreateNewBitmap
|
||||
{
|
||||
get { return IsCleared; }
|
||||
}
|
||||
|
||||
public override void ClearBitmap()
|
||||
{
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
<OldToolsVersion>3.5</OldToolsVersion>
|
||||
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
|
||||
<TargetFrameworkProfile />
|
||||
<NuGetPackageImportStamp>85aa022d</NuGetPackageImportStamp>
|
||||
<NuGetPackageImportStamp>578e8d6c</NuGetPackageImportStamp>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
@@ -142,9 +142,9 @@
|
||||
<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.redist.x64.3.2171.1972\build\cef.redist.x64.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\cef.redist.x64.3.2171.1972\build\cef.redist.x64.targets'))" />
|
||||
<Error Condition="!Exists('..\packages\cef.redist.x86.3.2171.1972\build\cef.redist.x86.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\cef.redist.x86.3.2171.1972\build\cef.redist.x86.targets'))" />
|
||||
<Error Condition="!Exists('..\packages\cef.redist.x64.3.2171.1979\build\cef.redist.x64.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\cef.redist.x64.3.2171.1979\build\cef.redist.x64.targets'))" />
|
||||
<Error Condition="!Exists('..\packages\cef.redist.x86.3.2171.1979\build\cef.redist.x86.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\cef.redist.x86.3.2171.1979\build\cef.redist.x86.targets'))" />
|
||||
</Target>
|
||||
<Import Project="..\packages\cef.redist.x64.3.2171.1972\build\cef.redist.x64.targets" Condition="Exists('..\packages\cef.redist.x64.3.2171.1972\build\cef.redist.x64.targets')" />
|
||||
<Import Project="..\packages\cef.redist.x86.3.2171.1972\build\cef.redist.x86.targets" Condition="Exists('..\packages\cef.redist.x86.3.2171.1972\build\cef.redist.x86.targets')" />
|
||||
<Import Project="..\packages\cef.redist.x64.3.2171.1979\build\cef.redist.x64.targets" Condition="Exists('..\packages\cef.redist.x64.3.2171.1979\build\cef.redist.x64.targets')" />
|
||||
<Import Project="..\packages\cef.redist.x86.3.2171.1979\build\cef.redist.x86.targets" Condition="Exists('..\packages\cef.redist.x86.3.2171.1979\build\cef.redist.x86.targets')" />
|
||||
</Project>
|
||||
@@ -2,8 +2,8 @@
|
||||
<packages>
|
||||
<package id="AutoFixture" version="3.18.7" targetFramework="net40" />
|
||||
<package id="AutoFixture.Xunit" version="3.18.7" targetFramework="net40" />
|
||||
<package id="cef.redist.x64" version="3.2171.1972" targetFramework="net40" />
|
||||
<package id="cef.redist.x86" version="3.2171.1972" targetFramework="net40" />
|
||||
<package id="cef.redist.x64" version="3.2171.1979" targetFramework="net40" />
|
||||
<package id="cef.redist.x86" version="3.2171.1979" targetFramework="net40" />
|
||||
<package id="xunit" version="1.9.2" targetFramework="net40" />
|
||||
<package id="xunit.extensions" version="1.9.2" targetFramework="net40" />
|
||||
</packages>
|
||||
@@ -1,8 +1,7 @@
|
||||
using System.Threading.Tasks;
|
||||
using CefSharp.Example;
|
||||
using CefSharp.WinForms.Example.Controls;
|
||||
using CefSharp.Example;
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using CefSharp.WinForms.Internals;
|
||||
|
||||
namespace CefSharp.WinForms.Example
|
||||
{
|
||||
@@ -26,6 +25,8 @@ namespace CefSharp.WinForms.Example
|
||||
browser.MenuHandler = new MenuHandler();
|
||||
browser.RequestHandler = new RequestHandler();
|
||||
browser.JsDialogHandler = new JsDialogHandler();
|
||||
browser.GeolocationHandler = new GeolocationHandler();
|
||||
browser.DownloadHandler = new DownloadHandler();
|
||||
//browser.FocusHandler = new FocusHandler(browser, urlTextBox);
|
||||
browser.NavStateChanged += OnBrowserNavStateChanged;
|
||||
browser.ConsoleMessage += OnBrowserConsoleMessage;
|
||||
@@ -41,24 +42,6 @@ namespace CefSharp.WinForms.Example
|
||||
|
||||
var version = String.Format("Chromium: {0}, CEF: {1}, CefSharp: {2}", Cef.ChromiumVersion, Cef.CefVersion, Cef.CefSharpVersion);
|
||||
DisplayOutput(version);
|
||||
|
||||
Disposed += BrowserTabUserControlDisposed;
|
||||
}
|
||||
|
||||
private void BrowserTabUserControlDisposed(object sender, EventArgs e)
|
||||
{
|
||||
var browser = (ChromiumWebBrowser)Browser;
|
||||
Disposed -= BrowserTabUserControlDisposed;
|
||||
|
||||
browser.NavStateChanged -= OnBrowserNavStateChanged;
|
||||
browser.ConsoleMessage -= OnBrowserConsoleMessage;
|
||||
browser.TitleChanged -= OnBrowserTitleChanged;
|
||||
browser.AddressChanged -= OnBrowserAddressChanged;
|
||||
browser.StatusMessage -= OnBrowserStatusMessage;
|
||||
browser.IsBrowserInitializedChanged -= OnIsBrowserInitializedChanged;
|
||||
browser.IsLoadingChanged -= OnIsLoadingChanged;
|
||||
|
||||
browser.Dispose();
|
||||
}
|
||||
|
||||
private void OnBrowserConsoleMessage(object sender, ConsoleMessageEventArgs args)
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
<OldToolsVersion>3.5</OldToolsVersion>
|
||||
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
|
||||
<TargetFrameworkProfile />
|
||||
<NuGetPackageImportStamp>e79ac826</NuGetPackageImportStamp>
|
||||
<NuGetPackageImportStamp>386a1560</NuGetPackageImportStamp>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
@@ -70,7 +70,6 @@
|
||||
<Compile Include="BrowserForm.Designer.cs">
|
||||
<DependentUpon>BrowserForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Controls\ControlExtensions.cs" />
|
||||
<Compile Include="BrowserTabUserControl.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
</Compile>
|
||||
@@ -78,6 +77,7 @@
|
||||
<DependentUpon>BrowserTabUserControl.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="FocusHandler.cs" />
|
||||
<Compile Include="GeolocationHandler.cs" />
|
||||
<Compile Include="MenuHandler.cs" />
|
||||
<Compile Include="Minimal\SimpleBrowserForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
@@ -85,6 +85,12 @@
|
||||
<Compile Include="Minimal\SimpleBrowserForm.Designer.cs">
|
||||
<DependentUpon>SimpleBrowserForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Minimal\TabulationDemoForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Minimal\TabulationDemoForm.Designer.cs">
|
||||
<DependentUpon>TabulationDemoForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Program.cs">
|
||||
</Compile>
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
@@ -110,6 +116,9 @@
|
||||
<EmbeddedResource Include="Minimal\SimpleBrowserForm.resx">
|
||||
<DependentUpon>SimpleBrowserForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Minimal\TabulationDemoForm.resx">
|
||||
<DependentUpon>TabulationDemoForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
@@ -159,9 +168,9 @@
|
||||
<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.redist.x64.3.2171.1972\build\cef.redist.x64.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\cef.redist.x64.3.2171.1972\build\cef.redist.x64.targets'))" />
|
||||
<Error Condition="!Exists('..\packages\cef.redist.x86.3.2171.1972\build\cef.redist.x86.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\cef.redist.x86.3.2171.1972\build\cef.redist.x86.targets'))" />
|
||||
<Error Condition="!Exists('..\packages\cef.redist.x64.3.2171.1979\build\cef.redist.x64.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\cef.redist.x64.3.2171.1979\build\cef.redist.x64.targets'))" />
|
||||
<Error Condition="!Exists('..\packages\cef.redist.x86.3.2171.1979\build\cef.redist.x86.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\cef.redist.x86.3.2171.1979\build\cef.redist.x86.targets'))" />
|
||||
</Target>
|
||||
<Import Project="..\packages\cef.redist.x64.3.2171.1972\build\cef.redist.x64.targets" Condition="Exists('..\packages\cef.redist.x64.3.2171.1972\build\cef.redist.x64.targets')" />
|
||||
<Import Project="..\packages\cef.redist.x86.3.2171.1972\build\cef.redist.x86.targets" Condition="Exists('..\packages\cef.redist.x86.3.2171.1972\build\cef.redist.x86.targets')" />
|
||||
<Import Project="..\packages\cef.redist.x64.3.2171.1979\build\cef.redist.x64.targets" Condition="Exists('..\packages\cef.redist.x64.3.2171.1979\build\cef.redist.x64.targets')" />
|
||||
<Import Project="..\packages\cef.redist.x86.3.2171.1979\build\cef.redist.x86.targets" Condition="Exists('..\packages\cef.redist.x86.3.2171.1979\build\cef.redist.x86.targets')" />
|
||||
</Project>
|
||||
@@ -1,29 +0,0 @@
|
||||
// Copyright © 2010-2014 The CefSharp Authors. All rights reserved.
|
||||
//
|
||||
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace CefSharp.WinForms.Example.Controls
|
||||
{
|
||||
public static class ControlExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Executes the Action asynchronously on the UI thread, does not block execution on the calling thread.
|
||||
/// </summary>
|
||||
/// <param name="control">the control for which the update is required</param>
|
||||
/// <param name="action">action to be performed on the control</param>
|
||||
public static void InvokeOnUiThreadIfRequired(this Control control, Action action)
|
||||
{
|
||||
if (control.InvokeRequired)
|
||||
{
|
||||
control.BeginInvoke(action);
|
||||
}
|
||||
else
|
||||
{
|
||||
action.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
// Copyright © 2010-2014 The CefSharp Authors. All rights reserved.
|
||||
//
|
||||
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace CefSharp.WinForms.Example
|
||||
{
|
||||
internal class GeolocationHandler : IGeolocationHandler
|
||||
{
|
||||
public bool OnRequestGeolocationPermission(IWebBrowser browser, string requestingUrl, int requestId)
|
||||
{
|
||||
var result = MessageBox.Show(String.Format("{0} wants to use your computer's location. Allow? ** You must set your Google API key in CefExample.Init() for this to work. **", requestingUrl), "Geolocation", MessageBoxButtons.YesNo);
|
||||
return result == DialogResult.Yes;
|
||||
}
|
||||
|
||||
public void OnCancelGeolocationPermission(IWebBrowser browser, string requestingUrl, int requestId)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,7 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using CefSharp.Example;
|
||||
using CefSharp.WinForms.Example.Controls;
|
||||
using CefSharp.WinForms.Internals;
|
||||
|
||||
namespace CefSharp.WinForms.Example.Minimal
|
||||
{
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
namespace CefSharp.WinForms.Example.Minimal
|
||||
{
|
||||
partial class TabulationDemoForm
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.txtURL = new System.Windows.Forms.TextBox();
|
||||
this.btnGO = new System.Windows.Forms.Button();
|
||||
this.grpBrowser = new System.Windows.Forms.GroupBox();
|
||||
this.txtDummy = new System.Windows.Forms.TextBox();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// txtURL
|
||||
//
|
||||
this.txtURL.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.txtURL.Location = new System.Drawing.Point(8, 11);
|
||||
this.txtURL.Name = "txtURL";
|
||||
this.txtURL.Size = new System.Drawing.Size(774, 20);
|
||||
this.txtURL.TabIndex = 0;
|
||||
this.txtURL.Text = "http://www.google.com";
|
||||
this.txtURL.Enter += new System.EventHandler(this.TxtUrlEnter);
|
||||
this.txtURL.Leave += new System.EventHandler(this.TxtUrlLeave);
|
||||
//
|
||||
// btnGO
|
||||
//
|
||||
this.btnGO.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.btnGO.Location = new System.Drawing.Point(782, 9);
|
||||
this.btnGO.Name = "btnGO";
|
||||
this.btnGO.Size = new System.Drawing.Size(33, 23);
|
||||
this.btnGO.TabIndex = 1;
|
||||
this.btnGO.Text = "GO";
|
||||
this.btnGO.UseVisualStyleBackColor = true;
|
||||
this.btnGO.Click += new System.EventHandler(this.BtnGoClick);
|
||||
//
|
||||
// grpBrowser
|
||||
//
|
||||
this.grpBrowser.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.grpBrowser.Location = new System.Drawing.Point(8, 37);
|
||||
this.grpBrowser.Name = "grpBrowser";
|
||||
this.grpBrowser.Size = new System.Drawing.Size(807, 568);
|
||||
this.grpBrowser.TabIndex = 2;
|
||||
this.grpBrowser.TabStop = false;
|
||||
this.grpBrowser.Text = "Browser";
|
||||
//
|
||||
// txtDummy
|
||||
//
|
||||
this.txtDummy.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.txtDummy.Location = new System.Drawing.Point(8, 612);
|
||||
this.txtDummy.Name = "txtDummy";
|
||||
this.txtDummy.Size = new System.Drawing.Size(807, 20);
|
||||
this.txtDummy.TabIndex = 3;
|
||||
this.txtDummy.Text = "Dummy Text";
|
||||
//
|
||||
// TabulationDemoForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(827, 642);
|
||||
this.Controls.Add(this.txtDummy);
|
||||
this.Controls.Add(this.grpBrowser);
|
||||
this.Controls.Add(this.btnGO);
|
||||
this.Controls.Add(this.txtURL);
|
||||
this.Name = "TabulationDemoForm";
|
||||
this.Text = "Tabulation Demo";
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.TextBox txtURL;
|
||||
private System.Windows.Forms.Button btnGO;
|
||||
private System.Windows.Forms.GroupBox grpBrowser;
|
||||
private System.Windows.Forms.TextBox txtDummy;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
// Copyright © 2010-2014 The CefSharp Authors. All rights reserved.
|
||||
//
|
||||
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace CefSharp.WinForms.Example.Minimal
|
||||
{
|
||||
public partial class TabulationDemoForm : Form
|
||||
{
|
||||
private readonly ChromiumWebBrowser chromiumWebBrowser;
|
||||
|
||||
public TabulationDemoForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
chromiumWebBrowser = new ChromiumWebBrowser(txtURL.Text) { Dock = DockStyle.Fill };
|
||||
var userControl = new UserControl { Dock = DockStyle.Fill };
|
||||
userControl.Controls.Add(chromiumWebBrowser);
|
||||
grpBrowser.Controls.Add(userControl);
|
||||
}
|
||||
|
||||
private void BtnGoClick(object sender, EventArgs e)
|
||||
{
|
||||
chromiumWebBrowser.Load(txtURL.Text);
|
||||
}
|
||||
|
||||
private void TxtUrlLeave(object sender, EventArgs e)
|
||||
{
|
||||
txtURL.BackColor = Color.White;
|
||||
}
|
||||
|
||||
private void TxtUrlEnter(object sender, EventArgs e)
|
||||
{
|
||||
txtURL.BackColor = Color.Yellow;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
@@ -18,6 +18,7 @@ namespace CefSharp.WinForms.Example
|
||||
|
||||
var browser = new BrowserForm();
|
||||
//var browser = new SimpleBrowserForm();
|
||||
//var browser = new TabulationDemoForm();
|
||||
Application.Run(browser);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,14 @@
|
||||
xmlns:asmv3="urn:schemas-microsoft-com:asm.v3"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
|
||||
<assemblyIdentity version="37.0.0.0" name="CefSharp.WinForms.Example.app" />
|
||||
<assemblyIdentity version="39.0.0.0" name="CefSharp.WinForms.Example.app" />
|
||||
|
||||
<dependency>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity type="Win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*"></assemblyIdentity>
|
||||
</dependentAssembly>
|
||||
</dependency>
|
||||
|
||||
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
|
||||
<security>
|
||||
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="cef.redist.x64" version="3.2171.1972" targetFramework="net45" />
|
||||
<package id="cef.redist.x86" version="3.2171.1972" targetFramework="net45" />
|
||||
<package id="cef.redist.x64" version="3.2171.1979" targetFramework="net45" />
|
||||
<package id="cef.redist.x86" version="3.2171.1979" targetFramework="net45" />
|
||||
</packages>
|
||||
@@ -43,6 +43,7 @@
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.ServiceModel" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
@@ -52,6 +53,9 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Internals\DefaultFocusHandler.cs" />
|
||||
<Compile Include="Internals\ControlExtensions.cs" />
|
||||
<Compile Include="Internals\ParentFormMessageInterceptor.cs" />
|
||||
<Compile Include="Internals\NativeMethods.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="ChromiumWebBrowser.cs">
|
||||
<SubType>Component</SubType>
|
||||
|
||||
@@ -14,6 +14,7 @@ namespace CefSharp.WinForms
|
||||
public class ChromiumWebBrowser : Control, IWebBrowserInternal, IWinFormsWebBrowser
|
||||
{
|
||||
private ManagedCefBrowserAdapter managedCefBrowserAdapter;
|
||||
private ParentFormMessageInterceptor parentFormMessageInterceptor;
|
||||
|
||||
public BrowserSettings BrowserSettings { get; set; }
|
||||
public string Title { get; set; }
|
||||
@@ -31,6 +32,7 @@ namespace CefSharp.WinForms
|
||||
public IFocusHandler FocusHandler { get; set; }
|
||||
public IDragHandler DragHandler { get; set; }
|
||||
public IResourceHandler ResourceHandler { get; set; }
|
||||
public IGeolocationHandler GeolocationHandler { get; set; }
|
||||
|
||||
public bool CanGoForward { get; private set; }
|
||||
public bool CanGoBack { get; private set; }
|
||||
@@ -55,6 +57,11 @@ namespace CefSharp.WinForms
|
||||
|
||||
public ChromiumWebBrowser(string address)
|
||||
{
|
||||
if (!Cef.IsInitialized && !Cef.Initialize())
|
||||
{
|
||||
throw new InvalidOperationException("Cef::Initialize() failed");
|
||||
}
|
||||
|
||||
Cef.AddDisposable(this);
|
||||
Address = address;
|
||||
|
||||
@@ -62,12 +69,23 @@ namespace CefSharp.WinForms
|
||||
|
||||
FocusHandler = new DefaultFocusHandler(this);
|
||||
ResourceHandler = new DefaultResourceHandler();
|
||||
BrowserSettings = new BrowserSettings();
|
||||
|
||||
managedCefBrowserAdapter = new ManagedCefBrowserAdapter(this, false);
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
// Don't utilize any of the handlers anymore:
|
||||
DialogHandler = null;
|
||||
JsDialogHandler = null;
|
||||
KeyboardHandler = null;
|
||||
RequestHandler = null;
|
||||
DownloadHandler = null;
|
||||
LifeSpanHandler = null;
|
||||
MenuHandler = null;
|
||||
DragHandler = null;
|
||||
GeolocationHandler = null;
|
||||
FocusHandler = null;
|
||||
ResourceHandler = null;
|
||||
|
||||
@@ -75,11 +93,37 @@ namespace CefSharp.WinForms
|
||||
|
||||
if (disposing)
|
||||
{
|
||||
IsBrowserInitialized = false;
|
||||
|
||||
if (BrowserSettings != null)
|
||||
{
|
||||
BrowserSettings.Dispose();
|
||||
BrowserSettings = null;
|
||||
}
|
||||
|
||||
if (parentFormMessageInterceptor != null)
|
||||
{
|
||||
parentFormMessageInterceptor.Dispose();
|
||||
parentFormMessageInterceptor = null;
|
||||
}
|
||||
|
||||
if (managedCefBrowserAdapter != null)
|
||||
{
|
||||
managedCefBrowserAdapter.Dispose();
|
||||
managedCefBrowserAdapter = null;
|
||||
}
|
||||
|
||||
// Don't maintain a reference to event listeners anylonger:
|
||||
LoadError = null;
|
||||
FrameLoadStart = null;
|
||||
FrameLoadEnd = null;
|
||||
NavStateChanged = null;
|
||||
ConsoleMessage = null;
|
||||
StatusMessage = null;
|
||||
AddressChanged = null;
|
||||
TitleChanged = null;
|
||||
IsBrowserInitializedChanged = null;
|
||||
IsLoadingChanged = null;
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
@@ -88,6 +132,15 @@ namespace CefSharp.WinForms
|
||||
{
|
||||
IsBrowserInitialized = true;
|
||||
|
||||
// By the time this callback gets called, this control
|
||||
// is most likely hooked into a browser Form of some sort.
|
||||
// (Which is what ParentFormMessageInterceptor relies on.)
|
||||
// Ensure the ParentFormMessageInterceptor construction occurs on the WinForms UI thread:
|
||||
this.InvokeOnUiThreadIfRequired(() =>
|
||||
{
|
||||
parentFormMessageInterceptor = new ParentFormMessageInterceptor(this);
|
||||
});
|
||||
|
||||
ResizeBrowser();
|
||||
|
||||
var handler = IsBrowserInitializedChanged;
|
||||
@@ -159,7 +212,7 @@ namespace CefSharp.WinForms
|
||||
|
||||
protected override void OnHandleCreated(EventArgs e)
|
||||
{
|
||||
managedCefBrowserAdapter.CreateBrowser(BrowserSettings ?? new BrowserSettings(), Handle, Address);
|
||||
managedCefBrowserAdapter.CreateBrowser(BrowserSettings, Handle, Address);
|
||||
|
||||
base.OnHandleCreated(e);
|
||||
}
|
||||
@@ -388,14 +441,6 @@ namespace CefSharp.WinForms
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set whether the browser is focused.
|
||||
/// </summary>
|
||||
public void SetFocus(bool isFocused)
|
||||
{
|
||||
managedCefBrowserAdapter.SetFocus(isFocused);
|
||||
}
|
||||
|
||||
protected override void OnSizeChanged(EventArgs e)
|
||||
{
|
||||
base.OnSizeChanged(e);
|
||||
@@ -405,7 +450,7 @@ namespace CefSharp.WinForms
|
||||
|
||||
private void ResizeBrowser()
|
||||
{
|
||||
if (IsBrowserInitialized && managedCefBrowserAdapter != null)
|
||||
if (IsBrowserInitialized)
|
||||
{
|
||||
managedCefBrowserAdapter.Resize(Width, Height);
|
||||
}
|
||||
@@ -413,7 +458,7 @@ namespace CefSharp.WinForms
|
||||
|
||||
public void NotifyMoveOrResizeStarted()
|
||||
{
|
||||
if (IsBrowserInitialized && managedCefBrowserAdapter != null)
|
||||
if (IsBrowserInitialized)
|
||||
{
|
||||
managedCefBrowserAdapter.NotifyMoveOrResizeStarted();
|
||||
}
|
||||
@@ -428,5 +473,30 @@ namespace CefSharp.WinForms
|
||||
{
|
||||
managedCefBrowserAdapter.AddWordToDictionary(word);
|
||||
}
|
||||
|
||||
protected override void OnEnter(EventArgs e)
|
||||
{
|
||||
SetFocus(true);
|
||||
|
||||
base.OnEnter(e);
|
||||
}
|
||||
|
||||
protected override void OnLeave(EventArgs e)
|
||||
{
|
||||
SetFocus(false);
|
||||
|
||||
base.OnLeave(e);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set whether the browser is focused.
|
||||
/// </summary>
|
||||
public void SetFocus(bool isFocused)
|
||||
{
|
||||
if (IsBrowserInitialized)
|
||||
{
|
||||
managedCefBrowserAdapter.SetFocus(isFocused);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
// Copyright © 2010-2014 The CefSharp Authors. All rights reserved.
|
||||
//
|
||||
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace CefSharp.WinForms.Internals
|
||||
{
|
||||
public static class ControlExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Executes the Action asynchronously on the UI thread, does not block execution on the calling thread.
|
||||
/// </summary>
|
||||
/// <param name="control">the control for which the update is required</param>
|
||||
/// <param name="action">action to be performed on the control</param>
|
||||
public static void InvokeOnUiThreadIfRequired(this Control control, Action action)
|
||||
{
|
||||
if (control.InvokeRequired)
|
||||
{
|
||||
control.BeginInvoke(action);
|
||||
}
|
||||
else
|
||||
{
|
||||
action.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
public static void Activate(this Control control)
|
||||
{
|
||||
// Notify WinForms world that inner browser window got focus. This will trigger Leave event to previous focused control
|
||||
var containerControl = control.GetContainerControl();
|
||||
if (containerControl != null)
|
||||
{
|
||||
containerControl.ActivateControl(control);
|
||||
}
|
||||
}
|
||||
|
||||
public static void SelectNextControl(this Control control, bool next)
|
||||
{
|
||||
var containerControl = control.GetContainerControl();
|
||||
|
||||
while (containerControl != null)
|
||||
{
|
||||
var containerControlAsControl = containerControl as Control;
|
||||
if (containerControlAsControl == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
var activeControl = containerControl.ActiveControl;
|
||||
if (containerControlAsControl.SelectNextControl(activeControl, next, true, true, false))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (containerControlAsControl.Parent == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
containerControl = containerControlAsControl.Parent.GetContainerControl();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,31 +2,32 @@
|
||||
//
|
||||
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace CefSharp.WinForms.Internals
|
||||
{
|
||||
internal class DefaultFocusHandler : IFocusHandler
|
||||
{
|
||||
private readonly ChromiumWebBrowser browser;
|
||||
internal class DefaultFocusHandler : IFocusHandler
|
||||
{
|
||||
private readonly ChromiumWebBrowser browser;
|
||||
|
||||
public DefaultFocusHandler(ChromiumWebBrowser browser)
|
||||
{
|
||||
this.browser = browser;
|
||||
}
|
||||
public DefaultFocusHandler(ChromiumWebBrowser browser)
|
||||
{
|
||||
this.browser = browser;
|
||||
}
|
||||
|
||||
public void OnGotFocus()
|
||||
{
|
||||
}
|
||||
public virtual void OnGotFocus()
|
||||
{
|
||||
browser.InvokeOnUiThreadIfRequired(browser.Activate);
|
||||
}
|
||||
|
||||
public bool OnSetFocus(CefFocusSource source)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
public virtual bool OnSetFocus(CefFocusSource source)
|
||||
{
|
||||
// Do not let the browser take focus when a Load method has been called
|
||||
return source == CefFocusSource.FocusSourceNavigation;
|
||||
}
|
||||
|
||||
public void OnTakeFocus(bool next)
|
||||
{
|
||||
browser.BeginInvoke(new MethodInvoker(() => browser.SelectNextControl(browser, next, true, true, true)));
|
||||
}
|
||||
}
|
||||
public virtual void OnTakeFocus(bool next)
|
||||
{
|
||||
// NOTE: OnTakeFocus means leaving focus / not taking focus
|
||||
browser.InvokeOnUiThreadIfRequired(() => browser.SelectNextControl(next));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace CefSharp.WinForms.Internals
|
||||
{
|
||||
internal static class NativeMethods
|
||||
{
|
||||
public const int WM_MOVE = 0x3;
|
||||
public const int WM_MOVING = 0x216;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,212 @@
|
||||
// Copyright © 2014 The CefSharp Authors. All rights reserved.
|
||||
//
|
||||
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace CefSharp.WinForms.Internals
|
||||
{
|
||||
internal class ParentFormMessageInterceptor : NativeWindow, IDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// Keep track of whether a move is in progress.
|
||||
/// </summary>
|
||||
private bool isMoving;
|
||||
|
||||
/// <summary>
|
||||
/// Used to determine the coordinates involved in the move
|
||||
/// </summary>
|
||||
private Rectangle movingRectangle;
|
||||
|
||||
private ChromiumWebBrowser Browser { get; set; }
|
||||
|
||||
private Form ParentForm { get; set; }
|
||||
|
||||
public ParentFormMessageInterceptor(ChromiumWebBrowser browser)
|
||||
{
|
||||
Browser = browser;
|
||||
// Get notified if our browser window parent changes:
|
||||
Browser.ParentChanged += ParentParentChanged;
|
||||
// Find the browser form to subclass to monitor WM_MOVE/WM_MOVING
|
||||
RefindParentForm();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Call to force refinding of the parent Form.
|
||||
/// (i.e. top level window that owns the ChromiumWebBrowserControl)
|
||||
/// </summary>
|
||||
public void RefindParentForm()
|
||||
{
|
||||
ParentParentChanged(Browser, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adjust the form to listen to if the ChromiumWebBrowserControl's parent changes.
|
||||
/// </summary>
|
||||
/// <param name="sender">The ChromiumWebBrowser whose parent has changed.</param>
|
||||
/// <param name="e"></param>
|
||||
private void ParentParentChanged(object sender, EventArgs e)
|
||||
{
|
||||
var control = (Control)sender;
|
||||
var oldForm = ParentForm;
|
||||
var newForm = control.FindForm();
|
||||
|
||||
if (oldForm == null || newForm == null || oldForm.Handle != newForm.Handle)
|
||||
{
|
||||
if (Handle != IntPtr.Zero)
|
||||
{
|
||||
ReleaseHandle();
|
||||
}
|
||||
if (oldForm != null)
|
||||
{
|
||||
oldForm.HandleCreated -= OnHandleCreated;
|
||||
oldForm.HandleDestroyed -= OnHandleDestroyed;
|
||||
}
|
||||
ParentForm = newForm;
|
||||
if (newForm != null)
|
||||
{
|
||||
newForm.HandleCreated += OnHandleCreated;
|
||||
newForm.HandleDestroyed += OnHandleDestroyed;
|
||||
// If newForm's Handle has been created already,
|
||||
// our event listener won't be called, so call it now.
|
||||
if (newForm.IsHandleCreated)
|
||||
{
|
||||
OnHandleCreated(newForm, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnHandleCreated(object sender, EventArgs e)
|
||||
{
|
||||
AssignHandle(((Form)sender).Handle);
|
||||
}
|
||||
|
||||
private void OnHandleDestroyed(object sender, EventArgs e)
|
||||
{
|
||||
ReleaseHandle();
|
||||
}
|
||||
|
||||
protected override void WndProc(ref Message m)
|
||||
{
|
||||
var isMovingMessage = false;
|
||||
|
||||
// Negative initial values keeps the compiler quiet and to
|
||||
// ensure we have actual window movement to notify CEF about.
|
||||
const int invalidMoveCoordinate = -1;
|
||||
var x = invalidMoveCoordinate;
|
||||
var y = invalidMoveCoordinate;
|
||||
|
||||
// Listen for operating system messages
|
||||
switch (m.Msg)
|
||||
{
|
||||
case NativeMethods.WM_MOVING:
|
||||
{
|
||||
movingRectangle = (Rectangle)Marshal.PtrToStructure(m.LParam, typeof(Rectangle));
|
||||
x = movingRectangle.Left;
|
||||
y = movingRectangle.Top;
|
||||
isMovingMessage = true;
|
||||
break;
|
||||
}
|
||||
case NativeMethods.WM_MOVE:
|
||||
{
|
||||
x = (m.LParam.ToInt32() & 0xffff);
|
||||
y = ((m.LParam.ToInt32() >> 16) & 0xffff);
|
||||
isMovingMessage = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Only notify about movement if:
|
||||
// * Browser Handle Created
|
||||
// NOTE: This is checked for paranoia.
|
||||
// This WndProc can't be called unless ParentForm has
|
||||
// its handle created, but that doesn't necessarily mean
|
||||
// Browser has had its handle created.
|
||||
// WinForm controls don't usually get eagerly created Handles
|
||||
// in their constructors.
|
||||
// * ParentForm Actually moved
|
||||
// * Not currently moving (on the UI thread only of course)
|
||||
// * The current WindowState is Normal.
|
||||
// This check is to simplify the effort here.
|
||||
// Other logic already handles the maximize/minimize
|
||||
// cases just fine.
|
||||
// You might consider checking Browser.Visible and
|
||||
// not notifying our browser control if the browser control isn't visible.
|
||||
// However, if you do that, the non-Visible CEF tab will still
|
||||
// have any SELECT drop downs rendering where they shouldn't.
|
||||
if (isMovingMessage
|
||||
&& Browser.IsHandleCreated
|
||||
&& ParentForm.WindowState == FormWindowState.Normal
|
||||
&& (ParentForm.Left != x || ParentForm.Top != y)
|
||||
&& !isMoving)
|
||||
{
|
||||
// ParentForm.Left & .Right are negative when the window
|
||||
// is transitioning from maximized to normal.
|
||||
// If we are transitioning, the form will also receive
|
||||
// a WM_SIZE which can deal with the move/size combo itself.
|
||||
if (ParentForm.Left >= 0 && ParentForm.Right >= 0)
|
||||
{
|
||||
OnMoving();
|
||||
}
|
||||
}
|
||||
DefWndProc(ref m);
|
||||
}
|
||||
|
||||
protected virtual void OnMoving()
|
||||
{
|
||||
isMoving = true;
|
||||
|
||||
if (Browser.IsBrowserInitialized)
|
||||
{
|
||||
Browser.NotifyMoveOrResizeStarted();
|
||||
}
|
||||
|
||||
isMoving = false;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
if (ParentForm != null)
|
||||
{
|
||||
ParentForm.HandleCreated -= OnHandleCreated;
|
||||
ParentForm.HandleDestroyed -= OnHandleDestroyed;
|
||||
ParentForm = null;
|
||||
}
|
||||
|
||||
// Unmanaged resource, but release here anyway.
|
||||
// NativeWindow has its own finalization logic
|
||||
// that should be run if this instance isn't disposed
|
||||
// properly before arriving at the finalization thread.
|
||||
// See: http://referencesource.microsoft.com/#System.Windows.Forms/winforms/Managed/System/WinForms/NativeWindow.cs,147
|
||||
// for the gruesome details.
|
||||
if (Handle != IntPtr.Zero)
|
||||
{
|
||||
ReleaseHandle();
|
||||
}
|
||||
|
||||
if (Browser != null)
|
||||
{
|
||||
Browser.ParentChanged -= ParentParentChanged;
|
||||
Browser = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnThreadException(Exception e)
|
||||
{
|
||||
// TODO: Do something more interesting here, logging, whatever, something.
|
||||
base.OnThreadException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,7 @@
|
||||
<OldToolsVersion>3.5</OldToolsVersion>
|
||||
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
|
||||
<TargetFrameworkProfile />
|
||||
<NuGetPackageImportStamp>eef213f7</NuGetPackageImportStamp>
|
||||
<NuGetPackageImportStamp>1dae910e</NuGetPackageImportStamp>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
@@ -105,6 +105,7 @@
|
||||
<SubType>Designer</SubType>
|
||||
</ApplicationDefinition>
|
||||
<Compile Include="Controls\NonReloadingTabControl.cs" />
|
||||
<Compile Include="Handlers\GeolocationHandler.cs" />
|
||||
<Compile Include="Handlers\MenuHandler.cs" />
|
||||
<Compile Include="Mvvm\DelegateCommand.cs" />
|
||||
<Compile Include="Mvvm\DelegateCommandT.cs" />
|
||||
@@ -172,9 +173,9 @@
|
||||
<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.redist.x64.3.2171.1972\build\cef.redist.x64.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\cef.redist.x64.3.2171.1972\build\cef.redist.x64.targets'))" />
|
||||
<Error Condition="!Exists('..\packages\cef.redist.x86.3.2171.1972\build\cef.redist.x86.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\cef.redist.x86.3.2171.1972\build\cef.redist.x86.targets'))" />
|
||||
<Error Condition="!Exists('..\packages\cef.redist.x64.3.2171.1979\build\cef.redist.x64.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\cef.redist.x64.3.2171.1979\build\cef.redist.x64.targets'))" />
|
||||
<Error Condition="!Exists('..\packages\cef.redist.x86.3.2171.1979\build\cef.redist.x86.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\cef.redist.x86.3.2171.1979\build\cef.redist.x86.targets'))" />
|
||||
</Target>
|
||||
<Import Project="..\packages\cef.redist.x64.3.2171.1972\build\cef.redist.x64.targets" Condition="Exists('..\packages\cef.redist.x64.3.2171.1972\build\cef.redist.x64.targets')" />
|
||||
<Import Project="..\packages\cef.redist.x86.3.2171.1972\build\cef.redist.x86.targets" Condition="Exists('..\packages\cef.redist.x86.3.2171.1972\build\cef.redist.x86.targets')" />
|
||||
<Import Project="..\packages\cef.redist.x64.3.2171.1979\build\cef.redist.x64.targets" Condition="Exists('..\packages\cef.redist.x64.3.2171.1979\build\cef.redist.x64.targets')" />
|
||||
<Import Project="..\packages\cef.redist.x86.3.2171.1979\build\cef.redist.x86.targets" Condition="Exists('..\packages\cef.redist.x86.3.2171.1979\build\cef.redist.x86.targets')" />
|
||||
</Project>
|
||||
@@ -0,0 +1,22 @@
|
||||
// Copyright © 2010-2014 The CefSharp Authors. All rights reserved.
|
||||
//
|
||||
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
using System;
|
||||
using System.Windows;
|
||||
|
||||
namespace CefSharp.Wpf.Example.Handlers
|
||||
{
|
||||
internal class GeolocationHandler : IGeolocationHandler
|
||||
{
|
||||
public bool OnRequestGeolocationPermission(IWebBrowser browser, string requestingUrl, int requestId)
|
||||
{
|
||||
var result = MessageBox.Show(String.Format("{0} wants to use your computer's location. Allow? ** You must set your Google API key in CefExample.Init() for this to work. **", requestingUrl), "Geolocation", MessageBoxButton.YesNo);
|
||||
return result == MessageBoxResult.Yes;
|
||||
}
|
||||
|
||||
public void OnCancelGeolocationPermission(IWebBrowser browser, string requestingUrl, int requestId)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -175,6 +175,7 @@
|
||||
Opacity="{Binding ElementName=opacitySlider, Path=Value}"
|
||||
Address="{Binding Address, Mode=TwoWay}"
|
||||
Title="{Binding Title, Mode=OneWayToSource}"
|
||||
AllowDrop="True"
|
||||
WebBrowser="{Binding WebBrowser, Mode=OneWayToSource}">
|
||||
<!-- Just an example of how you may override the BrowserSettings. Disabled by default since it looks so
|
||||
incredibly ugly... -->
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
//
|
||||
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
using System;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using CefSharp.Example;
|
||||
@@ -19,6 +18,8 @@ namespace CefSharp.Wpf.Example.Views
|
||||
browser.RegisterJsObject("bound", new BoundObject());
|
||||
|
||||
browser.MenuHandler = new Handlers.MenuHandler();
|
||||
browser.GeolocationHandler = new Handlers.GeolocationHandler();
|
||||
browser.DownloadHandler = new DownloadHandler();
|
||||
|
||||
CefExample.RegisterTestResources(browser);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="cef.redist.x64" version="3.2171.1972" targetFramework="net45" />
|
||||
<package id="cef.redist.x86" version="3.2171.1972" targetFramework="net45" />
|
||||
<package id="cef.redist.x64" version="3.2171.1979" targetFramework="net45" />
|
||||
<package id="cef.redist.x86" version="3.2171.1979" targetFramework="net45" />
|
||||
</packages>
|
||||
@@ -93,7 +93,7 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="DelegateCommand.cs" />
|
||||
<Compile Include="DisposableEventWrapper.cs" />
|
||||
<Compile Include="InteropBitmapInfo.cs" />
|
||||
<Compile Include="Rendering\InteropBitmapInfo.cs" />
|
||||
<Compile Include="IWpfWebBrowser.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs">
|
||||
<SubType>Code</SubType>
|
||||
@@ -101,7 +101,10 @@
|
||||
<AppDesigner Include="Properties\" />
|
||||
<Compile Include="ChromiumWebBrowser.cs" />
|
||||
<Compile Include="RenderingEventArgs.cs" />
|
||||
<Compile Include="Rendering\BitmapFactory.cs" />
|
||||
<Compile Include="WM.cs" />
|
||||
<Compile Include="Rendering\WpfBitmapInfo.cs" />
|
||||
<Compile Include="Rendering\WritableBitmapInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\CefSharp.Core\CefSharp.Core.vcxproj">
|
||||
@@ -113,6 +116,7 @@
|
||||
<Name>CefSharp</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
|
||||
@@ -4,9 +4,11 @@
|
||||
|
||||
using System.Text;
|
||||
using CefSharp.Internals;
|
||||
using CefSharp.Wpf.Rendering;
|
||||
using Microsoft.Win32.SafeHandles;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
@@ -20,8 +22,6 @@ namespace CefSharp.Wpf
|
||||
{
|
||||
public class ChromiumWebBrowser : ContentControl, IRenderWebBrowser, IWpfWebBrowser
|
||||
{
|
||||
private static readonly PixelFormat PixelFormat = PixelFormats.Bgra32;
|
||||
private static readonly int BytesPerPixel = PixelFormat.BitsPerPixel / 8;
|
||||
private HwndSource source;
|
||||
private HwndSourceHook sourceHook;
|
||||
private DispatcherTimer tooltipTimer;
|
||||
@@ -34,7 +34,6 @@ namespace CefSharp.Wpf
|
||||
private Image image;
|
||||
private Image popupImage;
|
||||
private Popup popup;
|
||||
private ScaleTransform dpiTransform;
|
||||
private readonly List<IDisposable> disposables = new List<IDisposable>();
|
||||
|
||||
public BrowserSettings BrowserSettings { get; set; }
|
||||
@@ -48,6 +47,8 @@ namespace CefSharp.Wpf
|
||||
public IFocusHandler FocusHandler { get; set; }
|
||||
public IDragHandler DragHandler { get; set; }
|
||||
public IResourceHandler ResourceHandler { get; set; }
|
||||
public IGeolocationHandler GeolocationHandler { get; set; }
|
||||
public IBitmapFactory BitmapFactory { get; set; }
|
||||
|
||||
public event EventHandler<ConsoleMessageEventArgs> ConsoleMessage;
|
||||
public event EventHandler<StatusMessageEventArgs> StatusMessage;
|
||||
@@ -316,34 +317,73 @@ namespace CefSharp.Wpf
|
||||
|
||||
protected virtual void Dispose(bool isdisposing)
|
||||
{
|
||||
PresentationSource.RemoveSourceChangedHandler(this, PresentationSourceChangedHandler);
|
||||
|
||||
BrowserSettings.Dispose();
|
||||
|
||||
BrowserSettings = null;
|
||||
ResourceHandler = null;
|
||||
|
||||
Loaded -= OnLoaded;
|
||||
|
||||
GotKeyboardFocus -= OnGotKeyboardFocus;
|
||||
LostKeyboardFocus -= OnLostKeyboardFocus;
|
||||
|
||||
IsVisibleChanged -= OnIsVisibleChanged;
|
||||
|
||||
Cef.RemoveDisposable(this);
|
||||
|
||||
foreach (var disposable in disposables)
|
||||
{
|
||||
disposable.Dispose();
|
||||
}
|
||||
disposables.Clear();
|
||||
|
||||
UiThreadRunAsync(() => WebBrowser = null);
|
||||
managedCefBrowserAdapter = null;
|
||||
// No longer reference event listeners:
|
||||
ConsoleMessage = null;
|
||||
FrameLoadStart = null;
|
||||
FrameLoadEnd = null;
|
||||
LoadError = null;
|
||||
NavStateChanged = null;
|
||||
|
||||
// No longer reference handlers:
|
||||
ResourceHandler = null;
|
||||
DialogHandler = null;
|
||||
JsDialogHandler = null;
|
||||
KeyboardHandler = null;
|
||||
RequestHandler = null;
|
||||
DownloadHandler = null;
|
||||
LifeSpanHandler = null;
|
||||
MenuHandler = null;
|
||||
FocusHandler = null;
|
||||
DragHandler = null;
|
||||
GeolocationHandler = null;
|
||||
Rendering = null;
|
||||
|
||||
if (isdisposing)
|
||||
{
|
||||
if (BrowserSettings != null)
|
||||
{
|
||||
BrowserSettings.Dispose();
|
||||
BrowserSettings = null;
|
||||
}
|
||||
|
||||
PresentationSource.RemoveSourceChangedHandler(this, PresentationSourceChangedHandler);
|
||||
|
||||
// Release internal event listeners:
|
||||
Loaded -= OnLoaded;
|
||||
GotKeyboardFocus -= OnGotKeyboardFocus;
|
||||
LostKeyboardFocus -= OnLostKeyboardFocus;
|
||||
|
||||
// Release internal event listeners for Drag Drop events:
|
||||
DragEnter -= OnDragEnter;
|
||||
DragOver -= OnDragOver;
|
||||
DragLeave -= OnDragLeave;
|
||||
Drop -= OnDrop;
|
||||
|
||||
IsVisibleChanged -= OnIsVisibleChanged;
|
||||
|
||||
if (tooltipTimer != null)
|
||||
{
|
||||
tooltipTimer.Tick -= OnTooltipTimerTick;
|
||||
}
|
||||
|
||||
if (CleanupElement != null)
|
||||
{
|
||||
CleanupElement.Unloaded -= OnCleanupElementUnloaded;
|
||||
}
|
||||
|
||||
foreach (var disposable in disposables)
|
||||
{
|
||||
disposable.Dispose();
|
||||
}
|
||||
disposables.Clear();
|
||||
UiThreadRunAsync(() => WebBrowser = null);
|
||||
}
|
||||
|
||||
Cef.RemoveDisposable(this);
|
||||
|
||||
RemoveSourceHook();
|
||||
|
||||
managedCefBrowserAdapter = null;
|
||||
}
|
||||
|
||||
#endregion CleanupElement dependency property
|
||||
@@ -410,6 +450,8 @@ namespace CefSharp.Wpf
|
||||
throw new InvalidOperationException("Cef::Initialize() failed");
|
||||
}
|
||||
|
||||
BitmapFactory = new BitmapFactory();
|
||||
|
||||
Cef.AddDisposable(this);
|
||||
Focusable = true;
|
||||
FocusVisualStyle = null;
|
||||
@@ -422,6 +464,12 @@ namespace CefSharp.Wpf
|
||||
GotKeyboardFocus += OnGotKeyboardFocus;
|
||||
LostKeyboardFocus += OnLostKeyboardFocus;
|
||||
|
||||
// Drag Drop events
|
||||
DragEnter += OnDragEnter;
|
||||
DragOver += OnDragOver;
|
||||
DragLeave += OnDragLeave;
|
||||
Drop += OnDrop;
|
||||
|
||||
IsVisibleChanged += OnIsVisibleChanged;
|
||||
|
||||
ToolTip = toolTip = new ToolTip();
|
||||
@@ -429,7 +477,6 @@ namespace CefSharp.Wpf
|
||||
toolTip.Visibility = Visibility.Collapsed;
|
||||
toolTip.Closed += OnTooltipClosed;
|
||||
|
||||
|
||||
BackCommand = new DelegateCommand(Back, () => CanGoBack);
|
||||
ForwardCommand = new DelegateCommand(Forward, () => CanGoForward);
|
||||
ReloadCommand = new DelegateCommand(Reload, () => CanReload);
|
||||
@@ -459,6 +506,139 @@ namespace CefSharp.Wpf
|
||||
PresentationSource.AddSourceChangedHandler(this, PresentationSourceChangedHandler);
|
||||
}
|
||||
|
||||
private void OnDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
managedCefBrowserAdapter.OnDragTargetDragDrop(GetMouseEvent(e));
|
||||
}
|
||||
|
||||
private void OnDragLeave(object sender, DragEventArgs e)
|
||||
{
|
||||
managedCefBrowserAdapter.OnDragTargetDragLeave();
|
||||
}
|
||||
|
||||
private void OnDragOver(object sender, DragEventArgs e)
|
||||
{
|
||||
managedCefBrowserAdapter.OnDragTargetDragOver(GetMouseEvent(e), GetDragOperationsMask(e.AllowedEffects));
|
||||
}
|
||||
|
||||
private void OnDragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
managedCefBrowserAdapter.OnDragTargetDragEnter(GetDragDataWrapper(e), GetMouseEvent(e), GetDragOperationsMask(e.AllowedEffects));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts .NET drag drop effects to CEF Drag Operations
|
||||
/// </summary>s
|
||||
private static DragOperationsMask GetDragOperationsMask(DragDropEffects dragDropEffects)
|
||||
{
|
||||
var operations = DragOperationsMask.None;
|
||||
|
||||
if (dragDropEffects.HasFlag(DragDropEffects.All))
|
||||
{
|
||||
operations |= DragOperationsMask.Every;
|
||||
}
|
||||
if (dragDropEffects.HasFlag(DragDropEffects.Copy))
|
||||
{
|
||||
operations |= DragOperationsMask.Copy;
|
||||
}
|
||||
if (dragDropEffects.HasFlag(DragDropEffects.Move))
|
||||
{
|
||||
operations |= DragOperationsMask.Move;
|
||||
}
|
||||
if (dragDropEffects.HasFlag(DragDropEffects.Link))
|
||||
{
|
||||
operations |= DragOperationsMask.Link;
|
||||
}
|
||||
|
||||
return operations;
|
||||
}
|
||||
|
||||
private CefDragDataWrapper GetDragDataWrapper(DragEventArgs e)
|
||||
{
|
||||
// Convert Drag Data
|
||||
var dragData = CefDragDataWrapper.Create();
|
||||
|
||||
// Files
|
||||
dragData.IsFile = e.Data.GetDataPresent(DataFormats.FileDrop);
|
||||
if (dragData.IsFile)
|
||||
{
|
||||
// As per documentation, we only need to specify FileNames, not FileName, when dragging into the browser (http://magpcss.org/ceforum/apidocs3/projects/(default)/CefDragData.html)
|
||||
foreach (var filePath in (string[])e.Data.GetData(DataFormats.FileDrop))
|
||||
{
|
||||
var displayName = Path.GetFileName(filePath);
|
||||
|
||||
dragData.AddFile(filePath.Replace("\\", "/"), displayName);
|
||||
}
|
||||
}
|
||||
|
||||
// Link/Url
|
||||
var link = GetLink(e.Data);
|
||||
dragData.IsLink = !string.IsNullOrEmpty(link);
|
||||
if (dragData.IsLink)
|
||||
{
|
||||
dragData.LinkUrl = link;
|
||||
}
|
||||
|
||||
// Text/HTML
|
||||
dragData.IsFragment = e.Data.GetDataPresent(DataFormats.Text);
|
||||
if (dragData.IsFragment)
|
||||
{
|
||||
dragData.FragmentText = (string)e.Data.GetData(DataFormats.Text);
|
||||
dragData.FragmentHtml = (string)e.Data.GetData(DataFormats.Html);
|
||||
}
|
||||
|
||||
return dragData;
|
||||
}
|
||||
|
||||
private static string GetLink(IDataObject data)
|
||||
{
|
||||
const string asciiUrlDataFormatName = "UniformResourceLocator";
|
||||
const string unicodeUrlDataFormatName = "UniformResourceLocatorW";
|
||||
|
||||
// Try Unicode
|
||||
if (data.GetDataPresent(unicodeUrlDataFormatName))
|
||||
{
|
||||
// Try to read a Unicode URL from the data
|
||||
var unicodeUrl = ReadUrlFromDragDropData(data, unicodeUrlDataFormatName, Encoding.Unicode);
|
||||
if (unicodeUrl != null)
|
||||
{
|
||||
return unicodeUrl;
|
||||
}
|
||||
}
|
||||
|
||||
// Try ASCII
|
||||
if (data.GetDataPresent(asciiUrlDataFormatName))
|
||||
{
|
||||
// Try to read an ASCII URL from the data
|
||||
return ReadUrlFromDragDropData(data, asciiUrlDataFormatName, Encoding.ASCII);
|
||||
}
|
||||
|
||||
// Not a valid link
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>Reads a URL using a particular text encoding from drag-and-drop data.</summary>
|
||||
/// <param name="data">The drag-and-drop data.</param>
|
||||
/// <param name="urlDataFormatName">The data format name of the URL type.</param>
|
||||
/// <param name="urlEncoding">The text encoding of the URL type.</param>
|
||||
/// <returns>A URL, or <see langword="null"/> if <paramref name="data"/> does not contain a URL
|
||||
/// of the correct type.</returns>
|
||||
private static string ReadUrlFromDragDropData(IDataObject data, string urlDataFormatName, Encoding urlEncoding)
|
||||
{
|
||||
// Read the URL from the data
|
||||
string url;
|
||||
using (var urlStream = (Stream)data.GetData(urlDataFormatName))
|
||||
{
|
||||
using (TextReader reader = new StreamReader(urlStream, urlEncoding))
|
||||
{
|
||||
url = reader.ReadToEnd();
|
||||
}
|
||||
}
|
||||
|
||||
// URLs in drag/drop data are often padded with null characters so remove these
|
||||
return url.TrimEnd('\0');
|
||||
}
|
||||
|
||||
~ChromiumWebBrowser()
|
||||
{
|
||||
Dispose(false);
|
||||
@@ -481,11 +661,16 @@ namespace CefSharp.Wpf
|
||||
}
|
||||
else if (args.OldSource != null)
|
||||
{
|
||||
if (source != null && sourceHook != null)
|
||||
{
|
||||
source.RemoveHook(sourceHook);
|
||||
source = null;
|
||||
}
|
||||
RemoveSourceHook();
|
||||
}
|
||||
}
|
||||
|
||||
private void RemoveSourceHook()
|
||||
{
|
||||
if (source != null && sourceHook != null)
|
||||
{
|
||||
source.RemoveHook(sourceHook);
|
||||
source = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -542,26 +727,25 @@ namespace CefSharp.Wpf
|
||||
{
|
||||
base.OnApplyTemplate();
|
||||
|
||||
CheckIsNonStandardDpi();
|
||||
|
||||
// Create main window
|
||||
Content = image = CreateImage();
|
||||
Transform(image);
|
||||
|
||||
popup = CreatePopup();
|
||||
Transform(popup);
|
||||
}
|
||||
|
||||
private static Image CreateImage()
|
||||
private Image CreateImage()
|
||||
{
|
||||
var temp = new Image();
|
||||
var img = new Image();
|
||||
|
||||
RenderOptions.SetBitmapScalingMode(temp, BitmapScalingMode.NearestNeighbor);
|
||||
RenderOptions.SetBitmapScalingMode(img, BitmapScalingMode.NearestNeighbor);
|
||||
|
||||
temp.Stretch = Stretch.None;
|
||||
temp.HorizontalAlignment = HorizontalAlignment.Left;
|
||||
temp.VerticalAlignment = VerticalAlignment.Top;
|
||||
return temp;
|
||||
img.Stretch = Stretch.None;
|
||||
img.HorizontalAlignment = HorizontalAlignment.Left;
|
||||
img.VerticalAlignment = VerticalAlignment.Top;
|
||||
//Scale Image based on DPI settings
|
||||
img.LayoutTransform = new ScaleTransform(1 / matrix.M11, 1 / matrix.M22);
|
||||
|
||||
return img;
|
||||
}
|
||||
|
||||
private Popup CreatePopup()
|
||||
@@ -579,22 +763,6 @@ namespace CefSharp.Wpf
|
||||
return newPopup;
|
||||
}
|
||||
|
||||
private void Transform(FrameworkElement element)
|
||||
{
|
||||
if (dpiTransform != null)
|
||||
{
|
||||
element.LayoutTransform = dpiTransform;
|
||||
}
|
||||
}
|
||||
|
||||
private void CheckIsNonStandardDpi()
|
||||
{
|
||||
dpiTransform = new ScaleTransform(
|
||||
1 / matrix.M11,
|
||||
1 / matrix.M22
|
||||
);
|
||||
}
|
||||
|
||||
private IntPtr SourceHook(IntPtr hWnd, int message, IntPtr wParam, IntPtr lParam, ref bool handled)
|
||||
{
|
||||
if(handled)
|
||||
@@ -636,7 +804,11 @@ namespace CefSharp.Wpf
|
||||
|
||||
public BitmapInfo CreateBitmapInfo(bool isPopup)
|
||||
{
|
||||
return new InteropBitmapInfo { IsPopup = isPopup, BytesPerPixel = BytesPerPixel };
|
||||
if (BitmapFactory == null)
|
||||
{
|
||||
throw new Exception("BitmapFactory cannot be null");
|
||||
}
|
||||
return BitmapFactory.CreateBitmap(isPopup);
|
||||
}
|
||||
|
||||
void IRenderWebBrowser.InvokeRenderAsync(BitmapInfo bitmapInfo)
|
||||
@@ -645,29 +817,22 @@ namespace CefSharp.Wpf
|
||||
{
|
||||
lock (bitmapInfo.BitmapLock)
|
||||
{
|
||||
var interopBitmapInfo = (InteropBitmapInfo)bitmapInfo;
|
||||
var wpfBitmapInfo = (WpfBitmapInfo)bitmapInfo;
|
||||
// Inform parents that the browser rendering is updating
|
||||
OnRendering(this, interopBitmapInfo);
|
||||
OnRendering(this, wpfBitmapInfo);
|
||||
|
||||
// Now update the WPF image
|
||||
var bitmap = interopBitmapInfo.InteropBitmap;
|
||||
if (bitmap == null)
|
||||
if (wpfBitmapInfo.CreateNewBitmap)
|
||||
{
|
||||
var img = bitmapInfo.IsPopup ? popupImage : image;
|
||||
|
||||
img.Source = null;
|
||||
GC.Collect(1);
|
||||
|
||||
var stride = bitmapInfo.Width * bitmapInfo.BytesPerPixel;
|
||||
|
||||
bitmap = (InteropBitmap)Imaging.CreateBitmapSourceFromMemorySection(bitmapInfo.FileMappingHandle,
|
||||
bitmapInfo.Width, bitmapInfo.Height, PixelFormat, stride, 0);
|
||||
img.Source = bitmap;
|
||||
|
||||
interopBitmapInfo.InteropBitmap = bitmap;
|
||||
img.Source = wpfBitmapInfo.CreateBitmap();
|
||||
}
|
||||
|
||||
bitmap.Invalidate();
|
||||
wpfBitmapInfo.Invalidate();
|
||||
}
|
||||
},
|
||||
DispatcherPriority.Render);
|
||||
@@ -736,6 +901,21 @@ namespace CefSharp.Wpf
|
||||
UiThreadRunAsync(() => { popup.IsOpen = isOpen; });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts a .NET Drag event to a CefSharp MouseEvent
|
||||
/// </summary>
|
||||
private MouseEvent GetMouseEvent(DragEventArgs e)
|
||||
{
|
||||
var point = e.GetPosition(this);
|
||||
|
||||
return new MouseEvent
|
||||
{
|
||||
X = (int)point.X,
|
||||
Y = (int)point.Y,
|
||||
//Modifiers = modifiers // TODO: Add support for modifiers in drag events (might not be need as it can be accessed via the mouse events)
|
||||
};
|
||||
}
|
||||
|
||||
private static CefEventFlags GetModifiers(MouseEventArgs e)
|
||||
{
|
||||
CefEventFlags modifiers = 0;
|
||||
@@ -974,19 +1154,24 @@ namespace CefSharp.Wpf
|
||||
switch (e.ChangedButton)
|
||||
{
|
||||
case MouseButton.Left:
|
||||
{
|
||||
mouseButtonType = MouseButtonType.Left;
|
||||
break;
|
||||
|
||||
}
|
||||
case MouseButton.Middle:
|
||||
{
|
||||
mouseButtonType = MouseButtonType.Middle;
|
||||
break;
|
||||
|
||||
}
|
||||
case MouseButton.Right:
|
||||
{
|
||||
mouseButtonType = MouseButtonType.Right;
|
||||
break;
|
||||
|
||||
}
|
||||
default:
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
var modifiers = GetModifiers(e);
|
||||
@@ -1009,6 +1194,11 @@ namespace CefSharp.Wpf
|
||||
//Added null check -> binding-triggered changes of Address will lead to a nullref after Dispose has been called.
|
||||
if (managedCefBrowserAdapter != null)
|
||||
{
|
||||
if (tooltipTimer != null)
|
||||
{
|
||||
tooltipTimer.Tick -= OnTooltipTimerTick;
|
||||
}
|
||||
|
||||
// TODO: Consider making the delay here configurable.
|
||||
tooltipTimer = new DispatcherTimer(
|
||||
TimeSpan.FromSeconds(0.5),
|
||||
@@ -1225,7 +1415,7 @@ namespace CefSharp.Wpf
|
||||
/// <summary>
|
||||
/// Raises Rendering event
|
||||
/// </summary>
|
||||
protected virtual void OnRendering(object sender, InteropBitmapInfo bitmapInfo)
|
||||
protected virtual void OnRendering(object sender, WpfBitmapInfo bitmapInfo)
|
||||
{
|
||||
var rendering = Rendering;
|
||||
if (rendering != null)
|
||||
@@ -1279,5 +1469,14 @@ namespace CefSharp.Wpf
|
||||
{
|
||||
managedCefBrowserAdapter.Invalidate(type);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Change the zoom level to the specified value. Specify 0.0 to reset the zoom level.
|
||||
/// </summary>
|
||||
/// <param name="zoomLevel">zoom level</param>
|
||||
public void SetZoomLevel(double zoomLevel)
|
||||
{
|
||||
managedCefBrowserAdapter.SetZoomLevel(zoomLevel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
using System.Windows.Interop;
|
||||
using CefSharp.Internals;
|
||||
|
||||
namespace CefSharp.Wpf
|
||||
{
|
||||
public class InteropBitmapInfo : BitmapInfo
|
||||
{
|
||||
// Cannot be InteropBitmap since we really don't want CefSharp to be dependent on WPF libraries.
|
||||
public InteropBitmap InteropBitmap { get; set; }
|
||||
|
||||
public override void ClearBitmap()
|
||||
{
|
||||
InteropBitmap = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
// Copyright © 2010-2014 The CefSharp Authors. All rights reserved.
|
||||
//
|
||||
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
using CefSharp.Internals;
|
||||
|
||||
namespace CefSharp.Wpf.Rendering
|
||||
{
|
||||
public class BitmapFactory : IBitmapFactory
|
||||
{
|
||||
public BitmapInfo CreateBitmap(bool isPopup)
|
||||
{
|
||||
//return new WritableBitmapInfo { IsPopup = isPopup };
|
||||
return new InteropBitmapInfo { IsPopup = isPopup };
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
// Copyright © 2010-2014 The CefSharp Authors. All rights reserved.
|
||||
//
|
||||
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
using System.Windows.Interop;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
|
||||
namespace CefSharp.Wpf.Rendering
|
||||
{
|
||||
public class InteropBitmapInfo : WpfBitmapInfo
|
||||
{
|
||||
private static readonly PixelFormat PixelFormat = PixelFormats.Bgra32;
|
||||
|
||||
public InteropBitmap Bitmap { get; private set; }
|
||||
|
||||
public InteropBitmapInfo()
|
||||
{
|
||||
BytesPerPixel = PixelFormat.BitsPerPixel / 8;
|
||||
}
|
||||
|
||||
public override bool CreateNewBitmap
|
||||
{
|
||||
get { return Bitmap == null; }
|
||||
}
|
||||
|
||||
public override void ClearBitmap()
|
||||
{
|
||||
Bitmap = null;
|
||||
}
|
||||
|
||||
public override void Invalidate()
|
||||
{
|
||||
Bitmap.Invalidate();
|
||||
}
|
||||
|
||||
public override BitmapSource CreateBitmap()
|
||||
{
|
||||
var stride = Width * BytesPerPixel;
|
||||
|
||||
Bitmap = (InteropBitmap)Imaging.CreateBitmapSourceFromMemorySection(FileMappingHandle, Width, Height, PixelFormat, stride, 0);
|
||||
|
||||
return Bitmap;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
// Copyright © 2010-2014 The CefSharp Authors. All rights reserved.
|
||||
//
|
||||
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
using System.Windows.Media.Imaging;
|
||||
using CefSharp.Internals;
|
||||
|
||||
namespace CefSharp.Wpf.Rendering
|
||||
{
|
||||
public abstract class WpfBitmapInfo : BitmapInfo
|
||||
{
|
||||
public abstract void Invalidate();
|
||||
public abstract BitmapSource CreateBitmap();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
// Copyright © 2010-2014 The CefSharp Authors. All rights reserved.
|
||||
//
|
||||
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
|
||||
namespace CefSharp.Wpf.Rendering
|
||||
{
|
||||
public class WritableBitmapInfo : WpfBitmapInfo
|
||||
{
|
||||
private static readonly PixelFormat PixelFormat = PixelFormats.Bgra32;
|
||||
|
||||
public WriteableBitmap Bitmap { get; private set; }
|
||||
|
||||
public WritableBitmapInfo()
|
||||
{
|
||||
BytesPerPixel = PixelFormat.BitsPerPixel / 8;
|
||||
DirtyRectSupport = true;
|
||||
}
|
||||
|
||||
public override bool CreateNewBitmap
|
||||
{
|
||||
get { return Bitmap == null; }
|
||||
}
|
||||
|
||||
public override void ClearBitmap()
|
||||
{
|
||||
Bitmap = null;
|
||||
}
|
||||
|
||||
public override void Invalidate()
|
||||
{
|
||||
var stride = Width*BytesPerPixel;
|
||||
var sourceBufferSize = stride*Height;
|
||||
|
||||
if (Width == 0 || Height == 0 || DirtyRect.Width == 0 || DirtyRect.Height == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Update the dirty region
|
||||
var sourceRect = new Int32Rect(DirtyRect.X, DirtyRect.Y, DirtyRect.Width, DirtyRect.Height);
|
||||
Bitmap.WritePixels(sourceRect, BackBufferHandle, sourceBufferSize, stride, DirtyRect.X, DirtyRect.Y);
|
||||
}
|
||||
|
||||
public override BitmapSource CreateBitmap()
|
||||
{
|
||||
Bitmap = new WriteableBitmap(Width, Height, 96, 96, PixelFormat, null);
|
||||
|
||||
return Bitmap;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
using System;
|
||||
using CefSharp.Wpf.Rendering;
|
||||
|
||||
namespace CefSharp.Wpf
|
||||
{
|
||||
@@ -11,7 +12,7 @@ namespace CefSharp.Wpf
|
||||
/// </summary>
|
||||
public class RenderingEventArgs : EventArgs
|
||||
{
|
||||
public RenderingEventArgs(InteropBitmapInfo bitmapInfo)
|
||||
public RenderingEventArgs(WpfBitmapInfo bitmapInfo)
|
||||
{
|
||||
BitmapInfo = bitmapInfo;
|
||||
}
|
||||
@@ -19,7 +20,6 @@ namespace CefSharp.Wpf
|
||||
/// <summary>
|
||||
/// The bitmap info being rendered.
|
||||
/// </summary>
|
||||
public InteropBitmapInfo BitmapInfo { get; private set; }
|
||||
|
||||
public WpfBitmapInfo BitmapInfo { get; private set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,14 +6,72 @@ namespace CefSharp
|
||||
{
|
||||
public class CefCustomScheme
|
||||
{
|
||||
/// <summary>
|
||||
/// Schema Name e.g. custom
|
||||
/// </summary>
|
||||
public string SchemeName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Optional Domain Name. An empty value for a standard scheme
|
||||
/// will cause the factory to match all domain names. The |domain_name| value
|
||||
/// will be ignored for non-standard schemes.
|
||||
/// </summary>
|
||||
public string DomainName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// If true the scheme will be treated as a standard scheme.
|
||||
/// Standard schemes are subject to URL canonicalization and parsing rules as
|
||||
/// defined in the Common Internet Scheme Syntax RFC 1738 Section 3.1 available
|
||||
/// at http://www.ietf.org/rfc/rfc1738.txt
|
||||
///
|
||||
/// In particular, the syntax for standard scheme URLs must be of the form:
|
||||
/// <pre>
|
||||
/// [scheme]://[username]:[password]@[host]:[port]/[url-path]
|
||||
/// </pre>
|
||||
/// Standard scheme URLs must have a host component that is a fully qualified
|
||||
/// domain name as defined in Section 3.5 of RFC 1034 [13] and Section 2.1 of
|
||||
/// RFC 1123. These URLs will be canonicalized to "scheme://host/path" in the
|
||||
/// simplest case and "scheme://username:password@host:port/path" in the most
|
||||
/// explicit case. For example, "scheme:host/path" and "scheme:///host/path"
|
||||
/// will both be canonicalized to "scheme://host/path". The origin of a
|
||||
/// standard scheme URL is the combination of scheme, host and port (i.e.,
|
||||
/// "scheme://host:port" in the most explicit case).
|
||||
///
|
||||
/// For non-standard scheme URLs only the "scheme:" component is parsed and
|
||||
/// canonicalized. The remainder of the URL will be passed to the handler
|
||||
/// as-is. For example, "scheme:///some%20text" will remain the same.
|
||||
/// Non-standard scheme URLs cannot be used as a target for form submission.
|
||||
/// </summary>
|
||||
public bool IsStandard { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// If true the scheme will be treated as local (i.e. with the
|
||||
/// same security rules as those applied to "file" URLs). Normal pages cannot
|
||||
/// link to or access local URLs. Also, by default, local URLs can only perform
|
||||
/// XMLHttpRequest calls to the same URL (origin + path) that originated the
|
||||
/// request. To allow XMLHttpRequest calls from a local URL to other URLs with
|
||||
/// the same origin set the CefSettings.file_access_from_file_urls_allowed
|
||||
/// value to true. To allow XMLHttpRequest calls from a local URL to all
|
||||
/// origins set the CefSettings.universal_access_from_file_urls_allowed value
|
||||
/// to true.
|
||||
/// </summary>
|
||||
public bool IsLocal { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// If true the scheme will be treated as display-isolated.
|
||||
/// This means that pages cannot display these URLs unless they are
|
||||
/// from the same scheme. For example, pages in another origin cannot create
|
||||
/// iframes or hyperlinks to URLs with this scheme.
|
||||
/// </summary>
|
||||
public bool IsDisplayIsolated { get; set; }
|
||||
|
||||
public ISchemeHandlerFactory SchemeHandlerFactory { get; set; }
|
||||
|
||||
public CefCustomScheme()
|
||||
{
|
||||
IsStandard = true;
|
||||
IsLocal = false;
|
||||
IsDisplayIsolated = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
// Copyright © 2010-2014 The CefSharp Authors. All rights reserved.
|
||||
//
|
||||
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
namespace CefSharp
|
||||
{
|
||||
public struct CefDirtyRect
|
||||
{
|
||||
private readonly int x;
|
||||
private readonly int y;
|
||||
private readonly int width;
|
||||
private readonly int height;
|
||||
|
||||
public CefDirtyRect(int x, int y, int width, int height)
|
||||
{
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
public int X { get { return x; } }
|
||||
public int Y { get { return y; } }
|
||||
public int Width { get { return width; } }
|
||||
public int Height { get { return height; } }
|
||||
}
|
||||
}
|
||||
@@ -88,12 +88,16 @@
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="CefDirtyRect.cs" />
|
||||
<Compile Include="CefFileDialogMode.cs" />
|
||||
<Compile Include="DefaultResourceHandler.cs" />
|
||||
<Compile Include="MouseEvent.cs" />
|
||||
<Compile Include="DragOperationsMask.cs" />
|
||||
<Compile Include="IBitmapFactory.cs" />
|
||||
<Compile Include="IDragData.cs" />
|
||||
<Compile Include="IFocusHandler.cs" />
|
||||
<Compile Include="IDragHandler.cs" />
|
||||
<Compile Include="IGeolocationHandler.cs" />
|
||||
<Compile Include="IResourceHandler.cs" />
|
||||
<Compile Include="IsBrowserInitializedChangedEventArgs.cs" />
|
||||
<Compile Include="CefTerminationStatus.cs" />
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
// Copyright © 2010-2014 The CefSharp Authors. All rights reserved.
|
||||
//
|
||||
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
using CefSharp.Internals;
|
||||
|
||||
namespace CefSharp
|
||||
{
|
||||
public interface IBitmapFactory
|
||||
{
|
||||
BitmapInfo CreateBitmap(bool isPopup);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
// Copyright © 2010-2014 The CefSharp Authors. All rights reserved.
|
||||
//
|
||||
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
namespace CefSharp
|
||||
{
|
||||
public interface IGeolocationHandler
|
||||
{
|
||||
/// <summary>
|
||||
/// Called when a page requests permission to access geolocation information.
|
||||
/// </summary>
|
||||
/// <param name="browser">the browser object</param>
|
||||
/// <param name="requestingUrl">the URL requesting permission</param>
|
||||
/// <param name="requestId">the unique ID for the permission request</param>
|
||||
/// <returns>true to allow the request and false to deny</returns>
|
||||
bool OnRequestGeolocationPermission(IWebBrowser browser, string requestingUrl, int requestId);
|
||||
|
||||
/// <summary>
|
||||
/// Called when a geolocation access request is canceled.
|
||||
/// </summary>
|
||||
/// <param name="browser">the browser object</param>
|
||||
/// <param name="requestingUrl">the URL that originally requested permission</param>
|
||||
/// <param name="requestId">the unique ID for the permission request, as seen in <see cref="OnRequestGeolocationPermission"/></param>
|
||||
void OnCancelGeolocationPermission(IWebBrowser browser, string requestingUrl, int requestId);
|
||||
}
|
||||
}
|
||||
@@ -154,6 +154,11 @@ namespace CefSharp
|
||||
/// </summary>
|
||||
IResourceHandler ResourceHandler { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Implement <see cref="IGeolocationHandler"/> and assign to handle requests for permission to use geolocation.
|
||||
/// </summary>
|
||||
IGeolocationHandler GeolocationHandler { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A flag that indicates whether the WebBrowser is initialized (true) or not (false).
|
||||
/// </summary>
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace CefSharp.Internals
|
||||
{
|
||||
@@ -17,10 +18,15 @@ namespace CefSharp.Internals
|
||||
|
||||
public IntPtr FileMappingHandle { get; set; }
|
||||
|
||||
public int BytesPerPixel { get; set; }
|
||||
public int BytesPerPixel { get; protected set; }
|
||||
public bool DirtyRectSupport { get; protected set; }
|
||||
public int NumberOfBytes { get; set; }
|
||||
|
||||
public abstract bool CreateNewBitmap { get; }
|
||||
public abstract void ClearBitmap();
|
||||
|
||||
public CefDirtyRect DirtyRect { get; set; }
|
||||
|
||||
protected BitmapInfo()
|
||||
{
|
||||
BitmapLock = new object();
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
// Copyright © 2010-2014 The CefSharp Authors. All rights reserved.
|
||||
//
|
||||
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
namespace CefSharp
|
||||
{
|
||||
public class MouseEvent
|
||||
{
|
||||
public int X { get; set; }
|
||||
public int Y { get; set; }
|
||||
public CefEventFlags Modifiers { get; set; }
|
||||
}
|
||||
}
|
||||
+2
-3
@@ -1,8 +1,6 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 2013
|
||||
VisualStudioVersion = 12.0.30723.0
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
# Visual Studio 2012
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CefSharp.Test", "CefSharp.Test\CefSharp.Test.csproj", "{7A4D5447-183B-4A11-8E63-9848991B46FF}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CefSharp.Example", "CefSharp.Example\CefSharp.Example.csproj", "{A4394E7B-1155-43A6-989E-8AB72DDDC9E4}"
|
||||
@@ -51,6 +49,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "NuGet", "NuGet", "{A23AA466
|
||||
NuGet\CefSharp.Wpf.nuspec = NuGet\CefSharp.Wpf.nuspec
|
||||
NuGet\CefSharp.Wpf.props = NuGet\CefSharp.Wpf.props
|
||||
NuGet\pack.bat = NuGet\pack.bat
|
||||
NuGet\Readme.txt = NuGet\Readme.txt
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CefSharp.Core", "CefSharp.Core\CefSharp.Core.vcxproj", "{7B495581-2271-4F41-9476-ACB86E8C864F}"
|
||||
|
||||
@@ -27,5 +27,7 @@
|
||||
<file src="..\CefSharp.OffScreen\bin\x64\Release\CefSharp.OffScreen.xml" target="lib" />
|
||||
|
||||
<file src="CefSharp.OffScreen.props" target="build" />
|
||||
|
||||
<file src="Readme.txt" target="" />
|
||||
</files>
|
||||
</package>
|
||||
|
||||
@@ -27,5 +27,7 @@
|
||||
<file src="..\CefSharp.WinForms\bin\x64\Release\CefSharp.WinForms.xml" target="lib" />
|
||||
|
||||
<file src="CefSharp.WinForms.props" target="build" />
|
||||
|
||||
<file src="Readme.txt" target="" />
|
||||
</files>
|
||||
</package>
|
||||
|
||||
@@ -27,5 +27,7 @@
|
||||
<file src="..\CefSharp.Wpf\bin\x64\Release\CefSharp.Wpf.xml" target="lib" />
|
||||
|
||||
<file src="CefSharp.Wpf.props" target="build" />
|
||||
|
||||
<file src="Readme.txt" target="" />
|
||||
</files>
|
||||
</package>
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
CefSharp Nuget Package
|
||||
|
||||
Background:
|
||||
CefSharp is a .Net wrapping library for CEF (Chromium Embedded Framework) https://code.google.com/p/chromiumembedded/
|
||||
CEF is a C/C++ library that allows developers to embed the HTML content rendering strengths of Google's Chrome open source WebKit engine (Chromium).
|
||||
|
||||
Post Installation:
|
||||
- Make sure you set either `x86` or x64`. (Won't work with `AnyCpu`)
|
||||
- After installing the `Nuget` package we recommend closing Visual Studio completely and then reopening (This ensures your references show up and you have full intellisense).
|
||||
- Check your output `\bin` directory to make sure the appropriate references have been copied.
|
||||
|
||||
Basic Troubleshooting:
|
||||
- Please ensure your binaries directory contains these required dependencies:
|
||||
* libcef.dll (CEF code)
|
||||
* icudtl.dat (Unicode Support data)
|
||||
* CefSharp.Core.dll, CefSharp.dll,
|
||||
CefSharp.BrowserSubprocess.exe, CefSharp.BrowserSubProcess.Core.dll
|
||||
- These are required CefSharp binaries that are the common core logic binaries of CefSharp.
|
||||
* One of the following UI presentation approaches:
|
||||
* CefSharp.WinForms.dll
|
||||
* CefSharp.Wpf.dll
|
||||
* CefSharp.OffScreen.dll
|
||||
- Additional optional CEF files are described at: https://github.com/cefsharp/cef-binary/blob/master/README.txt#L88
|
||||
NOTE: CefSharp does not currently support CEF sandboxing so wow_helper.exe is not currently useful.
|
||||
|
||||
For further help please read the following content:
|
||||
- CefSharp GitHub https://github.com/cefsharp/CefSharp
|
||||
- CefSharp's Wiki on github (https://github.com/cefsharp/CefSharp/wiki)
|
||||
- Minimal Example Projects showing the browser in action (https://github.com/cefsharp/CefSharp.MinimalExample)
|
||||
- FAQ: https://github.com/cefsharp/CefSharp/wiki/Frequently-asked-questions
|
||||
- Troubleshooting guide (https://github.com/cefsharp/CefSharp/wiki/Trouble-Shooting)
|
||||
- Google Groups (https://groups.google.com/forum/#!forum/cefsharp)
|
||||
- CefSharp vs Cef (https://github.com/cefsharp/CefSharp/blob/master/CONTRIBUTING.md#cefsharp-vs-cef)
|
||||
- Only when you've exhausted all other options then open an issue on `GitHub`
|
||||
|
||||
Please consider giving back, it's only with your help will this project to continue.
|
||||
|
||||
Regards,
|
||||
CefSharp Team
|
||||
@@ -14,11 +14,14 @@ Apart from code samples mentioned above work-in-progress documentation can be fo
|
||||
|
||||
Binary releases contain everything needed to embed Chromium in your .Net/CLR application. For usage see [FAQ #8](https://github.com/cefsharp/CefSharp/wiki/Frequently-asked-questions#CefSharp_binaries) item.
|
||||
|
||||
**CI Builds**<br/>
|
||||
Every commit on `master` produces a `Nuget` package. Use at your own risk! [CefSharp MyGet Feed](https://www.myget.org/F/cefsharp/)
|
||||
|
||||
**Stable**<br>
|
||||
 for either [WPF](http://www.nuget.org/packages/CefSharp.Wpf/) or
|
||||
[WinForms](http://www.nuget.org/packages/CefSharp.WinForms/) based on Chromium 37 now **including** JS Binding.
|
||||
|
||||
**Ultra stable/LTS** Read "He's dead Jim", based on Chromium 25. See the [CefSharp1](https://github.com/jornh/CefSharp/tree/CefSharp1#binary-release) branch README for CefSharp1 info. Please note that this version is no longer supported.
|
||||
**Ultra stable/LTS** Read "He's dead Jim", based on Chromium 25. See the [CefSharp1](https://github.com/cefsharp/CefSharp/tree/CefSharp1#binary-release) branch README for CefSharp1 info. Please note that this version is no longer supported.
|
||||
|
||||
# Branches & Forks
|
||||
|
||||
|
||||
@@ -3,11 +3,11 @@ param(
|
||||
[Parameter(Position = 0)]
|
||||
[string] $Target = "nupkg",
|
||||
[Parameter(Position = 1)]
|
||||
[string] $Version = "39.0.0-pre01",
|
||||
[string] $Version = "39.0.0-pre03",
|
||||
[Parameter(Position = 2)]
|
||||
[string] $AssemblyVersion = "39.0.0",
|
||||
[Parameter(Position = 3)]
|
||||
[string] $RedistVersion = "3.2171.1972"
|
||||
[string] $RedistVersion = "3.2171.1979"
|
||||
)
|
||||
|
||||
$WorkingDir = split-path -parent $MyInvocation.MyCommand.Definition
|
||||
|
||||
Reference in New Issue
Block a user