- Pass SSL certificate information to CefRequestHandler::OnCertificateError via a new CefSSLInfo interface (issue #1530).

- cefclient: Improve error message text and use a data: URI instead of LoadString for loading error messages (issue #579).
- Add functions in cef_url.h for base64 and URI encoding/decoding (issue #579).

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@2028 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt 2015-02-11 18:15:04 +00:00
parent cda8819b62
commit 7c5cb76692
34 changed files with 2005 additions and 24 deletions

View File

@ -994,6 +994,10 @@
'libcef/browser/software_output_device_osr.h',
'libcef/browser/speech_recognition_manager_delegate.cc',
'libcef/browser/speech_recognition_manager_delegate.h',
'libcef/browser/ssl_cert_principal_impl.cc',
'libcef/browser/ssl_cert_principal_impl.h',
'libcef/browser/ssl_info_impl.cc',
'libcef/browser/ssl_info_impl.h',
'libcef/browser/stream_impl.cc',
'libcef/browser/stream_impl.h',
'libcef/browser/trace_impl.cc',

View File

@ -55,6 +55,7 @@
'include/cef_resource_handler.h',
'include/cef_response.h',
'include/cef_scheme.h',
'include/cef_ssl_info.h',
'include/cef_stream.h',
'include/cef_string_visitor.h',
'include/cef_task.h',
@ -111,6 +112,7 @@
'include/capi/cef_resource_handler_capi.h',
'include/capi/cef_response_capi.h',
'include/capi/cef_scheme_capi.h',
'include/capi/cef_ssl_info_capi.h',
'include/capi/cef_stream_capi.h',
'include/capi/cef_string_visitor_capi.h',
'include/capi/cef_task_capi.h',
@ -250,6 +252,10 @@
'libcef_dll/cpptoc/response_cpptoc.h',
'libcef_dll/ctocpp/run_file_dialog_callback_ctocpp.cc',
'libcef_dll/ctocpp/run_file_dialog_callback_ctocpp.h',
'libcef_dll/cpptoc/sslcert_principal_cpptoc.cc',
'libcef_dll/cpptoc/sslcert_principal_cpptoc.h',
'libcef_dll/cpptoc/sslinfo_cpptoc.cc',
'libcef_dll/cpptoc/sslinfo_cpptoc.h',
'libcef_dll/ctocpp/scheme_handler_factory_ctocpp.cc',
'libcef_dll/ctocpp/scheme_handler_factory_ctocpp.h',
'libcef_dll/cpptoc/scheme_registrar_cpptoc.cc',
@ -422,6 +428,10 @@
'libcef_dll/ctocpp/response_ctocpp.h',
'libcef_dll/cpptoc/run_file_dialog_callback_cpptoc.cc',
'libcef_dll/cpptoc/run_file_dialog_callback_cpptoc.h',
'libcef_dll/ctocpp/sslcert_principal_ctocpp.cc',
'libcef_dll/ctocpp/sslcert_principal_ctocpp.h',
'libcef_dll/ctocpp/sslinfo_ctocpp.cc',
'libcef_dll/ctocpp/sslinfo_ctocpp.h',
'libcef_dll/cpptoc/scheme_handler_factory_cpptoc.cc',
'libcef_dll/cpptoc/scheme_handler_factory_cpptoc.h',
'libcef_dll/ctocpp/scheme_registrar_ctocpp.cc',

View File

@ -45,6 +45,7 @@
#include "include/capi/cef_request_capi.h"
#include "include/capi/cef_resource_handler_capi.h"
#include "include/capi/cef_response_capi.h"
#include "include/capi/cef_ssl_info_capi.h"
#include "include/capi/cef_web_plugin_capi.h"
#ifdef __cplusplus
@ -191,7 +192,8 @@ typedef struct _cef_request_handler_t {
// be accepted without calling this function.
///
int (CEF_CALLBACK *on_certificate_error)(struct _cef_request_handler_t* self,
cef_errorcode_t cert_error, const cef_string_t* request_url,
struct _cef_browser_t* browser, cef_errorcode_t cert_error,
const cef_string_t* request_url, struct _cef_sslinfo_t* ssl_info,
struct _cef_allow_certificate_error_callback_t* callback);
///

View File

@ -0,0 +1,180 @@
// Copyright (c) 2015 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool and should not edited
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
#ifndef CEF_INCLUDE_CAPI_CEF_SSL_INFO_CAPI_H_
#define CEF_INCLUDE_CAPI_CEF_SSL_INFO_CAPI_H_
#pragma once
#include "include/capi/cef_base_capi.h"
#include "include/capi/cef_values_capi.h"
#ifdef __cplusplus
extern "C" {
#endif
///
// Structure representing the issuer or subject field of an X.509 certificate.
///
typedef struct _cef_sslcert_principal_t {
///
// Base structure.
///
cef_base_t base;
///
// Returns a name that can be used to represent the issuer. It tries in this
// order: CN, O and OU and returns the first non-NULL one found.
///
// The resulting string must be freed by calling cef_string_userfree_free().
cef_string_userfree_t (CEF_CALLBACK *get_display_name)(
struct _cef_sslcert_principal_t* self);
///
// Returns the common name.
///
// The resulting string must be freed by calling cef_string_userfree_free().
cef_string_userfree_t (CEF_CALLBACK *get_common_name)(
struct _cef_sslcert_principal_t* self);
///
// Returns the locality name.
///
// The resulting string must be freed by calling cef_string_userfree_free().
cef_string_userfree_t (CEF_CALLBACK *get_locality_name)(
struct _cef_sslcert_principal_t* self);
///
// Returns the state or province name.
///
// The resulting string must be freed by calling cef_string_userfree_free().
cef_string_userfree_t (CEF_CALLBACK *get_state_or_province_name)(
struct _cef_sslcert_principal_t* self);
///
// Returns the country name.
///
// The resulting string must be freed by calling cef_string_userfree_free().
cef_string_userfree_t (CEF_CALLBACK *get_country_name)(
struct _cef_sslcert_principal_t* self);
///
// Retrieve the list of street addresses.
///
void (CEF_CALLBACK *get_street_addresses)(
struct _cef_sslcert_principal_t* self, cef_string_list_t addresses);
///
// Retrieve the list of organization names.
///
void (CEF_CALLBACK *get_organization_names)(
struct _cef_sslcert_principal_t* self, cef_string_list_t names);
///
// Retrieve the list of organization unit names.
///
void (CEF_CALLBACK *get_organization_unit_names)(
struct _cef_sslcert_principal_t* self, cef_string_list_t names);
///
// Retrieve the list of domain components.
///
void (CEF_CALLBACK *get_domain_components)(
struct _cef_sslcert_principal_t* self, cef_string_list_t components);
} cef_sslcert_principal_t;
///
// Structure representing SSL information.
///
typedef struct _cef_sslinfo_t {
///
// Base structure.
///
cef_base_t base;
///
// Returns the subject of the X.509 certificate. For HTTPS server certificates
// this represents the web server. The common name of the subject should
// match the host name of the web server.
///
struct _cef_sslcert_principal_t* (CEF_CALLBACK *get_subject)(
struct _cef_sslinfo_t* self);
///
// Returns the issuer of the X.509 certificate.
///
struct _cef_sslcert_principal_t* (CEF_CALLBACK *get_issuer)(
struct _cef_sslinfo_t* self);
///
// Returns the DER encoded serial number for the X.509 certificate. The value
// possibly includes a leading 00 byte.
///
struct _cef_binary_value_t* (CEF_CALLBACK *get_serial_number)(
struct _cef_sslinfo_t* self);
///
// Returns the date before which the X.509 certificate is invalid.
// CefTime.GetTimeT() will return 0 if no date was specified.
///
cef_time_t (CEF_CALLBACK *get_valid_start)(struct _cef_sslinfo_t* self);
///
// Returns the date after which the X.509 certificate is invalid.
// CefTime.GetTimeT() will return 0 if no date was specified.
///
cef_time_t (CEF_CALLBACK *get_valid_expiry)(struct _cef_sslinfo_t* self);
///
// Returns the DER encoded data for the X.509 certificate.
///
struct _cef_binary_value_t* (CEF_CALLBACK *get_derencoded)(
struct _cef_sslinfo_t* self);
///
// Returns the PEM encoded data for the X.509 certificate.
///
struct _cef_binary_value_t* (CEF_CALLBACK *get_pemencoded)(
struct _cef_sslinfo_t* self);
} cef_sslinfo_t;
#ifdef __cplusplus
}
#endif
#endif // CEF_INCLUDE_CAPI_CEF_SSL_INFO_CAPI_H_

View File

@ -75,6 +75,44 @@ CEF_EXPORT cef_string_userfree_t cef_get_mime_type(
CEF_EXPORT void cef_get_extensions_for_mime_type(const cef_string_t* mime_type,
cef_string_list_t extensions);
///
// Encodes |data| as a base64 string.
///
// The resulting string must be freed by calling cef_string_userfree_free().
CEF_EXPORT cef_string_userfree_t cef_base64encode(const void* data,
size_t data_size);
///
// Decodes the base64 encoded string |data|. The returned value will be NULL if
// the decoding fails.
///
CEF_EXPORT struct _cef_binary_value_t* cef_base64decode(
const cef_string_t* data);
///
// Escapes characters in |text| which are unsuitable for use as a query
// parameter value. Everything except alphanumerics and -_.!~*'() will be
// converted to "%XX". If |use_plus| is true (1) spaces will change to "+". The
// result is basically the same as encodeURIComponent in Javacript.
///
// The resulting string must be freed by calling cef_string_userfree_free().
CEF_EXPORT cef_string_userfree_t cef_uriencode(const cef_string_t* text,
int use_plus);
///
// Unescapes |text| and returns the result. Unescaping consists of looking for
// the exact pattern "%XX" where each X is a hex digit and converting to the
// character with the numerical value of those digits (e.g. "i%20=%203%3b"
// unescapes to "i = 3;"). If |convert_to_utf8| is true (1) this function will
// attempt to interpret the initial decoded result as UTF-8. If the result is
// convertable into UTF-8 it will be returned as converted. Otherwise the
// initial decoded result will be returned. The |unescape_rule| parameter
// supports further customization the decoding process.
///
// The resulting string must be freed by calling cef_string_userfree_free().
CEF_EXPORT cef_string_userfree_t cef_uridecode(const cef_string_t* text,
int convert_to_utf8, cef_uri_unescape_rule_t unescape_rule);
#ifdef __cplusplus
}
#endif

View File

@ -45,6 +45,7 @@
#include "include/cef_resource_handler.h"
#include "include/cef_response.h"
#include "include/cef_request.h"
#include "include/cef_ssl_info.h"
#include "include/cef_web_plugin.h"
///
@ -206,8 +207,10 @@ class CefRequestHandler : public virtual CefBase {
///
/*--cef()--*/
virtual bool OnCertificateError(
CefRefPtr<CefBrowser> browser,
cef_errorcode_t cert_error,
const CefString& request_url,
CefRefPtr<CefSSLInfo> ssl_info,
CefRefPtr<CefAllowCertificateErrorCallback> callback) {
return false;
}

162
include/cef_ssl_info.h Normal file
View File

@ -0,0 +1,162 @@
// Copyright (c) 2015 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// ---------------------------------------------------------------------------
//
// The contents of this file must follow a specific format in order to
// support the CEF translator tool. See the translator.README.txt file in the
// tools directory for more information.
//
#ifndef CEF_INCLUDE_CEF_SSL_INFO_H_
#define CEF_INCLUDE_CEF_SSL_INFO_H_
#pragma once
#include <vector>
#include "include/cef_base.h"
#include "include/cef_values.h"
///
// Class representing the issuer or subject field of an X.509 certificate.
///
/*--cef(source=library)--*/
class CefSSLCertPrincipal : public virtual CefBase {
public:
///
// Returns a name that can be used to represent the issuer. It tries in this
// order: CN, O and OU and returns the first non-empty one found.
///
/*--cef()--*/
virtual CefString GetDisplayName() =0;
///
// Returns the common name.
///
/*--cef()--*/
virtual CefString GetCommonName() =0;
///
// Returns the locality name.
///
/*--cef()--*/
virtual CefString GetLocalityName() =0;
///
// Returns the state or province name.
///
/*--cef()--*/
virtual CefString GetStateOrProvinceName() =0;
///
// Returns the country name.
///
/*--cef()--*/
virtual CefString GetCountryName() =0;
///
// Retrieve the list of street addresses.
///
/*--cef()--*/
virtual void GetStreetAddresses(std::vector<CefString>& addresses) =0;
///
// Retrieve the list of organization names.
///
/*--cef()--*/
virtual void GetOrganizationNames(std::vector<CefString>& names) =0;
///
// Retrieve the list of organization unit names.
///
/*--cef()--*/
virtual void GetOrganizationUnitNames(std::vector<CefString>& names) =0;
///
// Retrieve the list of domain components.
///
/*--cef()--*/
virtual void GetDomainComponents(std::vector<CefString>& components) =0;
};
///
// Class representing SSL information.
///
/*--cef(source=library)--*/
class CefSSLInfo : public virtual CefBase {
public:
///
// Returns the subject of the X.509 certificate. For HTTPS server
// certificates this represents the web server. The common name of the
// subject should match the host name of the web server.
///
/*--cef()--*/
virtual CefRefPtr<CefSSLCertPrincipal> GetSubject() =0;
///
// Returns the issuer of the X.509 certificate.
///
/*--cef()--*/
virtual CefRefPtr<CefSSLCertPrincipal> GetIssuer() =0;
///
// Returns the DER encoded serial number for the X.509 certificate. The value
// possibly includes a leading 00 byte.
///
/*--cef()--*/
virtual CefRefPtr<CefBinaryValue> GetSerialNumber() =0;
///
// Returns the date before which the X.509 certificate is invalid.
// CefTime.GetTimeT() will return 0 if no date was specified.
///
/*--cef()--*/
virtual CefTime GetValidStart() =0;
///
// Returns the date after which the X.509 certificate is invalid.
// CefTime.GetTimeT() will return 0 if no date was specified.
///
/*--cef()--*/
virtual CefTime GetValidExpiry() =0;
///
// Returns the DER encoded data for the X.509 certificate.
///
/*--cef()--*/
virtual CefRefPtr<CefBinaryValue> GetDEREncoded() =0;
///
// Returns the PEM encoded data for the X.509 certificate.
///
/*--cef()--*/
virtual CefRefPtr<CefBinaryValue> GetPEMEncoded() =0;
};
#endif // CEF_INCLUDE_CEF_SSL_INFO_H_

View File

@ -41,6 +41,7 @@
#include <vector>
#include "include/cef_base.h"
#include "include/cef_values.h"
///
// Parse the specified |url| into its component parts.
@ -74,4 +75,41 @@ CefString CefGetMimeType(const CefString& extension);
void CefGetExtensionsForMimeType(const CefString& mime_type,
std::vector<CefString>& extensions);
///
// Encodes |data| as a base64 string.
///
/*--cef()--*/
CefString CefBase64Encode(const void* data, size_t data_size);
///
// Decodes the base64 encoded string |data|. The returned value will be NULL if
// the decoding fails.
///
/*--cef()--*/
CefRefPtr<CefBinaryValue> CefBase64Decode(const CefString& data);
///
// Escapes characters in |text| which are unsuitable for use as a query
// parameter value. Everything except alphanumerics and -_.!~*'() will be
// converted to "%XX". If |use_plus| is true spaces will change to "+". The
// result is basically the same as encodeURIComponent in Javacript.
///
/*--cef()--*/
CefString CefURIEncode(const CefString& text, bool use_plus);
///
// Unescapes |text| and returns the result. Unescaping consists of looking for
// the exact pattern "%XX" where each X is a hex digit and converting to the
// character with the numerical value of those digits (e.g. "i%20=%203%3b"
// unescapes to "i = 3;"). If |convert_to_utf8| is true this function will
// attempt to interpret the initial decoded result as UTF-8. If the result is
// convertable into UTF-8 it will be returned as converted. Otherwise the
// initial decoded result will be returned. The |unescape_rule| parameter
// supports further customization the decoding process.
///
/*--cef()--*/
CefString CefURIDecode(const CefString& text,
bool convert_to_utf8,
cef_uri_unescape_rule_t unescape_rule);
#endif // CEF_INCLUDE_CEF_URL_H_

View File

@ -1927,6 +1927,57 @@ typedef struct _cef_cursor_info_t {
cef_size_t size;
} cef_cursor_info_t;
///
// URI unescape rules passed to CefURIDecode().
///
typedef enum {
///
// Don't unescape anything at all.
///
UU_NONE = 0,
///
// Don't unescape anything special, but all normal unescaping will happen.
// This is a placeholder and can't be combined with other flags (since it's
// just the absence of them). All other unescape rules imply "normal" in
// addition to their special meaning. Things like escaped letters, digits,
// and most symbols will get unescaped with this mode.
///
UU_NORMAL = 1,
///
// Convert %20 to spaces. In some places where we're showing URLs, we may
// want this. In places where the URL may be copied and pasted out, then
// you wouldn't want this since it might not be interpreted in one piece
// by other applications.
///
UU_SPACES = 2,
///
// Unescapes various characters that will change the meaning of URLs,
// including '%', '+', '&', '/', '#'. If we unescaped these characters, the
// resulting URL won't be the same as the source one. This flag is used when
// generating final output like filenames for URLs where we won't be
// interpreting as a URL and want to do as much unescaping as possible.
///
UU_URL_SPECIAL_CHARS = 4,
///
// Unescapes control characters such as %01. This INCLUDES NULLs. This is
// used for rare cases such as data: URL decoding where the result is binary
// data. This flag also unescapes BiDi control characters.
//
// DO NOT use CONTROL_CHARS if the URL is going to be displayed in the UI
// for security reasons.
///
UU_CONTROL_CHARS = 8,
///
// URL queries use "+" for space. This flag controls that replacement.
///
UU_REPLACE_PLUS_WITH_SPACE = 16,
} cef_uri_unescape_rule_t;
#ifdef __cplusplus
}
#endif

View File

@ -20,6 +20,7 @@
#include "libcef/browser/printing/printing_message_filter.h"
#include "libcef/browser/resource_dispatcher_host_delegate.h"
#include "libcef/browser/speech_recognition_manager_delegate.h"
#include "libcef/browser/ssl_info_impl.h"
#include "libcef/browser/thread_util.h"
#include "libcef/browser/web_plugin_impl.h"
#include "libcef/common/cef_switches.h"
@ -774,13 +775,15 @@ void CefContentBrowserClient::AllowCertificateError(
if (!handler.get())
return;
CefRefPtr<CefSSLInfo> cef_ssl_info = new CefSSLInfoImpl(ssl_info);
CefRefPtr<CefAllowCertificateErrorCallbackImpl> callbackImpl;
if (overridable && !strict_enforcement)
callbackImpl = new CefAllowCertificateErrorCallbackImpl(callback);
bool proceed = handler->OnCertificateError(
static_cast<cef_errorcode_t>(cert_error), request_url.spec(),
callbackImpl.get());
browser.get(), static_cast<cef_errorcode_t>(cert_error),
request_url.spec(), cef_ssl_info, callbackImpl.get());
if (!proceed && callbackImpl.get())
callbackImpl->Disconnect();

View File

@ -0,0 +1,66 @@
// Copyright (c) 2015 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.
#include "libcef/browser/ssl_cert_principal_impl.h"
namespace {
void TransferVector(const std::vector<std::string>& source,
std::vector<CefString>& target) {
if (!target.empty())
target.clear();
if (!source.empty()) {
std::vector<std::string>::const_iterator it = source.begin();
for (; it != source.end(); ++it)
target.push_back(*it);
}
}
} // namespace
CefSSLCertPrincipalImpl::CefSSLCertPrincipalImpl(
const net::CertPrincipal& value)
: value_(value) {
}
CefString CefSSLCertPrincipalImpl::GetDisplayName() {
return value_.GetDisplayName();
}
CefString CefSSLCertPrincipalImpl::GetCommonName() {
return value_.common_name;
}
CefString CefSSLCertPrincipalImpl::GetLocalityName() {
return value_.locality_name;
}
CefString CefSSLCertPrincipalImpl::GetStateOrProvinceName() {
return value_.state_or_province_name;
}
CefString CefSSLCertPrincipalImpl::GetCountryName() {
return value_.country_name;
}
void CefSSLCertPrincipalImpl::GetStreetAddresses(
std::vector<CefString>& addresses) {
TransferVector(value_.street_addresses, addresses);
}
void CefSSLCertPrincipalImpl::GetOrganizationNames(
std::vector<CefString>& names) {
TransferVector(value_.organization_names, names);
}
void CefSSLCertPrincipalImpl::GetOrganizationUnitNames(
std::vector<CefString>& names) {
TransferVector(value_.organization_unit_names, names);
}
void CefSSLCertPrincipalImpl::GetDomainComponents(
std::vector<CefString>& components) {
TransferVector(value_.domain_components, components);
}

View File

@ -0,0 +1,36 @@
// Copyright (c) 2015 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.
#ifndef CEF_LIBCEF_BROWSER_SSL_CERT_PRINCIPAL_IMPL_H_
#define CEF_LIBCEF_BROWSER_SSL_CERT_PRINCIPAL_IMPL_H_
#pragma once
#include "include/cef_ssl_info.h"
#include "net/cert/x509_cert_types.h"
// CefSSLCertPrincipal implementation
class CefSSLCertPrincipalImpl : public CefSSLCertPrincipal {
public:
explicit CefSSLCertPrincipalImpl(const net::CertPrincipal& value);
// CefSSLCertPrincipal methods.
CefString GetDisplayName() override;
CefString GetCommonName() override;
CefString GetLocalityName() override;
CefString GetStateOrProvinceName() override;
CefString GetCountryName() override;
void GetStreetAddresses(std::vector<CefString>& addresses) override;
void GetOrganizationNames(std::vector<CefString>& names) override;
void GetOrganizationUnitNames(std::vector<CefString>& names) override;
void GetDomainComponents(std::vector<CefString>& components) override;
private:
net::CertPrincipal value_;
IMPLEMENT_REFCOUNTING(CefSSLCertPrincipalImpl);
DISALLOW_COPY_AND_ASSIGN(CefSSLCertPrincipalImpl);
};
#endif // CEF_LIBCEF_BROWSER_SSL_CERT_PRINCIPAL_IMPL_H_

View File

@ -0,0 +1,70 @@
// Copyright (c) 2015 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.
#include "libcef/browser/ssl_info_impl.h"
#include "libcef/browser/ssl_cert_principal_impl.h"
#include "libcef/common/time_util.h"
#include "net/cert/x509_certificate.h"
CefSSLInfoImpl::CefSSLInfoImpl(const net::SSLInfo& value) {
if (value.cert.get()) {
subject_ = new CefSSLCertPrincipalImpl(value.cert->subject());
issuer_ = new CefSSLCertPrincipalImpl(value.cert->issuer());
const std::string& serial_number = value.cert->serial_number();
serial_number_ = CefBinaryValue::Create(serial_number.c_str(),
serial_number.size());
const base::Time& valid_start = value.cert->valid_start();
if (!valid_start.is_null())
cef_time_from_basetime(valid_start, valid_start_);
const base::Time& valid_expiry = value.cert->valid_expiry();
if (!valid_expiry.is_null())
cef_time_from_basetime(valid_expiry, valid_expiry_);
net::X509Certificate::OSCertHandle os_handle = value.cert->os_cert_handle();
if (os_handle) {
std::string encoded;
if (value.cert->GetDEREncoded(os_handle, &encoded)) {
der_encoded_ = CefBinaryValue::Create(encoded.c_str(),
encoded.size());
}
encoded.clear();
if (value.cert->GetPEMEncoded(os_handle, &encoded)) {
pem_encoded_ = CefBinaryValue::Create(encoded.c_str(),
encoded.size());
}
}
}
}
CefRefPtr<CefSSLCertPrincipal> CefSSLInfoImpl::GetSubject() {
return subject_;
}
CefRefPtr<CefSSLCertPrincipal> CefSSLInfoImpl::GetIssuer() {
return issuer_;
}
CefRefPtr<CefBinaryValue> CefSSLInfoImpl::GetSerialNumber() {
return serial_number_;
}
CefTime CefSSLInfoImpl::GetValidStart() {
return valid_start_;
}
CefTime CefSSLInfoImpl::GetValidExpiry() {
return valid_expiry_;
}
CefRefPtr<CefBinaryValue> CefSSLInfoImpl::GetDEREncoded() {
return der_encoded_;
}
CefRefPtr<CefBinaryValue> CefSSLInfoImpl::GetPEMEncoded() {
return pem_encoded_;
}

View File

@ -0,0 +1,40 @@
// Copyright (c) 2015 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.
#ifndef CEF_LIBCEF_BROWSER_SSL_INFO_IMPL_H_
#define CEF_LIBCEF_BROWSER_SSL_INFO_IMPL_H_
#pragma once
#include "include/cef_ssl_info.h"
#include "net/ssl/ssl_info.h"
// CefSSLInfo implementation
class CefSSLInfoImpl : public CefSSLInfo {
public:
explicit CefSSLInfoImpl(const net::SSLInfo& value);
// CefSSLInfo methods.
CefRefPtr<CefSSLCertPrincipal> GetSubject() override;
CefRefPtr<CefSSLCertPrincipal> GetIssuer() override;
CefRefPtr<CefBinaryValue> GetSerialNumber() override;
CefTime GetValidStart() override;
CefTime GetValidExpiry() override;
CefRefPtr<CefBinaryValue> GetDEREncoded() override;
CefRefPtr<CefBinaryValue> GetPEMEncoded() override;
private:
CefRefPtr<CefSSLCertPrincipal> subject_;
CefRefPtr<CefSSLCertPrincipal> issuer_;
CefRefPtr<CefBinaryValue> serial_number_;
CefTime valid_start_;
CefTime valid_expiry_;
CefRefPtr<CefBinaryValue> der_encoded_;
CefRefPtr<CefBinaryValue> pem_encoded_;
IMPLEMENT_REFCOUNTING(CefSSLInfoImpl);
DISALLOW_COPY_AND_ASSIGN(CefSSLInfoImpl);
};
#endif // CEF_LIBCEF_BROWSER_SSL_INFO_IMPL_H_

View File

@ -4,6 +4,9 @@
#include <sstream>
#include "include/cef_url.h"
#include "base/base64.h"
#include "net/base/escape.h"
#include "net/base/mime_util.h"
#include "url/gurl.h"
@ -85,3 +88,39 @@ void CefGetExtensionsForMimeType(const CefString& mime_type,
extensions.push_back(*it);
}
CefString CefBase64Encode(const void* data, size_t data_size) {
if (data_size == 0)
return CefString();
base::StringPiece input;
input.set(static_cast<const char*>(data), data_size);
std::string output;
base::Base64Encode(input, &output);
return output;
}
CefRefPtr<CefBinaryValue> CefBase64Decode(const CefString& data) {
if (data.size() == 0)
return NULL;
const std::string& input = data;
std::string output;
if (base::Base64Decode(input, &output))
return CefBinaryValue::Create(output.data(), output.size());
return NULL;
}
CefString CefURIEncode(const CefString& text, bool use_plus) {
return net::EscapeQueryParamValue(text, use_plus);
}
CefString CefURIDecode(const CefString& text,
bool convert_to_utf8,
cef_uri_unescape_rule_t unescape_rule) {
const net::UnescapeRule::Type type =
static_cast<net::UnescapeRule::Type>(unescape_rule);
if (convert_to_utf8)
return net::UnescapeAndDecodeUTF8URLComponent(text.ToString(), type);
else
return net::UnescapeURLComponent(text.ToString(), type);
}

View File

@ -18,6 +18,7 @@
#include "libcef_dll/ctocpp/frame_ctocpp.h"
#include "libcef_dll/ctocpp/quota_callback_ctocpp.h"
#include "libcef_dll/ctocpp/request_ctocpp.h"
#include "libcef_dll/ctocpp/sslinfo_ctocpp.h"
#include "libcef_dll/ctocpp/web_plugin_info_ctocpp.h"
@ -271,18 +272,27 @@ void CEF_CALLBACK request_handler_on_protocol_execution(
}
int CEF_CALLBACK request_handler_on_certificate_error(
struct _cef_request_handler_t* self, cef_errorcode_t cert_error,
const cef_string_t* request_url,
struct _cef_request_handler_t* self, cef_browser_t* browser,
cef_errorcode_t cert_error, const cef_string_t* request_url,
struct _cef_sslinfo_t* ssl_info,
cef_allow_certificate_error_callback_t* callback) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Verify param: browser; type: refptr_diff
DCHECK(browser);
if (!browser)
return 0;
// Verify param: request_url; type: string_byref_const
DCHECK(request_url);
if (!request_url)
return 0;
// Verify param: ssl_info; type: refptr_diff
DCHECK(ssl_info);
if (!ssl_info)
return 0;
// Verify param: callback; type: refptr_diff
DCHECK(callback);
if (!callback)
@ -290,8 +300,10 @@ int CEF_CALLBACK request_handler_on_certificate_error(
// Execute
bool _retval = CefRequestHandlerCppToC::Get(self)->OnCertificateError(
CefBrowserCToCpp::Wrap(browser),
cert_error,
CefString(request_url),
CefSSLInfoCToCpp::Wrap(ssl_info),
CefAllowCertificateErrorCallbackCToCpp::Wrap(callback));
// Return type: bool

View File

@ -0,0 +1,220 @@
// Copyright (c) 2015 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/sslcert_principal_cpptoc.h"
#include "libcef_dll/transfer_util.h"
// MEMBER FUNCTIONS - Body may be edited by hand.
cef_string_userfree_t CEF_CALLBACK sslcert_principal_get_display_name(
struct _cef_sslcert_principal_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return NULL;
// Execute
CefString _retval = CefSSLCertPrincipalCppToC::Get(self)->GetDisplayName();
// Return type: string
return _retval.DetachToUserFree();
}
cef_string_userfree_t CEF_CALLBACK sslcert_principal_get_common_name(
struct _cef_sslcert_principal_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return NULL;
// Execute
CefString _retval = CefSSLCertPrincipalCppToC::Get(self)->GetCommonName();
// Return type: string
return _retval.DetachToUserFree();
}
cef_string_userfree_t CEF_CALLBACK sslcert_principal_get_locality_name(
struct _cef_sslcert_principal_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return NULL;
// Execute
CefString _retval = CefSSLCertPrincipalCppToC::Get(self)->GetLocalityName();
// Return type: string
return _retval.DetachToUserFree();
}
cef_string_userfree_t CEF_CALLBACK sslcert_principal_get_state_or_province_name(
struct _cef_sslcert_principal_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return NULL;
// Execute
CefString _retval = CefSSLCertPrincipalCppToC::Get(
self)->GetStateOrProvinceName();
// Return type: string
return _retval.DetachToUserFree();
}
cef_string_userfree_t CEF_CALLBACK sslcert_principal_get_country_name(
struct _cef_sslcert_principal_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return NULL;
// Execute
CefString _retval = CefSSLCertPrincipalCppToC::Get(self)->GetCountryName();
// Return type: string
return _retval.DetachToUserFree();
}
void CEF_CALLBACK sslcert_principal_get_street_addresses(
struct _cef_sslcert_principal_t* self, cef_string_list_t addresses) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return;
// Verify param: addresses; type: string_vec_byref
DCHECK(addresses);
if (!addresses)
return;
// Translate param: addresses; type: string_vec_byref
std::vector<CefString> addressesList;
transfer_string_list_contents(addresses, addressesList);
// Execute
CefSSLCertPrincipalCppToC::Get(self)->GetStreetAddresses(
addressesList);
// Restore param: addresses; type: string_vec_byref
cef_string_list_clear(addresses);
transfer_string_list_contents(addressesList, addresses);
}
void CEF_CALLBACK sslcert_principal_get_organization_names(
struct _cef_sslcert_principal_t* self, cef_string_list_t names) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return;
// Verify param: names; type: string_vec_byref
DCHECK(names);
if (!names)
return;
// Translate param: names; type: string_vec_byref
std::vector<CefString> namesList;
transfer_string_list_contents(names, namesList);
// Execute
CefSSLCertPrincipalCppToC::Get(self)->GetOrganizationNames(
namesList);
// Restore param: names; type: string_vec_byref
cef_string_list_clear(names);
transfer_string_list_contents(namesList, names);
}
void CEF_CALLBACK sslcert_principal_get_organization_unit_names(
struct _cef_sslcert_principal_t* self, cef_string_list_t names) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return;
// Verify param: names; type: string_vec_byref
DCHECK(names);
if (!names)
return;
// Translate param: names; type: string_vec_byref
std::vector<CefString> namesList;
transfer_string_list_contents(names, namesList);
// Execute
CefSSLCertPrincipalCppToC::Get(self)->GetOrganizationUnitNames(
namesList);
// Restore param: names; type: string_vec_byref
cef_string_list_clear(names);
transfer_string_list_contents(namesList, names);
}
void CEF_CALLBACK sslcert_principal_get_domain_components(
struct _cef_sslcert_principal_t* self, cef_string_list_t components) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return;
// Verify param: components; type: string_vec_byref
DCHECK(components);
if (!components)
return;
// Translate param: components; type: string_vec_byref
std::vector<CefString> componentsList;
transfer_string_list_contents(components, componentsList);
// Execute
CefSSLCertPrincipalCppToC::Get(self)->GetDomainComponents(
componentsList);
// Restore param: components; type: string_vec_byref
cef_string_list_clear(components);
transfer_string_list_contents(componentsList, components);
}
// CONSTRUCTOR - Do not edit by hand.
CefSSLCertPrincipalCppToC::CefSSLCertPrincipalCppToC(CefSSLCertPrincipal* cls)
: CefCppToC<CefSSLCertPrincipalCppToC, CefSSLCertPrincipal,
cef_sslcert_principal_t>(cls) {
struct_.struct_.get_display_name = sslcert_principal_get_display_name;
struct_.struct_.get_common_name = sslcert_principal_get_common_name;
struct_.struct_.get_locality_name = sslcert_principal_get_locality_name;
struct_.struct_.get_state_or_province_name =
sslcert_principal_get_state_or_province_name;
struct_.struct_.get_country_name = sslcert_principal_get_country_name;
struct_.struct_.get_street_addresses = sslcert_principal_get_street_addresses;
struct_.struct_.get_organization_names =
sslcert_principal_get_organization_names;
struct_.struct_.get_organization_unit_names =
sslcert_principal_get_organization_unit_names;
struct_.struct_.get_domain_components =
sslcert_principal_get_domain_components;
}
#ifndef NDEBUG
template<> base::AtomicRefCount CefCppToC<CefSSLCertPrincipalCppToC,
CefSSLCertPrincipal, cef_sslcert_principal_t>::DebugObjCt = 0;
#endif

View File

@ -0,0 +1,36 @@
// Copyright (c) 2015 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_SSLCERT_PRINCIPAL_CPPTOC_H_
#define CEF_LIBCEF_DLL_CPPTOC_SSLCERT_PRINCIPAL_CPPTOC_H_
#pragma once
#ifndef BUILDING_CEF_SHARED
#pragma message("Warning: "__FILE__" may be accessed DLL-side only")
#else // BUILDING_CEF_SHARED
#include "include/cef_ssl_info.h"
#include "include/capi/cef_ssl_info_capi.h"
#include "libcef_dll/cpptoc/cpptoc.h"
// Wrap a C++ class with a C structure.
// This class may be instantiated and accessed DLL-side only.
class CefSSLCertPrincipalCppToC
: public CefCppToC<CefSSLCertPrincipalCppToC, CefSSLCertPrincipal,
cef_sslcert_principal_t> {
public:
explicit CefSSLCertPrincipalCppToC(CefSSLCertPrincipal* cls);
};
#endif // BUILDING_CEF_SHARED
#endif // CEF_LIBCEF_DLL_CPPTOC_SSLCERT_PRINCIPAL_CPPTOC_H_

View File

@ -0,0 +1,146 @@
// Copyright (c) 2015 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/binary_value_cpptoc.h"
#include "libcef_dll/cpptoc/sslcert_principal_cpptoc.h"
#include "libcef_dll/cpptoc/sslinfo_cpptoc.h"
// MEMBER FUNCTIONS - Body may be edited by hand.
cef_sslcert_principal_t* CEF_CALLBACK sslinfo_get_subject(
struct _cef_sslinfo_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return NULL;
// Execute
CefRefPtr<CefSSLCertPrincipal> _retval = CefSSLInfoCppToC::Get(
self)->GetSubject();
// Return type: refptr_same
return CefSSLCertPrincipalCppToC::Wrap(_retval);
}
cef_sslcert_principal_t* CEF_CALLBACK sslinfo_get_issuer(
struct _cef_sslinfo_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return NULL;
// Execute
CefRefPtr<CefSSLCertPrincipal> _retval = CefSSLInfoCppToC::Get(
self)->GetIssuer();
// Return type: refptr_same
return CefSSLCertPrincipalCppToC::Wrap(_retval);
}
struct _cef_binary_value_t* CEF_CALLBACK sslinfo_get_serial_number(
struct _cef_sslinfo_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return NULL;
// Execute
CefRefPtr<CefBinaryValue> _retval = CefSSLInfoCppToC::Get(
self)->GetSerialNumber();
// Return type: refptr_same
return CefBinaryValueCppToC::Wrap(_retval);
}
cef_time_t CEF_CALLBACK sslinfo_get_valid_start(struct _cef_sslinfo_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return CefTime();
// Execute
cef_time_t _retval = CefSSLInfoCppToC::Get(self)->GetValidStart();
// Return type: simple
return _retval;
}
cef_time_t CEF_CALLBACK sslinfo_get_valid_expiry(struct _cef_sslinfo_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return CefTime();
// Execute
cef_time_t _retval = CefSSLInfoCppToC::Get(self)->GetValidExpiry();
// Return type: simple
return _retval;
}
struct _cef_binary_value_t* CEF_CALLBACK sslinfo_get_derencoded(
struct _cef_sslinfo_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return NULL;
// Execute
CefRefPtr<CefBinaryValue> _retval = CefSSLInfoCppToC::Get(
self)->GetDEREncoded();
// Return type: refptr_same
return CefBinaryValueCppToC::Wrap(_retval);
}
struct _cef_binary_value_t* CEF_CALLBACK sslinfo_get_pemencoded(
struct _cef_sslinfo_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return NULL;
// Execute
CefRefPtr<CefBinaryValue> _retval = CefSSLInfoCppToC::Get(
self)->GetPEMEncoded();
// Return type: refptr_same
return CefBinaryValueCppToC::Wrap(_retval);
}
// CONSTRUCTOR - Do not edit by hand.
CefSSLInfoCppToC::CefSSLInfoCppToC(CefSSLInfo* cls)
: CefCppToC<CefSSLInfoCppToC, CefSSLInfo, cef_sslinfo_t>(cls) {
struct_.struct_.get_subject = sslinfo_get_subject;
struct_.struct_.get_issuer = sslinfo_get_issuer;
struct_.struct_.get_serial_number = sslinfo_get_serial_number;
struct_.struct_.get_valid_start = sslinfo_get_valid_start;
struct_.struct_.get_valid_expiry = sslinfo_get_valid_expiry;
struct_.struct_.get_derencoded = sslinfo_get_derencoded;
struct_.struct_.get_pemencoded = sslinfo_get_pemencoded;
}
#ifndef NDEBUG
template<> base::AtomicRefCount CefCppToC<CefSSLInfoCppToC, CefSSLInfo,
cef_sslinfo_t>::DebugObjCt = 0;
#endif

View File

@ -0,0 +1,35 @@
// Copyright (c) 2015 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_SSLINFO_CPPTOC_H_
#define CEF_LIBCEF_DLL_CPPTOC_SSLINFO_CPPTOC_H_
#pragma once
#ifndef BUILDING_CEF_SHARED
#pragma message("Warning: "__FILE__" may be accessed DLL-side only")
#else // BUILDING_CEF_SHARED
#include "include/cef_ssl_info.h"
#include "include/capi/cef_ssl_info_capi.h"
#include "libcef_dll/cpptoc/cpptoc.h"
// Wrap a C++ class with a C structure.
// This class may be instantiated and accessed DLL-side only.
class CefSSLInfoCppToC
: public CefCppToC<CefSSLInfoCppToC, CefSSLInfo, cef_sslinfo_t> {
public:
explicit CefSSLInfoCppToC(CefSSLInfo* cls);
};
#endif // BUILDING_CEF_SHARED
#endif // CEF_LIBCEF_DLL_CPPTOC_SSLINFO_CPPTOC_H_

View File

@ -16,6 +16,7 @@
#include "libcef_dll/cpptoc/frame_cpptoc.h"
#include "libcef_dll/cpptoc/quota_callback_cpptoc.h"
#include "libcef_dll/cpptoc/request_cpptoc.h"
#include "libcef_dll/cpptoc/sslinfo_cpptoc.h"
#include "libcef_dll/cpptoc/web_plugin_info_cpptoc.h"
#include "libcef_dll/ctocpp/request_handler_ctocpp.h"
#include "libcef_dll/ctocpp/resource_handler_ctocpp.h"
@ -252,18 +253,27 @@ void CefRequestHandlerCToCpp::OnProtocolExecution(CefRefPtr<CefBrowser> browser,
allow_os_execution = allow_os_executionInt?true:false;
}
bool CefRequestHandlerCToCpp::OnCertificateError(cef_errorcode_t cert_error,
const CefString& request_url,
bool CefRequestHandlerCToCpp::OnCertificateError(CefRefPtr<CefBrowser> browser,
cef_errorcode_t cert_error, const CefString& request_url,
CefRefPtr<CefSSLInfo> ssl_info,
CefRefPtr<CefAllowCertificateErrorCallback> callback) {
if (CEF_MEMBER_MISSING(struct_, on_certificate_error))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: browser; type: refptr_diff
DCHECK(browser.get());
if (!browser.get())
return false;
// Verify param: request_url; type: string_byref_const
DCHECK(!request_url.empty());
if (request_url.empty())
return false;
// Verify param: ssl_info; type: refptr_diff
DCHECK(ssl_info.get());
if (!ssl_info.get())
return false;
// Verify param: callback; type: refptr_diff
DCHECK(callback.get());
if (!callback.get())
@ -271,8 +281,10 @@ bool CefRequestHandlerCToCpp::OnCertificateError(cef_errorcode_t cert_error,
// Execute
int _retval = struct_->on_certificate_error(struct_,
CefBrowserCppToC::Wrap(browser),
cert_error,
request_url.GetStruct(),
CefSSLInfoCppToC::Wrap(ssl_info),
CefAllowCertificateErrorCallbackCppToC::Wrap(callback));
// Return type: bool

View File

@ -52,8 +52,9 @@ class CefRequestHandlerCToCpp
CefRefPtr<CefQuotaCallback> callback) override;
void OnProtocolExecution(CefRefPtr<CefBrowser> browser, const CefString& url,
bool& allow_os_execution) override;
bool OnCertificateError(cef_errorcode_t cert_error,
const CefString& request_url,
bool OnCertificateError(CefRefPtr<CefBrowser> browser,
cef_errorcode_t cert_error, const CefString& request_url,
CefRefPtr<CefSSLInfo> ssl_info,
CefRefPtr<CefAllowCertificateErrorCallback> callback) override;
bool OnBeforePluginLoad(CefRefPtr<CefBrowser> browser, const CefString& url,
const CefString& policy_url, CefRefPtr<CefWebPluginInfo> info) override;

View File

@ -0,0 +1,199 @@
// Copyright (c) 2015 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/sslcert_principal_ctocpp.h"
#include "libcef_dll/transfer_util.h"
// VIRTUAL METHODS - Body may be edited by hand.
CefString CefSSLCertPrincipalCToCpp::GetDisplayName() {
if (CEF_MEMBER_MISSING(struct_, get_display_name))
return CefString();
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
cef_string_userfree_t _retval = struct_->get_display_name(struct_);
// Return type: string
CefString _retvalStr;
_retvalStr.AttachToUserFree(_retval);
return _retvalStr;
}
CefString CefSSLCertPrincipalCToCpp::GetCommonName() {
if (CEF_MEMBER_MISSING(struct_, get_common_name))
return CefString();
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
cef_string_userfree_t _retval = struct_->get_common_name(struct_);
// Return type: string
CefString _retvalStr;
_retvalStr.AttachToUserFree(_retval);
return _retvalStr;
}
CefString CefSSLCertPrincipalCToCpp::GetLocalityName() {
if (CEF_MEMBER_MISSING(struct_, get_locality_name))
return CefString();
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
cef_string_userfree_t _retval = struct_->get_locality_name(struct_);
// Return type: string
CefString _retvalStr;
_retvalStr.AttachToUserFree(_retval);
return _retvalStr;
}
CefString CefSSLCertPrincipalCToCpp::GetStateOrProvinceName() {
if (CEF_MEMBER_MISSING(struct_, get_state_or_province_name))
return CefString();
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
cef_string_userfree_t _retval = struct_->get_state_or_province_name(struct_);
// Return type: string
CefString _retvalStr;
_retvalStr.AttachToUserFree(_retval);
return _retvalStr;
}
CefString CefSSLCertPrincipalCToCpp::GetCountryName() {
if (CEF_MEMBER_MISSING(struct_, get_country_name))
return CefString();
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
cef_string_userfree_t _retval = struct_->get_country_name(struct_);
// Return type: string
CefString _retvalStr;
_retvalStr.AttachToUserFree(_retval);
return _retvalStr;
}
void CefSSLCertPrincipalCToCpp::GetStreetAddresses(
std::vector<CefString>& addresses) {
if (CEF_MEMBER_MISSING(struct_, get_street_addresses))
return;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Translate param: addresses; type: string_vec_byref
cef_string_list_t addressesList = cef_string_list_alloc();
DCHECK(addressesList);
if (addressesList)
transfer_string_list_contents(addresses, addressesList);
// Execute
struct_->get_street_addresses(struct_,
addressesList);
// Restore param:addresses; type: string_vec_byref
if (addressesList) {
addresses.clear();
transfer_string_list_contents(addressesList, addresses);
cef_string_list_free(addressesList);
}
}
void CefSSLCertPrincipalCToCpp::GetOrganizationNames(
std::vector<CefString>& names) {
if (CEF_MEMBER_MISSING(struct_, get_organization_names))
return;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Translate param: names; type: string_vec_byref
cef_string_list_t namesList = cef_string_list_alloc();
DCHECK(namesList);
if (namesList)
transfer_string_list_contents(names, namesList);
// Execute
struct_->get_organization_names(struct_,
namesList);
// Restore param:names; type: string_vec_byref
if (namesList) {
names.clear();
transfer_string_list_contents(namesList, names);
cef_string_list_free(namesList);
}
}
void CefSSLCertPrincipalCToCpp::GetOrganizationUnitNames(
std::vector<CefString>& names) {
if (CEF_MEMBER_MISSING(struct_, get_organization_unit_names))
return;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Translate param: names; type: string_vec_byref
cef_string_list_t namesList = cef_string_list_alloc();
DCHECK(namesList);
if (namesList)
transfer_string_list_contents(names, namesList);
// Execute
struct_->get_organization_unit_names(struct_,
namesList);
// Restore param:names; type: string_vec_byref
if (namesList) {
names.clear();
transfer_string_list_contents(namesList, names);
cef_string_list_free(namesList);
}
}
void CefSSLCertPrincipalCToCpp::GetDomainComponents(
std::vector<CefString>& components) {
if (CEF_MEMBER_MISSING(struct_, get_domain_components))
return;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Translate param: components; type: string_vec_byref
cef_string_list_t componentsList = cef_string_list_alloc();
DCHECK(componentsList);
if (componentsList)
transfer_string_list_contents(components, componentsList);
// Execute
struct_->get_domain_components(struct_,
componentsList);
// Restore param:components; type: string_vec_byref
if (componentsList) {
components.clear();
transfer_string_list_contents(componentsList, components);
cef_string_list_free(componentsList);
}
}
#ifndef NDEBUG
template<> base::AtomicRefCount CefCToCpp<CefSSLCertPrincipalCToCpp,
CefSSLCertPrincipal, cef_sslcert_principal_t>::DebugObjCt = 0;
#endif

View File

@ -0,0 +1,50 @@
// Copyright (c) 2015 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_SSLCERT_PRINCIPAL_CTOCPP_H_
#define CEF_LIBCEF_DLL_CTOCPP_SSLCERT_PRINCIPAL_CTOCPP_H_
#pragma once
#ifndef USING_CEF_SHARED
#pragma message("Warning: "__FILE__" may be accessed wrapper-side only")
#else // USING_CEF_SHARED
#include <vector>
#include "include/cef_ssl_info.h"
#include "include/capi/cef_ssl_info_capi.h"
#include "libcef_dll/ctocpp/ctocpp.h"
// Wrap a C structure with a C++ class.
// This class may be instantiated and accessed wrapper-side only.
class CefSSLCertPrincipalCToCpp
: public CefCToCpp<CefSSLCertPrincipalCToCpp, CefSSLCertPrincipal,
cef_sslcert_principal_t> {
public:
explicit CefSSLCertPrincipalCToCpp(cef_sslcert_principal_t* str)
: CefCToCpp<CefSSLCertPrincipalCToCpp, CefSSLCertPrincipal,
cef_sslcert_principal_t>(str) {}
// CefSSLCertPrincipal methods
virtual CefString GetDisplayName() OVERRIDE;
virtual CefString GetCommonName() OVERRIDE;
virtual CefString GetLocalityName() OVERRIDE;
virtual CefString GetStateOrProvinceName() OVERRIDE;
virtual CefString GetCountryName() OVERRIDE;
virtual void GetStreetAddresses(std::vector<CefString>& addresses) OVERRIDE;
virtual void GetOrganizationNames(std::vector<CefString>& names) OVERRIDE;
virtual void GetOrganizationUnitNames(std::vector<CefString>& names) OVERRIDE;
virtual void GetDomainComponents(std::vector<CefString>& components) OVERRIDE;
};
#endif // USING_CEF_SHARED
#endif // CEF_LIBCEF_DLL_CTOCPP_SSLCERT_PRINCIPAL_CTOCPP_H_

View File

@ -0,0 +1,116 @@
// Copyright (c) 2015 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/binary_value_ctocpp.h"
#include "libcef_dll/ctocpp/sslcert_principal_ctocpp.h"
#include "libcef_dll/ctocpp/sslinfo_ctocpp.h"
// VIRTUAL METHODS - Body may be edited by hand.
CefRefPtr<CefSSLCertPrincipal> CefSSLInfoCToCpp::GetSubject() {
if (CEF_MEMBER_MISSING(struct_, get_subject))
return NULL;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
cef_sslcert_principal_t* _retval = struct_->get_subject(struct_);
// Return type: refptr_same
return CefSSLCertPrincipalCToCpp::Wrap(_retval);
}
CefRefPtr<CefSSLCertPrincipal> CefSSLInfoCToCpp::GetIssuer() {
if (CEF_MEMBER_MISSING(struct_, get_issuer))
return NULL;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
cef_sslcert_principal_t* _retval = struct_->get_issuer(struct_);
// Return type: refptr_same
return CefSSLCertPrincipalCToCpp::Wrap(_retval);
}
CefRefPtr<CefBinaryValue> CefSSLInfoCToCpp::GetSerialNumber() {
if (CEF_MEMBER_MISSING(struct_, get_serial_number))
return NULL;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
cef_binary_value_t* _retval = struct_->get_serial_number(struct_);
// Return type: refptr_same
return CefBinaryValueCToCpp::Wrap(_retval);
}
CefTime CefSSLInfoCToCpp::GetValidStart() {
if (CEF_MEMBER_MISSING(struct_, get_valid_start))
return CefTime();
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
cef_time_t _retval = struct_->get_valid_start(struct_);
// Return type: simple
return _retval;
}
CefTime CefSSLInfoCToCpp::GetValidExpiry() {
if (CEF_MEMBER_MISSING(struct_, get_valid_expiry))
return CefTime();
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
cef_time_t _retval = struct_->get_valid_expiry(struct_);
// Return type: simple
return _retval;
}
CefRefPtr<CefBinaryValue> CefSSLInfoCToCpp::GetDEREncoded() {
if (CEF_MEMBER_MISSING(struct_, get_derencoded))
return NULL;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
cef_binary_value_t* _retval = struct_->get_derencoded(struct_);
// Return type: refptr_same
return CefBinaryValueCToCpp::Wrap(_retval);
}
CefRefPtr<CefBinaryValue> CefSSLInfoCToCpp::GetPEMEncoded() {
if (CEF_MEMBER_MISSING(struct_, get_pemencoded))
return NULL;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
cef_binary_value_t* _retval = struct_->get_pemencoded(struct_);
// Return type: refptr_same
return CefBinaryValueCToCpp::Wrap(_retval);
}
#ifndef NDEBUG
template<> base::AtomicRefCount CefCToCpp<CefSSLInfoCToCpp, CefSSLInfo,
cef_sslinfo_t>::DebugObjCt = 0;
#endif

View File

@ -0,0 +1,45 @@
// Copyright (c) 2015 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_SSLINFO_CTOCPP_H_
#define CEF_LIBCEF_DLL_CTOCPP_SSLINFO_CTOCPP_H_
#pragma once
#ifndef USING_CEF_SHARED
#pragma message("Warning: "__FILE__" may be accessed wrapper-side only")
#else // USING_CEF_SHARED
#include "include/cef_ssl_info.h"
#include "include/capi/cef_ssl_info_capi.h"
#include "libcef_dll/ctocpp/ctocpp.h"
// Wrap a C structure with a C++ class.
// This class may be instantiated and accessed wrapper-side only.
class CefSSLInfoCToCpp
: public CefCToCpp<CefSSLInfoCToCpp, CefSSLInfo, cef_sslinfo_t> {
public:
explicit CefSSLInfoCToCpp(cef_sslinfo_t* str)
: CefCToCpp<CefSSLInfoCToCpp, CefSSLInfo, cef_sslinfo_t>(str) {}
// CefSSLInfo methods
virtual CefRefPtr<CefSSLCertPrincipal> GetSubject() OVERRIDE;
virtual CefRefPtr<CefSSLCertPrincipal> GetIssuer() OVERRIDE;
virtual CefRefPtr<CefBinaryValue> GetSerialNumber() OVERRIDE;
virtual CefTime GetValidStart() OVERRIDE;
virtual CefTime GetValidExpiry() OVERRIDE;
virtual CefRefPtr<CefBinaryValue> GetDEREncoded() OVERRIDE;
virtual CefRefPtr<CefBinaryValue> GetPEMEncoded() OVERRIDE;
};
#endif // USING_CEF_SHARED
#endif // CEF_LIBCEF_DLL_CTOCPP_SSLINFO_CTOCPP_H_

View File

@ -59,6 +59,8 @@
#include "libcef_dll/cpptoc/print_settings_cpptoc.h"
#include "libcef_dll/cpptoc/process_message_cpptoc.h"
#include "libcef_dll/cpptoc/quota_callback_cpptoc.h"
#include "libcef_dll/cpptoc/sslcert_principal_cpptoc.h"
#include "libcef_dll/cpptoc/sslinfo_cpptoc.h"
#include "libcef_dll/cpptoc/scheme_registrar_cpptoc.h"
#include "libcef_dll/cpptoc/stream_reader_cpptoc.h"
#include "libcef_dll/cpptoc/stream_writer_cpptoc.h"
@ -244,6 +246,8 @@ CEF_EXPORT void cef_shutdown() {
DCHECK(base::AtomicRefCountIsZero(&CefResourceHandlerCToCpp::DebugObjCt));
DCHECK(base::AtomicRefCountIsZero(
&CefRunFileDialogCallbackCToCpp::DebugObjCt));
DCHECK(base::AtomicRefCountIsZero(&CefSSLCertPrincipalCppToC::DebugObjCt));
DCHECK(base::AtomicRefCountIsZero(&CefSSLInfoCppToC::DebugObjCt));
DCHECK(base::AtomicRefCountIsZero(
&CefSchemeHandlerFactoryCToCpp::DebugObjCt));
DCHECK(base::AtomicRefCountIsZero(&CefSchemeRegistrarCppToC::DebugObjCt));
@ -639,6 +643,78 @@ CEF_EXPORT void cef_get_extensions_for_mime_type(const cef_string_t* mime_type,
transfer_string_list_contents(extensionsList, extensions);
}
CEF_EXPORT cef_string_userfree_t cef_base64encode(const void* data,
size_t data_size) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: data; type: simple_byaddr
DCHECK(data);
if (!data)
return NULL;
// Execute
CefString _retval = CefBase64Encode(
data,
data_size);
// Return type: string
return _retval.DetachToUserFree();
}
CEF_EXPORT struct _cef_binary_value_t* cef_base64decode(
const cef_string_t* data) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: data; type: string_byref_const
DCHECK(data);
if (!data)
return NULL;
// Execute
CefRefPtr<CefBinaryValue> _retval = CefBase64Decode(
CefString(data));
// Return type: refptr_same
return CefBinaryValueCppToC::Wrap(_retval);
}
CEF_EXPORT cef_string_userfree_t cef_uriencode(const cef_string_t* text,
int use_plus) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: text; type: string_byref_const
DCHECK(text);
if (!text)
return NULL;
// Execute
CefString _retval = CefURIEncode(
CefString(text),
use_plus?true:false);
// Return type: string
return _retval.DetachToUserFree();
}
CEF_EXPORT cef_string_userfree_t cef_uridecode(const cef_string_t* text,
int convert_to_utf8, cef_uri_unescape_rule_t unescape_rule) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: text; type: string_byref_const
DCHECK(text);
if (!text)
return NULL;
// Execute
CefString _retval = CefURIDecode(
CefString(text),
convert_to_utf8?true:false,
unescape_rule);
// Return type: string
return _retval.DetachToUserFree();
}
CEF_EXPORT int cef_register_extension(const cef_string_t* extension_name,
const cef_string_t* javascript_code, struct _cef_v8handler_t* handler) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING

View File

@ -97,6 +97,8 @@
#include "libcef_dll/ctocpp/print_settings_ctocpp.h"
#include "libcef_dll/ctocpp/process_message_ctocpp.h"
#include "libcef_dll/ctocpp/quota_callback_ctocpp.h"
#include "libcef_dll/ctocpp/sslcert_principal_ctocpp.h"
#include "libcef_dll/ctocpp/sslinfo_ctocpp.h"
#include "libcef_dll/ctocpp/scheme_registrar_ctocpp.h"
#include "libcef_dll/ctocpp/stream_reader_ctocpp.h"
#include "libcef_dll/ctocpp/stream_writer_ctocpp.h"
@ -236,6 +238,8 @@ CEF_GLOBAL void CefShutdown() {
DCHECK(base::AtomicRefCountIsZero(&CefResourceHandlerCppToC::DebugObjCt));
DCHECK(base::AtomicRefCountIsZero(
&CefRunFileDialogCallbackCppToC::DebugObjCt));
DCHECK(base::AtomicRefCountIsZero(&CefSSLCertPrincipalCToCpp::DebugObjCt));
DCHECK(base::AtomicRefCountIsZero(&CefSSLInfoCToCpp::DebugObjCt));
DCHECK(base::AtomicRefCountIsZero(
&CefSchemeHandlerFactoryCppToC::DebugObjCt));
DCHECK(base::AtomicRefCountIsZero(&CefSchemeRegistrarCToCpp::DebugObjCt));
@ -593,6 +597,81 @@ CEF_GLOBAL void CefGetExtensionsForMimeType(const CefString& mime_type,
}
}
CEF_GLOBAL CefString CefBase64Encode(const void* data, size_t data_size) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: data; type: simple_byaddr
DCHECK(data);
if (!data)
return CefString();
// Execute
cef_string_userfree_t _retval = cef_base64encode(
data,
data_size);
// Return type: string
CefString _retvalStr;
_retvalStr.AttachToUserFree(_retval);
return _retvalStr;
}
CEF_GLOBAL CefRefPtr<CefBinaryValue> CefBase64Decode(const CefString& data) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: data; type: string_byref_const
DCHECK(!data.empty());
if (data.empty())
return NULL;
// Execute
cef_binary_value_t* _retval = cef_base64decode(
data.GetStruct());
// Return type: refptr_same
return CefBinaryValueCToCpp::Wrap(_retval);
}
CEF_GLOBAL CefString CefURIEncode(const CefString& text, bool use_plus) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: text; type: string_byref_const
DCHECK(!text.empty());
if (text.empty())
return CefString();
// Execute
cef_string_userfree_t _retval = cef_uriencode(
text.GetStruct(),
use_plus);
// Return type: string
CefString _retvalStr;
_retvalStr.AttachToUserFree(_retval);
return _retvalStr;
}
CEF_GLOBAL CefString CefURIDecode(const CefString& text, bool convert_to_utf8,
cef_uri_unescape_rule_t unescape_rule) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: text; type: string_byref_const
DCHECK(!text.empty());
if (text.empty())
return CefString();
// Execute
cef_string_userfree_t _retval = cef_uridecode(
text.GetStruct(),
convert_to_utf8,
unescape_rule);
// Return type: string
CefString _retvalStr;
_retvalStr.AttachToUserFree(_retval);
return _retvalStr;
}
CEF_GLOBAL bool CefRegisterExtension(const CefString& extension_name,
const CefString& javascript_code, CefRefPtr<CefV8Handler> handler) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING

