mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-04-24 07:37:21 +02:00
Add DNS resolution methods to CefRequestContext (issue #1841)
This commit is contained in:
parent
fabd3db33e
commit
a1d9c22b58
@ -252,6 +252,8 @@
|
|||||||
'libcef_dll/ctocpp/request_context_handler_ctocpp.h',
|
'libcef_dll/ctocpp/request_context_handler_ctocpp.h',
|
||||||
'libcef_dll/ctocpp/request_handler_ctocpp.cc',
|
'libcef_dll/ctocpp/request_handler_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/request_handler_ctocpp.h',
|
'libcef_dll/ctocpp/request_handler_ctocpp.h',
|
||||||
|
'libcef_dll/ctocpp/resolve_callback_ctocpp.cc',
|
||||||
|
'libcef_dll/ctocpp/resolve_callback_ctocpp.h',
|
||||||
'libcef_dll/cpptoc/resource_bundle_cpptoc.cc',
|
'libcef_dll/cpptoc/resource_bundle_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/resource_bundle_cpptoc.h',
|
'libcef_dll/cpptoc/resource_bundle_cpptoc.h',
|
||||||
'libcef_dll/ctocpp/resource_bundle_handler_ctocpp.cc',
|
'libcef_dll/ctocpp/resource_bundle_handler_ctocpp.cc',
|
||||||
@ -452,6 +454,8 @@
|
|||||||
'libcef_dll/cpptoc/request_context_handler_cpptoc.h',
|
'libcef_dll/cpptoc/request_context_handler_cpptoc.h',
|
||||||
'libcef_dll/cpptoc/request_handler_cpptoc.cc',
|
'libcef_dll/cpptoc/request_handler_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/request_handler_cpptoc.h',
|
'libcef_dll/cpptoc/request_handler_cpptoc.h',
|
||||||
|
'libcef_dll/cpptoc/resolve_callback_cpptoc.cc',
|
||||||
|
'libcef_dll/cpptoc/resolve_callback_cpptoc.h',
|
||||||
'libcef_dll/ctocpp/resource_bundle_ctocpp.cc',
|
'libcef_dll/ctocpp/resource_bundle_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/resource_bundle_ctocpp.h',
|
'libcef_dll/ctocpp/resource_bundle_ctocpp.h',
|
||||||
'libcef_dll/cpptoc/resource_bundle_handler_cpptoc.cc',
|
'libcef_dll/cpptoc/resource_bundle_handler_cpptoc.cc',
|
||||||
|
@ -49,6 +49,26 @@ extern "C" {
|
|||||||
|
|
||||||
struct _cef_scheme_handler_factory_t;
|
struct _cef_scheme_handler_factory_t;
|
||||||
|
|
||||||
|
///
|
||||||
|
// Callback structure for cef_request_tContext::ResolveHost.
|
||||||
|
///
|
||||||
|
typedef struct _cef_resolve_callback_t {
|
||||||
|
///
|
||||||
|
// Base structure.
|
||||||
|
///
|
||||||
|
cef_base_t base;
|
||||||
|
|
||||||
|
///
|
||||||
|
// Called after the ResolveHost request has completed. |result| will be the
|
||||||
|
// result code. |resolved_ips| will be the list of resolved IP addresses or
|
||||||
|
// NULL if the resolution failed.
|
||||||
|
///
|
||||||
|
void (CEF_CALLBACK *on_resolve_completed)(
|
||||||
|
struct _cef_resolve_callback_t* self, cef_errorcode_t result,
|
||||||
|
cef_string_list_t resolved_ips);
|
||||||
|
} cef_resolve_callback_t;
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// A request context provides request handling for a set of related browser or
|
// A request context provides request handling for a set of related browser or
|
||||||
// URL request objects. A request context can be specified when creating a new
|
// URL request objects. A request context can be specified when creating a new
|
||||||
@ -222,6 +242,23 @@ typedef struct _cef_request_context_t {
|
|||||||
void (CEF_CALLBACK *close_all_connections)(
|
void (CEF_CALLBACK *close_all_connections)(
|
||||||
struct _cef_request_context_t* self,
|
struct _cef_request_context_t* self,
|
||||||
struct _cef_completion_callback_t* callback);
|
struct _cef_completion_callback_t* callback);
|
||||||
|
|
||||||
|
///
|
||||||
|
// Attempts to resolve |origin| to a list of associated IP addresses.
|
||||||
|
// |callback| will be executed on the UI thread after completion.
|
||||||
|
///
|
||||||
|
void (CEF_CALLBACK *resolve_host)(struct _cef_request_context_t* self,
|
||||||
|
const cef_string_t* origin, struct _cef_resolve_callback_t* callback);
|
||||||
|
|
||||||
|
///
|
||||||
|
// 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 NULL if no cached data is available. Returns ERR_NONE on
|
||||||
|
// success. This function must be called on the browser process IO thread.
|
||||||
|
///
|
||||||
|
cef_errorcode_t (CEF_CALLBACK *resolve_host_cached)(
|
||||||
|
struct _cef_request_context_t* self, const cef_string_t* origin,
|
||||||
|
cef_string_list_t resolved_ips);
|
||||||
} cef_request_context_t;
|
} cef_request_context_t;
|
||||||
|
|
||||||
|
|
||||||
|
@ -38,6 +38,8 @@
|
|||||||
#define CEF_INCLUDE_CEF_REQUEST_CONTEXT_H_
|
#define CEF_INCLUDE_CEF_REQUEST_CONTEXT_H_
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "include/cef_callback.h"
|
#include "include/cef_callback.h"
|
||||||
#include "include/cef_cookie.h"
|
#include "include/cef_cookie.h"
|
||||||
#include "include/cef_request_context_handler.h"
|
#include "include/cef_request_context_handler.h"
|
||||||
@ -45,6 +47,25 @@
|
|||||||
|
|
||||||
class CefSchemeHandlerFactory;
|
class CefSchemeHandlerFactory;
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
// Callback interface for CefRequestContext::ResolveHost.
|
||||||
|
///
|
||||||
|
/*--cef(source=client)--*/
|
||||||
|
class CefResolveCallback : public virtual CefBase {
|
||||||
|
public:
|
||||||
|
///
|
||||||
|
// Called after the ResolveHost request has completed. |result| will be the
|
||||||
|
// result code. |resolved_ips| will be the list of resolved IP addresses or
|
||||||
|
// empty if the resolution failed.
|
||||||
|
///
|
||||||
|
/*--cef(optional_param=resolved_ips)--*/
|
||||||
|
virtual void OnResolveCompleted(
|
||||||
|
cef_errorcode_t result,
|
||||||
|
const std::vector<CefString>& resolved_ips) =0;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// A request context provides request handling for a set of related browser
|
// A request context provides request handling for a set of related browser
|
||||||
// or URL request objects. A request context can be specified when creating a
|
// or URL request objects. A request context can be specified when creating a
|
||||||
@ -240,6 +261,26 @@ class CefRequestContext : public virtual CefBase {
|
|||||||
/*--cef(optional_param=callback)--*/
|
/*--cef(optional_param=callback)--*/
|
||||||
virtual void CloseAllConnections(
|
virtual void CloseAllConnections(
|
||||||
CefRefPtr<CefCompletionCallback> callback) =0;
|
CefRefPtr<CefCompletionCallback> callback) =0;
|
||||||
|
|
||||||
|
///
|
||||||
|
// 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(
|
||||||
|
const CefString& origin,
|
||||||
|
CefRefPtr<CefResolveCallback> callback) =0;
|
||||||
|
|
||||||
|
///
|
||||||
|
// 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 cef_errorcode_t ResolveHostCached(
|
||||||
|
const CefString& origin,
|
||||||
|
std::vector<CefString>& resolved_ips) =0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CEF_INCLUDE_CEF_REQUEST_CONTEXT_H_
|
#endif // CEF_INCLUDE_CEF_REQUEST_CONTEXT_H_
|
||||||
|
@ -50,6 +50,30 @@ const char* GetTypeString(base::Value::Type type) {
|
|||||||
return "UNKNOWN";
|
return "UNKNOWN";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Helper for HostResolver::Resolve.
|
||||||
|
struct ResolveHostHelper {
|
||||||
|
explicit ResolveHostHelper(CefRefPtr<CefResolveCallback> callback)
|
||||||
|
: callback_(callback) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnResolveCompleted(int result) {
|
||||||
|
std::vector<CefString> resolved_ips;
|
||||||
|
|
||||||
|
net::AddressList::const_iterator iter = address_list_.begin();
|
||||||
|
for (; iter != address_list_.end(); ++iter)
|
||||||
|
resolved_ips.push_back(iter->ToStringWithoutPort());
|
||||||
|
|
||||||
|
CEF_POST_TASK(CEF_UIT,
|
||||||
|
base::Bind(&CefResolveCallback::OnResolveCompleted, callback_.get(),
|
||||||
|
static_cast<cef_errorcode_t>(result), resolved_ips));
|
||||||
|
|
||||||
|
delete this;
|
||||||
|
}
|
||||||
|
|
||||||
|
CefRefPtr<CefResolveCallback> callback_;
|
||||||
|
net::AddressList address_list_;
|
||||||
|
};
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
|
||||||
@ -463,6 +487,47 @@ void CefRequestContextImpl::CloseAllConnections(
|
|||||||
callback));
|
callback));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CefRequestContextImpl::ResolveHost(
|
||||||
|
const CefString& origin,
|
||||||
|
CefRefPtr<CefResolveCallback> callback) {
|
||||||
|
GetRequestContextImpl(
|
||||||
|
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO),
|
||||||
|
base::Bind(&CefRequestContextImpl::ResolveHostInternal, this, origin,
|
||||||
|
callback));
|
||||||
|
}
|
||||||
|
|
||||||
|
cef_errorcode_t CefRequestContextImpl::ResolveHostCached(
|
||||||
|
const CefString& origin,
|
||||||
|
std::vector<CefString>& resolved_ips) {
|
||||||
|
resolved_ips.clear();
|
||||||
|
|
||||||
|
if (!CEF_CURRENTLY_ON_IOT()) {
|
||||||
|
NOTREACHED() << "called on invalid thread";
|
||||||
|
return ERR_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!request_context_impl_)
|
||||||
|
return ERR_FAILED;
|
||||||
|
|
||||||
|
int retval = ERR_FAILED;
|
||||||
|
|
||||||
|
net::HostResolver* host_resolver = request_context_impl_->GetHostResolver();
|
||||||
|
if (host_resolver) {
|
||||||
|
net::HostResolver::RequestInfo request_info(
|
||||||
|
net::HostPortPair::FromURL(GURL(origin.ToString())));
|
||||||
|
net::AddressList address_list;
|
||||||
|
retval = host_resolver->ResolveFromCache(request_info, &address_list,
|
||||||
|
net::BoundNetLog());
|
||||||
|
if (retval == net::OK) {
|
||||||
|
net::AddressList::const_iterator iter = address_list.begin();
|
||||||
|
for (; iter != address_list.end(); ++iter)
|
||||||
|
resolved_ips.push_back(iter->ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return static_cast<cef_errorcode_t>(retval);
|
||||||
|
}
|
||||||
|
|
||||||
CefRequestContextImpl::CefRequestContextImpl(
|
CefRequestContextImpl::CefRequestContextImpl(
|
||||||
scoped_refptr<CefBrowserContext> browser_context)
|
scoped_refptr<CefBrowserContext> browser_context)
|
||||||
: browser_context_(browser_context),
|
: browser_context_(browser_context),
|
||||||
@ -605,3 +670,33 @@ void CefRequestContextImpl::CloseAllConnectionsInternal(
|
|||||||
base::Bind(&CefCompletionCallback::OnComplete, callback.get()));
|
base::Bind(&CefCompletionCallback::OnComplete, callback.get()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CefRequestContextImpl::ResolveHostInternal(
|
||||||
|
const CefString& origin,
|
||||||
|
CefRefPtr<CefResolveCallback> callback,
|
||||||
|
scoped_refptr<CefURLRequestContextGetterImpl> request_context) {
|
||||||
|
CEF_REQUIRE_IOT();
|
||||||
|
|
||||||
|
int retval = ERR_FAILED;
|
||||||
|
|
||||||
|
// |helper| will be deleted in ResolveHostHelper::OnResolveCompleted().
|
||||||
|
ResolveHostHelper* helper = new ResolveHostHelper(callback);
|
||||||
|
|
||||||
|
net::HostResolver* host_resolver = request_context->GetHostResolver();
|
||||||
|
if (host_resolver) {
|
||||||
|
net::HostResolver::RequestInfo request_info(
|
||||||
|
net::HostPortPair::FromURL(GURL(origin.ToString())));
|
||||||
|
retval = host_resolver->Resolve(
|
||||||
|
request_info, net::DEFAULT_PRIORITY,
|
||||||
|
&helper->address_list_,
|
||||||
|
base::Bind(&ResolveHostHelper::OnResolveCompleted,
|
||||||
|
base::Unretained(helper)),
|
||||||
|
NULL, net::BoundNetLog());
|
||||||
|
if (retval == net::ERR_IO_PENDING) {
|
||||||
|
// The result will be delivered asynchronously via the callback.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
helper->OnResolveCompleted(retval);
|
||||||
|
}
|
||||||
|
@ -72,6 +72,12 @@ class CefRequestContextImpl : public CefRequestContext {
|
|||||||
void ClearCertificateExceptions(
|
void ClearCertificateExceptions(
|
||||||
CefRefPtr<CefCompletionCallback> callback) override;
|
CefRefPtr<CefCompletionCallback> callback) override;
|
||||||
void CloseAllConnections(CefRefPtr<CefCompletionCallback> callback) override;
|
void CloseAllConnections(CefRefPtr<CefCompletionCallback> callback) override;
|
||||||
|
void ResolveHost(
|
||||||
|
const CefString& origin,
|
||||||
|
CefRefPtr<CefResolveCallback> callback) override;
|
||||||
|
cef_errorcode_t ResolveHostCached(
|
||||||
|
const CefString& origin,
|
||||||
|
std::vector<CefString>& resolved_ips) override;
|
||||||
|
|
||||||
const CefRequestContextSettings& settings() const { return settings_; }
|
const CefRequestContextSettings& settings() const { return settings_; }
|
||||||
|
|
||||||
@ -112,6 +118,10 @@ class CefRequestContextImpl : public CefRequestContext {
|
|||||||
void CloseAllConnectionsInternal(
|
void CloseAllConnectionsInternal(
|
||||||
CefRefPtr<CefCompletionCallback> callback,
|
CefRefPtr<CefCompletionCallback> callback,
|
||||||
scoped_refptr<CefURLRequestContextGetterImpl> request_context);
|
scoped_refptr<CefURLRequestContextGetterImpl> request_context);
|
||||||
|
void ResolveHostInternal(
|
||||||
|
const CefString& origin,
|
||||||
|
CefRefPtr<CefResolveCallback> callback,
|
||||||
|
scoped_refptr<CefURLRequestContextGetterImpl> request_context);
|
||||||
|
|
||||||
scoped_refptr<CefBrowserContext> browser_context_;
|
scoped_refptr<CefBrowserContext> browser_context_;
|
||||||
CefRequestContextSettings settings_;
|
CefRequestContextSettings settings_;
|
||||||
|
@ -16,7 +16,9 @@
|
|||||||
#include "libcef_dll/cpptoc/value_cpptoc.h"
|
#include "libcef_dll/cpptoc/value_cpptoc.h"
|
||||||
#include "libcef_dll/ctocpp/completion_callback_ctocpp.h"
|
#include "libcef_dll/ctocpp/completion_callback_ctocpp.h"
|
||||||
#include "libcef_dll/ctocpp/request_context_handler_ctocpp.h"
|
#include "libcef_dll/ctocpp/request_context_handler_ctocpp.h"
|
||||||
|
#include "libcef_dll/ctocpp/resolve_callback_ctocpp.h"
|
||||||
#include "libcef_dll/ctocpp/scheme_handler_factory_ctocpp.h"
|
#include "libcef_dll/ctocpp/scheme_handler_factory_ctocpp.h"
|
||||||
|
#include "libcef_dll/transfer_util.h"
|
||||||
|
|
||||||
|
|
||||||
// GLOBAL FUNCTIONS - Body may be edited by hand.
|
// GLOBAL FUNCTIONS - Body may be edited by hand.
|
||||||
@ -378,6 +380,64 @@ void CEF_CALLBACK request_context_close_all_connections(
|
|||||||
CefCompletionCallbackCToCpp::Wrap(callback));
|
CefCompletionCallbackCToCpp::Wrap(callback));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CEF_CALLBACK request_context_resolve_host(
|
||||||
|
struct _cef_request_context_t* self, const cef_string_t* origin,
|
||||||
|
cef_resolve_callback_t* callback) {
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
DCHECK(self);
|
||||||
|
if (!self)
|
||||||
|
return;
|
||||||
|
// Verify param: origin; type: string_byref_const
|
||||||
|
DCHECK(origin);
|
||||||
|
if (!origin)
|
||||||
|
return;
|
||||||
|
// Verify param: callback; type: refptr_diff
|
||||||
|
DCHECK(callback);
|
||||||
|
if (!callback)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
CefRequestContextCppToC::Get(self)->ResolveHost(
|
||||||
|
CefString(origin),
|
||||||
|
CefResolveCallbackCToCpp::Wrap(callback));
|
||||||
|
}
|
||||||
|
|
||||||
|
cef_errorcode_t CEF_CALLBACK request_context_resolve_host_cached(
|
||||||
|
struct _cef_request_context_t* self, const cef_string_t* origin,
|
||||||
|
cef_string_list_t resolved_ips) {
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
DCHECK(self);
|
||||||
|
if (!self)
|
||||||
|
return ERR_FAILED;
|
||||||
|
// Verify param: origin; type: string_byref_const
|
||||||
|
DCHECK(origin);
|
||||||
|
if (!origin)
|
||||||
|
return ERR_FAILED;
|
||||||
|
// Verify param: resolved_ips; type: string_vec_byref
|
||||||
|
DCHECK(resolved_ips);
|
||||||
|
if (!resolved_ips)
|
||||||
|
return ERR_FAILED;
|
||||||
|
|
||||||
|
// Translate param: resolved_ips; type: string_vec_byref
|
||||||
|
std::vector<CefString> resolved_ipsList;
|
||||||
|
transfer_string_list_contents(resolved_ips, resolved_ipsList);
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
cef_errorcode_t _retval = CefRequestContextCppToC::Get(
|
||||||
|
self)->ResolveHostCached(
|
||||||
|
CefString(origin),
|
||||||
|
resolved_ipsList);
|
||||||
|
|
||||||
|
// Restore param: resolved_ips; type: string_vec_byref
|
||||||
|
cef_string_list_clear(resolved_ips);
|
||||||
|
transfer_string_list_contents(resolved_ipsList, resolved_ips);
|
||||||
|
|
||||||
|
// Return type: simple
|
||||||
|
return _retval;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
|
||||||
@ -405,6 +465,8 @@ CefRequestContextCppToC::CefRequestContextCppToC() {
|
|||||||
GetStruct()->clear_certificate_exceptions =
|
GetStruct()->clear_certificate_exceptions =
|
||||||
request_context_clear_certificate_exceptions;
|
request_context_clear_certificate_exceptions;
|
||||||
GetStruct()->close_all_connections = request_context_close_all_connections;
|
GetStruct()->close_all_connections = request_context_close_all_connections;
|
||||||
|
GetStruct()->resolve_host = request_context_resolve_host;
|
||||||
|
GetStruct()->resolve_host_cached = request_context_resolve_host_cached;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<> CefRefPtr<CefRequestContext> CefCppToC<CefRequestContextCppToC,
|
template<> CefRefPtr<CefRequestContext> CefCppToC<CefRequestContextCppToC,
|
||||||
|
64
libcef_dll/cpptoc/resolve_callback_cpptoc.cc
Normal file
64
libcef_dll/cpptoc/resolve_callback_cpptoc.cc
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
// Copyright (c) 2016 The Chromium Embedded Framework Authors. All rights
|
||||||
|
// reserved. Use of this source code is governed by a BSD-style license that
|
||||||
|
// can be found in the LICENSE file.
|
||||||
|
//
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// This file was generated by the CEF translator tool. If making changes by
|
||||||
|
// hand only do so within the body of existing method and function
|
||||||
|
// implementations. See the translator.README.txt file in the tools directory
|
||||||
|
// for more information.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "libcef_dll/cpptoc/resolve_callback_cpptoc.h"
|
||||||
|
#include "libcef_dll/transfer_util.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
// MEMBER FUNCTIONS - Body may be edited by hand.
|
||||||
|
|
||||||
|
void CEF_CALLBACK resolve_callback_on_resolve_completed(
|
||||||
|
struct _cef_resolve_callback_t* self, cef_errorcode_t result,
|
||||||
|
cef_string_list_t resolved_ips) {
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
DCHECK(self);
|
||||||
|
if (!self)
|
||||||
|
return;
|
||||||
|
// Unverified params: resolved_ips
|
||||||
|
|
||||||
|
// Translate param: resolved_ips; type: string_vec_byref_const
|
||||||
|
std::vector<CefString> resolved_ipsList;
|
||||||
|
transfer_string_list_contents(resolved_ips, resolved_ipsList);
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
CefResolveCallbackCppToC::Get(self)->OnResolveCompleted(
|
||||||
|
result,
|
||||||
|
resolved_ipsList);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
|
||||||
|
// CONSTRUCTOR - Do not edit by hand.
|
||||||
|
|
||||||
|
CefResolveCallbackCppToC::CefResolveCallbackCppToC() {
|
||||||
|
GetStruct()->on_resolve_completed = resolve_callback_on_resolve_completed;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<> CefRefPtr<CefResolveCallback> CefCppToC<CefResolveCallbackCppToC,
|
||||||
|
CefResolveCallback, cef_resolve_callback_t>::UnwrapDerived(
|
||||||
|
CefWrapperType type, cef_resolve_callback_t* s) {
|
||||||
|
NOTREACHED() << "Unexpected class type: " << type;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef NDEBUG
|
||||||
|
template<> base::AtomicRefCount CefCppToC<CefResolveCallbackCppToC,
|
||||||
|
CefResolveCallback, cef_resolve_callback_t>::DebugObjCt = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
template<> CefWrapperType CefCppToC<CefResolveCallbackCppToC,
|
||||||
|
CefResolveCallback, cef_resolve_callback_t>::kWrapperType =
|
||||||
|
WT_RESOLVE_CALLBACK;
|
37
libcef_dll/cpptoc/resolve_callback_cpptoc.h
Normal file
37
libcef_dll/cpptoc/resolve_callback_cpptoc.h
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
// Copyright (c) 2016 The Chromium Embedded Framework Authors. All rights
|
||||||
|
// reserved. Use of this source code is governed by a BSD-style license that
|
||||||
|
// can be found in the LICENSE file.
|
||||||
|
//
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// This file was generated by the CEF translator tool. If making changes by
|
||||||
|
// hand only do so within the body of existing method and function
|
||||||
|
// implementations. See the translator.README.txt file in the tools directory
|
||||||
|
// for more information.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef CEF_LIBCEF_DLL_CPPTOC_RESOLVE_CALLBACK_CPPTOC_H_
|
||||||
|
#define CEF_LIBCEF_DLL_CPPTOC_RESOLVE_CALLBACK_CPPTOC_H_
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef USING_CEF_SHARED
|
||||||
|
#pragma message("Warning: "__FILE__" may be accessed wrapper-side only")
|
||||||
|
#else // USING_CEF_SHARED
|
||||||
|
|
||||||
|
#include "include/cef_request_context.h"
|
||||||
|
#include "include/capi/cef_request_context_capi.h"
|
||||||
|
#include "include/cef_scheme.h"
|
||||||
|
#include "include/capi/cef_scheme_capi.h"
|
||||||
|
#include "libcef_dll/cpptoc/cpptoc.h"
|
||||||
|
|
||||||
|
// Wrap a C++ class with a C structure.
|
||||||
|
// This class may be instantiated and accessed wrapper-side only.
|
||||||
|
class CefResolveCallbackCppToC
|
||||||
|
: public CefCppToC<CefResolveCallbackCppToC, CefResolveCallback,
|
||||||
|
cef_resolve_callback_t> {
|
||||||
|
public:
|
||||||
|
CefResolveCallbackCppToC();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // USING_CEF_SHARED
|
||||||
|
#endif // CEF_LIBCEF_DLL_CPPTOC_RESOLVE_CALLBACK_CPPTOC_H_
|
@ -12,11 +12,13 @@
|
|||||||
|
|
||||||
#include "libcef_dll/cpptoc/completion_callback_cpptoc.h"
|
#include "libcef_dll/cpptoc/completion_callback_cpptoc.h"
|
||||||
#include "libcef_dll/cpptoc/request_context_handler_cpptoc.h"
|
#include "libcef_dll/cpptoc/request_context_handler_cpptoc.h"
|
||||||
|
#include "libcef_dll/cpptoc/resolve_callback_cpptoc.h"
|
||||||
#include "libcef_dll/cpptoc/scheme_handler_factory_cpptoc.h"
|
#include "libcef_dll/cpptoc/scheme_handler_factory_cpptoc.h"
|
||||||
#include "libcef_dll/ctocpp/cookie_manager_ctocpp.h"
|
#include "libcef_dll/ctocpp/cookie_manager_ctocpp.h"
|
||||||
#include "libcef_dll/ctocpp/dictionary_value_ctocpp.h"
|
#include "libcef_dll/ctocpp/dictionary_value_ctocpp.h"
|
||||||
#include "libcef_dll/ctocpp/request_context_ctocpp.h"
|
#include "libcef_dll/ctocpp/request_context_ctocpp.h"
|
||||||
#include "libcef_dll/ctocpp/value_ctocpp.h"
|
#include "libcef_dll/ctocpp/value_ctocpp.h"
|
||||||
|
#include "libcef_dll/transfer_util.h"
|
||||||
|
|
||||||
|
|
||||||
// STATIC METHODS - Body may be edited by hand.
|
// STATIC METHODS - Body may be edited by hand.
|
||||||
@ -355,6 +357,64 @@ void CefRequestContextCToCpp::CloseAllConnections(
|
|||||||
CefCompletionCallbackCppToC::Wrap(callback));
|
CefCompletionCallbackCppToC::Wrap(callback));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CefRequestContextCToCpp::ResolveHost(const CefString& origin,
|
||||||
|
CefRefPtr<CefResolveCallback> callback) {
|
||||||
|
cef_request_context_t* _struct = GetStruct();
|
||||||
|
if (CEF_MEMBER_MISSING(_struct, resolve_host))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
// Verify param: origin; type: string_byref_const
|
||||||
|
DCHECK(!origin.empty());
|
||||||
|
if (origin.empty())
|
||||||
|
return;
|
||||||
|
// Verify param: callback; type: refptr_diff
|
||||||
|
DCHECK(callback.get());
|
||||||
|
if (!callback.get())
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
_struct->resolve_host(_struct,
|
||||||
|
origin.GetStruct(),
|
||||||
|
CefResolveCallbackCppToC::Wrap(callback));
|
||||||
|
}
|
||||||
|
|
||||||
|
cef_errorcode_t CefRequestContextCToCpp::ResolveHostCached(
|
||||||
|
const CefString& origin, std::vector<CefString>& resolved_ips) {
|
||||||
|
cef_request_context_t* _struct = GetStruct();
|
||||||
|
if (CEF_MEMBER_MISSING(_struct, resolve_host_cached))
|
||||||
|
return ERR_FAILED;
|
||||||
|
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
// Verify param: origin; type: string_byref_const
|
||||||
|
DCHECK(!origin.empty());
|
||||||
|
if (origin.empty())
|
||||||
|
return ERR_FAILED;
|
||||||
|
|
||||||
|
// Translate param: resolved_ips; type: string_vec_byref
|
||||||
|
cef_string_list_t resolved_ipsList = cef_string_list_alloc();
|
||||||
|
DCHECK(resolved_ipsList);
|
||||||
|
if (resolved_ipsList)
|
||||||
|
transfer_string_list_contents(resolved_ips, resolved_ipsList);
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
cef_errorcode_t _retval = _struct->resolve_host_cached(_struct,
|
||||||
|
origin.GetStruct(),
|
||||||
|
resolved_ipsList);
|
||||||
|
|
||||||
|
// Restore param:resolved_ips; type: string_vec_byref
|
||||||
|
if (resolved_ipsList) {
|
||||||
|
resolved_ips.clear();
|
||||||
|
transfer_string_list_contents(resolved_ipsList, resolved_ips);
|
||||||
|
cef_string_list_free(resolved_ipsList);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return type: simple
|
||||||
|
return _retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// CONSTRUCTOR - Do not edit by hand.
|
// CONSTRUCTOR - Do not edit by hand.
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
#pragma message("Warning: "__FILE__" may be accessed wrapper-side only")
|
#pragma message("Warning: "__FILE__" may be accessed wrapper-side only")
|
||||||
#else // USING_CEF_SHARED
|
#else // USING_CEF_SHARED
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
#include "include/cef_request_context.h"
|
#include "include/cef_request_context.h"
|
||||||
#include "include/capi/cef_request_context_capi.h"
|
#include "include/capi/cef_request_context_capi.h"
|
||||||
#include "include/cef_scheme.h"
|
#include "include/cef_scheme.h"
|
||||||
@ -55,6 +56,10 @@ class CefRequestContextCToCpp
|
|||||||
void ClearCertificateExceptions(
|
void ClearCertificateExceptions(
|
||||||
CefRefPtr<CefCompletionCallback> callback) OVERRIDE;
|
CefRefPtr<CefCompletionCallback> callback) OVERRIDE;
|
||||||
void CloseAllConnections(CefRefPtr<CefCompletionCallback> callback) OVERRIDE;
|
void CloseAllConnections(CefRefPtr<CefCompletionCallback> callback) OVERRIDE;
|
||||||
|
void ResolveHost(const CefString& origin,
|
||||||
|
CefRefPtr<CefResolveCallback> callback) OVERRIDE;
|
||||||
|
cef_errorcode_t ResolveHostCached(const CefString& origin,
|
||||||
|
std::vector<CefString>& resolved_ips) OVERRIDE;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // USING_CEF_SHARED
|
#endif // USING_CEF_SHARED
|
||||||
|
65
libcef_dll/ctocpp/resolve_callback_ctocpp.cc
Normal file
65
libcef_dll/ctocpp/resolve_callback_ctocpp.cc
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
// Copyright (c) 2016 The Chromium Embedded Framework Authors. All rights
|
||||||
|
// reserved. Use of this source code is governed by a BSD-style license that
|
||||||
|
// can be found in the LICENSE file.
|
||||||
|
//
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// This file was generated by the CEF translator tool. If making changes by
|
||||||
|
// hand only do so within the body of existing method and function
|
||||||
|
// implementations. See the translator.README.txt file in the tools directory
|
||||||
|
// for more information.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "libcef_dll/ctocpp/resolve_callback_ctocpp.h"
|
||||||
|
#include "libcef_dll/transfer_util.h"
|
||||||
|
|
||||||
|
|
||||||
|
// VIRTUAL METHODS - Body may be edited by hand.
|
||||||
|
|
||||||
|
void CefResolveCallbackCToCpp::OnResolveCompleted(cef_errorcode_t result,
|
||||||
|
const std::vector<CefString>& resolved_ips) {
|
||||||
|
cef_resolve_callback_t* _struct = GetStruct();
|
||||||
|
if (CEF_MEMBER_MISSING(_struct, on_resolve_completed))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
// Unverified params: resolved_ips
|
||||||
|
|
||||||
|
// Translate param: resolved_ips; type: string_vec_byref_const
|
||||||
|
cef_string_list_t resolved_ipsList = cef_string_list_alloc();
|
||||||
|
DCHECK(resolved_ipsList);
|
||||||
|
if (resolved_ipsList)
|
||||||
|
transfer_string_list_contents(resolved_ips, resolved_ipsList);
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
_struct->on_resolve_completed(_struct,
|
||||||
|
result,
|
||||||
|
resolved_ipsList);
|
||||||
|
|
||||||
|
// Restore param:resolved_ips; type: string_vec_byref_const
|
||||||
|
if (resolved_ipsList)
|
||||||
|
cef_string_list_free(resolved_ipsList);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// CONSTRUCTOR - Do not edit by hand.
|
||||||
|
|
||||||
|
CefResolveCallbackCToCpp::CefResolveCallbackCToCpp() {
|
||||||
|
}
|
||||||
|
|
||||||
|
template<> cef_resolve_callback_t* CefCToCpp<CefResolveCallbackCToCpp,
|
||||||
|
CefResolveCallback, cef_resolve_callback_t>::UnwrapDerived(
|
||||||
|
CefWrapperType type, CefResolveCallback* c) {
|
||||||
|
NOTREACHED() << "Unexpected class type: " << type;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef NDEBUG
|
||||||
|
template<> base::AtomicRefCount CefCToCpp<CefResolveCallbackCToCpp,
|
||||||
|
CefResolveCallback, cef_resolve_callback_t>::DebugObjCt = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
template<> CefWrapperType CefCToCpp<CefResolveCallbackCToCpp,
|
||||||
|
CefResolveCallback, cef_resolve_callback_t>::kWrapperType =
|
||||||
|
WT_RESOLVE_CALLBACK;
|
42
libcef_dll/ctocpp/resolve_callback_ctocpp.h
Normal file
42
libcef_dll/ctocpp/resolve_callback_ctocpp.h
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
// Copyright (c) 2016 The Chromium Embedded Framework Authors. All rights
|
||||||
|
// reserved. Use of this source code is governed by a BSD-style license that
|
||||||
|
// can be found in the LICENSE file.
|
||||||
|
//
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// This file was generated by the CEF translator tool. If making changes by
|
||||||
|
// hand only do so within the body of existing method and function
|
||||||
|
// implementations. See the translator.README.txt file in the tools directory
|
||||||
|
// for more information.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef CEF_LIBCEF_DLL_CTOCPP_RESOLVE_CALLBACK_CTOCPP_H_
|
||||||
|
#define CEF_LIBCEF_DLL_CTOCPP_RESOLVE_CALLBACK_CTOCPP_H_
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef BUILDING_CEF_SHARED
|
||||||
|
#pragma message("Warning: "__FILE__" may be accessed DLL-side only")
|
||||||
|
#else // BUILDING_CEF_SHARED
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include "include/cef_request_context.h"
|
||||||
|
#include "include/capi/cef_request_context_capi.h"
|
||||||
|
#include "include/cef_scheme.h"
|
||||||
|
#include "include/capi/cef_scheme_capi.h"
|
||||||
|
#include "libcef_dll/ctocpp/ctocpp.h"
|
||||||
|
|
||||||
|
// Wrap a C structure with a C++ class.
|
||||||
|
// This class may be instantiated and accessed DLL-side only.
|
||||||
|
class CefResolveCallbackCToCpp
|
||||||
|
: public CefCToCpp<CefResolveCallbackCToCpp, CefResolveCallback,
|
||||||
|
cef_resolve_callback_t> {
|
||||||
|
public:
|
||||||
|
CefResolveCallbackCToCpp();
|
||||||
|
|
||||||
|
// CefResolveCallback methods.
|
||||||
|
void OnResolveCompleted(cef_errorcode_t result,
|
||||||
|
const std::vector<CefString>& resolved_ips) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // BUILDING_CEF_SHARED
|
||||||
|
#endif // CEF_LIBCEF_DLL_CTOCPP_RESOLVE_CALLBACK_CTOCPP_H_
|
@ -102,6 +102,7 @@
|
|||||||
#include "libcef_dll/ctocpp/render_handler_ctocpp.h"
|
#include "libcef_dll/ctocpp/render_handler_ctocpp.h"
|
||||||
#include "libcef_dll/ctocpp/render_process_handler_ctocpp.h"
|
#include "libcef_dll/ctocpp/render_process_handler_ctocpp.h"
|
||||||
#include "libcef_dll/ctocpp/request_handler_ctocpp.h"
|
#include "libcef_dll/ctocpp/request_handler_ctocpp.h"
|
||||||
|
#include "libcef_dll/ctocpp/resolve_callback_ctocpp.h"
|
||||||
#include "libcef_dll/ctocpp/resource_bundle_handler_ctocpp.h"
|
#include "libcef_dll/ctocpp/resource_bundle_handler_ctocpp.h"
|
||||||
#include "libcef_dll/ctocpp/resource_handler_ctocpp.h"
|
#include "libcef_dll/ctocpp/resource_handler_ctocpp.h"
|
||||||
#include "libcef_dll/ctocpp/response_filter_ctocpp.h"
|
#include "libcef_dll/ctocpp/response_filter_ctocpp.h"
|
||||||
@ -247,6 +248,7 @@ CEF_EXPORT void cef_shutdown() {
|
|||||||
&CefRenderProcessHandlerCToCpp::DebugObjCt));
|
&CefRenderProcessHandlerCToCpp::DebugObjCt));
|
||||||
DCHECK(base::AtomicRefCountIsZero(&CefRequestCallbackCppToC::DebugObjCt));
|
DCHECK(base::AtomicRefCountIsZero(&CefRequestCallbackCppToC::DebugObjCt));
|
||||||
DCHECK(base::AtomicRefCountIsZero(&CefRequestHandlerCToCpp::DebugObjCt));
|
DCHECK(base::AtomicRefCountIsZero(&CefRequestHandlerCToCpp::DebugObjCt));
|
||||||
|
DCHECK(base::AtomicRefCountIsZero(&CefResolveCallbackCToCpp::DebugObjCt));
|
||||||
DCHECK(base::AtomicRefCountIsZero(
|
DCHECK(base::AtomicRefCountIsZero(
|
||||||
&CefResourceBundleHandlerCToCpp::DebugObjCt));
|
&CefResourceBundleHandlerCToCpp::DebugObjCt));
|
||||||
DCHECK(base::AtomicRefCountIsZero(&CefResourceHandlerCToCpp::DebugObjCt));
|
DCHECK(base::AtomicRefCountIsZero(&CefResourceHandlerCToCpp::DebugObjCt));
|
||||||
|
@ -60,6 +60,7 @@
|
|||||||
#include "libcef_dll/cpptoc/render_handler_cpptoc.h"
|
#include "libcef_dll/cpptoc/render_handler_cpptoc.h"
|
||||||
#include "libcef_dll/cpptoc/render_process_handler_cpptoc.h"
|
#include "libcef_dll/cpptoc/render_process_handler_cpptoc.h"
|
||||||
#include "libcef_dll/cpptoc/request_handler_cpptoc.h"
|
#include "libcef_dll/cpptoc/request_handler_cpptoc.h"
|
||||||
|
#include "libcef_dll/cpptoc/resolve_callback_cpptoc.h"
|
||||||
#include "libcef_dll/cpptoc/resource_bundle_handler_cpptoc.h"
|
#include "libcef_dll/cpptoc/resource_bundle_handler_cpptoc.h"
|
||||||
#include "libcef_dll/cpptoc/resource_handler_cpptoc.h"
|
#include "libcef_dll/cpptoc/resource_handler_cpptoc.h"
|
||||||
#include "libcef_dll/cpptoc/response_filter_cpptoc.h"
|
#include "libcef_dll/cpptoc/response_filter_cpptoc.h"
|
||||||
@ -239,6 +240,7 @@ CEF_GLOBAL void CefShutdown() {
|
|||||||
&CefRenderProcessHandlerCppToC::DebugObjCt));
|
&CefRenderProcessHandlerCppToC::DebugObjCt));
|
||||||
DCHECK(base::AtomicRefCountIsZero(&CefRequestCallbackCToCpp::DebugObjCt));
|
DCHECK(base::AtomicRefCountIsZero(&CefRequestCallbackCToCpp::DebugObjCt));
|
||||||
DCHECK(base::AtomicRefCountIsZero(&CefRequestHandlerCppToC::DebugObjCt));
|
DCHECK(base::AtomicRefCountIsZero(&CefRequestHandlerCppToC::DebugObjCt));
|
||||||
|
DCHECK(base::AtomicRefCountIsZero(&CefResolveCallbackCppToC::DebugObjCt));
|
||||||
DCHECK(base::AtomicRefCountIsZero(
|
DCHECK(base::AtomicRefCountIsZero(
|
||||||
&CefResourceBundleHandlerCppToC::DebugObjCt));
|
&CefResourceBundleHandlerCppToC::DebugObjCt));
|
||||||
DCHECK(base::AtomicRefCountIsZero(&CefResourceHandlerCppToC::DebugObjCt));
|
DCHECK(base::AtomicRefCountIsZero(&CefResourceHandlerCppToC::DebugObjCt));
|
||||||
|
@ -76,6 +76,7 @@ enum CefWrapperType {
|
|||||||
WT_REQUEST_CONTEXT,
|
WT_REQUEST_CONTEXT,
|
||||||
WT_REQUEST_CONTEXT_HANDLER,
|
WT_REQUEST_CONTEXT_HANDLER,
|
||||||
WT_REQUEST_HANDLER,
|
WT_REQUEST_HANDLER,
|
||||||
|
WT_RESOLVE_CALLBACK,
|
||||||
WT_RESOURCE_BUNDLE,
|
WT_RESOURCE_BUNDLE,
|
||||||
WT_RESOURCE_BUNDLE_HANDLER,
|
WT_RESOURCE_BUNDLE_HANDLER,
|
||||||
WT_RESOURCE_HANDLER,
|
WT_RESOURCE_HANDLER,
|
||||||
|
@ -654,17 +654,23 @@ TEST(RequestContextTest, NoReferrerLinkDifferentOrigin) {
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
const char kResolveOrigin[] = "http://www.google.com";
|
||||||
|
|
||||||
class MethodTestHandler : public TestHandler {
|
class MethodTestHandler : public TestHandler {
|
||||||
public:
|
public:
|
||||||
enum Method {
|
enum Method {
|
||||||
METHOD_CLEAR_CERTIFICATE_EXCEPTIONS,
|
METHOD_CLEAR_CERTIFICATE_EXCEPTIONS,
|
||||||
METHOD_CLOSE_ALL_CONNECTIONS,
|
METHOD_CLOSE_ALL_CONNECTIONS,
|
||||||
|
METHOD_RESOLVE_HOST,
|
||||||
};
|
};
|
||||||
|
|
||||||
class CompletionCallback : public CefCompletionCallback {
|
class CompletionCallback : public CefCompletionCallback,
|
||||||
|
public CefResolveCallback {
|
||||||
public:
|
public:
|
||||||
explicit CompletionCallback(MethodTestHandler* test_handler)
|
CompletionCallback(MethodTestHandler* test_handler,
|
||||||
: test_handler_(test_handler) {
|
CefRefPtr<CefBrowser> browser)
|
||||||
|
: test_handler_(test_handler),
|
||||||
|
browser_(browser) {
|
||||||
}
|
}
|
||||||
|
|
||||||
~CompletionCallback() override {
|
~CompletionCallback() override {
|
||||||
@ -679,12 +685,22 @@ class MethodTestHandler : public TestHandler {
|
|||||||
|
|
||||||
// OnComplete should be executed only one time.
|
// OnComplete should be executed only one time.
|
||||||
EXPECT_TRUE(test_handler_);
|
EXPECT_TRUE(test_handler_);
|
||||||
test_handler_->OnCompleteCallback();
|
test_handler_->OnCompleteCallback(browser_);
|
||||||
test_handler_ = nullptr;
|
test_handler_ = nullptr;
|
||||||
|
browser_ = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnResolveCompleted(
|
||||||
|
cef_errorcode_t result,
|
||||||
|
const std::vector<CefString>& resolved_ips) override {
|
||||||
|
EXPECT_EQ(ERR_NONE, result);
|
||||||
|
EXPECT_TRUE(!resolved_ips.empty());
|
||||||
|
OnComplete();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MethodTestHandler* test_handler_;
|
MethodTestHandler* test_handler_;
|
||||||
|
CefRefPtr<CefBrowser> browser_;
|
||||||
|
|
||||||
IMPLEMENT_REFCOUNTING(CompletionCallback);
|
IMPLEMENT_REFCOUNTING(CompletionCallback);
|
||||||
};
|
};
|
||||||
@ -717,19 +733,43 @@ class MethodTestHandler : public TestHandler {
|
|||||||
int httpStatusCode) override {
|
int httpStatusCode) override {
|
||||||
CefRefPtr<CefRequestContext> context =
|
CefRefPtr<CefRequestContext> context =
|
||||||
browser->GetHost()->GetRequestContext();
|
browser->GetHost()->GetRequestContext();
|
||||||
CefRefPtr<CefCompletionCallback> callback = new CompletionCallback(this);
|
CefRefPtr<CompletionCallback> callback =
|
||||||
|
new CompletionCallback(this, browser);
|
||||||
if (method_ == METHOD_CLEAR_CERTIFICATE_EXCEPTIONS)
|
if (method_ == METHOD_CLEAR_CERTIFICATE_EXCEPTIONS)
|
||||||
context->ClearCertificateExceptions(callback);
|
context->ClearCertificateExceptions(callback);
|
||||||
else if (method_ == METHOD_CLOSE_ALL_CONNECTIONS)
|
else if (method_ == METHOD_CLOSE_ALL_CONNECTIONS)
|
||||||
context->CloseAllConnections(callback);
|
context->CloseAllConnections(callback);
|
||||||
|
else if (method_ == METHOD_RESOLVE_HOST)
|
||||||
|
context->ResolveHost(kResolveOrigin, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnCompleteCallback() {
|
void OnCompleteCallback(CefRefPtr<CefBrowser> browser) {
|
||||||
EXPECT_UI_THREAD();
|
EXPECT_UI_THREAD();
|
||||||
EXPECT_FALSE(got_completion_callback_);
|
EXPECT_FALSE(got_completion_callback_);
|
||||||
got_completion_callback_.yes();
|
got_completion_callback_.yes();
|
||||||
|
|
||||||
|
if (method_ == METHOD_RESOLVE_HOST) {
|
||||||
|
// Now try a cached request.
|
||||||
|
CefPostTask(TID_IO,
|
||||||
|
base::Bind(&MethodTestHandler::ResolveHostCached, this, browser));
|
||||||
|
} else {
|
||||||
DestroyTest();
|
DestroyTest();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ResolveHostCached(CefRefPtr<CefBrowser> browser) {
|
||||||
|
EXPECT_IO_THREAD();
|
||||||
|
|
||||||
|
CefRefPtr<CefRequestContext> context =
|
||||||
|
browser->GetHost()->GetRequestContext();
|
||||||
|
std::vector<CefString> resolved_ips;
|
||||||
|
cef_errorcode_t result =
|
||||||
|
context->ResolveHostCached(kResolveOrigin, resolved_ips);
|
||||||
|
EXPECT_EQ(ERR_NONE, result);
|
||||||
|
EXPECT_TRUE(!resolved_ips.empty());
|
||||||
|
|
||||||
|
CefPostTask(TID_UI, base::Bind(&MethodTestHandler::DestroyTest, this));
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void DestroyTest() override {
|
void DestroyTest() override {
|
||||||
@ -782,3 +822,21 @@ TEST(RequestContextTest, CloseAllConnectionsCustom) {
|
|||||||
handler->ExecuteTest();
|
handler->ExecuteTest();
|
||||||
ReleaseAndWaitForDestructor(handler);
|
ReleaseAndWaitForDestructor(handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Test CefRequestContext::ResolveHost with the global context.
|
||||||
|
TEST(RequestContextTest, ResolveHostGlobal) {
|
||||||
|
CefRefPtr<MethodTestHandler> handler =
|
||||||
|
new MethodTestHandler(true,
|
||||||
|
MethodTestHandler::METHOD_RESOLVE_HOST);
|
||||||
|
handler->ExecuteTest();
|
||||||
|
ReleaseAndWaitForDestructor(handler);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test CefRequestContext::ResolveHost with a custom context.
|
||||||
|
TEST(RequestContextTest, ResolveHostCustom) {
|
||||||
|
CefRefPtr<MethodTestHandler> handler =
|
||||||
|
new MethodTestHandler(false,
|
||||||
|
MethodTestHandler::METHOD_RESOLVE_HOST);
|
||||||
|
handler->ExecuteTest();
|
||||||
|
ReleaseAndWaitForDestructor(handler);
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user