mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
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:
@@ -14,6 +14,7 @@
|
||||
#include "libcef_dll/cpptoc/run_file_dialog_callback_cpptoc.h"
|
||||
#include "libcef_dll/ctocpp/browser_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/browser_host_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/request_context_ctocpp.h"
|
||||
#include "libcef_dll/transfer_util.h"
|
||||
|
||||
|
||||
@@ -21,17 +22,19 @@
|
||||
|
||||
bool CefBrowserHost::CreateBrowser(const CefWindowInfo& windowInfo,
|
||||
CefRefPtr<CefClient> client, const CefString& url,
|
||||
const CefBrowserSettings& settings) {
|
||||
const CefBrowserSettings& settings,
|
||||
CefRefPtr<CefRequestContext> request_context) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Unverified params: client, url
|
||||
// Unverified params: client, url, request_context
|
||||
|
||||
// Execute
|
||||
int _retval = cef_browser_host_create_browser(
|
||||
&windowInfo,
|
||||
CefClientCppToC::Wrap(client),
|
||||
url.GetStruct(),
|
||||
&settings);
|
||||
&settings,
|
||||
CefRequestContextCToCpp::Unwrap(request_context));
|
||||
|
||||
// Return type: bool
|
||||
return _retval?true:false;
|
||||
@@ -39,17 +42,19 @@ bool CefBrowserHost::CreateBrowser(const CefWindowInfo& windowInfo,
|
||||
|
||||
CefRefPtr<CefBrowser> CefBrowserHost::CreateBrowserSync(
|
||||
const CefWindowInfo& windowInfo, CefRefPtr<CefClient> client,
|
||||
const CefString& url, const CefBrowserSettings& settings) {
|
||||
const CefString& url, const CefBrowserSettings& settings,
|
||||
CefRefPtr<CefRequestContext> request_context) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Unverified params: client, url
|
||||
// Unverified params: client, url, request_context
|
||||
|
||||
// Execute
|
||||
cef_browser_t* _retval = cef_browser_host_create_browser_sync(
|
||||
&windowInfo,
|
||||
CefClientCppToC::Wrap(client),
|
||||
url.GetStruct(),
|
||||
&settings);
|
||||
&settings,
|
||||
CefRequestContextCToCpp::Unwrap(request_context));
|
||||
|
||||
// Return type: refptr_same
|
||||
return CefBrowserCToCpp::Wrap(_retval);
|
||||
@@ -142,6 +147,19 @@ CefRefPtr<CefClient> CefBrowserHostCToCpp::GetClient() {
|
||||
return CefClientCppToC::Unwrap(_retval);
|
||||
}
|
||||
|
||||
CefRefPtr<CefRequestContext> CefBrowserHostCToCpp::GetRequestContext() {
|
||||
if (CEF_MEMBER_MISSING(struct_, get_request_context))
|
||||
return NULL;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
cef_request_context_t* _retval = struct_->get_request_context(struct_);
|
||||
|
||||
// Return type: refptr_same
|
||||
return CefRequestContextCToCpp::Wrap(_retval);
|
||||
}
|
||||
|
||||
CefString CefBrowserHostCToCpp::GetDevToolsURL(bool http_scheme) {
|
||||
if (CEF_MEMBER_MISSING(struct_, get_dev_tools_url))
|
||||
return CefString();
|
||||
|
@@ -44,6 +44,7 @@ class CefBrowserHostCToCpp
|
||||
virtual CefWindowHandle GetWindowHandle() OVERRIDE;
|
||||
virtual CefWindowHandle GetOpenerWindowHandle() OVERRIDE;
|
||||
virtual CefRefPtr<CefClient> GetClient() OVERRIDE;
|
||||
virtual CefRefPtr<CefRequestContext> GetRequestContext() OVERRIDE;
|
||||
virtual CefString GetDevToolsURL(bool http_scheme) OVERRIDE;
|
||||
virtual double GetZoomLevel() OVERRIDE;
|
||||
virtual void SetZoomLevel(double zoomLevel) OVERRIDE;
|
||||
|
96
libcef_dll/ctocpp/request_context_ctocpp.cc
Normal file
96
libcef_dll/ctocpp/request_context_ctocpp.cc
Normal file
@@ -0,0 +1,96 @@
|
||||
// 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/request_context_ctocpp.h"
|
||||
|
||||
|
||||
// STATIC METHODS - Body may be edited by hand.
|
||||
|
||||
CefRefPtr<CefRequestContext> CefRequestContext::GetGlobalContext() {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
cef_request_context_t* _retval = cef_request_context_get_global_context();
|
||||
|
||||
// Return type: refptr_same
|
||||
return CefRequestContextCToCpp::Wrap(_retval);
|
||||
}
|
||||
|
||||
CefRefPtr<CefRequestContext> CefRequestContext::CreateContext(
|
||||
CefRefPtr<CefRequestContextHandler> handler) {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Unverified params: handler
|
||||
|
||||
// Execute
|
||||
cef_request_context_t* _retval = cef_request_context_create_context(
|
||||
CefRequestContextHandlerCppToC::Wrap(handler));
|
||||
|
||||
// Return type: refptr_same
|
||||
return CefRequestContextCToCpp::Wrap(_retval);
|
||||
}
|
||||
|
||||
|
||||
// VIRTUAL METHODS - Body may be edited by hand.
|
||||
|
||||
bool CefRequestContextCToCpp::IsSame(CefRefPtr<CefRequestContext> other) {
|
||||
if (CEF_MEMBER_MISSING(struct_, is_same))
|
||||
return false;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Verify param: other; type: refptr_same
|
||||
DCHECK(other.get());
|
||||
if (!other.get())
|
||||
return false;
|
||||
|
||||
// Execute
|
||||
int _retval = struct_->is_same(struct_,
|
||||
CefRequestContextCToCpp::Unwrap(other));
|
||||
|
||||
// Return type: bool
|
||||
return _retval?true:false;
|
||||
}
|
||||
|
||||
bool CefRequestContextCToCpp::IsGlobal() {
|
||||
if (CEF_MEMBER_MISSING(struct_, is_global))
|
||||
return false;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
int _retval = struct_->is_global(struct_);
|
||||
|
||||
// Return type: bool
|
||||
return _retval?true:false;
|
||||
}
|
||||
|
||||
CefRefPtr<CefRequestContextHandler> CefRequestContextCToCpp::GetHandler() {
|
||||
if (CEF_MEMBER_MISSING(struct_, get_handler))
|
||||
return NULL;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
cef_request_context_handler_t* _retval = struct_->get_handler(struct_);
|
||||
|
||||
// Return type: refptr_diff
|
||||
return CefRequestContextHandlerCppToC::Unwrap(_retval);
|
||||
}
|
||||
|
||||
|
||||
#ifndef NDEBUG
|
||||
template<> long CefCToCpp<CefRequestContextCToCpp, CefRequestContext,
|
||||
cef_request_context_t>::DebugObjCt = 0;
|
||||
#endif
|
||||
|
44
libcef_dll/ctocpp/request_context_ctocpp.h
Normal file
44
libcef_dll/ctocpp/request_context_ctocpp.h
Normal file
@@ -0,0 +1,44 @@
|
||||
// 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_CTOCPP_REQUEST_CONTEXT_CTOCPP_H_
|
||||
#define CEF_LIBCEF_DLL_CTOCPP_REQUEST_CONTEXT_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_request_context.h"
|
||||
#include "include/capi/cef_request_context_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 CefRequestContextCToCpp
|
||||
: public CefCToCpp<CefRequestContextCToCpp, CefRequestContext,
|
||||
cef_request_context_t> {
|
||||
public:
|
||||
explicit CefRequestContextCToCpp(cef_request_context_t* str)
|
||||
: CefCToCpp<CefRequestContextCToCpp, CefRequestContext,
|
||||
cef_request_context_t>(str) {}
|
||||
virtual ~CefRequestContextCToCpp() {}
|
||||
|
||||
// CefRequestContext methods
|
||||
virtual bool IsSame(CefRefPtr<CefRequestContext> other) OVERRIDE;
|
||||
virtual bool IsGlobal() OVERRIDE;
|
||||
virtual CefRefPtr<CefRequestContextHandler> GetHandler() OVERRIDE;
|
||||
};
|
||||
|
||||
#endif // USING_CEF_SHARED
|
||||
#endif // CEF_LIBCEF_DLL_CTOCPP_REQUEST_CONTEXT_CTOCPP_H_
|
||||
|
37
libcef_dll/ctocpp/request_context_handler_ctocpp.cc
Normal file
37
libcef_dll/ctocpp/request_context_handler_ctocpp.cc
Normal 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.
|
||||
//
|
||||
|
||||
#include "libcef_dll/cpptoc/cookie_manager_cpptoc.h"
|
||||
#include "libcef_dll/ctocpp/request_context_handler_ctocpp.h"
|
||||
|
||||
|
||||
// VIRTUAL METHODS - Body may be edited by hand.
|
||||
|
||||
CefRefPtr<CefCookieManager> CefRequestContextHandlerCToCpp::GetCookieManager() {
|
||||
if (CEF_MEMBER_MISSING(struct_, get_cookie_manager))
|
||||
return NULL;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
cef_cookie_manager_t* _retval = struct_->get_cookie_manager(struct_);
|
||||
|
||||
// Return type: refptr_diff
|
||||
return CefCookieManagerCppToC::Unwrap(_retval);
|
||||
}
|
||||
|
||||
|
||||
#ifndef NDEBUG
|
||||
template<> long CefCToCpp<CefRequestContextHandlerCToCpp,
|
||||
CefRequestContextHandler, cef_request_context_handler_t>::DebugObjCt = 0;
|
||||
#endif
|
||||
|
42
libcef_dll/ctocpp/request_context_handler_ctocpp.h
Normal file
42
libcef_dll/ctocpp/request_context_handler_ctocpp.h
Normal file
@@ -0,0 +1,42 @@
|
||||
// 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_CTOCPP_REQUEST_CONTEXT_HANDLER_CTOCPP_H_
|
||||
#define CEF_LIBCEF_DLL_CTOCPP_REQUEST_CONTEXT_HANDLER_CTOCPP_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_handler.h"
|
||||
#include "include/capi/cef_request_context_handler_capi.h"
|
||||
#include "libcef_dll/ctocpp/ctocpp.h"
|
||||
|
||||
// Wrap a C structure with a C++ class.
|
||||
// This class may be instantiated and accessed DLL-side only.
|
||||
class CefRequestContextHandlerCToCpp
|
||||
: public CefCToCpp<CefRequestContextHandlerCToCpp, CefRequestContextHandler,
|
||||
cef_request_context_handler_t> {
|
||||
public:
|
||||
explicit CefRequestContextHandlerCToCpp(cef_request_context_handler_t* str)
|
||||
: CefCToCpp<CefRequestContextHandlerCToCpp, CefRequestContextHandler,
|
||||
cef_request_context_handler_t>(str) {}
|
||||
virtual ~CefRequestContextHandlerCToCpp() {}
|
||||
|
||||
// CefRequestContextHandler methods
|
||||
virtual CefRefPtr<CefCookieManager> GetCookieManager() OVERRIDE;
|
||||
};
|
||||
|
||||
#endif // BUILDING_CEF_SHARED
|
||||
#endif // CEF_LIBCEF_DLL_CTOCPP_REQUEST_CONTEXT_HANDLER_CTOCPP_H_
|
||||
|
@@ -13,7 +13,6 @@
|
||||
#include "libcef_dll/cpptoc/allow_certificate_error_callback_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/auth_callback_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/browser_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/cookie_manager_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/frame_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/quota_callback_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/request_cpptoc.h"
|
||||
@@ -192,31 +191,6 @@ bool CefRequestHandlerCToCpp::OnQuotaRequest(CefRefPtr<CefBrowser> browser,
|
||||
return _retval?true:false;
|
||||
}
|
||||
|
||||
CefRefPtr<CefCookieManager> CefRequestHandlerCToCpp::GetCookieManager(
|
||||
CefRefPtr<CefBrowser> browser, const CefString& main_url) {
|
||||
if (CEF_MEMBER_MISSING(struct_, get_cookie_manager))
|
||||
return NULL;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Verify param: browser; type: refptr_diff
|
||||
DCHECK(browser.get());
|
||||
if (!browser.get())
|
||||
return NULL;
|
||||
// Verify param: main_url; type: string_byref_const
|
||||
DCHECK(!main_url.empty());
|
||||
if (main_url.empty())
|
||||
return NULL;
|
||||
|
||||
// Execute
|
||||
cef_cookie_manager_t* _retval = struct_->get_cookie_manager(struct_,
|
||||
CefBrowserCppToC::Wrap(browser),
|
||||
main_url.GetStruct());
|
||||
|
||||
// Return type: refptr_diff
|
||||
return CefCookieManagerCppToC::Unwrap(_retval);
|
||||
}
|
||||
|
||||
void CefRequestHandlerCToCpp::OnProtocolExecution(CefRefPtr<CefBrowser> browser,
|
||||
const CefString& url, bool& allow_os_execution) {
|
||||
if (CEF_MEMBER_MISSING(struct_, on_protocol_execution))
|
||||
|
@@ -49,8 +49,6 @@ class CefRequestHandlerCToCpp
|
||||
virtual bool OnQuotaRequest(CefRefPtr<CefBrowser> browser,
|
||||
const CefString& origin_url, int64 new_size,
|
||||
CefRefPtr<CefQuotaCallback> callback) OVERRIDE;
|
||||
virtual CefRefPtr<CefCookieManager> GetCookieManager(
|
||||
CefRefPtr<CefBrowser> browser, const CefString& main_url) OVERRIDE;
|
||||
virtual void OnProtocolExecution(CefRefPtr<CefBrowser> browser,
|
||||
const CefString& url, bool& allow_os_execution) OVERRIDE;
|
||||
virtual bool OnBeforePluginLoad(CefRefPtr<CefBrowser> browser,
|
||||
|
Reference in New Issue
Block a user