Structural improvements for request handling (issue #1044)

- Add new CefRequestContext and CefRequestContextHandler classes.
- Add CefRequestContext argument to CefBrowserHost static factory methods.
- Move GetCookieManager from CefRequestHandler to CefRequestContextHandler.
- Use BrowserContext as the root proxy object for network requests.
- Move accessors for CefBrowserMainParts members from CefContext to CefContentBrowserClient.

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@1424 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt
2013-09-03 16:43:31 +00:00
parent 935a35f21c
commit 385be456c3
57 changed files with 2288 additions and 440 deletions

View File

@ -12,6 +12,7 @@
#include "libcef_dll/cpptoc/browser_cpptoc.h"
#include "libcef_dll/cpptoc/browser_host_cpptoc.h"
#include "libcef_dll/cpptoc/request_context_cpptoc.h"
#include "libcef_dll/ctocpp/client_ctocpp.h"
#include "libcef_dll/ctocpp/run_file_dialog_callback_ctocpp.h"
#include "libcef_dll/transfer_util.h"
@ -21,7 +22,8 @@
CEF_EXPORT int cef_browser_host_create_browser(
const cef_window_info_t* windowInfo, struct _cef_client_t* client,
const cef_string_t* url, const struct _cef_browser_settings_t* settings) {
const cef_string_t* url, const struct _cef_browser_settings_t* settings,
struct _cef_request_context_t* request_context) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: windowInfo; type: struct_byref_const
@ -32,7 +34,7 @@ CEF_EXPORT int cef_browser_host_create_browser(
DCHECK(settings);
if (!settings)
return 0;
// Unverified params: client, url
// Unverified params: client, url, request_context
// Translate param: windowInfo; type: struct_byref_const
CefWindowInfo windowInfoObj;
@ -48,7 +50,8 @@ CEF_EXPORT int cef_browser_host_create_browser(
windowInfoObj,
CefClientCToCpp::Wrap(client),
CefString(url),
settingsObj);
settingsObj,
CefRequestContextCppToC::Unwrap(request_context));
// Return type: bool
return _retval;
@ -56,7 +59,8 @@ CEF_EXPORT int cef_browser_host_create_browser(
CEF_EXPORT cef_browser_t* cef_browser_host_create_browser_sync(
const cef_window_info_t* windowInfo, struct _cef_client_t* client,
const cef_string_t* url, const struct _cef_browser_settings_t* settings) {
const cef_string_t* url, const struct _cef_browser_settings_t* settings,
struct _cef_request_context_t* request_context) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: windowInfo; type: struct_byref_const
@ -67,7 +71,7 @@ CEF_EXPORT cef_browser_t* cef_browser_host_create_browser_sync(
DCHECK(settings);
if (!settings)
return NULL;
// Unverified params: client, url
// Unverified params: client, url, request_context
// Translate param: windowInfo; type: struct_byref_const
CefWindowInfo windowInfoObj;
@ -83,7 +87,8 @@ CEF_EXPORT cef_browser_t* cef_browser_host_create_browser_sync(
windowInfoObj,
CefClientCToCpp::Wrap(client),
CefString(url),
settingsObj);
settingsObj,
CefRequestContextCppToC::Unwrap(request_context));
// Return type: refptr_same
return CefBrowserCppToC::Wrap(_retval);
@ -192,6 +197,22 @@ struct _cef_client_t* CEF_CALLBACK browser_host_get_client(
return CefClientCToCpp::Unwrap(_retval);
}
struct _cef_request_context_t* CEF_CALLBACK browser_host_get_request_context(
struct _cef_browser_host_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return NULL;
// Execute
CefRefPtr<CefRequestContext> _retval = CefBrowserHostCppToC::Get(
self)->GetRequestContext();
// Return type: refptr_same
return CefRequestContextCppToC::Wrap(_retval);
}
cef_string_userfree_t CEF_CALLBACK browser_host_get_dev_tools_url(
struct _cef_browser_host_t* self, int http_scheme) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
@ -559,6 +580,7 @@ CefBrowserHostCppToC::CefBrowserHostCppToC(CefBrowserHost* cls)
struct_.struct_.get_opener_window_handle =
browser_host_get_opener_window_handle;
struct_.struct_.get_client = browser_host_get_client;
struct_.struct_.get_request_context = browser_host_get_request_context;
struct_.struct_.get_dev_tools_url = browser_host_get_dev_tools_url;
struct_.struct_.get_zoom_level = browser_host_get_zoom_level;
struct_.struct_.set_zoom_level = browser_host_set_zoom_level;

View File

@ -0,0 +1,112 @@
// Copyright (c) 2013 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/request_context_cpptoc.h"
#include "libcef_dll/ctocpp/request_context_handler_ctocpp.h"
// GLOBAL FUNCTIONS - Body may be edited by hand.
CEF_EXPORT cef_request_context_t* cef_request_context_get_global_context() {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
CefRefPtr<CefRequestContext> _retval = CefRequestContext::GetGlobalContext();
// Return type: refptr_same
return CefRequestContextCppToC::Wrap(_retval);
}
CEF_EXPORT cef_request_context_t* cef_request_context_create_context(
struct _cef_request_context_handler_t* handler) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Unverified params: handler
// Execute
CefRefPtr<CefRequestContext> _retval = CefRequestContext::CreateContext(
CefRequestContextHandlerCToCpp::Wrap(handler));
// Return type: refptr_same
return CefRequestContextCppToC::Wrap(_retval);
}
// MEMBER FUNCTIONS - Body may be edited by hand.
int CEF_CALLBACK request_context_is_same(struct _cef_request_context_t* self,
struct _cef_request_context_t* other) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Verify param: other; type: refptr_same
DCHECK(other);
if (!other)
return 0;
// Execute
bool _retval = CefRequestContextCppToC::Get(self)->IsSame(
CefRequestContextCppToC::Unwrap(other));
// Return type: bool
return _retval;
}
int CEF_CALLBACK request_context_is_global(
struct _cef_request_context_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Execute
bool _retval = CefRequestContextCppToC::Get(self)->IsGlobal();
// Return type: bool
return _retval;
}
struct _cef_request_context_handler_t* CEF_CALLBACK request_context_get_handler(
struct _cef_request_context_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return NULL;
// Execute
CefRefPtr<CefRequestContextHandler> _retval = CefRequestContextCppToC::Get(
self)->GetHandler();
// Return type: refptr_diff
return CefRequestContextHandlerCToCpp::Unwrap(_retval);
}
// CONSTRUCTOR - Do not edit by hand.
CefRequestContextCppToC::CefRequestContextCppToC(CefRequestContext* cls)
: CefCppToC<CefRequestContextCppToC, CefRequestContext,
cef_request_context_t>(cls) {
struct_.struct_.is_same = request_context_is_same;
struct_.struct_.is_global = request_context_is_global;
struct_.struct_.get_handler = request_context_get_handler;
}
#ifndef NDEBUG
template<> long CefCppToC<CefRequestContextCppToC, CefRequestContext,
cef_request_context_t>::DebugObjCt = 0;
#endif

