mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-02-10 00:50:38 +01:00
Add CefHandler::HandleAuthenticationRequest for handling authentication requests (issue #150).
git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@158 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
parent
c7959e2106
commit
874c73b1e1
@ -651,6 +651,19 @@ public:
|
|||||||
int64 contentLength,
|
int64 contentLength,
|
||||||
CefRefPtr<CefDownloadHandler>& handler) =0;
|
CefRefPtr<CefDownloadHandler>& handler) =0;
|
||||||
|
|
||||||
|
// Called when the browser needs credentials from the user. |isProxy|
|
||||||
|
// indicates whether the host is a proxy server. |host| contains the hostname
|
||||||
|
// and port number. Set |username| and |password| and return RV_HANDLED to
|
||||||
|
// handle the request. Return RV_CONTINUE to cancel the request.
|
||||||
|
/*--cef()--*/
|
||||||
|
virtual RetVal HandleAuthenticationRequest(CefRefPtr<CefBrowser> browser,
|
||||||
|
bool isProxy,
|
||||||
|
const CefString& host,
|
||||||
|
const CefString& realm,
|
||||||
|
const CefString& scheme,
|
||||||
|
CefString& username,
|
||||||
|
CefString& password) =0;
|
||||||
|
|
||||||
// Structure representing menu information.
|
// Structure representing menu information.
|
||||||
typedef cef_handler_menuinfo_t MenuInfo;
|
typedef cef_handler_menuinfo_t MenuInfo;
|
||||||
|
|
||||||
|
@ -460,6 +460,16 @@ typedef struct _cef_handler_t
|
|||||||
const cef_string_t* mimeType, const cef_string_t* fileName,
|
const cef_string_t* mimeType, const cef_string_t* fileName,
|
||||||
int64 contentLength, struct _cef_download_handler_t** handler);
|
int64 contentLength, struct _cef_download_handler_t** handler);
|
||||||
|
|
||||||
|
// Called when the browser needs credentials from the user. |isProxy|
|
||||||
|
// indicates whether the host is a proxy server. |host| contains the hostname
|
||||||
|
// and port number. Set |username| and |password| and return RV_HANDLED to
|
||||||
|
// handle the request. Return RV_CONTINUE to cancel the request.
|
||||||
|
enum cef_retval_t (CEF_CALLBACK *handle_authentication_request)(
|
||||||
|
struct _cef_handler_t* self, struct _cef_browser_t* browser, int isProxy,
|
||||||
|
const cef_string_t* host, const cef_string_t* realm,
|
||||||
|
const cef_string_t* scheme, cef_string_t* username,
|
||||||
|
cef_string_t* password);
|
||||||
|
|
||||||
// Event called before a context menu is displayed. To cancel display of the
|
// Event called before a context menu is displayed. To cancel display of the
|
||||||
// default context menu return RV_HANDLED.
|
// default context menu return RV_HANDLED.
|
||||||
enum cef_retval_t (CEF_CALLBACK *handle_before_menu)(
|
enum cef_retval_t (CEF_CALLBACK *handle_before_menu)(
|
||||||
|
@ -54,6 +54,7 @@
|
|||||||
#include "base/timer.h"
|
#include "base/timer.h"
|
||||||
#include "base/thread.h"
|
#include "base/thread.h"
|
||||||
#include "base/waitable_event.h"
|
#include "base/waitable_event.h"
|
||||||
|
#include "net/base/auth.h"
|
||||||
#include "net/base/cookie_store.h"
|
#include "net/base/cookie_store.h"
|
||||||
#include "net/base/file_stream.h"
|
#include "net/base/file_stream.h"
|
||||||
#include "net/base/io_buffer.h"
|
#include "net/base/io_buffer.h"
|
||||||
@ -552,6 +553,26 @@ class RequestProxy : public net::URLRequest::Delegate,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual void OnAuthRequired(net::URLRequest* request,
|
||||||
|
net::AuthChallengeInfo* auth_info) {
|
||||||
|
if (browser_.get()) {
|
||||||
|
CefRefPtr<CefHandler> handler = browser_->GetHandler();
|
||||||
|
if(handler.get()) {
|
||||||
|
CefString username, password;
|
||||||
|
CefHandler::RetVal rv = handler->HandleAuthenticationRequest(
|
||||||
|
browser_, auth_info->is_proxy,
|
||||||
|
auth_info->host_and_port, auth_info->realm,
|
||||||
|
auth_info->scheme, username, password);
|
||||||
|
if (rv == RV_HANDLED) {
|
||||||
|
request->SetAuth(username, password);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
request->CancelAuth();
|
||||||
|
}
|
||||||
|
|
||||||
virtual void OnSSLCertificateError(net::URLRequest* request,
|
virtual void OnSSLCertificateError(net::URLRequest* request,
|
||||||
int cert_error,
|
int cert_error,
|
||||||
net::X509Certificate* cert) {
|
net::X509Certificate* cert) {
|
||||||
|
@ -237,6 +237,27 @@ enum cef_retval_t CEF_CALLBACK handler_handle_download_response(
|
|||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum cef_retval_t CEF_CALLBACK handler_handle_authentication_request(
|
||||||
|
struct _cef_handler_t* self, cef_browser_t* browser, int isProxy,
|
||||||
|
const cef_string_t* host, const cef_string_t* realm,
|
||||||
|
const cef_string_t* scheme, cef_string_t* username,
|
||||||
|
cef_string_t* password)
|
||||||
|
{
|
||||||
|
DCHECK(self);
|
||||||
|
DCHECK(browser);
|
||||||
|
DCHECK(username && password);
|
||||||
|
if (!self || !browser || !username || !password)
|
||||||
|
return RV_CONTINUE;
|
||||||
|
|
||||||
|
CefString usernameStr(username);
|
||||||
|
CefString passwordStr(password);
|
||||||
|
|
||||||
|
return CefHandlerCppToC::Get(self)->
|
||||||
|
HandleAuthenticationRequest(CefBrowserCToCpp::Wrap(browser),
|
||||||
|
(isProxy ? true : false), CefString(host), CefString(realm),
|
||||||
|
CefString(scheme), usernameStr, passwordStr);
|
||||||
|
}
|
||||||
|
|
||||||
enum cef_retval_t CEF_CALLBACK handler_handle_before_menu(
|
enum cef_retval_t CEF_CALLBACK handler_handle_before_menu(
|
||||||
struct _cef_handler_t* self, cef_browser_t* browser,
|
struct _cef_handler_t* self, cef_browser_t* browser,
|
||||||
const cef_handler_menuinfo_t* menuInfo)
|
const cef_handler_menuinfo_t* menuInfo)
|
||||||
@ -511,6 +532,8 @@ CefHandlerCppToC::CefHandlerCppToC(CefHandler* cls)
|
|||||||
struct_.struct_.handle_before_resource_load =
|
struct_.struct_.handle_before_resource_load =
|
||||||
handler_handle_before_resource_load;
|
handler_handle_before_resource_load;
|
||||||
struct_.struct_.handle_download_response = handler_handle_download_response;
|
struct_.struct_.handle_download_response = handler_handle_download_response;
|
||||||
|
struct_.struct_.handle_authentication_request =
|
||||||
|
handler_handle_authentication_request;
|
||||||
struct_.struct_.handle_before_menu = handler_handle_before_menu;
|
struct_.struct_.handle_before_menu = handler_handle_before_menu;
|
||||||
struct_.struct_.handle_get_menu_label = handler_handle_get_menu_label;
|
struct_.struct_.handle_get_menu_label = handler_handle_get_menu_label;
|
||||||
struct_.struct_.handle_menu_action = handler_handle_menu_action;
|
struct_.struct_.handle_menu_action = handler_handle_menu_action;
|
||||||
|
@ -178,6 +178,20 @@ CefHandler::RetVal CefHandlerCToCpp::HandleDownloadResponse(
|
|||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CefHandler::RetVal CefHandlerCToCpp::HandleAuthenticationRequest(
|
||||||
|
CefRefPtr<CefBrowser> browser, bool isProxy, const CefString& host,
|
||||||
|
const CefString& realm, const CefString& scheme, CefString& username,
|
||||||
|
CefString& password)
|
||||||
|
{
|
||||||
|
if(CEF_MEMBER_MISSING(struct_, handle_authentication_request))
|
||||||
|
return RV_CONTINUE;
|
||||||
|
|
||||||
|
return struct_->handle_authentication_request(struct_,
|
||||||
|
CefBrowserCppToC::Wrap(browser), isProxy,
|
||||||
|
host.GetStruct(), realm.GetStruct(), scheme.GetStruct(),
|
||||||
|
username.GetWritableStruct(), password.GetWritableStruct());
|
||||||
|
}
|
||||||
|
|
||||||
CefHandler::RetVal CefHandlerCToCpp::HandleBeforeMenu(
|
CefHandler::RetVal CefHandlerCToCpp::HandleBeforeMenu(
|
||||||
CefRefPtr<CefBrowser> browser, const MenuInfo& menuInfo)
|
CefRefPtr<CefBrowser> browser, const MenuInfo& menuInfo)
|
||||||
{
|
{
|
||||||
|
@ -57,6 +57,9 @@ public:
|
|||||||
virtual RetVal HandleDownloadResponse(CefRefPtr<CefBrowser> browser,
|
virtual RetVal HandleDownloadResponse(CefRefPtr<CefBrowser> browser,
|
||||||
const CefString& mimeType, const CefString& fileName,
|
const CefString& mimeType, const CefString& fileName,
|
||||||
int64 contentLength, CefRefPtr<CefDownloadHandler>& handler);
|
int64 contentLength, CefRefPtr<CefDownloadHandler>& handler);
|
||||||
|
virtual RetVal HandleAuthenticationRequest(CefRefPtr<CefBrowser> browser,
|
||||||
|
bool isProxy, const CefString& host, const CefString& realm,
|
||||||
|
const CefString& scheme, CefString& username, CefString& password);
|
||||||
virtual RetVal HandleBeforeMenu(CefRefPtr<CefBrowser> browser,
|
virtual RetVal HandleBeforeMenu(CefRefPtr<CefBrowser> browser,
|
||||||
const MenuInfo& menuInfo);
|
const MenuInfo& menuInfo);
|
||||||
virtual RetVal HandleGetMenuLabel(CefRefPtr<CefBrowser> browser,
|
virtual RetVal HandleGetMenuLabel(CefRefPtr<CefBrowser> browser,
|
||||||
|
@ -120,13 +120,27 @@ public:
|
|||||||
// no size was provided. Set |handler| to the CefDownloadHandler instance that
|
// no size was provided. Set |handler| to the CefDownloadHandler instance that
|
||||||
// will recieve the file contents. Return RV_CONTINUE to download the file
|
// will recieve the file contents. Return RV_CONTINUE to download the file
|
||||||
// or RV_HANDLED to cancel the file download.
|
// or RV_HANDLED to cancel the file download.
|
||||||
/*--cef()--*/
|
|
||||||
virtual RetVal HandleDownloadResponse(CefRefPtr<CefBrowser> browser,
|
virtual RetVal HandleDownloadResponse(CefRefPtr<CefBrowser> browser,
|
||||||
const CefString& mimeType,
|
const CefString& mimeType,
|
||||||
const CefString& fileName,
|
const CefString& fileName,
|
||||||
int64 contentLength,
|
int64 contentLength,
|
||||||
CefRefPtr<CefDownloadHandler>& handler);
|
CefRefPtr<CefDownloadHandler>& handler);
|
||||||
|
|
||||||
|
// Called when the browser needs credentials from the user. |isProxy|
|
||||||
|
// indicates whether the host is a proxy server. |host| contains the hostname
|
||||||
|
// and port number. Set |username| and |password| and return RV_HANDLED to
|
||||||
|
// handle the request. Return RV_CONTINUE to cancel the request.
|
||||||
|
virtual RetVal HandleAuthenticationRequest(CefRefPtr<CefBrowser> browser,
|
||||||
|
bool isProxy,
|
||||||
|
const CefString& host,
|
||||||
|
const CefString& realm,
|
||||||
|
const CefString& scheme,
|
||||||
|
CefString& username,
|
||||||
|
CefString& password)
|
||||||
|
{
|
||||||
|
return RV_CONTINUE;
|
||||||
|
}
|
||||||
|
|
||||||
// Event called before a context menu is displayed. To cancel display of the
|
// Event called before a context menu is displayed. To cancel display of the
|
||||||
// default context menu return RV_HANDLED.
|
// default context menu return RV_HANDLED.
|
||||||
virtual RetVal HandleBeforeMenu(CefRefPtr<CefBrowser> browser,
|
virtual RetVal HandleBeforeMenu(CefRefPtr<CefBrowser> browser,
|
||||||
|
@ -121,6 +121,17 @@ public:
|
|||||||
return RV_CONTINUE;
|
return RV_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual RetVal HandleAuthenticationRequest(CefRefPtr<CefBrowser> browser,
|
||||||
|
bool isProxy,
|
||||||
|
const CefString& host,
|
||||||
|
const CefString& realm,
|
||||||
|
const CefString& scheme,
|
||||||
|
CefString& username,
|
||||||
|
CefString& password)
|
||||||
|
{
|
||||||
|
return RV_CONTINUE;
|
||||||
|
}
|
||||||
|
|
||||||
virtual RetVal HandleBeforeMenu(CefRefPtr<CefBrowser> browser,
|
virtual RetVal HandleBeforeMenu(CefRefPtr<CefBrowser> browser,
|
||||||
const MenuInfo& menuInfo)
|
const MenuInfo& menuInfo)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user