Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 1 addition & 13 deletions CefSharp.Core/Internals/ClientAdapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -351,20 +351,8 @@ namespace CefSharp
}

auto requestWrapper = gcnew CefRequestWrapper(request);
auto response = gcnew Response();

bool ret = handler->OnBeforeResourceLoad(_browserControl, requestWrapper, response, frame->IsMain());

if (response->Action == ResponseAction::Redirect)
{
request->SetURL(StringUtils::ToNative(response->RedirectUrl));
}
else if (response->Action == ResponseAction::Cancel)
{
return true;
}

return ret;
return handler->OnBeforeResourceLoad(_browserControl, requestWrapper, frame->IsMain());
}

CefRefPtr<CefDownloadHandler> ClientAdapter::GetDownloadHandler()
Expand Down
8 changes: 7 additions & 1 deletion CefSharp.Example/RequestHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,14 @@ void IRequestHandler.OnPluginCrashed(IWebBrowser browser, string pluginPath)
// TODO: Add your own code here for handling scenarios where a plugin crashed, for one reason or another.
}

bool IRequestHandler.OnBeforeResourceLoad(IWebBrowser browser, IRequest request, IResponse response, bool isMainFrame)
bool IRequestHandler.OnBeforeResourceLoad(IWebBrowser browser, IRequest request, bool isMainFrame)
{
//Note to Redirect simply set the request Url
//if (request.Url.StartsWith("https://www.google.com", StringComparison.OrdinalIgnoreCase))
//{
// request.Url = "https://github.com/";
//}

return false;
}

Expand Down
2 changes: 0 additions & 2 deletions CefSharp/CefSharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@
<Compile Include="Internals\WCFExtensions.cs" />
<Compile Include="KeyType.cs" />
<Compile Include="ResourceHandler.cs" />
<Compile Include="Response.cs" />
<Compile Include="ResponseAction.cs" />
<Compile Include="ScreenInfo.cs" />
<Compile Include="TransitionType.cs" />
Expand All @@ -152,7 +151,6 @@
<Compile Include="WebPluginInfo.cs" />
<Compile Include="IRequest.cs" />
<Compile Include="IRequestHandler.cs" />
<Compile Include="IResponse.cs" />
<Compile Include="ISchemeHandler.cs" />
<Compile Include="ISchemeHandlerFactory.cs" />
<Compile Include="ISchemeHandlerResponse.cs" />
Expand Down
3 changes: 1 addition & 2 deletions CefSharp/IRequestHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,9 @@ public interface IRequestHandler
/// </summary>
/// <param name="browser">the browser object</param>
/// <param name="request">the request object - can be modified in this callback.</param>
/// <param name="response">the request object - can be modified in this callback.</param>
/// /// <param name="isMainFrame">whether the request comes from main frame or not</param>
/// <returns>To cancel loading of the resource return true or false to allow the resource to load normally.</returns>
bool OnBeforeResourceLoad(IWebBrowser browser, IRequest request, IResponse response, bool isMainFrame);
bool OnBeforeResourceLoad(IWebBrowser browser, IRequest request, bool isMainFrame);

/// <summary>
/// Called when the browser needs credentials from the user.
Expand Down
15 changes: 0 additions & 15 deletions CefSharp/IResponse.cs

This file was deleted.

30 changes: 0 additions & 30 deletions CefSharp/Response.cs

This file was deleted.