View File

@ -0,0 +1,37 @@
// Copyright (c) 2013 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_REQUEST_CONTEXT_CPPTOC_H_
#define CEF_LIBCEF_DLL_CPPTOC_REQUEST_CONTEXT_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_request_context.h"
#include "include/capi/cef_request_context_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 CefRequestContextCppToC
: public CefCppToC<CefRequestContextCppToC, CefRequestContext,
cef_request_context_t> {
public:
explicit CefRequestContextCppToC(CefRequestContext* cls);
virtual ~CefRequestContextCppToC() {}
};
#endif // BUILDING_CEF_SHARED
#endif // CEF_LIBCEF_DLL_CPPTOC_REQUEST_CONTEXT_CPPTOC_H_

View File

@ -0,0 +1,50 @@
// Copyright (c) 2013 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/request_context_handler_cpptoc.h"
#include "libcef_dll/ctocpp/cookie_manager_ctocpp.h"
// MEMBER FUNCTIONS - Body may be edited by hand.
cef_cookie_manager_t* CEF_CALLBACK request_context_handler_get_cookie_manager(
struct _cef_request_context_handler_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return NULL;
// Execute
CefRefPtr<CefCookieManager> _retval = CefRequestContextHandlerCppToC::Get(
self)->GetCookieManager();
// Return type: refptr_diff
return CefCookieManagerCToCpp::Unwrap(_retval);
}
// CONSTRUCTOR - Do not edit by hand.
CefRequestContextHandlerCppToC::CefRequestContextHandlerCppToC(
CefRequestContextHandler* cls)
: CefCppToC<CefRequestContextHandlerCppToC, CefRequestContextHandler,
cef_request_context_handler_t>(cls) {
struct_.struct_.get_cookie_manager =
request_context_handler_get_cookie_manager;
}
#ifndef NDEBUG
template<> long CefCppToC<CefRequestContextHandlerCppToC,
CefRequestContextHandler, cef_request_context_handler_t>::DebugObjCt = 0;
#endif

