Add support for complete isolation of storage and permissions (cache, cookies, localStorage, access grants, etc) on a per-request-context basis (issue #1044).

- CefRequestContext instances can be configured using a new CefRequestContextSettings structure passed to CefRequestContext::CreateContext.
- Scheme registration is now per-request-context using new CefRequestContext::RegisterSchemeHandlerFactory and ClearSchemeHandlerFactories methods.
- Cookie managers are now per-request-context by default and can be retrieved using a new CefRequestContext::GetDefaultCookieManager method.
- CefURLRequest::Create now accepts an optional CefRequestContext argument for associating a URL request with a context (browser process only).
- The CefRequestContextHandler associated with a CefRequestContext will not be released until all objects related to that context have been destroyed.
- When the cache path is empty an in-memory cache ("incognito mode") will be used for storage and no data will be persisted to disk.
- Add CefSettings.user_data_path which specifies the location where user data such as spell checking dictionary files will be stored on disk.
- Add asynchronous callbacks for all CefCookieManager methods.
- Add PK_LOCAL_APP_DATA and PK_USER_DATA path keys for retrieving user directories via CefGetPath.
- cefclient: Add "New Window" test that creates a new window unrelated to existing windows. When used in combination with `--request-context-per-browser` the new window will be given a new and isolated request context.

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@2040 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt
2015-03-02 20:25:14 +00:00
parent 031f192e5a
commit ca0e381681
91 changed files with 3816 additions and 1347 deletions

View File

@ -13,31 +13,39 @@
#include "libcef_dll/cpptoc/cookie_manager_cpptoc.h"
#include "libcef_dll/ctocpp/completion_callback_ctocpp.h"
#include "libcef_dll/ctocpp/cookie_visitor_ctocpp.h"
#include "libcef_dll/ctocpp/delete_cookies_callback_ctocpp.h"
#include "libcef_dll/ctocpp/set_cookie_callback_ctocpp.h"
#include "libcef_dll/transfer_util.h"
// GLOBAL FUNCTIONS - Body may be edited by hand.
CEF_EXPORT cef_cookie_manager_t* cef_cookie_manager_get_global_manager() {
CEF_EXPORT cef_cookie_manager_t* cef_cookie_manager_get_global_manager(
cef_completion_callback_t* callback) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Unverified params: callback
// Execute
CefRefPtr<CefCookieManager> _retval = CefCookieManager::GetGlobalManager();
CefRefPtr<CefCookieManager> _retval = CefCookieManager::GetGlobalManager(
CefCompletionCallbackCToCpp::Wrap(callback));
// Return type: refptr_same
return CefCookieManagerCppToC::Wrap(_retval);
}
CEF_EXPORT cef_cookie_manager_t* cef_cookie_manager_create_manager(
const cef_string_t* path, int persist_session_cookies) {
const cef_string_t* path, int persist_session_cookies,
cef_completion_callback_t* callback) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Unverified params: path
// Unverified params: path, callback
// Execute
CefRefPtr<CefCookieManager> _retval = CefCookieManager::CreateManager(
CefString(path),
persist_session_cookies?true:false);
persist_session_cookies?true:false,
CefCompletionCallbackCToCpp::Wrap(callback));
// Return type: refptr_same
return CefCookieManagerCppToC::Wrap(_retval);
@ -47,7 +55,8 @@ CEF_EXPORT cef_cookie_manager_t* cef_cookie_manager_create_manager(
// MEMBER FUNCTIONS - Body may be edited by hand.
void CEF_CALLBACK cookie_manager_set_supported_schemes(
struct _cef_cookie_manager_t* self, cef_string_list_t schemes) {
struct _cef_cookie_manager_t* self, cef_string_list_t schemes,
cef_completion_callback_t* callback) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
@ -57,6 +66,7 @@ void CEF_CALLBACK cookie_manager_set_supported_schemes(
DCHECK(schemes);
if (!schemes)
return;
// Unverified params: callback
// Translate param: schemes; type: string_vec_byref_const
std::vector<CefString> schemesList;
@ -64,7 +74,8 @@ void CEF_CALLBACK cookie_manager_set_supported_schemes(
// Execute
CefCookieManagerCppToC::Get(self)->SetSupportedSchemes(
schemesList);
schemesList,
CefCompletionCallbackCToCpp::Wrap(callback));
}
int CEF_CALLBACK cookie_manager_visit_all_cookies(
@ -116,7 +127,8 @@ int CEF_CALLBACK cookie_manager_visit_url_cookies(
}
int CEF_CALLBACK cookie_manager_set_cookie(struct _cef_cookie_manager_t* self,
const cef_string_t* url, const struct _cef_cookie_t* cookie) {
const cef_string_t* url, const struct _cef_cookie_t* cookie,
struct _cef_set_cookie_callback_t* callback) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
@ -130,6 +142,7 @@ int CEF_CALLBACK cookie_manager_set_cookie(struct _cef_cookie_manager_t* self,
DCHECK(cookie);
if (!cookie)
return 0;
// Unverified params: callback
// Translate param: cookie; type: struct_byref_const
CefCookie cookieObj;
@ -139,7 +152,8 @@ int CEF_CALLBACK cookie_manager_set_cookie(struct _cef_cookie_manager_t* self,
// Execute
bool _retval = CefCookieManagerCppToC::Get(self)->SetCookie(
CefString(url),
cookieObj);
cookieObj,
CefSetCookieCallbackCToCpp::Wrap(callback));
// Return type: bool
return _retval;
@ -147,18 +161,20 @@ int CEF_CALLBACK cookie_manager_set_cookie(struct _cef_cookie_manager_t* self,
int CEF_CALLBACK cookie_manager_delete_cookies(
struct _cef_cookie_manager_t* self, const cef_string_t* url,
const cef_string_t* cookie_name) {
const cef_string_t* cookie_name,
struct _cef_delete_cookies_callback_t* callback) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Unverified params: url, cookie_name
// Unverified params: url, cookie_name, callback
// Execute
bool _retval = CefCookieManagerCppToC::Get(self)->DeleteCookies(
CefString(url),
CefString(cookie_name));
CefString(cookie_name),
CefDeleteCookiesCallbackCToCpp::Wrap(callback));
// Return type: bool
return _retval;
@ -166,18 +182,19 @@ int CEF_CALLBACK cookie_manager_delete_cookies(
int CEF_CALLBACK cookie_manager_set_storage_path(
struct _cef_cookie_manager_t* self, const cef_string_t* path,
int persist_session_cookies) {
int persist_session_cookies, cef_completion_callback_t* callback) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Unverified params: path
// Unverified params: path, callback
// Execute
bool _retval = CefCookieManagerCppToC::Get(self)->SetStoragePath(
CefString(path),
persist_session_cookies?true:false);
persist_session_cookies?true:false,
CefCompletionCallbackCToCpp::Wrap(callback));
// Return type: bool
return _retval;
@ -190,10 +207,7 @@ int CEF_CALLBACK cookie_manager_flush_store(struct _cef_cookie_manager_t* self,
DCHECK(self);
if (!self)
return 0;
// Verify param: callback; type: refptr_diff
DCHECK(callback);
if (!callback)
return 0;
// Unverified params: callback
// Execute
bool _retval = CefCookieManagerCppToC::Get(self)->FlushStore(

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.
//
#include "libcef_dll/cpptoc/delete_cookies_callback_cpptoc.h"
// MEMBER FUNCTIONS - Body may be edited by hand.
void CEF_CALLBACK delete_cookies_callback_on_complete(
struct _cef_delete_cookies_callback_t* self, int num_deleted) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return;
// Execute
CefDeleteCookiesCallbackCppToC::Get(self)->OnComplete(
num_deleted);
}
// CONSTRUCTOR - Do not edit by hand.
CefDeleteCookiesCallbackCppToC::CefDeleteCookiesCallbackCppToC(
CefDeleteCookiesCallback* cls)
: CefCppToC<CefDeleteCookiesCallbackCppToC, CefDeleteCookiesCallback,
cef_delete_cookies_callback_t>(cls) {
struct_.struct_.on_complete = delete_cookies_callback_on_complete;
}
#ifndef NDEBUG
template<> base::AtomicRefCount CefCppToC<CefDeleteCookiesCallbackCppToC,
CefDeleteCookiesCallback, cef_delete_cookies_callback_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_DELETE_COOKIES_CALLBACK_CPPTOC_H_
#define CEF_LIBCEF_DLL_CPPTOC_DELETE_COOKIES_CALLBACK_CPPTOC_H_
#pragma once
#ifndef USING_CEF_SHARED
#pragma message("Warning: "__FILE__" may be accessed wrapper-side only")
#else // USING_CEF_SHARED
#include "include/cef_cookie.h"
#include "include/capi/cef_cookie_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 CefDeleteCookiesCallbackCppToC
: public CefCppToC<CefDeleteCookiesCallbackCppToC, CefDeleteCookiesCallback,
cef_delete_cookies_callback_t> {
public:
explicit CefDeleteCookiesCallbackCppToC(CefDeleteCookiesCallback* cls);
};
#endif // USING_CEF_SHARED
#endif // CEF_LIBCEF_DLL_CPPTOC_DELETE_COOKIES_CALLBACK_CPPTOC_H_

View File

@ -10,8 +10,11 @@
// for more information.
//
#include "libcef_dll/cpptoc/cookie_manager_cpptoc.h"
#include "libcef_dll/cpptoc/request_context_cpptoc.h"
#include "libcef_dll/ctocpp/completion_callback_ctocpp.h"
#include "libcef_dll/ctocpp/request_context_handler_ctocpp.h"
#include "libcef_dll/ctocpp/scheme_handler_factory_ctocpp.h"
// GLOBAL FUNCTIONS - Body may be edited by hand.
@ -27,13 +30,44 @@ CEF_EXPORT cef_request_context_t* cef_request_context_get_global_context() {
}
CEF_EXPORT cef_request_context_t* cef_request_context_create_context(
const struct _cef_request_context_settings_t* settings,
struct _cef_request_context_handler_t* handler) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: settings; type: struct_byref_const
DCHECK(settings);
if (!settings)
return NULL;
// Unverified params: handler
// Translate param: settings; type: struct_byref_const
CefRequestContextSettings settingsObj;
if (settings)
settingsObj.Set(*settings, false);
// Execute
CefRefPtr<CefRequestContext> _retval = CefRequestContext::CreateContext(
settingsObj,
CefRequestContextHandlerCToCpp::Wrap(handler));
// Return type: refptr_same
return CefRequestContextCppToC::Wrap(_retval);
}
CEF_EXPORT cef_request_context_t* create_context_shared(
cef_request_context_t* other,
struct _cef_request_context_handler_t* handler) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: other; type: refptr_same
DCHECK(other);
if (!other)
return NULL;
// Unverified params: handler
// Execute
CefRefPtr<CefRequestContext> _retval = CefRequestContext::CreateContext(
CefRequestContextCppToC::Unwrap(other),
CefRequestContextHandlerCToCpp::Wrap(handler));
// Return type: refptr_same
@ -63,6 +97,27 @@ int CEF_CALLBACK request_context_is_same(struct _cef_request_context_t* self,
return _retval;
}
int CEF_CALLBACK request_context_is_sharing_with(
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)->IsSharingWith(
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
@ -94,6 +149,81 @@ struct _cef_request_context_handler_t* CEF_CALLBACK request_context_get_handler(
return CefRequestContextHandlerCToCpp::Unwrap(_retval);
}
cef_string_userfree_t CEF_CALLBACK request_context_get_cache_path(
struct _cef_request_context_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return NULL;
// Execute
CefString _retval = CefRequestContextCppToC::Get(self)->GetCachePath();
// Return type: string
return _retval.DetachToUserFree();
}
cef_cookie_manager_t* CEF_CALLBACK request_context_get_default_cookie_manager(
struct _cef_request_context_t* self, cef_completion_callback_t* callback) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return NULL;
// Unverified params: callback
// Execute
CefRefPtr<CefCookieManager> _retval = CefRequestContextCppToC::Get(
self)->GetDefaultCookieManager(
CefCompletionCallbackCToCpp::Wrap(callback));
// Return type: refptr_same
return CefCookieManagerCppToC::Wrap(_retval);
}
int CEF_CALLBACK request_context_register_scheme_handler_factory(
struct _cef_request_context_t* self, const cef_string_t* scheme_name,
const cef_string_t* domain_name,
struct _cef_scheme_handler_factory_t* factory) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Verify param: scheme_name; type: string_byref_const
DCHECK(scheme_name);
if (!scheme_name)
return 0;
// Unverified params: domain_name, factory
// Execute
bool _retval = CefRequestContextCppToC::Get(
self)->RegisterSchemeHandlerFactory(
CefString(scheme_name),
CefString(domain_name),
CefSchemeHandlerFactoryCToCpp::Wrap(factory));
// Return type: bool
return _retval;
}
int CEF_CALLBACK request_context_clear_scheme_handler_factories(
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)->ClearSchemeHandlerFactories();
// Return type: bool
return _retval;
}
// CONSTRUCTOR - Do not edit by hand.
@ -101,8 +231,16 @@ CefRequestContextCppToC::CefRequestContextCppToC(CefRequestContext* cls)
: CefCppToC<CefRequestContextCppToC, CefRequestContext,
cef_request_context_t>(cls) {
struct_.struct_.is_same = request_context_is_same;
struct_.struct_.is_sharing_with = request_context_is_sharing_with;
struct_.struct_.is_global = request_context_is_global;
struct_.struct_.get_handler = request_context_get_handler;
struct_.struct_.get_cache_path = request_context_get_cache_path;
struct_.struct_.get_default_cookie_manager =
request_context_get_default_cookie_manager;
struct_.struct_.register_scheme_handler_factory =
request_context_register_scheme_handler_factory;
struct_.struct_.clear_scheme_handler_factories =
request_context_clear_scheme_handler_factories;
}
#ifndef NDEBUG

View File

@ -20,6 +20,8 @@
#include "include/cef_request_context.h"
#include "include/capi/cef_request_context_capi.h"
#include "include/cef_scheme.h"
#include "include/capi/cef_scheme_capi.h"
#include "libcef_dll/cpptoc/cpptoc.h"
// Wrap a C++ class with a C structure.

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.
//
#include "libcef_dll/cpptoc/set_cookie_callback_cpptoc.h"
// MEMBER FUNCTIONS - Body may be edited by hand.
void CEF_CALLBACK set_cookie_callback_on_complete(
struct _cef_set_cookie_callback_t* self, int success) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return;
// Execute
CefSetCookieCallbackCppToC::Get(self)->OnComplete(
success?true:false);
}
// CONSTRUCTOR - Do not edit by hand.
CefSetCookieCallbackCppToC::CefSetCookieCallbackCppToC(
CefSetCookieCallback* cls)
: CefCppToC<CefSetCookieCallbackCppToC, CefSetCookieCallback,
cef_set_cookie_callback_t>(cls) {
struct_.struct_.on_complete = set_cookie_callback_on_complete;
}
#ifndef NDEBUG
template<> base::AtomicRefCount CefCppToC<CefSetCookieCallbackCppToC,
CefSetCookieCallback, cef_set_cookie_callback_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_SET_COOKIE_CALLBACK_CPPTOC_H_
#define CEF_LIBCEF_DLL_CPPTOC_SET_COOKIE_CALLBACK_CPPTOC_H_
#pragma once
#ifndef USING_CEF_SHARED
#pragma message("Warning: "__FILE__" may be accessed wrapper-side only")
#else // USING_CEF_SHARED
#include "include/cef_cookie.h"
#include "include/capi/cef_cookie_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 CefSetCookieCallbackCppToC
: public CefCppToC<CefSetCookieCallbackCppToC, CefSetCookieCallback,
cef_set_cookie_callback_t> {
public:
explicit CefSetCookieCallbackCppToC(CefSetCookieCallback* cls);
};
#endif // USING_CEF_SHARED
#endif // CEF_LIBCEF_DLL_CPPTOC_SET_COOKIE_CALLBACK_CPPTOC_H_

