diff --git a/CefSharp.Core/CefSharp.Core.vcxproj b/CefSharp.Core/CefSharp.Core.vcxproj
index 19845baf91..c53c893a5b 100644
--- a/CefSharp.Core/CefSharp.Core.vcxproj
+++ b/CefSharp.Core/CefSharp.Core.vcxproj
@@ -266,6 +266,7 @@
+
diff --git a/CefSharp.Core/CefSharp.Core.vcxproj.filters b/CefSharp.Core/CefSharp.Core.vcxproj.filters
index 393c721b01..71d5201ea5 100644
--- a/CefSharp.Core/CefSharp.Core.vcxproj.filters
+++ b/CefSharp.Core/CefSharp.Core.vcxproj.filters
@@ -253,6 +253,9 @@
Header Files
+
+ Header Files
+
diff --git a/CefSharp.Core/Internals/CefResolveCallbackAdapter.h b/CefSharp.Core/Internals/CefResolveCallbackAdapter.h
new file mode 100644
index 0000000000..cd7a7c970e
--- /dev/null
+++ b/CefSharp.Core/Internals/CefResolveCallbackAdapter.h
@@ -0,0 +1,35 @@
+// Copyright © 2010-2016 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_context.h"
+
+namespace CefSharp
+{
+ private class CefResolveCallbackAdapter : public CefResolveCallback
+ {
+ private:
+ gcroot _handler;
+
+ public:
+ CefResolveCallbackAdapter(IResolveCallback^ handler)
+ {
+ _handler = handler;
+ }
+
+ ~CefResolveCallbackAdapter()
+ {
+ _handler = nullptr;
+ }
+
+ void OnResolveCompleted(cef_errorcode_t result, const std::vector& resolvedIps) OVERRIDE
+ {
+ _handler->OnResolveCompleted((CefErrorCode)result, StringUtils::ToClr(resolvedIps));
+ }
+
+ IMPLEMENT_REFCOUNTING(CefResolveCallbackAdapter);
+ };
+}
\ No newline at end of file
diff --git a/CefSharp.Core/RequestContext.h b/CefSharp.Core/RequestContext.h
index f11601b423..27749dc070 100644
--- a/CefSharp.Core/RequestContext.h
+++ b/CefSharp.Core/RequestContext.h
@@ -12,6 +12,7 @@
#include "Internals\CefCompletionCallbackAdapter.h"
#include "Internals\CookieManager.h"
#include "Internals\CefWrapper.h"
+#include "Internals\CefResolveCallbackAdapter.h"
using namespace System::Runtime::InteropServices;
@@ -280,6 +281,45 @@ namespace CefSharp
_requestContext->CloseAllConnections(wrapper);
}
+ ///
+ // Attempts to resolve |origin| to a list of associated IP addresses.
+ // |callback| will be executed on the UI thread after completion.
+ ///
+ /*--cef()--*/
+ virtual void ResolveHost(String^ origin, IResolveCallback^ callback)
+ {
+ ThrowIfDisposed();
+
+ if (callback == nullptr)
+ {
+ throw gcnew ArgumentNullException("callback");
+ }
+
+ CefRefPtr callbackWrapper = new CefResolveCallbackAdapter(callback);
+
+ _requestContext->ResolveHost(StringUtils::ToNative(origin), callbackWrapper);
+ }
+
+ ///
+ // Attempts to resolve |origin| to a list of associated IP addresses using
+ // cached data. |resolved_ips| will be populated with the list of resolved IP
+ // addresses or empty if no cached data is available. Returns ERR_NONE on
+ // success. This method must be called on the browser process IO thread.
+ ///
+ /*--cef(default_retval=ERR_FAILED)--*/
+ virtual CefErrorCode ResolveHostCached(String^ origin, [Out] IList^ %resolvedIpAddresses)
+ {
+ ThrowIfDisposed();
+
+ std::vector addresses;
+
+ auto errorCode =_requestContext->ResolveHostCached(StringUtils::ToNative(origin), addresses);
+
+ resolvedIpAddresses = StringUtils::ToClr(addresses);
+
+ return (CefErrorCode)errorCode;
+ }
+
operator CefRefPtr()
{
if(this == nullptr)
diff --git a/CefSharp/CefSharp.csproj b/CefSharp/CefSharp.csproj
index 982c829058..23a7536811 100644
--- a/CefSharp/CefSharp.csproj
+++ b/CefSharp/CefSharp.csproj
@@ -93,6 +93,7 @@
+
diff --git a/CefSharp/IRequestContext.cs b/CefSharp/IRequestContext.cs
index 5712e31e26..afca979eb7 100644
--- a/CefSharp/IRequestContext.cs
+++ b/CefSharp/IRequestContext.cs
@@ -151,5 +151,22 @@ public interface IRequestContext : IDisposable
/// If is non-NULL it will be executed on the CEF UI thread after
/// completion. This param is optional
void CloseAllConnections(ICompletionCallback callback);
+
+ ///
+ /// Attempts to resolve origin to a list of associated IP addresses.
+ ///
+ /// host name to resolve
+ /// callback will be executed on the CEF UI thread after completion.
+ void ResolveHost(string origin, IResolveCallback callback);
+
+ ///
+ /// Attempts to resolve origin to a list of associated IP addresses using
+ /// cached data. This method must be called on the CEF IO thread.
+ ///
+ /// host name to resolve
+ /// list of resolved IP
+ /// addresses or null if no cached data is available.
+ /// Returns on success
+ CefErrorCode ResolveHostCached(string origin, out IList resolvedIpAddresses);
}
}
diff --git a/CefSharp/IResolveCallback.cs b/CefSharp/IResolveCallback.cs
new file mode 100644
index 0000000000..c1f627e4c0
--- /dev/null
+++ b/CefSharp/IResolveCallback.cs
@@ -0,0 +1,25 @@
+// Copyright © 2010-2016 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.Collections.Generic;
+
+namespace CefSharp
+{
+ public interface IResolveCallback : IDisposable
+ {
+ ///
+ /// Called after the ResolveHost request has completed.
+ ///
+ /// The result code
+ /// will be the list of resolved IP addresses or
+ /// null if the resolution failed.
+ void OnResolveCompleted(CefErrorCode result, IList resolvedIpAddresses);
+
+ ///
+ /// Gets a value indicating whether the callback has been disposed of.
+ ///
+ bool IsDisposed { get; }
+ }
+}