From 2b4a8cb18e8c46c0c0b43be28beda8bbebaf994c Mon Sep 17 00:00:00 2001 From: Alex Maitland Date: Wed, 13 Jan 2021 14:56:27 +1000 Subject: [PATCH] Core - PublicApi remove references to CefSharp.Core.Runtime - Add an UnWrap method to the interfaces (should be hidden from IntelliSense) - For .Net 4.5.2 projects they're not a decorator class which an inner instance of the CefSharp.Core.Runtime Type - For Net Core we have a ref assembly which allows us to reference the CefSharp.Core.Runtime without issues We can potentially remove the ref assembly now and forgo any direct reference. --- .../CefSharp.Core.Runtime.cs | 7 +- CefSharp.Core.Runtime/BrowserSettings.h | 5 + .../Internals/CefBrowserHostWrapper.cpp | 3 +- .../Internals/CefFrameWrapper.cpp | 4 +- .../ManagedCefBrowserAdapter.cpp | 13 +- CefSharp.Core.Runtime/PostData.h | 9 +- CefSharp.Core.Runtime/PostDataElement.h | 5 + CefSharp.Core.Runtime/Request.cpp | 2 +- CefSharp.Core.Runtime/Request.h | 5 + CefSharp.Core.Runtime/RequestContext.cpp | 9 +- CefSharp.Core.Runtime/RequestContext.h | 10 +- CefSharp.Core.Runtime/WindowInfo.h | 5 + CefSharp.Core/BrowserSettings.cs | 262 +++++++++++++++++- CefSharp.Core/BrowserSettings.netcore.cs | 28 ++ CefSharp.Core/CefSharp.Core.netcore.csproj | 10 + CefSharp.Core/DragData.cs | 7 + CefSharp.Core/ObjectFactory.cs | 12 + CefSharp.Core/PostData.cs | 78 +++++- CefSharp.Core/PostData.netcore.cs | 21 ++ CefSharp.Core/PostDataElement.cs | 65 ++++- CefSharp.Core/PostDataElement.netcore.cs | 21 ++ CefSharp.Core/Request.cs | 131 ++++++++- CefSharp.Core/Request.netcore.cs | 21 ++ CefSharp.Core/RequestContext.cs | 177 +++++++++++- CefSharp.Core/RequestContext.netcore.cs | 56 ++++ CefSharp.Core/UrlRequest.cs | 96 ++++++- CefSharp.Core/UrlRequest.netcore.cs | 52 ++++ CefSharp.Core/WindowInfo.cs | 126 ++++++++- CefSharp.Core/WindowInfo.netcore.cs | 21 ++ .../CefSharp.OffScreen.Example.csproj | 4 - .../WinForms/WinFormsBrowserBasicFacts.cs | 42 +++ CefSharp.Test/Wpf/WpfBrowserBasicFacts.cs | 37 +++ .../CefSharp.WinForms.Example.csproj | 4 - CefSharp.WinForms/ChromiumWebBrowser.cs | 4 +- .../CefSharp.Wpf.Example.csproj | 4 - CefSharp.Wpf/ChromiumWebBrowser.cs | 2 +- CefSharp/IBrowserSettings.cs | 8 + CefSharp/IPostData.cs | 8 + CefSharp/IPostDataElement.cs | 8 + CefSharp/IRequest.cs | 8 + CefSharp/IRequestContext.cs | 8 + CefSharp/IWindowInfo.cs | 8 + 42 files changed, 1358 insertions(+), 48 deletions(-) create mode 100644 CefSharp.Core/BrowserSettings.netcore.cs create mode 100644 CefSharp.Core/PostData.netcore.cs create mode 100644 CefSharp.Core/PostDataElement.netcore.cs create mode 100644 CefSharp.Core/Request.netcore.cs create mode 100644 CefSharp.Core/RequestContext.netcore.cs create mode 100644 CefSharp.Core/UrlRequest.netcore.cs create mode 100644 CefSharp.Core/WindowInfo.netcore.cs diff --git a/CefSharp.Core.Runtime.RefAssembly/CefSharp.Core.Runtime.cs b/CefSharp.Core.Runtime.RefAssembly/CefSharp.Core.Runtime.cs index 63f18541e0..066f6642c8 100644 --- a/CefSharp.Core.Runtime.RefAssembly/CefSharp.Core.Runtime.cs +++ b/CefSharp.Core.Runtime.RefAssembly/CefSharp.Core.Runtime.cs @@ -51,6 +51,7 @@ public void Dispose() { } [System.Runtime.ExceptionServices.HandleProcessCorruptedStateExceptionsAttribute] protected virtual void Dispose(bool A_0) { } ~BrowserSettings() { } + public virtual CefSharp.IBrowserSettings UnWrap() { throw null; } } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public sealed partial class Cef @@ -224,6 +225,7 @@ protected virtual void Dispose(bool A_0) { } ~PostData() { } public virtual bool RemoveElement(CefSharp.IPostDataElement element) { throw null; } public virtual void RemoveElements() { } + public virtual CefSharp.IPostData UnWrap() { throw null; } } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public partial class PostDataElement : CefSharp.Internals.CefWrapper, CefSharp.IPostDataElement @@ -238,6 +240,7 @@ public void Dispose() { } protected virtual void Dispose(bool A_0) { } ~PostDataElement() { } public virtual void SetToEmpty() { } + public virtual CefSharp.IPostDataElement UnWrap() { throw null; } } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public partial class Request : CefSharp.Internals.CefWrapper, CefSharp.IRequest @@ -262,6 +265,7 @@ protected virtual void Dispose(bool A_0) { } public virtual void InitializePostData() { } public virtual void SetHeaderByName(string name, string value, bool overwrite) { } public virtual void SetReferrer(string referrerUrl, CefSharp.ReferrerPolicy policy) { } + public virtual CefSharp.IRequest UnWrap() { throw null; } } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public partial class RequestContext : CefSharp.Internals.CefWrapper, CefSharp.IRequestContext @@ -299,6 +303,7 @@ public virtual void PurgePluginListCache(bool reloadPages) { } public virtual bool RegisterSchemeHandlerFactory(string schemeName, string domainName, CefSharp.ISchemeHandlerFactory factory) { throw null; } public virtual System.Threading.Tasks.Task ResolveHostAsync(System.Uri origin) { throw null; } public virtual bool SetPreference(string name, object value, out string error) { throw null; } + public virtual CefSharp.IRequestContext UnWrap() { throw null; } } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public partial class RequestContextSettings : System.IDisposable @@ -350,6 +355,7 @@ public virtual void SetAsChild(System.IntPtr parentHandle) { } public virtual void SetAsChild(System.IntPtr parentHandle, int left, int top, int right, int bottom) { } public virtual void SetAsPopup(System.IntPtr parentHandle, string windowName) { } public virtual void SetAsWindowless(System.IntPtr parentHandle) { } + public virtual CefSharp.IWindowInfo UnWrap() { throw null; } } } namespace CefSharp.Internals @@ -364,4 +370,3 @@ protected void ThrowIfExecutedOnNonCefUiThread() { } } } - diff --git a/CefSharp.Core.Runtime/BrowserSettings.h b/CefSharp.Core.Runtime/BrowserSettings.h index 3569f66812..7badcd8870 100644 --- a/CefSharp.Core.Runtime/BrowserSettings.h +++ b/CefSharp.Core.Runtime/BrowserSettings.h @@ -408,6 +408,11 @@ namespace CefSharp { bool get() { return _autoDispose; } } + + virtual IBrowserSettings^ UnWrap() + { + return this; + } }; } } diff --git a/CefSharp.Core.Runtime/Internals/CefBrowserHostWrapper.cpp b/CefSharp.Core.Runtime/Internals/CefBrowserHostWrapper.cpp index 55ae02c348..de69c6b573 100644 --- a/CefSharp.Core.Runtime/Internals/CefBrowserHostWrapper.cpp +++ b/CefSharp.Core.Runtime/Internals/CefBrowserHostWrapper.cpp @@ -176,7 +176,8 @@ void CefBrowserHostWrapper::ShowDevTools(IWindowInfo^ windowInfo, int inspectEle } else { - auto cefWindowInfoWrapper = static_cast(windowInfo); + //Get the inner instance then case that + auto cefWindowInfoWrapper = static_cast(windowInfo->UnWrap()); nativeWindowInfo = *cefWindowInfoWrapper->GetWindowInfo(); } diff --git a/CefSharp.Core.Runtime/Internals/CefFrameWrapper.cpp b/CefSharp.Core.Runtime/Internals/CefFrameWrapper.cpp index 5a52ca87a4..987123dcce 100644 --- a/CefSharp.Core.Runtime/Internals/CefFrameWrapper.cpp +++ b/CefSharp.Core.Runtime/Internals/CefFrameWrapper.cpp @@ -194,7 +194,7 @@ void CefFrameWrapper::LoadRequest(IRequest^ request) ThrowIfDisposed(); ThrowIfFrameInvalid(); - auto requestWrapper = (Request^)request; + auto requestWrapper = (Request^)request->UnWrap(); _frame->LoadRequest(requestWrapper); } @@ -416,7 +416,7 @@ IUrlRequest^ CefFrameWrapper::CreateUrlRequest(IRequest^ request, IUrlRequestCli } auto urlRequest = _frame->CreateURLRequest( - (Request^)request, + (Request^)request->UnWrap(), new CefUrlRequestClientAdapter(client)); return gcnew UrlRequest(urlRequest); diff --git a/CefSharp.Core.Runtime/ManagedCefBrowserAdapter.cpp b/CefSharp.Core.Runtime/ManagedCefBrowserAdapter.cpp index 474e8473aa..39edc4659f 100644 --- a/CefSharp.Core.Runtime/ManagedCefBrowserAdapter.cpp +++ b/CefSharp.Core.Runtime/ManagedCefBrowserAdapter.cpp @@ -83,11 +83,18 @@ namespace CefSharp } } - auto requestCtx = (RequestContext^)requestContext; - auto bSettings =(BrowserSettings^)browserSettings; + CefRefPtr requestCtx; + + if (requestContext != nullptr) + { + auto managedRequestCtx = (RequestContext^)requestContext->UnWrap(); + requestCtx = static_cast>(managedRequestCtx); + } + + auto bSettings = (BrowserSettings^)browserSettings->UnWrap(); if (!CefBrowserHost::CreateBrowser(*cefWindowInfoWrapper->GetWindowInfo(), _clientAdapter.get(), addressNative, - *bSettings->_browserSettings, extraInfo, static_cast>(requestCtx))) + *bSettings->_browserSettings, extraInfo, requestCtx)) { throw gcnew InvalidOperationException("CefBrowserHost::CreateBrowser call failed, review the CEF log file for more details."); } diff --git a/CefSharp.Core.Runtime/PostData.h b/CefSharp.Core.Runtime/PostData.h index a62e39cbdc..18945b526f 100644 --- a/CefSharp.Core.Runtime/PostData.h +++ b/CefSharp.Core.Runtime/PostData.h @@ -164,7 +164,7 @@ namespace CefSharp _postDataElements->Add(element); - auto elementWrapper = (PostDataElement^)element; + auto elementWrapper = (PostDataElement^)element->UnWrap(); return _postData->AddElement(elementWrapper); } @@ -190,7 +190,7 @@ namespace CefSharp _postDataElements->Remove(element); - auto elementWrapper = (PostDataElement^)element; + auto elementWrapper = (PostDataElement^)element->UnWrap(); return _postData->RemoveElement(elementWrapper); } @@ -233,6 +233,11 @@ namespace CefSharp return _postData->HasExcludedElements(); } } + + virtual IPostData^ UnWrap() + { + return this; + } }; } } diff --git a/CefSharp.Core.Runtime/PostDataElement.h b/CefSharp.Core.Runtime/PostDataElement.h index 9966da0492..575fbe44e7 100644 --- a/CefSharp.Core.Runtime/PostDataElement.h +++ b/CefSharp.Core.Runtime/PostDataElement.h @@ -124,6 +124,11 @@ namespace CefSharp _postDataElement->SetToBytes(val->Length, static_cast(src)); } } + + virtual IPostDataElement^ UnWrap() + { + return this; + } }; } } diff --git a/CefSharp.Core.Runtime/Request.cpp b/CefSharp.Core.Runtime/Request.cpp index c89d6f279f..96ed56fa0f 100644 --- a/CefSharp.Core.Runtime/Request.cpp +++ b/CefSharp.Core.Runtime/Request.cpp @@ -176,7 +176,7 @@ namespace CefSharp ThrowIfReadOnly(); - _request->SetPostData((CefSharp::Core::PostData^)postData); + _request->SetPostData((CefSharp::Core::PostData^)postData->UnWrap()); } bool Request::IsReadOnly::get() diff --git a/CefSharp.Core.Runtime/Request.h b/CefSharp.Core.Runtime/Request.h index 4f8a4816ca..a105895cc9 100644 --- a/CefSharp.Core.Runtime/Request.h +++ b/CefSharp.Core.Runtime/Request.h @@ -79,6 +79,11 @@ namespace CefSharp virtual String^ GetHeaderByName(String^ name); virtual void SetHeaderByName(String^ name, String^ value, bool overwrite); + + virtual IRequest^ UnWrap() + { + return this; + } }; } } diff --git a/CefSharp.Core.Runtime/RequestContext.cpp b/CefSharp.Core.Runtime/RequestContext.cpp index 4276736621..90d212dcfb 100644 --- a/CefSharp.Core.Runtime/RequestContext.cpp +++ b/CefSharp.Core.Runtime/RequestContext.cpp @@ -37,7 +37,7 @@ namespace CefSharp { ThrowIfDisposed(); - auto requestContext = (RequestContext^)context; + auto requestContext = (RequestContext^)context->UnWrap(); return _requestContext->IsSame(requestContext); } @@ -46,7 +46,7 @@ namespace CefSharp { ThrowIfDisposed(); - auto requestContext = (RequestContext^)context; + auto requestContext = (RequestContext^)context->UnWrap(); return _requestContext->IsSharingWith(requestContext); } @@ -268,5 +268,10 @@ namespace CefSharp CefPostTask(TID_UI, base::Bind(&CefRequestContext::LoadExtension, _requestContext.get(), StringUtils::ToNative(rootDirectory), manifest, extensionHandler)); } } + + IRequestContext^ RequestContext::UnWrap() + { + return this; + } } } diff --git a/CefSharp.Core.Runtime/RequestContext.h b/CefSharp.Core.Runtime/RequestContext.h index 18a2ae0a12..a465814d3c 100644 --- a/CefSharp.Core.Runtime/RequestContext.h +++ b/CefSharp.Core.Runtime/RequestContext.h @@ -87,12 +87,12 @@ namespace CefSharp ///Creates a new context object that shares storage with | other | and uses an optional | handler | . RequestContext(IRequestContext^ otherRequestContext) { - _requestContext = CefRequestContext::CreateContext((RequestContext^)otherRequestContext, NULL); + _requestContext = CefRequestContext::CreateContext((RequestContext^)otherRequestContext->UnWrap(), NULL); } RequestContext(IRequestContext^ otherRequestContext, IRequestContextHandler^ requestContextHandler) { - _requestContext = CefRequestContext::CreateContext((RequestContext^)otherRequestContext, new CefRequestContextHandlerAdapter(requestContextHandler)); + _requestContext = CefRequestContext::CreateContext((RequestContext^)otherRequestContext->UnWrap(), new CefRequestContextHandlerAdapter(requestContextHandler)); } !RequestContext() @@ -396,6 +396,12 @@ namespace CefSharp /// and manifestJson should contain the contents that would otherwise be read from the manifest.json file on disk /// handle events related to browser extensions virtual void LoadExtension(String^ rootDirectory, String^ manifestJson, IExtensionHandler^ handler); + + /// + /// Gets the inner most instance + /// + /// current instance + virtual IRequestContext^ UnWrap(); }; } } diff --git a/CefSharp.Core.Runtime/WindowInfo.h b/CefSharp.Core.Runtime/WindowInfo.h index eb4d88bda1..cc48a8ca94 100644 --- a/CefSharp.Core.Runtime/WindowInfo.h +++ b/CefSharp.Core.Runtime/WindowInfo.h @@ -211,6 +211,11 @@ namespace CefSharp { _windowInfo->SetAsWindowless((HWND)parentHandle.ToPointer()); } + + virtual IWindowInfo^ UnWrap() + { + return this; + } }; } } diff --git a/CefSharp.Core/BrowserSettings.cs b/CefSharp.Core/BrowserSettings.cs index 3d00b7ac9b..754e228a87 100644 --- a/CefSharp.Core/BrowserSettings.cs +++ b/CefSharp.Core/BrowserSettings.cs @@ -7,12 +7,270 @@ namespace CefSharp { /// - public class BrowserSettings : CefSharp.Core.BrowserSettings + public class BrowserSettings : IBrowserSettings { + private CefSharp.Core.BrowserSettings settings; + + /// + public BrowserSettings(bool autoDispose = false) + { + settings = new CefSharp.Core.BrowserSettings(autoDispose); + } + + /// + public string StandardFontFamily + { + get { return settings.StandardFontFamily; } + set { settings.StandardFontFamily = value; } + } + + /// + public string FixedFontFamily + { + get { return settings.FixedFontFamily; } + set { settings.FixedFontFamily = value; } + } + + /// + public string SerifFontFamily + { + get { return settings.SerifFontFamily; } + set { settings.SerifFontFamily = value; } + } + + /// + public string SansSerifFontFamily + { + get { return settings.SansSerifFontFamily; } + set { settings.SansSerifFontFamily = value; } + } + + /// + public string CursiveFontFamily + { + get { return settings.CursiveFontFamily; } + set { settings.CursiveFontFamily = value; } + } + + /// + public string FantasyFontFamily + { + get { return settings.FantasyFontFamily; } + set { settings.FantasyFontFamily = value; } + } + + /// + public int DefaultFontSize + { + get { return settings.DefaultFontSize; } + set { settings.DefaultFontSize = value; } + } + + /// + public int DefaultFixedFontSize + { + get { return settings.DefaultFixedFontSize; } + set { settings.DefaultFixedFontSize = value; } + } + + /// + public int MinimumFontSize + { + get { return settings.MinimumFontSize; } + set { settings.MinimumFontSize = value; } + } + + /// + public int MinimumLogicalFontSize + { + get { return settings.MinimumLogicalFontSize; } + set { settings.MinimumLogicalFontSize = value; } + } + + /// + public string DefaultEncoding + { + get { return settings.DefaultEncoding; } + set { settings.DefaultEncoding = value; } + } + + /// + public CefState RemoteFonts + { + get { return settings.RemoteFonts; } + set { settings.RemoteFonts = value; } + } + + /// + public CefState Javascript + { + get { return settings.Javascript; } + set { settings.Javascript = value; } + } + + /// + public CefState JavascriptCloseWindows + { + get { return settings.JavascriptCloseWindows; } + set { settings.JavascriptCloseWindows = value; } + } + + /// + public CefState JavascriptAccessClipboard + { + get { return settings.JavascriptAccessClipboard; } + set { settings.JavascriptAccessClipboard = value; } + } + + /// + public CefState JavascriptDomPaste + { + get { return settings.JavascriptDomPaste; } + set { settings.JavascriptDomPaste = value; } + } + + /// + public CefState Plugins + { + get { return settings.Plugins; } + set { settings.Plugins = value; } + } + + /// + public CefState UniversalAccessFromFileUrls + { + get { return settings.UniversalAccessFromFileUrls; } + set { settings.UniversalAccessFromFileUrls = value; } + } + + /// + public CefState FileAccessFromFileUrls + { + get { return settings.FileAccessFromFileUrls; } + set { settings.FileAccessFromFileUrls = value; } + } + + /// + public CefState WebSecurity + { + get { return settings.WebSecurity; } + set { settings.WebSecurity = value; } + } + + /// + public CefState ImageLoading + { + get { return settings.ImageLoading; } + set { settings.ImageLoading = value; } + } + /// - public BrowserSettings(bool autoDispose = false) : base(autoDispose) + public CefState ImageShrinkStandaloneToFit { + get { return settings.ImageShrinkStandaloneToFit; } + set { settings.ImageShrinkStandaloneToFit = value; } + } + + /// + public CefState TextAreaResize + { + get { return settings.TextAreaResize; } + set { settings.TextAreaResize = value; } + } + + /// + public CefState TabToLinks + { + get { return settings.TabToLinks; } + set { settings.TabToLinks = value; } + } + /// + public CefState LocalStorage + { + get { return settings.LocalStorage; } + set { settings.LocalStorage = value; } + } + + /// + public CefState Databases + { + get { return settings.Databases; } + set { settings.Databases = value; } + } + + /// + public CefState ApplicationCache + { + get { return settings.ApplicationCache; } + set { settings.ApplicationCache = value; } + } + + /// + public CefState WebGl + { + get { return settings.WebGl; } + set { settings.WebGl = value; } + } + + /// + public uint BackgroundColor + { + get { return settings.BackgroundColor; } + set { settings.BackgroundColor = value; } + } + + /// + public string AcceptLanguageList + { + get { return settings.AcceptLanguageList; } + set { settings.AcceptLanguageList = value; } + } + + /// + public int WindowlessFrameRate + { + get { return settings.WindowlessFrameRate; } + set { settings.WindowlessFrameRate = value; } + } + + /// + public bool IsDisposed + { + get { return settings.IsDisposed; } + } + + /// + public bool AutoDispose + { + get { return settings.AutoDispose; } + } + + /// + public void Dispose() + { + settings.Dispose(); + } + + /// + /// Used internally to get the underlying instance. + /// Unlikely you'll use this yourself. + /// + /// the inner most instance + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public IBrowserSettings UnWrap() + { + return settings; + } + + /// + /// Create a new instance of + /// + /// set to false if you plan to reuse the instance, otherwise true + /// BrowserSettings + public static IBrowserSettings Create(bool autoDispose = false) + { + return new CefSharp.Core.BrowserSettings(autoDispose); } } } diff --git a/CefSharp.Core/BrowserSettings.netcore.cs b/CefSharp.Core/BrowserSettings.netcore.cs new file mode 100644 index 0000000000..5c5a6467ca --- /dev/null +++ b/CefSharp.Core/BrowserSettings.netcore.cs @@ -0,0 +1,28 @@ +// Copyright © 2020 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. + +//NOTE:Classes in the CefSharp.Core namespace have been hidden from intellisnse so users don't use them directly + +namespace CefSharp +{ + /// + public class BrowserSettings : CefSharp.Core.BrowserSettings + { + /// + public BrowserSettings(bool autoDispose = false) : base(autoDispose) + { + + } + + /// + /// Create a new instance of + /// + /// set to false if you plan to reuse the instance, otherwise true + /// BrowserSettings + public static IBrowserSettings Create(bool autoDispose = false) + { + return new CefSharp.Core.BrowserSettings(autoDispose); + } + } +} diff --git a/CefSharp.Core/CefSharp.Core.netcore.csproj b/CefSharp.Core/CefSharp.Core.netcore.csproj index eac7203705..7d26f16618 100644 --- a/CefSharp.Core/CefSharp.Core.netcore.csproj +++ b/CefSharp.Core/CefSharp.Core.netcore.csproj @@ -30,6 +30,16 @@ TRACE;NETCOREAPP + + + + + + + + + + all diff --git a/CefSharp.Core/DragData.cs b/CefSharp.Core/DragData.cs index de3e7d4776..770707270f 100644 --- a/CefSharp.Core/DragData.cs +++ b/CefSharp.Core/DragData.cs @@ -6,8 +6,15 @@ namespace CefSharp { + /// + /// Used to represent Drag Data. + /// public static class DragData { + /// + /// Create a new instance of + /// + /// DragData public static IDragData Create() { return Core.DragData.Create(); diff --git a/CefSharp.Core/ObjectFactory.cs b/CefSharp.Core/ObjectFactory.cs index 181d62d2e4..9caad333da 100644 --- a/CefSharp.Core/ObjectFactory.cs +++ b/CefSharp.Core/ObjectFactory.cs @@ -94,5 +94,17 @@ public static IDragData CreateDragData() { return Core.DragData.Create(); } + + /// + /// Create a new which can be used to + /// create a new in a fluent flashion. + /// Call to create the actual + /// instance + /// + /// RequestContextBuilder + public static RequestContextBuilder ConfigureRequestContext() + { + return new RequestContextBuilder(); + } } } diff --git a/CefSharp.Core/PostData.cs b/CefSharp.Core/PostData.cs index 6c7b04253b..1f296f29c5 100644 --- a/CefSharp.Core/PostData.cs +++ b/CefSharp.Core/PostData.cs @@ -4,11 +4,87 @@ //NOTE:Classes in the CefSharp.Core namespace have been hidden from intellisnse so users don't use them directly +using System.Collections.Generic; + namespace CefSharp { /// - public class PostData : CefSharp.Core.PostData + public class PostData : IPostData { + private CefSharp.Core.PostData postData = new CefSharp.Core.PostData(); + + /// + public IList Elements + { + get { return postData.Elements; } + } + + /// + public bool IsReadOnly + { + get { return postData.IsReadOnly; } + } + + /// + public bool IsDisposed + { + get { return postData.IsDisposed; } + } + + /// + public bool HasExcludedElements + { + get { return postData.HasExcludedElements; } + } + + /// + public bool AddElement(IPostDataElement element) + { + return postData.AddElement(element); + } + + /// + public IPostDataElement CreatePostDataElement() + { + return new CefSharp.Core.PostDataElement(); + } + + /// + public void Dispose() + { + postData.Dispose(); + } + + /// + public bool RemoveElement(IPostDataElement element) + { + return postData.RemoveElement(element); + } + + /// + public void RemoveElements() + { + postData.RemoveElements(); + } + + /// + /// Used internally to get the underlying instance. + /// Unlikely you'll use this yourself. + /// + /// the inner most instance + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public IPostData UnWrap() + { + return postData; + } + /// + /// Create a new instance of + /// + /// PostData + public static IPostData Create() + { + return new CefSharp.Core.PostData(); + } } } diff --git a/CefSharp.Core/PostData.netcore.cs b/CefSharp.Core/PostData.netcore.cs new file mode 100644 index 0000000000..1f3cdb2bb5 --- /dev/null +++ b/CefSharp.Core/PostData.netcore.cs @@ -0,0 +1,21 @@ +// Copyright © 2020 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. + +//NOTE:Classes in the CefSharp.Core namespace have been hidden from intellisnse so users don't use them directly + +namespace CefSharp +{ + /// + public class PostData : CefSharp.Core.PostData + { + /// + /// Create a new instance of + /// + /// PostData + public static IPostData Create() + { + return new CefSharp.Core.PostData(); + } + } +} diff --git a/CefSharp.Core/PostDataElement.cs b/CefSharp.Core/PostDataElement.cs index 12e4352ef8..961f4552d6 100644 --- a/CefSharp.Core/PostDataElement.cs +++ b/CefSharp.Core/PostDataElement.cs @@ -6,9 +6,70 @@ namespace CefSharp { - /// - public class PostDataElement : CefSharp.Core.PostDataElement + /// + /// Class used to represent a single element in the request post data. + /// The methods of this class may be called on any thread. + /// + public class PostDataElement : IPostDataElement { + internal CefSharp.Core.PostDataElement postDataElement = new CefSharp.Core.PostDataElement(); + /// + public string File + { + get { return postDataElement.File; } + set { postDataElement.File = value; } + } + + /// + public bool IsReadOnly + { + get { return postDataElement.IsReadOnly; } + } + + /// + public PostDataElementType Type + { + get { return postDataElement.Type; } + } + + /// + public byte[] Bytes + { + get { return postDataElement.Bytes; } + set { postDataElement.Bytes = value; } + } + + /// + public void Dispose() + { + postDataElement.Dispose(); + } + + /// + public void SetToEmpty() + { + postDataElement.SetToEmpty(); + } + + /// + /// Used internally to get the underlying instance. + /// Unlikely you'll use this yourself. + /// + /// the inner most instance + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public IPostDataElement UnWrap() + { + return postDataElement; + } + + /// + /// Create a new instance of + /// + /// PostDataElement + public static IPostDataElement Create() + { + return new CefSharp.Core.PostDataElement(); + } } } diff --git a/CefSharp.Core/PostDataElement.netcore.cs b/CefSharp.Core/PostDataElement.netcore.cs new file mode 100644 index 0000000000..b01848ae6d --- /dev/null +++ b/CefSharp.Core/PostDataElement.netcore.cs @@ -0,0 +1,21 @@ +// Copyright © 2020 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. + +//NOTE:Classes in the CefSharp.Core namespace have been hidden from intellisnse so users don't use them directly + +namespace CefSharp +{ + /// + public class PostDataElement : CefSharp.Core.PostDataElement + { + /// + /// Create a new instance of + /// + /// PostDataElement + public static IPostDataElement Create() + { + return new CefSharp.Core.PostDataElement(); + } + } +} diff --git a/CefSharp.Core/Request.cs b/CefSharp.Core/Request.cs index 6fff9e8f34..c8a29667dc 100644 --- a/CefSharp.Core/Request.cs +++ b/CefSharp.Core/Request.cs @@ -4,11 +4,140 @@ //NOTE:Classes in the CefSharp.Core namespace have been hidden from intellisnse so users don't use them directly +using System.Collections.Specialized; + namespace CefSharp { /// - public class Request : CefSharp.Core.Request + public class Request : IRequest { + internal Core.Request request = new Core.Request(); + + /// + public UrlRequestFlags Flags + { + get { return request.Flags; } + set { request.Flags = value; } + } + + /// + public string Url + { + get { return request.Url; } + set { request.Url = value; } + } + + /// + public ulong Identifier + { + get { return request.Identifier; } + } + + /// + public string Method + { + get { return request.Method; } + set { request.Method = value; } + } + + /// + public string ReferrerUrl + { + get { return request.ReferrerUrl; } + } + + /// + public ResourceType ResourceType + { + get { return request.ResourceType; } + } + + /// + public ReferrerPolicy ReferrerPolicy + { + get { return request.ReferrerPolicy; } + } + + /// + public NameValueCollection Headers + { + get { return request.Headers; } + set { request.Headers = value; } + } + + /// + public IPostData PostData + { + get { return request.PostData; } + set { request.PostData = value; } + } + + /// + public TransitionType TransitionType + { + get { return request.TransitionType; } + } + + /// + public bool IsDisposed + { + get { return request.IsDisposed; } + } + + /// + public bool IsReadOnly + { + get { return request.IsReadOnly; } + } + + /// + public void Dispose() + { + request.Dispose(); + } + + /// + public string GetHeaderByName(string name) + { + return request.GetHeaderByName(name); + } + + /// + public void InitializePostData() + { + request.InitializePostData(); + } + + /// + public void SetHeaderByName(string name, string value, bool overwrite) + { + request.SetHeaderByName(name, value, overwrite); + } + + /// + public void SetReferrer(string referrerUrl, ReferrerPolicy policy) + { + request.SetReferrer(referrerUrl, policy); + } + + /// + /// Used internally to get the underlying instance. + /// Unlikely you'll use this yourself. + /// + /// the inner most instance + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public IRequest UnWrap() + { + return request; + } + /// + /// Create a new instance + /// + /// Request + public static IRequest Create() + { + return new CefSharp.Core.Request(); + } } } diff --git a/CefSharp.Core/Request.netcore.cs b/CefSharp.Core/Request.netcore.cs new file mode 100644 index 0000000000..1970c6b52b --- /dev/null +++ b/CefSharp.Core/Request.netcore.cs @@ -0,0 +1,21 @@ +// Copyright © 2020 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. + +//NOTE:Classes in the CefSharp.Core namespace have been hidden from intellisnse so users don't use them directly + +namespace CefSharp +{ + /// + public class Request : CefSharp.Core.Request + { + /// + /// Create a new instance + /// + /// Request + public static IRequest Create() + { + return new CefSharp.Core.Request(); + } + } +} diff --git a/CefSharp.Core/RequestContext.cs b/CefSharp.Core/RequestContext.cs index 12a470970b..52695778d0 100644 --- a/CefSharp.Core/RequestContext.cs +++ b/CefSharp.Core/RequestContext.cs @@ -4,41 +4,51 @@ //NOTE:Classes in the CefSharp.Core namespace have been hidden from intellisnse so users don't use them directly +using System; +using System.Collections.Generic; +using System.Threading.Tasks; + namespace CefSharp { /// - public class RequestContext : CefSharp.Core.RequestContext + public class RequestContext : IRequestContext { + private CefSharp.Core.RequestContext requestContext; + /// - public RequestContext() : base() + public RequestContext() { + requestContext = new CefSharp.Core.RequestContext(); } /// - public RequestContext(CefSharp.IRequestContext otherRequestContext) : base(otherRequestContext) + public RequestContext(IRequestContext otherRequestContext) { - + requestContext = new CefSharp.Core.RequestContext(otherRequestContext); } /// - public RequestContext(CefSharp.IRequestContext otherRequestContext, CefSharp.IRequestContextHandler requestContextHandler) : base(otherRequestContext, requestContextHandler) + public RequestContext(IRequestContext otherRequestContext, IRequestContextHandler requestContextHandler) { + requestContext = new CefSharp.Core.RequestContext(otherRequestContext, requestContextHandler); } /// - public RequestContext(CefSharp.IRequestContextHandler requestContextHandler) : base(requestContextHandler) + public RequestContext(IRequestContextHandler requestContextHandler) { + requestContext = new CefSharp.Core.RequestContext(requestContextHandler); } /// - public RequestContext(CefSharp.RequestContextSettings settings) : base(settings.settings) + public RequestContext(RequestContextSettings settings) { - + requestContext = new CefSharp.Core.RequestContext(settings.settings); } /// - public RequestContext(CefSharp.RequestContextSettings settings, CefSharp.IRequestContextHandler requestContextHandler) : base(settings.settings, requestContextHandler) + public RequestContext(RequestContextSettings settings, IRequestContextHandler requestContextHandler) { + requestContext = new CefSharp.Core.RequestContext(settings.settings, requestContextHandler); } /// @@ -52,5 +62,154 @@ public static RequestContextBuilder Configure() return builder; } + + /// + public bool IsGlobal + { + get { return requestContext.IsGlobal; } + } + + /// + public string CachePath + { + get { return requestContext.CachePath; } + } + + /// + public bool IsSame(IRequestContext context) + { + return requestContext.IsSame(context); + } + + /// + public bool IsSharingWith(IRequestContext context) + { + return requestContext.IsSharingWith(context); + } + + /// + public ICookieManager GetCookieManager(ICompletionCallback callback) + { + return requestContext.GetCookieManager(callback); + } + + /// + public bool RegisterSchemeHandlerFactory(string schemeName, string domainName, ISchemeHandlerFactory factory) + { + return requestContext.RegisterSchemeHandlerFactory(schemeName, domainName, factory); + } + + /// + public bool ClearSchemeHandlerFactories() + { + return requestContext.ClearSchemeHandlerFactories(); + } + + /// + public void PurgePluginListCache(bool reloadPages) + { + requestContext.PurgePluginListCache(reloadPages); + } + + /// + public bool HasPreference(string name) + { + return requestContext.HasPreference(name); + } + + /// + public object GetPreference(string name) + { + return requestContext.GetPreference(name); + } + + /// + public IDictionary GetAllPreferences(bool includeDefaults) + { + return requestContext.GetAllPreferences(includeDefaults); + } + + /// + public bool CanSetPreference(string name) + { + return requestContext.CanSetPreference(name); + } + + /// + public bool SetPreference(string name, object value, out string error) + { + return requestContext.SetPreference(name, value, out error); + } + + /// + public void ClearCertificateExceptions(ICompletionCallback callback) + { + requestContext.ClearCertificateExceptions(callback); + } + + /// + public void ClearHttpAuthCredentials(ICompletionCallback callback = null) + { + requestContext.ClearHttpAuthCredentials(callback); + } + + /// + public void CloseAllConnections(ICompletionCallback callback) + { + requestContext.CloseAllConnections(callback); + } + + /// + public Task ResolveHostAsync(Uri origin) + { + return requestContext.ResolveHostAsync(origin); + } + + /// + public bool DidLoadExtension(string extensionId) + { + return requestContext.DidLoadExtension(extensionId); + } + + /// + public IExtension GetExtension(string extensionId) + { + return requestContext.GetExtension(extensionId); + } + + /// + public bool GetExtensions(out IList extensionIds) + { + return requestContext.GetExtensions(out extensionIds); + } + + /// + public bool HasExtension(string extensionId) + { + return requestContext.CanSetPreference(extensionId); + } + + /// + public void LoadExtension(string rootDirectory, string manifestJson, IExtensionHandler handler) + { + requestContext.LoadExtension(rootDirectory, manifestJson, handler); + } + + /// + public void Dispose() + { + requestContext.Dispose(); + } + + /// + /// Used internally to get the underlying instance. + /// Unlikely you'll use this yourself. + /// + /// the inner most instance + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public IRequestContext UnWrap() + { + return requestContext; + } } } diff --git a/CefSharp.Core/RequestContext.netcore.cs b/CefSharp.Core/RequestContext.netcore.cs new file mode 100644 index 0000000000..12a470970b --- /dev/null +++ b/CefSharp.Core/RequestContext.netcore.cs @@ -0,0 +1,56 @@ +// Copyright © 2020 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. + +//NOTE:Classes in the CefSharp.Core namespace have been hidden from intellisnse so users don't use them directly + +namespace CefSharp +{ + /// + public class RequestContext : CefSharp.Core.RequestContext + { + /// + public RequestContext() : base() + { + } + + /// + public RequestContext(CefSharp.IRequestContext otherRequestContext) : base(otherRequestContext) + { + + } + + /// + public RequestContext(CefSharp.IRequestContext otherRequestContext, CefSharp.IRequestContextHandler requestContextHandler) : base(otherRequestContext, requestContextHandler) + { + } + + /// + public RequestContext(CefSharp.IRequestContextHandler requestContextHandler) : base(requestContextHandler) + { + } + + /// + public RequestContext(CefSharp.RequestContextSettings settings) : base(settings.settings) + { + + } + + /// + public RequestContext(CefSharp.RequestContextSettings settings, CefSharp.IRequestContextHandler requestContextHandler) : base(settings.settings, requestContextHandler) + { + } + + /// + /// Creates a new RequestContextBuilder which can be used to fluently set + /// preferences + /// + /// Returns a new RequestContextBuilder + public static RequestContextBuilder Configure() + { + var builder = new RequestContextBuilder(); + + return builder; + } + } +} diff --git a/CefSharp.Core/UrlRequest.cs b/CefSharp.Core/UrlRequest.cs index 17858fe468..074df34da0 100644 --- a/CefSharp.Core/UrlRequest.cs +++ b/CefSharp.Core/UrlRequest.cs @@ -4,17 +4,107 @@ //NOTE:Classes in the CefSharp.Core namespace have been hidden from intellisnse so users don't use them directly +using System; + namespace CefSharp { /// - public class UrlRequest : CefSharp.Core.UrlRequest + public class UrlRequest : IUrlRequest { - public UrlRequest(IRequest request, IUrlRequestClient urlRequestClient) : base(request, urlRequestClient) + private CefSharp.Core.UrlRequest urlRequest; + + /// + /// Create a new URL request that is not associated with a specific browser or frame. + /// Use instead if you want the + /// request to have this association, in which case it may be handled differently. + /// For requests originating from the browser process: It may be intercepted by the client via or . + /// POST data may only contain only a single element of type PDE_TYPE_FILE or PDE_TYPE_BYTES. + /// Uses the Global RequestContext + /// + /// request + /// url request client + public UrlRequest(IRequest request, IUrlRequestClient urlRequestClient) : this(request, urlRequestClient, null) + { + + } + + /// + /// Create a new URL request that is not associated with a specific browser or frame. + /// Use instead if you want the + /// request to have this association, in which case it may be handled differently. + /// For requests originating from the browser process: It may be intercepted by the client via or . + /// POST data may only contain only a single element of type PDE_TYPE_FILE or PDE_TYPE_BYTES. + /// + /// request + /// url request client + /// request context associated with this requets. + public UrlRequest(IRequest request, IUrlRequestClient urlRequestClient, IRequestContext requestContext) + { + if (request == null) + { + throw new ArgumentNullException(nameof(request)); + } + + if (urlRequestClient == null) + { + throw new ArgumentNullException(nameof(urlRequestClient)); + } + + urlRequest = new CefSharp.Core.UrlRequest(request.UnWrap(), urlRequestClient, requestContext?.UnWrap()); + } + + /// + public bool ResponseWasCached + { + get { return urlRequest.ResponseWasCached; } + } + + /// + public IResponse Response + { + get { return urlRequest.Response; } + } + + /// + public UrlRequestStatus RequestStatus + { + get { return urlRequest.RequestStatus; } + } + + /// + public void Dispose() + { + urlRequest.Dispose(); + } + + /// + /// Create a new URL request that is not associated with a specific browser or frame. + /// Use instead if you want the + /// request to have this association, in which case it may be handled differently. + /// For requests originating from the browser process: It may be intercepted by the client via or . + /// POST data may only contain only a single element of type PDE_TYPE_FILE or PDE_TYPE_BYTES. + /// Uses the Global RequestContext + /// + /// request + /// url request client + public IUrlRequest Create(IRequest request, IUrlRequestClient urlRequestClient) { + return new CefSharp.Core.UrlRequest(request, urlRequestClient); } - public UrlRequest(IRequest request, IUrlRequestClient urlRequestClient, IRequestContext requestContext) : base(request, urlRequestClient, requestContext) + /// + /// Create a new URL request that is not associated with a specific browser or frame. + /// Use instead if you want the + /// request to have this association, in which case it may be handled differently. + /// For requests originating from the browser process: It may be intercepted by the client via or . + /// POST data may only contain only a single element of type PDE_TYPE_FILE or PDE_TYPE_BYTES. + /// + /// request + /// url request client + /// request context associated with this requets. + public IUrlRequest Create(IRequest request, IUrlRequestClient urlRequestClient, IRequestContext requestContext) { + return new CefSharp.Core.UrlRequest(request, urlRequestClient, requestContext); } } } diff --git a/CefSharp.Core/UrlRequest.netcore.cs b/CefSharp.Core/UrlRequest.netcore.cs new file mode 100644 index 0000000000..d51e798a5d --- /dev/null +++ b/CefSharp.Core/UrlRequest.netcore.cs @@ -0,0 +1,52 @@ +// Copyright © 2020 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. + +//NOTE:Classes in the CefSharp.Core namespace have been hidden from intellisnse so users don't use them directly + +namespace CefSharp +{ + /// + public class UrlRequest : CefSharp.Core.UrlRequest + { + /// + public UrlRequest(IRequest request, IUrlRequestClient urlRequestClient) : base(request, urlRequestClient) + { + } + + /// + public UrlRequest(IRequest request, IUrlRequestClient urlRequestClient, IRequestContext requestContext) : base(request, urlRequestClient, requestContext) + { + } + + /// + /// Create a new URL request that is not associated with a specific browser or frame. + /// Use instead if you want the + /// request to have this association, in which case it may be handled differently. + /// For requests originating from the browser process: It may be intercepted by the client via or . + /// POST data may only contain only a single element of type PDE_TYPE_FILE or PDE_TYPE_BYTES. + /// Uses the Global RequestContext + /// + /// request + /// url request client + public IUrlRequest Create(IRequest request, IUrlRequestClient urlRequestClient) + { + return new CefSharp.Core.UrlRequest(request, urlRequestClient); + } + + /// + /// Create a new URL request that is not associated with a specific browser or frame. + /// Use instead if you want the + /// request to have this association, in which case it may be handled differently. + /// For requests originating from the browser process: It may be intercepted by the client via or . + /// POST data may only contain only a single element of type PDE_TYPE_FILE or PDE_TYPE_BYTES. + /// + /// request + /// url request client + /// request context associated with this requets. + public IUrlRequest Create(IRequest request, IUrlRequestClient urlRequestClient, IRequestContext requestContext) + { + return new CefSharp.Core.UrlRequest(request, urlRequestClient, requestContext); + } + } +} diff --git a/CefSharp.Core/WindowInfo.cs b/CefSharp.Core/WindowInfo.cs index f80ddf6aac..42f71dc252 100644 --- a/CefSharp.Core/WindowInfo.cs +++ b/CefSharp.Core/WindowInfo.cs @@ -4,11 +4,135 @@ //NOTE:Classes in the CefSharp.Core namespace have been hidden from intellisnse so users don't use them directly +using System; + namespace CefSharp { /// - public class WindowInfo : CefSharp.Core.WindowInfo + public class WindowInfo : IWindowInfo { + private CefSharp.Core.WindowInfo windowInfo = new CefSharp.Core.WindowInfo(); + + /// + public int X + { + get { return windowInfo.X; } + set { windowInfo.X = value; } + } + + /// + public int Y + { + get { return windowInfo.Y; } + set { windowInfo.Y = value; } + } + + /// + public int Width + { + get { return windowInfo.Width; } + set { windowInfo.Width = value; } + } + + /// + public int Height + { + get { return windowInfo.Height; } + set { windowInfo.Height = value; } + } + + /// + public uint Style + { + get { return windowInfo.Style; } + set { windowInfo.Style = value; } + } + + /// + public uint ExStyle + { + get { return windowInfo.ExStyle; } + set { windowInfo.ExStyle = value; } + } + + /// + public IntPtr ParentWindowHandle + { + get { return windowInfo.ParentWindowHandle; } + set { windowInfo.ParentWindowHandle = value; } + } + + /// + public bool WindowlessRenderingEnabled + { + get { return windowInfo.WindowlessRenderingEnabled; } + set { windowInfo.WindowlessRenderingEnabled = value; } + } + + /// + public bool SharedTextureEnabled + { + get { return windowInfo.SharedTextureEnabled; } + set { windowInfo.SharedTextureEnabled = value; } + } + + /// + public bool ExternalBeginFrameEnabled + { + get { return windowInfo.ExternalBeginFrameEnabled; } + set { windowInfo.ExternalBeginFrameEnabled = value; } + } + + /// + public IntPtr WindowHandle + { + get { return windowInfo.WindowHandle; } + set { windowInfo.WindowHandle = value; } + } + + /// + public void Dispose() + { + windowInfo.Dispose(); + } + + /// + public void SetAsChild(IntPtr parentHandle) + { + windowInfo.SetAsChild(parentHandle); + } + + /// + public void SetAsChild(IntPtr parentHandle, int left, int top, int right, int bottom) + { + windowInfo.SetAsChild(parentHandle, left, top, right, bottom); + } + + /// + public void SetAsPopup(IntPtr parentHandle, string windowName) + { + windowInfo.SetAsPopup(parentHandle, windowName); + } + + /// + public void SetAsWindowless(IntPtr parentHandle) + { + windowInfo.SetAsWindowless(parentHandle); + } + + /// + /// Create a new instance + /// + /// WindowInfo + public static IWindowInfo Create() + { + return new CefSharp.Core.WindowInfo(); + } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public IWindowInfo UnWrap() + { + return windowInfo; + } } } diff --git a/CefSharp.Core/WindowInfo.netcore.cs b/CefSharp.Core/WindowInfo.netcore.cs new file mode 100644 index 0000000000..8650b9f3f8 --- /dev/null +++ b/CefSharp.Core/WindowInfo.netcore.cs @@ -0,0 +1,21 @@ +// Copyright © 2020 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. + +//NOTE:Classes in the CefSharp.Core namespace have been hidden from intellisnse so users don't use them directly + +namespace CefSharp +{ + /// + public class WindowInfo : CefSharp.Core.WindowInfo + { + /// + /// Create a new WindowInfo instance + /// + /// new instance + public static IWindowInfo Create() + { + return new CefSharp.Core.WindowInfo(); + } + } +} diff --git a/CefSharp.OffScreen.Example/CefSharp.OffScreen.Example.csproj b/CefSharp.OffScreen.Example/CefSharp.OffScreen.Example.csproj index 51ebe6bc82..5d8581a91c 100644 --- a/CefSharp.OffScreen.Example/CefSharp.OffScreen.Example.csproj +++ b/CefSharp.OffScreen.Example/CefSharp.OffScreen.Example.csproj @@ -73,10 +73,6 @@ - - {7b495581-2271-4f41-9476-acb86e8c864f} - CefSharp.Core.Runtime - {b760b002-d277-4525-9f63-67ed2065034a} CefSharp.Core diff --git a/CefSharp.Test/WinForms/WinFormsBrowserBasicFacts.cs b/CefSharp.Test/WinForms/WinFormsBrowserBasicFacts.cs index 16408bd288..32212c9df0 100644 --- a/CefSharp.Test/WinForms/WinFormsBrowserBasicFacts.cs +++ b/CefSharp.Test/WinForms/WinFormsBrowserBasicFacts.cs @@ -84,5 +84,47 @@ public async Task CanSetBrowserSettingsDisableImageLoading() output.WriteLine("Url {0}", mainFrame.Url); } } + + [WinFormsFact] + public async Task CanSetRequestContextViaRequestContextBuilder() + { + using (var browser = new ChromiumWebBrowser("www.google.com")) + { + var settings = Core.ObjectFactory.CreateBrowserSettings(true); + settings.ImageLoading = CefState.Disabled; + browser.RequestContext = RequestContext.Configure().Create(); + + browser.Size = new System.Drawing.Size(1024, 768); + browser.CreateControl(); + + await browser.LoadPageAsync(); + + var mainFrame = browser.GetMainFrame(); + Assert.True(mainFrame.IsValid); + Assert.Contains("www.google", mainFrame.Url); + + output.WriteLine("Url {0}", mainFrame.Url); + } + } + + [WinFormsFact] + public async Task CanSetRequestContext() + { + using (var browser = new ChromiumWebBrowser("www.google.com")) + { + browser.RequestContext = new RequestContext(); + + browser.Size = new System.Drawing.Size(1024, 768); + browser.CreateControl(); + + await browser.LoadPageAsync(); + + var mainFrame = browser.GetMainFrame(); + Assert.True(mainFrame.IsValid); + Assert.Contains("www.google", mainFrame.Url); + + output.WriteLine("Url {0}", mainFrame.Url); + } + } } } diff --git a/CefSharp.Test/Wpf/WpfBrowserBasicFacts.cs b/CefSharp.Test/Wpf/WpfBrowserBasicFacts.cs index 3183f2fdea..7fde401112 100644 --- a/CefSharp.Test/Wpf/WpfBrowserBasicFacts.cs +++ b/CefSharp.Test/Wpf/WpfBrowserBasicFacts.cs @@ -37,5 +37,42 @@ public async Task CanLoadGoogle() output.WriteLine("Url {0}", mainFrame.Url); } } + + [WpfFact] + public async Task CanSetRequestContext() + { + using (var browser = new ChromiumWebBrowser("www.google.com")) + { + browser.RequestContext = new RequestContext(); + browser.CreateBrowser(null, new Size(1024, 786)); + + await browser.LoadPageAsync(); + + var mainFrame = browser.GetMainFrame(); + Assert.True(mainFrame.IsValid); + Assert.Contains("www.google", mainFrame.Url); + + output.WriteLine("Url {0}", mainFrame.Url); + } + } + + [WpfFact] + public async Task CanSetRequestContextViaBuilder() + { + using (var browser = new ChromiumWebBrowser("www.google.com")) + { + browser.RequestContext = RequestContext.Configure().Create(); + + browser.CreateBrowser(null, new Size(1024, 786)); + + await browser.LoadPageAsync(); + + var mainFrame = browser.GetMainFrame(); + Assert.True(mainFrame.IsValid); + Assert.Contains("www.google", mainFrame.Url); + + output.WriteLine("Url {0}", mainFrame.Url); + } + } } } diff --git a/CefSharp.WinForms.Example/CefSharp.WinForms.Example.csproj b/CefSharp.WinForms.Example/CefSharp.WinForms.Example.csproj index e68938c083..7295e1693d 100644 --- a/CefSharp.WinForms.Example/CefSharp.WinForms.Example.csproj +++ b/CefSharp.WinForms.Example/CefSharp.WinForms.Example.csproj @@ -176,10 +176,6 @@ - - {7b495581-2271-4f41-9476-acb86e8c864f} - CefSharp.Core.Runtime - {b760b002-d277-4525-9f63-67ed2065034a} CefSharp.Core diff --git a/CefSharp.WinForms/ChromiumWebBrowser.cs b/CefSharp.WinForms/ChromiumWebBrowser.cs index 5f0e79e429..8d63029b4d 100644 --- a/CefSharp.WinForms/ChromiumWebBrowser.cs +++ b/CefSharp.WinForms/ChromiumWebBrowser.cs @@ -136,7 +136,7 @@ public IBrowserSettings BrowserSettings throw new Exception("Browser has already been created. BrowserSettings must be " + "set before the underlying CEF browser is created."); } - if (value != null && !Core.ObjectFactory.BrowserSetingsType.IsAssignableFrom(value.GetType())) + if (value != null && !Core.ObjectFactory.BrowserSetingsType.IsAssignableFrom(value.UnWrap().GetType())) { throw new Exception(string.Format("BrowserSettings can only be of type {0} or null", Core.ObjectFactory.BrowserSetingsType)); } @@ -165,7 +165,7 @@ public IRequestContext RequestContext throw new Exception("Browser has already been created. RequestContext must be " + "set before the underlying CEF browser is created."); } - if (value != null && !Core.ObjectFactory.RequestContextType.IsAssignableFrom(value.GetType())) + if (value != null && !Core.ObjectFactory.RequestContextType.IsAssignableFrom(value.UnWrap().GetType())) { throw new Exception(string.Format("RequestContext can only be of type {0} or null", Core.ObjectFactory.RequestContextType)); } diff --git a/CefSharp.Wpf.Example/CefSharp.Wpf.Example.csproj b/CefSharp.Wpf.Example/CefSharp.Wpf.Example.csproj index 2269a18d53..60dab70ca3 100644 --- a/CefSharp.Wpf.Example/CefSharp.Wpf.Example.csproj +++ b/CefSharp.Wpf.Example/CefSharp.Wpf.Example.csproj @@ -176,10 +176,6 @@ - - {7b495581-2271-4f41-9476-acb86e8c864f} - CefSharp.Core.Runtime - {b760b002-d277-4525-9f63-67ed2065034a} CefSharp.Core diff --git a/CefSharp.Wpf/ChromiumWebBrowser.cs b/CefSharp.Wpf/ChromiumWebBrowser.cs index dabc6437e7..1e7299f9c7 100644 --- a/CefSharp.Wpf/ChromiumWebBrowser.cs +++ b/CefSharp.Wpf/ChromiumWebBrowser.cs @@ -218,7 +218,7 @@ public IRequestContext RequestContext throw new Exception("Browser has already been created. RequestContext must be " + "set before the underlying CEF browser is created."); } - if (value != null && !Core.ObjectFactory.RequestContextType.IsAssignableFrom(value.GetType())) + if (value != null && !Core.ObjectFactory.RequestContextType.IsAssignableFrom(value.UnWrap().GetType())) { throw new Exception(string.Format("RequestContext can only be of type {0} or null", Core.ObjectFactory.RequestContextType)); } diff --git a/CefSharp/IBrowserSettings.cs b/CefSharp/IBrowserSettings.cs index 85ae4a2e46..554f2b14e9 100644 --- a/CefSharp/IBrowserSettings.cs +++ b/CefSharp/IBrowserSettings.cs @@ -217,5 +217,13 @@ public interface IBrowserSettings : IDisposable /// create an set BrowserSettings yourself. /// bool AutoDispose { get; } + + /// + /// Used internally to get the underlying instance. + /// Unlikely you'll use this yourself. + /// + /// the inner most instance + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + IBrowserSettings UnWrap(); } } diff --git a/CefSharp/IPostData.cs b/CefSharp/IPostData.cs index 85db06c68c..42f6ec43cf 100644 --- a/CefSharp/IPostData.cs +++ b/CefSharp/IPostData.cs @@ -59,5 +59,13 @@ public interface IPostData : IDisposable /// the request failing. /// bool HasExcludedElements { get; } + + /// + /// Used internally to get the underlying instance. + /// Unlikely you'll use this yourself. + /// + /// the inner most instance + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + IPostData UnWrap(); } } diff --git a/CefSharp/IPostDataElement.cs b/CefSharp/IPostDataElement.cs index 749889fb9b..ea7ecae075 100644 --- a/CefSharp/IPostDataElement.cs +++ b/CefSharp/IPostDataElement.cs @@ -36,5 +36,13 @@ public interface IPostDataElement : IDisposable /// Gets or sets the bytes of this . /// byte[] Bytes { get; set; } + + /// + /// Used internally to get the underlying instance. + /// Unlikely you'll use this yourself. + /// + /// the inner most instance + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + IPostDataElement UnWrap(); } } diff --git a/CefSharp/IRequest.cs b/CefSharp/IRequest.cs index 27dfe33968..94a2d2fdff 100644 --- a/CefSharp/IRequest.cs +++ b/CefSharp/IRequest.cs @@ -127,5 +127,13 @@ public interface IRequest : IDisposable /// new header value /// If overwrite is true any existing values will be replaced with the new value. If overwrite is false any existing values will not be overwritten void SetHeaderByName(string name, string value, bool overwrite); + + /// + /// Used internally to get the underlying instance. + /// Unlikely you'll use this yourself. + /// + /// the inner most instance + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + IRequest UnWrap(); } } diff --git a/CefSharp/IRequestContext.cs b/CefSharp/IRequestContext.cs index 7b7878cc01..4f6105ae00 100644 --- a/CefSharp/IRequestContext.cs +++ b/CefSharp/IRequestContext.cs @@ -274,5 +274,13 @@ public interface IRequestContext : IDisposable /// then fulfilling the resource rquests made to . /// void LoadExtension(string rootDirectory, string manifestJson, IExtensionHandler handler); + + /// + /// Used internally to get the underlying instance. + /// Unlikely you'll use this yourself. + /// + /// the inner most instance + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + IRequestContext UnWrap(); } } diff --git a/CefSharp/IWindowInfo.cs b/CefSharp/IWindowInfo.cs index 4ad7911f09..8ab8ed8022 100644 --- a/CefSharp/IWindowInfo.cs +++ b/CefSharp/IWindowInfo.cs @@ -96,5 +96,13 @@ public interface IWindowInfo : IDisposable /// If not provided then the main screen monitor will be used and some functionality that requires a parent window may not function correctly. /// In order to create windowless browsers the CefSettings.windowless_rendering_enabled value must be set to true. void SetAsWindowless(IntPtr parentHandle); + + /// + /// Used internally to get the underlying instance. + /// Unlikely you'll use this yourself. + /// + /// the inner most instance + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + IWindowInfo UnWrap(); } }