diff --git a/CefSharp.Core/Internals/ClientAdapter.cpp b/CefSharp.Core/Internals/ClientAdapter.cpp index cf4aa98fd4..b312db755a 100644 --- a/CefSharp.Core/Internals/ClientAdapter.cpp +++ b/CefSharp.Core/Internals/ClientAdapter.cpp @@ -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 ClientAdapter::GetDownloadHandler() diff --git a/CefSharp.Example/RequestHandler.cs b/CefSharp.Example/RequestHandler.cs index 7fc2b71a82..e6ae2d6249 100644 --- a/CefSharp.Example/RequestHandler.cs +++ b/CefSharp.Example/RequestHandler.cs @@ -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; } diff --git a/CefSharp/CefSharp.csproj b/CefSharp/CefSharp.csproj index 6c635dc745..6aab6c7e13 100644 --- a/CefSharp/CefSharp.csproj +++ b/CefSharp/CefSharp.csproj @@ -126,7 +126,6 @@ - @@ -152,7 +151,6 @@ - diff --git a/CefSharp/IRequestHandler.cs b/CefSharp/IRequestHandler.cs index a8eec29402..a33d7f6662 100644 --- a/CefSharp/IRequestHandler.cs +++ b/CefSharp/IRequestHandler.cs @@ -40,10 +40,9 @@ public interface IRequestHandler /// /// the browser object /// the request object - can be modified in this callback. - /// the request object - can be modified in this callback. /// /// whether the request comes from main frame or not /// To cancel loading of the resource return true or false to allow the resource to load normally. - bool OnBeforeResourceLoad(IWebBrowser browser, IRequest request, IResponse response, bool isMainFrame); + bool OnBeforeResourceLoad(IWebBrowser browser, IRequest request, bool isMainFrame); /// /// Called when the browser needs credentials from the user. diff --git a/CefSharp/IResponse.cs b/CefSharp/IResponse.cs deleted file mode 100644 index d95b7ede57..0000000000 --- a/CefSharp/IResponse.cs +++ /dev/null @@ -1,15 +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. - -namespace CefSharp -{ - public interface IResponse - { - /// cancel the request, return nothing - void Cancel(); - - /// respond with redirection to the provided URL - void Redirect(string url); - } -} diff --git a/CefSharp/Response.cs b/CefSharp/Response.cs deleted file mode 100644 index a5eda1fcac..0000000000 --- a/CefSharp/Response.cs +++ /dev/null @@ -1,30 +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; - -namespace CefSharp -{ - public class Response : IResponse - { - public String RedirectUrl { get; private set; } - public ResponseAction Action { get; private set; } - - public Response() - { - Action = ResponseAction.Continue; - } - - public void Cancel() - { - Action = ResponseAction.Cancel; - } - - public void Redirect(String url) - { - RedirectUrl = url; - Action = ResponseAction.Redirect; - } - } -}