Core - Rename CefSharp.Internals.CefRequestWrapper to CefSharp.Request

- Made public
- Added public constructor

Related issue #1721
This commit is contained in:
amaitland
2019-11-23 14:27:27 +10:00
parent b8418f4045
commit 493897983d
12 changed files with 316 additions and 317 deletions
+2 -2
View File
@@ -240,7 +240,6 @@
<ClCompile Include="Internals\CefValueWrapper.cpp" />
<ClCompile Include="Internals\ClientAdapter.cpp" />
<ClCompile Include="Internals\CookieVisitor.cpp" />
<ClCompile Include="Internals\CefRequestWrapper.cpp" />
<ClCompile Include="Internals\JavascriptCallbackProxy.cpp" />
<ClCompile Include="Internals\JavascriptCallbackFactory.cpp" />
<ClCompile Include="Internals\Serialization\ObjectsSerialization.cpp" />
@@ -251,6 +250,7 @@
<ClCompile Include="Internals\Serialization\Primitives.cpp" />
<ClCompile Include="Internals\Serialization\JsObjectsSerialization.cpp" />
<ClCompile Include="Internals\CefRequestContextHandlerAdapter.cpp" />
<ClCompile Include="Request.cpp" />
<ClCompile Include="RequestContext.cpp" />
<ClCompile Include="ResourceHandlerWrapper.cpp" />
<ClCompile Include="Stdafx.cpp">
@@ -307,13 +307,13 @@
<ClInclude Include="Internals\CefRequestContextHandlerAdapter.h" />
<ClInclude Include="PostData.h" />
<ClInclude Include="PostDataElement.h" />
<ClInclude Include="Request.h" />
<ClInclude Include="resource.h" />
<ClInclude Include="WindowInfo.h" />
<ClInclude Include="Internals\CefCompletionCallbackAdapter.h" />
<ClInclude Include="Internals\ClientAdapter.h" />
<ClInclude Include="Internals\CookieVisitor.h" />
<ClInclude Include="Internals\CefSharpApp.h" />
<ClInclude Include="Internals\CefRequestWrapper.h" />
<ClInclude Include="Internals\CefJSDialogCallbackWrapper.h" />
<ClInclude Include="Internals\JavascriptCallbackProxy.h" />
<ClInclude Include="Internals\JavascriptCallbackFactory.h" />
+6 -6
View File
@@ -17,9 +17,6 @@
<ClCompile Include="Stdafx.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Internals\CefRequestWrapper.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Internals\CookieVisitor.cpp">
<Filter>Source Files</Filter>
</ClCompile>
@@ -89,6 +86,9 @@
<ClCompile Include="Internals\CefUrlRequestWrapper.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Request.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="vcclr_local.h">
@@ -106,9 +106,6 @@
<ClInclude Include="Internals\CefSharpApp.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Internals\CefRequestWrapper.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Internals\CookieVisitor.h">
<Filter>Header Files</Filter>
</ClInclude>
@@ -325,6 +322,9 @@
<ClInclude Include="PostData.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Request.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Internals\CefSharpBrowserWrapper.h">
@@ -8,7 +8,7 @@
#include "include\cef_resource_request_handler.h"
#include "CefResponseWrapper.h"
#include "CefRequestWrapper.h"
#include "Request.h"
#include "CefFrameWrapper.h"
#include "CefSharpBrowserWrapper.h"
@@ -39,7 +39,7 @@ namespace CefSharp
bool CanSendCookie(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, CefRefPtr<CefRequest> request, const CefCookie& cookie) OVERRIDE
{
CefRequestWrapper requestWrapper(request);
Request requestWrapper(request);
auto managedCookie = TypeConversion::FromNative(cookie);
//For ServiceWorker browser and frame will be null
@@ -57,7 +57,7 @@ namespace CefSharp
bool CanSaveCookie(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, CefRefPtr<CefRequest> request, CefRefPtr<CefResponse> response, const CefCookie& cookie) OVERRIDE
{
CefRequestWrapper requestWrapper(request);
Request requestWrapper(request);
CefResponseWrapper responseWrapper(response);
auto managedCookie = TypeConversion::FromNative(cookie);
+4 -4
View File
@@ -5,8 +5,8 @@
#include "Stdafx.h"
#include <msclr/lock.h>
#include "Request.h"
#include "Internals\CefSharpBrowserWrapper.h"
#include "Internals\CefRequestWrapper.h"
#include "Internals\CefFrameWrapper.h"
#include "Internals\StringVisitor.h"
#include "Internals\ClientAdapter.h"
@@ -193,7 +193,7 @@ void CefFrameWrapper::LoadRequest(IRequest^ request)
ThrowIfDisposed();
ThrowIfFrameInvalid();
auto requestWrapper = (CefRequestWrapper^)request;
auto requestWrapper = (Request^)request;
_frame->LoadRequest(requestWrapper);
}
@@ -392,7 +392,7 @@ IRequest^ CefFrameWrapper::CreateRequest(bool initializePostData)
request->SetPostData(CefPostData::Create());
}
return gcnew CefRequestWrapper(request);
return gcnew Request(request);
}
IUrlRequest^ CefFrameWrapper::CreateUrlRequest(IRequest^ request, IUrlRequestClient^ client)
@@ -410,7 +410,7 @@ IUrlRequest^ CefFrameWrapper::CreateUrlRequest(IRequest^ request, IUrlRequestCli
}
auto urlRequest = _frame->CreateURLRequest(
(CefRequestWrapper^)request,
(Request^)request,
new CefUrlRequestClientAdapter(client));
return gcnew CefUrlRequestWrapper(urlRequest);
@@ -1,204 +0,0 @@
// Copyright © 2010 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 "CefRequestWrapper.h"
#include "PostData.h"
using namespace System::Text;
namespace CefSharp
{
namespace Internals
{
UrlRequestFlags CefRequestWrapper::Flags::get()
{
ThrowIfDisposed();
return (UrlRequestFlags)_request->GetFlags();
}
void CefRequestWrapper::Flags::set(UrlRequestFlags flags)
{
ThrowIfDisposed();
ThrowIfReadOnly();
_request->SetFlags((int)flags);
}
String^ CefRequestWrapper::Url::get()
{
ThrowIfDisposed();
return StringUtils::ToClr(_request->GetURL());
}
void CefRequestWrapper::Url::set(String^ url)
{
if (url == nullptr)
{
throw gcnew System::ArgumentException("cannot be null", "url");
}
ThrowIfDisposed();
ThrowIfReadOnly();
CefString str = StringUtils::ToNative(url);
_request->SetURL(str);
}
String^ CefRequestWrapper::Method::get()
{
ThrowIfDisposed();
return StringUtils::ToClr(_request->GetMethod());
}
void CefRequestWrapper::Method::set(String^ method)
{
if (method == nullptr)
{
throw gcnew System::ArgumentException("cannot be null", "method");
}
ThrowIfDisposed();
ThrowIfReadOnly();
_request->SetMethod(StringUtils::ToNative(method));
}
UInt64 CefRequestWrapper::Identifier::get()
{
ThrowIfDisposed();
return _request->GetIdentifier();
}
void CefRequestWrapper::SetReferrer(String^ referrerUrl, CefSharp::ReferrerPolicy policy)
{
ThrowIfDisposed();
ThrowIfReadOnly();
_request->SetReferrer(StringUtils::ToNative(referrerUrl), (cef_referrer_policy_t)policy);
}
String^ CefRequestWrapper::ReferrerUrl::get()
{
ThrowIfDisposed();
return StringUtils::ToClr(_request->GetReferrerURL());
}
CefSharp::ResourceType CefRequestWrapper::ResourceType::get()
{
ThrowIfDisposed();
return (CefSharp::ResourceType)_request->GetResourceType();
}
CefSharp::ReferrerPolicy CefRequestWrapper::ReferrerPolicy::get()
{
ThrowIfDisposed();
return (CefSharp::ReferrerPolicy)_request->GetReferrerPolicy();
}
NameValueCollection^ CefRequestWrapper::Headers::get()
{
ThrowIfDisposed();
CefRequest::HeaderMap hm;
_request->GetHeaderMap(hm);
auto headers = gcnew HeaderNameValueCollection();
for (CefRequest::HeaderMap::iterator it = hm.begin(); it != hm.end(); ++it)
{
String^ name = StringUtils::ToClr(it->first);
String^ value = StringUtils::ToClr(it->second);
headers->Add(name, value);
}
if (_request->IsReadOnly())
{
headers->SetReadOnly();
}
return headers;
}
void CefRequestWrapper::Headers::set(NameValueCollection^ headers)
{
ThrowIfDisposed();
ThrowIfReadOnly();
CefRequest::HeaderMap hm;
for each(String^ key in headers)
{
CefString name = StringUtils::ToNative(key);
for each(String^ element in headers->GetValues(key))
{
CefString value = StringUtils::ToNative(element);
hm.insert(std::make_pair(name, value));
}
}
_request->SetHeaderMap(hm);
}
TransitionType CefRequestWrapper::TransitionType::get()
{
ThrowIfDisposed();
return (CefSharp::TransitionType) _request->GetTransitionType();
}
IPostData^ CefRequestWrapper::PostData::get()
{
ThrowIfDisposed();
if (_postData == nullptr)
{
auto postData = _request->GetPostData();
if (postData.get())
{
_postData = gcnew CefSharp::PostData(postData);
}
}
return _postData;
}
bool CefRequestWrapper::IsReadOnly::get()
{
ThrowIfDisposed();
return _request->IsReadOnly();
}
void CefRequestWrapper::InitializePostData()
{
ThrowIfDisposed();
ThrowIfReadOnly();
_request->SetPostData(CefPostData::Create());
}
String^ CefRequestWrapper::GetHeaderByName(String^ name)
{
ThrowIfDisposed();
return StringUtils::ToClr(_request->GetHeaderByName(StringUtils::ToNative(name)));
}
void CefRequestWrapper::SetHeaderByName(String^ name, String^ value, bool overwrite)
{
ThrowIfDisposed();
ThrowIfReadOnly();
_request->SetHeaderByName(StringUtils::ToNative(name), StringUtils::ToNative(value), overwrite);
}
}
}
@@ -1,78 +0,0 @@
// Copyright © 2010 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_request.h"
#include "CefWrapper.h"
using namespace System::Collections::Specialized;
namespace CefSharp
{
namespace Internals
{
private ref class CefRequestWrapper : public IRequest, public CefWrapper
{
MCefRefPtr<CefRequest> _request;
IPostData^ _postData;
internal:
CefRequestWrapper(CefRefPtr<CefRequest> &cefRequest) :
_request(cefRequest), _postData(nullptr)
{
}
!CefRequestWrapper()
{
_request = nullptr;
}
~CefRequestWrapper()
{
this->!CefRequestWrapper();
delete _postData;
_disposed = true;
}
public:
virtual property UrlRequestFlags Flags { UrlRequestFlags get(); void set(UrlRequestFlags flags); }
virtual property String^ Url { String^ get(); void set(String^ url); }
virtual property String^ Method { String^ get(); void set(String^ method); }
virtual property UInt64 Identifier { UInt64 get(); }
virtual void SetReferrer(String^ referrerUrl, CefSharp::ReferrerPolicy policy);
virtual property String^ ReferrerUrl { String^ get(); }
virtual property ResourceType ResourceType { CefSharp::ResourceType get(); }
virtual property ReferrerPolicy ReferrerPolicy { CefSharp::ReferrerPolicy get(); }
virtual property NameValueCollection^ Headers { NameValueCollection^ get(); void set(NameValueCollection^ url); }
virtual property TransitionType TransitionType { CefSharp::TransitionType get(); }
virtual property IPostData^ PostData { IPostData^ get(); }
virtual property bool IsReadOnly { bool get(); }
virtual void InitializePostData();
virtual String^ GetHeaderByName(String^ name);
virtual void SetHeaderByName(String^ name, String^ value, bool overwrite);
operator CefRefPtr<CefRequest>()
{
if (this == nullptr)
{
return NULL;
}
return _request.get();
}
void ThrowIfReadOnly()
{
if (_request->IsReadOnly())
{
throw gcnew NotSupportedException("IRequest is read-only and cannot be modified. Check IRequest.IsReadOnly to guard against this exception.");
}
}
};
}
}
@@ -10,7 +10,7 @@
#include "include\wrapper\cef_stream_resource_handler.h"
#include "CefResponseWrapper.h"
#include "CefRequestWrapper.h"
#include "Request.h"
#include "CefFrameWrapper.h"
#include "CefSharpBrowserWrapper.h"
#include "ResourceHandlerWrapper.h"
@@ -46,7 +46,7 @@ namespace CefSharp
CefRefPtr<CefCookieAccessFilter> GetCookieAccessFilter(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, CefRefPtr<CefRequest> request) OVERRIDE
{
ICookieAccessFilter^ accessFilter;
CefRequestWrapper requestWrapper(request);
Request requestWrapper(request);
//For ServiceWorker browser and frame will be null
if (browser.get() && frame.get())
@@ -79,13 +79,13 @@ namespace CefSharp
//We pass the frame and request wrappers to CefRequestCallbackWrapper so they can be disposed of
//when the callback is executed
auto frameWrapper = gcnew CefFrameWrapper(frame);
auto requestWrapper = gcnew CefRequestWrapper(request);
auto requestWrapper = gcnew Request(request);
auto requestCallback = gcnew CefRequestCallbackWrapper(callback, frameWrapper, requestWrapper);
return (cef_return_value_t)_handler->OnBeforeResourceLoad(_browserControl, %browserWrapper, frameWrapper, requestWrapper, requestCallback);
}
auto requestWrapper = gcnew CefRequestWrapper(request);
auto requestWrapper = gcnew Request(request);
auto requestCallback = gcnew CefRequestCallbackWrapper(callback, nullptr, requestWrapper);
return (cef_return_value_t)_handler->OnBeforeResourceLoad(_browserControl, nullptr, nullptr, requestWrapper, requestCallback);
@@ -94,7 +94,7 @@ namespace CefSharp
CefRefPtr<CefResourceHandler> GetResourceHandler(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, CefRefPtr<CefRequest> request) OVERRIDE
{
IResourceHandler^ resourceHandler;
CefRequestWrapper requestWrapper(request);
Request requestWrapper(request);
//For ServiceWorker browser and frame will be null
if (browser.get() && frame.get())
@@ -151,7 +151,7 @@ namespace CefSharp
void OnResourceRedirect(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, CefRefPtr<CefRequest> request, CefRefPtr<CefResponse> response, CefString& newUrl) OVERRIDE
{
auto managedNewUrl = StringUtils::ToClr(newUrl);
CefRequestWrapper requestWrapper(request);
Request requestWrapper(request);
CefResponseWrapper responseWrapper(response);
//For ServiceWorker browser and frame will be null
@@ -173,7 +173,7 @@ namespace CefSharp
bool OnResourceResponse(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, CefRefPtr<CefRequest> request, CefRefPtr<CefResponse> response) OVERRIDE
{
CefRequestWrapper requestWrapper(request);
Request requestWrapper(request);
CefResponseWrapper responseWrapper(response);
//For ServiceWorker browser and frame will be null
@@ -192,7 +192,7 @@ namespace CefSharp
CefRefPtr<CefResponseFilter> GetResourceResponseFilter(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, CefRefPtr<CefRequest> request, CefRefPtr<CefResponse> response) OVERRIDE
{
IResponseFilter^ responseFilter;
CefRequestWrapper requestWrapper(request);
Request requestWrapper(request);
CefResponseWrapper responseWrapper(response);
//For ServiceWorker browser and frame will be null
@@ -218,7 +218,7 @@ namespace CefSharp
void OnResourceLoadComplete(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, CefRefPtr<CefRequest> request, CefRefPtr<CefResponse> response, URLRequestStatus status, int64 receivedContentLength) OVERRIDE
{
CefRequestWrapper requestWrapper(request);
Request requestWrapper(request);
CefResponseWrapper responseWrapper(response);
//For ServiceWorker browser and frame will be null
@@ -237,7 +237,7 @@ namespace CefSharp
void OnProtocolExecution(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, CefRefPtr<CefRequest> request, bool& allowOSExecution) OVERRIDE
{
CefRequestWrapper requestWrapper(request);
Request requestWrapper(request);
//For ServiceWorker browser and frame will be null
if (browser.get() && frame.get())
+3 -3
View File
@@ -18,7 +18,7 @@
#include "CefFrameWrapper.h"
#include "CefJSDialogCallbackWrapper.h"
#include "CefMenuModelWrapper.h"
#include "CefRequestWrapper.h"
#include "Request.h"
#include "CefResourceRequestHandlerAdapter.h"
#include "CefRequestCallbackWrapper.h"
#include "CefRunContextMenuCallbackWrapper.h"
@@ -515,7 +515,7 @@ namespace CefSharp
auto browserWrapper = GetBrowserWrapper(browser->GetIdentifier(), browser->IsPopup());
CefFrameWrapper frameWrapper(frame);
CefRequestWrapper requestWrapper(request);
Request requestWrapper(request);
return handler->OnBeforeBrowse(_browserControl, browserWrapper, %frameWrapper, %requestWrapper, userGesture, isRedirect);
}
@@ -550,7 +550,7 @@ namespace CefSharp
auto browserWrapper = GetBrowserWrapper(browser->GetIdentifier(), browser->IsPopup());
CefFrameWrapper frameWrapper(frame);
CefRequestWrapper requestWrapper(request);
Request requestWrapper(request);
if (handler != nullptr)
{
+201
View File
@@ -0,0 +1,201 @@
// Copyright © 2010 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 "Request.h"
#include "PostData.h"
using namespace System::Text;
namespace CefSharp
{
UrlRequestFlags Request::Flags::get()
{
ThrowIfDisposed();
return (UrlRequestFlags)_request->GetFlags();
}
void Request::Flags::set(UrlRequestFlags flags)
{
ThrowIfDisposed();
ThrowIfReadOnly();
_request->SetFlags((int)flags);
}
String^ Request::Url::get()
{
ThrowIfDisposed();
return StringUtils::ToClr(_request->GetURL());
}
void Request::Url::set(String^ url)
{
if (url == nullptr)
{
throw gcnew System::ArgumentException("cannot be null", "url");
}
ThrowIfDisposed();
ThrowIfReadOnly();
CefString str = StringUtils::ToNative(url);
_request->SetURL(str);
}
String^ Request::Method::get()
{
ThrowIfDisposed();
return StringUtils::ToClr(_request->GetMethod());
}
void Request::Method::set(String^ method)
{
if (method == nullptr)
{
throw gcnew System::ArgumentException("cannot be null", "method");
}
ThrowIfDisposed();
ThrowIfReadOnly();
_request->SetMethod(StringUtils::ToNative(method));
}
UInt64 Request::Identifier::get()
{
ThrowIfDisposed();
return _request->GetIdentifier();
}
void Request::SetReferrer(String^ referrerUrl, CefSharp::ReferrerPolicy policy)
{
ThrowIfDisposed();
ThrowIfReadOnly();
_request->SetReferrer(StringUtils::ToNative(referrerUrl), (cef_referrer_policy_t)policy);
}
String^ Request::ReferrerUrl::get()
{
ThrowIfDisposed();
return StringUtils::ToClr(_request->GetReferrerURL());
}
CefSharp::ResourceType Request::ResourceType::get()
{
ThrowIfDisposed();
return (CefSharp::ResourceType)_request->GetResourceType();
}
CefSharp::ReferrerPolicy Request::ReferrerPolicy::get()
{
ThrowIfDisposed();
return (CefSharp::ReferrerPolicy)_request->GetReferrerPolicy();
}
NameValueCollection^ Request::Headers::get()
{
ThrowIfDisposed();
CefRequest::HeaderMap hm;
_request->GetHeaderMap(hm);
auto headers = gcnew HeaderNameValueCollection();
for (CefRequest::HeaderMap::iterator it = hm.begin(); it != hm.end(); ++it)
{
String^ name = StringUtils::ToClr(it->first);
String^ value = StringUtils::ToClr(it->second);
headers->Add(name, value);
}
if (_request->IsReadOnly())
{
headers->SetReadOnly();
}
return headers;
}
void Request::Headers::set(NameValueCollection^ headers)
{
ThrowIfDisposed();
ThrowIfReadOnly();
CefRequest::HeaderMap hm;
for each(String^ key in headers)
{
CefString name = StringUtils::ToNative(key);
for each(String^ element in headers->GetValues(key))
{
CefString value = StringUtils::ToNative(element);
hm.insert(std::make_pair(name, value));
}
}
_request->SetHeaderMap(hm);
}
TransitionType Request::TransitionType::get()
{
ThrowIfDisposed();
return (CefSharp::TransitionType) _request->GetTransitionType();
}
IPostData^ Request::PostData::get()
{
ThrowIfDisposed();
if (_postData == nullptr)
{
auto postData = _request->GetPostData();
if (postData.get())
{
_postData = gcnew CefSharp::PostData(postData);
}
}
return _postData;
}
bool Request::IsReadOnly::get()
{
ThrowIfDisposed();
return _request->IsReadOnly();
}
void Request::InitializePostData()
{
ThrowIfDisposed();
ThrowIfReadOnly();
_request->SetPostData(CefPostData::Create());
}
String^ Request::GetHeaderByName(String^ name)
{
ThrowIfDisposed();
return StringUtils::ToClr(_request->GetHeaderByName(StringUtils::ToNative(name)));
}
void Request::SetHeaderByName(String^ name, String^ value, bool overwrite)
{
ThrowIfDisposed();
ThrowIfReadOnly();
_request->SetHeaderByName(StringUtils::ToNative(name), StringUtils::ToNative(value), overwrite);
}
}
+80
View File
@@ -0,0 +1,80 @@
// Copyright © 2010 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_request.h"
#include "Internals\CefWrapper.h"
using namespace System::Collections::Specialized;
namespace CefSharp
{
public ref class Request : public IRequest, public CefWrapper
{
MCefRefPtr<CefRequest> _request;
IPostData^ _postData;
internal:
Request(CefRefPtr<CefRequest> &cefRequest) :
_request(cefRequest), _postData(nullptr)
{
}
!Request()
{
_request = nullptr;
}
~Request()
{
this->!Request();
delete _postData;
_disposed = true;
}
public:
Request()
{
_request = CefRequest::Create();
}
virtual property UrlRequestFlags Flags { UrlRequestFlags get(); void set(UrlRequestFlags flags); }
virtual property String^ Url { String^ get(); void set(String^ url); }
virtual property String^ Method { String^ get(); void set(String^ method); }
virtual property UInt64 Identifier { UInt64 get(); }
virtual void SetReferrer(String^ referrerUrl, CefSharp::ReferrerPolicy policy);
virtual property String^ ReferrerUrl { String^ get(); }
virtual property ResourceType ResourceType { CefSharp::ResourceType get(); }
virtual property ReferrerPolicy ReferrerPolicy { CefSharp::ReferrerPolicy get(); }
virtual property NameValueCollection^ Headers { NameValueCollection^ get(); void set(NameValueCollection^ url); }
virtual property TransitionType TransitionType { CefSharp::TransitionType get(); }
virtual property IPostData^ PostData { IPostData^ get(); }
virtual property bool IsReadOnly { bool get(); }
virtual void InitializePostData();
virtual String^ GetHeaderByName(String^ name);
virtual void SetHeaderByName(String^ name, String^ value, bool overwrite);
operator CefRefPtr<CefRequest>()
{
if (this == nullptr)
{
return NULL;
}
return _request.get();
}
void ThrowIfReadOnly()
{
if (_request->IsReadOnly())
{
throw gcnew NotSupportedException("IRequest is read-only and cannot be modified. Check IRequest.IsReadOnly to guard against this exception.");
}
}
};
}
+4 -4
View File
@@ -4,13 +4,13 @@
#include "Stdafx.h"
#include "Internals/CefRequestWrapper.h"
#include "Request.h"
#include "ResourceHandlerWrapper.h"
#include "Internals/CefResponseWrapper.h"
#include "Internals/CefCallbackWrapper.h"
#include "Internals/CefResourceReadCallbackWrapper.h"
#include "Internals/CefResourceSkipCallbackWrapper.h"
#include "Internals/TypeConversion.h"
#include "ResourceHandlerWrapper.h"
using namespace System::Runtime::InteropServices;
using namespace System::IO;
@@ -20,7 +20,7 @@ namespace CefSharp
bool ResourceHandlerWrapper::Open(CefRefPtr<CefRequest> request, bool& handleRequest, CefRefPtr<CefCallback> callback)
{
auto callbackWrapper = gcnew CefCallbackWrapper(callback);
_request = gcnew CefRequestWrapper(request);
_request = gcnew Request(request);
return _handler->Open(_request, handleRequest, callbackWrapper);
}
@@ -63,7 +63,7 @@ namespace CefSharp
bool ResourceHandlerWrapper::ProcessRequest(CefRefPtr<CefRequest> request, CefRefPtr<CefCallback> callback)
{
auto callbackWrapper = gcnew CefCallbackWrapper(callback);
_request = gcnew CefRequestWrapper(request);
_request = gcnew Request(request);
return _handler->ProcessRequest(_request, callbackWrapper);
}
+3 -3
View File
@@ -10,7 +10,7 @@
#include "Internals\CefSharpBrowserWrapper.h"
#include "Internals\CefFrameWrapper.h"
#include "Internals\CefRequestWrapper.h"
#include "Request.h"
#include "ResourceHandlerWrapper.h"
using namespace System::IO;
@@ -37,7 +37,7 @@ namespace CefSharp
{
CefSharpBrowserWrapper browserWrapper(browser);
CefFrameWrapper frameWrapper(frame);
CefRequestWrapper requestWrapper(request);
Request requestWrapper(request);
auto handler = _factory->Create(%browserWrapper, %frameWrapper, StringUtils::ToClr(schemeName), %requestWrapper);
@@ -82,4 +82,4 @@ namespace CefSharp
IMPLEMENT_REFCOUNTING(SchemeHandlerFactoryWrapper);
};
}
}