View File

@ -6,12 +6,14 @@
#include <stdio.h>
#include <algorithm>
#include <iomanip>
#include <sstream>
#include <string>
#include "include/base/cef_bind.h"
#include "include/cef_browser.h"
#include "include/cef_frame.h"
#include "include/cef_url.h"
#include "include/wrapper/cef_closure_task.h"
#include "cefclient/browser/main_context.h"
#include "cefclient/browser/resource_util.h"
@ -44,6 +46,121 @@ enum client_menu_ids {
// Musr match the value in client_renderer.cc.
const char kFocusedNodeChangedMessage[] = "ClientRenderer.FocusedNodeChanged";
std::string GetTimeString(const CefTime& value) {
if (value.GetTimeT() == 0)
return "Unspecified";
static const char* kMonths[] = {
"January", "February", "March", "April", "May", "June", "July", "August",
"September", "October", "November", "December"
};
std::string month;
if (value.month >= 1 && value.month <= 12)
month = kMonths[value.month - 1];
else
month = "Invalid";
std::stringstream ss;
ss << month << " " << value.day_of_month << ", " << value.year << " " <<
std::setfill('0') << std::setw(2) << value.hour << ":" <<
std::setfill('0') << std::setw(2) << value.minute << ":" <<
std::setfill('0') << std::setw(2) << value.second;
return ss.str();
}
std::string GetBinaryString(CefRefPtr<CefBinaryValue> value) {
if (!value.get())
return "&nbsp;";
// Retrieve the value.
const size_t size = value->GetSize();
std::string src;
src.resize(size);
value->GetData(const_cast<char*>(src.data()), size, 0);
// Encode the value.
return CefBase64Encode(src.data(), src.size());
}
std::string GetErrorString(cef_errorcode_t code) {
// Case condition that returns |code| as a string.
#define CASE(code) case code: return #code
switch (code) {
CASE(ERR_NONE);
CASE(ERR_FAILED);
CASE(ERR_ABORTED);
CASE(ERR_INVALID_ARGUMENT);
CASE(ERR_INVALID_HANDLE);
CASE(ERR_FILE_NOT_FOUND);
CASE(ERR_TIMED_OUT);
CASE(ERR_FILE_TOO_BIG);
CASE(ERR_UNEXPECTED);
CASE(ERR_ACCESS_DENIED);
CASE(ERR_NOT_IMPLEMENTED);
CASE(ERR_CONNECTION_CLOSED);
CASE(ERR_CONNECTION_RESET);
CASE(ERR_CONNECTION_REFUSED);
CASE(ERR_CONNECTION_ABORTED);
CASE(ERR_CONNECTION_FAILED);
CASE(ERR_NAME_NOT_RESOLVED);
CASE(ERR_INTERNET_DISCONNECTED);
CASE(ERR_SSL_PROTOCOL_ERROR);
CASE(ERR_ADDRESS_INVALID);
CASE(ERR_ADDRESS_UNREACHABLE);
CASE(ERR_SSL_CLIENT_AUTH_CERT_NEEDED);
CASE(ERR_TUNNEL_CONNECTION_FAILED);
CASE(ERR_NO_SSL_VERSIONS_ENABLED);
CASE(ERR_SSL_VERSION_OR_CIPHER_MISMATCH);
CASE(ERR_SSL_RENEGOTIATION_REQUESTED);
CASE(ERR_CERT_COMMON_NAME_INVALID);
CASE(ERR_CERT_DATE_INVALID);
CASE(ERR_CERT_AUTHORITY_INVALID);
CASE(ERR_CERT_CONTAINS_ERRORS);
CASE(ERR_CERT_NO_REVOCATION_MECHANISM);
CASE(ERR_CERT_UNABLE_TO_CHECK_REVOCATION);
CASE(ERR_CERT_REVOKED);
CASE(ERR_CERT_INVALID);
CASE(ERR_CERT_END);
CASE(ERR_INVALID_URL);
CASE(ERR_DISALLOWED_URL_SCHEME);
CASE(ERR_UNKNOWN_URL_SCHEME);
CASE(ERR_TOO_MANY_REDIRECTS);
CASE(ERR_UNSAFE_REDIRECT);
CASE(ERR_UNSAFE_PORT);
CASE(ERR_INVALID_RESPONSE);
CASE(ERR_INVALID_CHUNKED_ENCODING);
CASE(ERR_METHOD_NOT_SUPPORTED);
CASE(ERR_UNEXPECTED_PROXY_AUTH);
CASE(ERR_EMPTY_RESPONSE);
CASE(ERR_RESPONSE_HEADERS_TOO_BIG);
CASE(ERR_CACHE_MISS);
CASE(ERR_INSECURE_RESPONSE);
default:
return "UNKNOWN";
}
}
// Load a data: URI containing the error message.
void LoadErrorPage(CefRefPtr<CefFrame> frame,
const std::string& failed_url,
cef_errorcode_t error_code,
const std::string& other_info) {
std::stringstream ss;
ss << "<html><head><title>Page failed to load</title></head>"
"<body bgcolor=\"white\">"
"<h3>Page failed to load.</h3>"
"URL: <a href=\"" << failed_url << "\">"<< failed_url << "</a>"
"<br/>Error: " << GetErrorString(error_code) <<
" (" << error_code << ")";
if (!other_info.empty())
ss << "<br/>" << other_info;
ss << "</body></html>";
frame->LoadURL(test_runner::GetDataURI(ss.str(), "text/html"));
}
} // namespace
ClientHandler::ClientHandler(Delegate* delegate,
@ -360,13 +477,8 @@ void ClientHandler::OnLoadError(CefRefPtr<CefBrowser> browser,
return;
}
// Display a load error message.
std::stringstream ss;
ss << "<html><body bgcolor=\"white\">"
"<h2>Failed to load URL " << std::string(failedUrl) <<
" with error " << std::string(errorText) << " (" << errorCode <<
").</h2></body></html>";
frame->LoadString(ss.str(), failedUrl);
// Load the error page.
LoadErrorPage(frame, failedUrl, errorCode, errorText);
}
bool ClientHandler::OnBeforeBrowse(CefRefPtr<CefBrowser> browser,
@ -413,6 +525,47 @@ void ClientHandler::OnProtocolExecution(CefRefPtr<CefBrowser> browser,
allow_os_execution = true;
}
bool ClientHandler::OnCertificateError(
CefRefPtr<CefBrowser> browser,
ErrorCode cert_error,
const CefString& request_url,
CefRefPtr<CefSSLInfo> ssl_info,
CefRefPtr<CefAllowCertificateErrorCallback> callback) {
CEF_REQUIRE_UI_THREAD();
CefRefPtr<CefSSLCertPrincipal> subject = ssl_info->GetSubject();
CefRefPtr<CefSSLCertPrincipal> issuer = ssl_info->GetIssuer();
// Build a table showing certificate information.
std::stringstream ss;
ss << "X.509 Certificate Information:"
"<table border=1><tr><th>Field</th><th>Value</th></tr>" <<
"<tr><td>Subject</td><td>" <<
(subject.get() ? subject->GetDisplayName().ToString() : "&nbsp;") <<
"</td></tr>"
"<tr><td>Issuer</td><td>" <<
(issuer.get() ? issuer->GetDisplayName().ToString() : "&nbsp;") <<
"</td></tr>"
"<tr><td>Serial #*</td><td>" <<
GetBinaryString(ssl_info->GetSerialNumber()) << "</td></tr>"
"<tr><td>Valid Start</td><td>" <<
GetTimeString(ssl_info->GetValidStart()) << "</td></tr>"
"<tr><td>Valid Expiry</td><td>" <<
GetTimeString(ssl_info->GetValidExpiry()) << "</td></tr>"
"<tr><td>DER Encoded*</td>"
"<td style=\"max-width:800px;overflow:scroll;\">" <<
GetBinaryString(ssl_info->GetDEREncoded()) << "</td></tr>"
"<tr><td>PEM Encoded*</td>"
"<td style=\"max-width:800px;overflow:scroll;\">" <<
GetBinaryString(ssl_info->GetPEMEncoded()) << "</td></tr>"
"</table> * Displayed value is base64 encoded.";
// Load the error page.
LoadErrorPage(browser->GetMainFrame(), request_url, cert_error, ss.str());
return false; // Cancel the request.
}
void ClientHandler::OnRenderProcessTerminated(CefRefPtr<CefBrowser> browser,
TerminationStatus status) {
CEF_REQUIRE_UI_THREAD();

View File

@ -206,6 +206,12 @@ class ClientHandler : public CefClient,
void OnProtocolExecution(CefRefPtr<CefBrowser> browser,
const CefString& url,
bool& allow_os_execution) OVERRIDE;
bool OnCertificateError(
CefRefPtr<CefBrowser> browser,
ErrorCode cert_error,
const CefString& request_url,
CefRefPtr<CefSSLInfo> ssl_info,
CefRefPtr<CefAllowCertificateErrorCallback> callback) OVERRIDE;
void OnRenderProcessTerminated(CefRefPtr<CefBrowser> browser,
TerminationStatus status) OVERRIDE;

View File

@ -46,8 +46,7 @@ class ClientSchemeHandler : public CefResourceHandler {
"<br/><img src=\"client://tests/logo.png\"><pre>";
// Output a string representation of the request
std::string dump;
test_runner::DumpRequestContents(request, dump);
const std::string& dump = test_runner::DumpRequestContents(request);
data_.append(dump);
data_.append("</pre><br/>Try the test form:"

View File

@ -4,6 +4,8 @@
#include "cefclient/browser/test_runner.h"
#include <sstream>
#include "include/base/cef_bind.h"
#include "include/cef_task.h"
#include "include/cef_trace.h"
@ -318,7 +320,7 @@ void RunTest(CefRefPtr<CefBrowser> browser, int id) {
}
}
void DumpRequestContents(CefRefPtr<CefRequest> request, std::string& str) {
std::string DumpRequestContents(CefRefPtr<CefRequest> request) {
std::stringstream ss;
ss << "URL: " << std::string(request->GetURL());
@ -365,7 +367,13 @@ void DumpRequestContents(CefRefPtr<CefRequest> request, std::string& str) {
}
}
str = ss.str();
return ss.str();
}
std::string GetDataURI(const std::string& data,
const std::string& mime_type) {
return "data:" + mime_type + ";base64," +
CefURIEncode(CefBase64Encode(data.data(), data.size()), false).ToString();
}
CefRefPtr<CefResourceHandler> GetResourceHandler(
@ -379,8 +387,7 @@ CefRefPtr<CefResourceHandler> GetResourceHandler(
if (ParseTestUrl(url, &file_name, &mime_type)) {
if (file_name == "request.html") {
// Show the request contents.
std::string dump;
DumpRequestContents(request, dump);
const std::string& dump = DumpRequestContents(request);
std::string str = "<html><body bgcolor=\"white\"><pre>" + dump +
"</pre></body></html>";
CefRefPtr<CefStreamReader> stream =

View File

@ -20,8 +20,12 @@ namespace test_runner {
// Run a test.
void RunTest(CefRefPtr<CefBrowser> browser, int id);
// Dump the contents of the request into a string.
void DumpRequestContents(CefRefPtr<CefRequest> request, std::string& str);
// Returns the contents of the CefRequest as a string.
std::string DumpRequestContents(CefRefPtr<CefRequest> request);
// Returns a data: URI with the specified contents.
std::string GetDataURI(const std::string& data,
const std::string& mime_type);
// Get test resources.
CefRefPtr<CefResourceHandler> GetResourceHandler(

View File

@ -231,3 +231,46 @@ TEST(URLTest, GetMimeType) {
mime_type = CefGetMimeType("gif");
EXPECT_STREQ("image/gif", mime_type.ToString().c_str());
}
TEST(URLTest, Base64Encode) {
const std::string& test_str_decoded = "A test string";
const std::string& test_str_encoded = "QSB0ZXN0IHN0cmluZw==";
const CefString& encoded_value =
CefBase64Encode(test_str_decoded.data(), test_str_decoded.size());
EXPECT_STREQ(test_str_encoded.c_str(), encoded_value.ToString().c_str());
}
TEST(URLTest, Base64Decode) {
const std::string& test_str_decoded = "A test string";
const std::string& test_str_encoded = "QSB0ZXN0IHN0cmluZw==";
CefRefPtr<CefBinaryValue> decoded_value = CefBase64Decode(test_str_encoded);
EXPECT_TRUE(decoded_value.get());
const size_t decoded_size = decoded_value->GetSize();
EXPECT_EQ(test_str_decoded.size(), decoded_size);
std::string decoded_str;
decoded_str.resize(decoded_size + 1); // Include space for NUL-terminator.
const size_t get_data_result =
decoded_value->GetData(const_cast<char*>(decoded_str.data()),
decoded_size, 0);
EXPECT_EQ(decoded_size, get_data_result);
EXPECT_STREQ(test_str_decoded.c_str(), decoded_str.c_str());
}
TEST(URLTest, URIEncode) {
const std::string& test_str_decoded = "A test string=";
const std::string& test_str_encoded = "A%20test%20string%3D";
const CefString& encoded_value = CefURIEncode(test_str_decoded, false);
EXPECT_STREQ(test_str_encoded.c_str(), encoded_value.ToString().c_str());
}
TEST(URLTest, URIDecode) {
const std::string& test_str_decoded = "A test string=";
const std::string& test_str_encoded = "A%20test%20string%3D";
const CefString& decoded_value =
CefURIDecode(test_str_encoded, false,
static_cast<cef_uri_unescape_rule_t>(
UU_SPACES | UU_URL_SPECIAL_CHARS));
EXPECT_STREQ(test_str_decoded.c_str(), decoded_value.ToString().c_str());
}