View File

@ -11,6 +11,7 @@
//
#include "libcef_dll/cpptoc/request_cpptoc.h"
#include "libcef_dll/cpptoc/request_context_cpptoc.h"
#include "libcef_dll/cpptoc/response_cpptoc.h"
#include "libcef_dll/cpptoc/urlrequest_cpptoc.h"
#include "libcef_dll/ctocpp/urlrequest_client_ctocpp.h"
@ -19,7 +20,8 @@
// GLOBAL FUNCTIONS - Body may be edited by hand.
CEF_EXPORT cef_urlrequest_t* cef_urlrequest_create(cef_request_t* request,
struct _cef_urlrequest_client_t* client) {
struct _cef_urlrequest_client_t* client,
cef_request_context_t* request_context) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: request; type: refptr_same
@ -30,11 +32,13 @@ CEF_EXPORT cef_urlrequest_t* cef_urlrequest_create(cef_request_t* request,
DCHECK(client);
if (!client)
return NULL;
// Unverified params: request_context
// Execute
CefRefPtr<CefURLRequest> _retval = CefURLRequest::Create(
CefRequestCppToC::Unwrap(request),
CefURLRequestClientCToCpp::Wrap(client));
CefURLRequestClientCToCpp::Wrap(client),
CefRequestContextCppToC::Unwrap(request_context));
// Return type: refptr_same
return CefURLRequestCppToC::Wrap(_retval);