View File

@ -0,0 +1,37 @@
// Copyright (c) 2013 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_REQUEST_CONTEXT_HANDLER_CPPTOC_H_
#define CEF_LIBCEF_DLL_CPPTOC_REQUEST_CONTEXT_HANDLER_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_handler.h"
#include "include/capi/cef_request_context_handler_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 CefRequestContextHandlerCppToC
: public CefCppToC<CefRequestContextHandlerCppToC, CefRequestContextHandler,
cef_request_context_handler_t> {
public:
explicit CefRequestContextHandlerCppToC(CefRequestContextHandler* cls);
virtual ~CefRequestContextHandlerCppToC() {}
};
#endif // USING_CEF_SHARED
#endif // CEF_LIBCEF_DLL_CPPTOC_REQUEST_CONTEXT_HANDLER_CPPTOC_H_

View File

@ -15,7 +15,6 @@
#include "libcef_dll/ctocpp/allow_certificate_error_callback_ctocpp.h"
#include "libcef_dll/ctocpp/auth_callback_ctocpp.h"
#include "libcef_dll/ctocpp/browser_ctocpp.h"
#include "libcef_dll/ctocpp/cookie_manager_ctocpp.h"
#include "libcef_dll/ctocpp/frame_ctocpp.h"
#include "libcef_dll/ctocpp/quota_callback_ctocpp.h"
#include "libcef_dll/ctocpp/request_ctocpp.h"
@ -203,33 +202,6 @@ int CEF_CALLBACK request_handler_on_quota_request(
return _retval;
}
cef_cookie_manager_t* CEF_CALLBACK request_handler_get_cookie_manager(
struct _cef_request_handler_t* self, cef_browser_t* browser,
const cef_string_t* main_url) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return NULL;
// Verify param: browser; type: refptr_diff
DCHECK(browser);
if (!browser)
return NULL;
// Verify param: main_url; type: string_byref_const
DCHECK(main_url);
if (!main_url)
return NULL;
// Execute
CefRefPtr<CefCookieManager> _retval = CefRequestHandlerCppToC::Get(
self)->GetCookieManager(
CefBrowserCToCpp::Wrap(browser),
CefString(main_url));
// Return type: refptr_diff
return CefCookieManagerCToCpp::Unwrap(_retval);
}
void CEF_CALLBACK request_handler_on_protocol_execution(
struct _cef_request_handler_t* self, cef_browser_t* browser,
const cef_string_t* url, int* allow_os_execution) {
@ -336,7 +308,6 @@ CefRequestHandlerCppToC::CefRequestHandlerCppToC(CefRequestHandler* cls)
struct_.struct_.on_resource_redirect = request_handler_on_resource_redirect;
struct_.struct_.get_auth_credentials = request_handler_get_auth_credentials;
struct_.struct_.on_quota_request = request_handler_on_quota_request;
struct_.struct_.get_cookie_manager = request_handler_get_cookie_manager;
struct_.struct_.on_protocol_execution = request_handler_on_protocol_execution;
struct_.struct_.on_before_plugin_load = request_handler_on_before_plugin_load;
struct_.struct_.on_certificate_error = request_handler_on_certificate_error;