mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Add CefRequestHandler::OnQuotaRequest callback for handling webkitStorageInfo.requestQuota requests (issue #732).
git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@816 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
@ -178,6 +178,8 @@
|
|||||||
'libcef_dll/cpptoc/process_message_cpptoc.h',
|
'libcef_dll/cpptoc/process_message_cpptoc.h',
|
||||||
'libcef_dll/ctocpp/proxy_handler_ctocpp.cc',
|
'libcef_dll/ctocpp/proxy_handler_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/proxy_handler_ctocpp.h',
|
'libcef_dll/ctocpp/proxy_handler_ctocpp.h',
|
||||||
|
'libcef_dll/cpptoc/quota_callback_cpptoc.cc',
|
||||||
|
'libcef_dll/cpptoc/quota_callback_cpptoc.h',
|
||||||
'libcef_dll/ctocpp/read_handler_ctocpp.cc',
|
'libcef_dll/ctocpp/read_handler_ctocpp.cc',
|
||||||
'libcef_dll/ctocpp/read_handler_ctocpp.h',
|
'libcef_dll/ctocpp/read_handler_ctocpp.h',
|
||||||
'libcef_dll/ctocpp/render_process_handler_ctocpp.cc',
|
'libcef_dll/ctocpp/render_process_handler_ctocpp.cc',
|
||||||
@ -312,6 +314,8 @@
|
|||||||
'libcef_dll/ctocpp/process_message_ctocpp.h',
|
'libcef_dll/ctocpp/process_message_ctocpp.h',
|
||||||
'libcef_dll/cpptoc/proxy_handler_cpptoc.cc',
|
'libcef_dll/cpptoc/proxy_handler_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/proxy_handler_cpptoc.h',
|
'libcef_dll/cpptoc/proxy_handler_cpptoc.h',
|
||||||
|
'libcef_dll/ctocpp/quota_callback_ctocpp.cc',
|
||||||
|
'libcef_dll/ctocpp/quota_callback_ctocpp.h',
|
||||||
'libcef_dll/cpptoc/read_handler_cpptoc.cc',
|
'libcef_dll/cpptoc/read_handler_cpptoc.cc',
|
||||||
'libcef_dll/cpptoc/read_handler_cpptoc.h',
|
'libcef_dll/cpptoc/read_handler_cpptoc.h',
|
||||||
'libcef_dll/cpptoc/render_process_handler_cpptoc.cc',
|
'libcef_dll/cpptoc/render_process_handler_cpptoc.cc',
|
||||||
|
@ -68,6 +68,28 @@ typedef struct _cef_auth_callback_t {
|
|||||||
} cef_auth_callback_t;
|
} cef_auth_callback_t;
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
// Callback structure used for asynchronous continuation of quota requests.
|
||||||
|
///
|
||||||
|
typedef struct _cef_quota_callback_t {
|
||||||
|
///
|
||||||
|
// Base structure.
|
||||||
|
///
|
||||||
|
cef_base_t base;
|
||||||
|
|
||||||
|
///
|
||||||
|
// Continue the quota request. If |allow| is true (1) the request will be
|
||||||
|
// allowed. Otherwise, the request will be denied.
|
||||||
|
///
|
||||||
|
void (CEF_CALLBACK *cont)(struct _cef_quota_callback_t* self, int allow);
|
||||||
|
|
||||||
|
///
|
||||||
|
// Cancel the quota request.
|
||||||
|
///
|
||||||
|
void (CEF_CALLBACK *cancel)(struct _cef_quota_callback_t* self);
|
||||||
|
} cef_quota_callback_t;
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// Implement this structure to handle events related to browser requests. The
|
// Implement this structure to handle events related to browser requests. The
|
||||||
// functions of this structure will be called on the thread indicated.
|
// functions of this structure will be called on the thread indicated.
|
||||||
@ -119,6 +141,18 @@ typedef struct _cef_request_handler_t {
|
|||||||
const cef_string_t* host, int port, const cef_string_t* realm,
|
const cef_string_t* host, int port, const cef_string_t* realm,
|
||||||
const cef_string_t* scheme, struct _cef_auth_callback_t* callback);
|
const cef_string_t* scheme, struct _cef_auth_callback_t* callback);
|
||||||
|
|
||||||
|
///
|
||||||
|
// Called on the IO thread when JavaScript requests a specific storage quota
|
||||||
|
// size via the webkitStorageInfo.requestQuota function. |origin_url| is the
|
||||||
|
// origin of the page making the request. |new_size| is the requested quota
|
||||||
|
// size in bytes. Return true (1) and call cef_quota_callback_t::Complete()
|
||||||
|
// either in this function or at a later time to grant or deny the request.
|
||||||
|
// Return false (0) to cancel the request.
|
||||||
|
///
|
||||||
|
int (CEF_CALLBACK *on_quota_request)(struct _cef_request_handler_t* self,
|
||||||
|
struct _cef_browser_t* browser, const cef_string_t* origin_url,
|
||||||
|
int64 new_size, struct _cef_quota_callback_t* callback);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Called on the IO thread to retrieve the cookie manager. |main_url| is the
|
// Called on the IO thread to retrieve the cookie manager. |main_url| is the
|
||||||
// URL of the top-level frame. Cookies managers can be unique per browser or
|
// URL of the top-level frame. Cookies managers can be unique per browser or
|
||||||
|
@ -68,6 +68,27 @@ class CefAuthCallback : public virtual CefBase {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
// Callback interface used for asynchronous continuation of quota requests.
|
||||||
|
///
|
||||||
|
/*--cef(source=library)--*/
|
||||||
|
class CefQuotaCallback : public virtual CefBase {
|
||||||
|
public:
|
||||||
|
///
|
||||||
|
// Continue the quota request. If |allow| is true the request will be
|
||||||
|
// allowed. Otherwise, the request will be denied.
|
||||||
|
///
|
||||||
|
/*--cef(capi_name=cont)--*/
|
||||||
|
virtual void Continue(bool allow) =0;
|
||||||
|
|
||||||
|
///
|
||||||
|
// Cancel the quota request.
|
||||||
|
///
|
||||||
|
/*--cef()--*/
|
||||||
|
virtual void Cancel() =0;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// Implement this interface to handle events related to browser requests. The
|
// Implement this interface to handle events related to browser requests. The
|
||||||
// methods of this class will be called on the thread indicated.
|
// methods of this class will be called on the thread indicated.
|
||||||
@ -131,6 +152,22 @@ class CefRequestHandler : public virtual CefBase {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
// Called on the IO thread when JavaScript requests a specific storage quota
|
||||||
|
// size via the webkitStorageInfo.requestQuota function. |origin_url| is the
|
||||||
|
// origin of the page making the request. |new_size| is the requested quota
|
||||||
|
// size in bytes. Return true and call CefQuotaCallback::Complete() either in
|
||||||
|
// this function or at a later time to grant or deny the request. Return false
|
||||||
|
// to cancel the request.
|
||||||
|
///
|
||||||
|
/*--cef(optional_param=realm)--*/
|
||||||
|
virtual bool OnQuotaRequest(CefRefPtr<CefBrowser> browser,
|
||||||
|
const CefString& origin_url,
|
||||||
|
int64 new_size,
|
||||||
|
CefRefPtr<CefQuotaCallback> callback) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
// Called on the IO thread to retrieve the cookie manager. |main_url| is the
|
// Called on the IO thread to retrieve the cookie manager. |main_url| is the
|
||||||
// URL of the top-level frame. Cookies managers can be unique per browser or
|
// URL of the top-level frame. Cookies managers can be unique per browser or
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#include "base/path_service.h"
|
#include "base/path_service.h"
|
||||||
#include "content/public/browser/access_token_store.h"
|
#include "content/public/browser/access_token_store.h"
|
||||||
#include "content/public/browser/media_observer.h"
|
#include "content/public/browser/media_observer.h"
|
||||||
|
#include "content/public/browser/quota_permission_context.h"
|
||||||
#include "content/public/browser/render_process_host.h"
|
#include "content/public/browser/render_process_host.h"
|
||||||
#include "content/public/browser/resource_dispatcher_host.h"
|
#include "content/public/browser/resource_dispatcher_host.h"
|
||||||
#include "content/public/common/content_switches.h"
|
#include "content/public/common/content_switches.h"
|
||||||
@ -49,6 +50,117 @@ class CefAccessTokenStore : public content::AccessTokenStore {
|
|||||||
AccessTokenSet access_token_set_;
|
AccessTokenSet access_token_set_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class CefQuotaCallbackImpl : public CefQuotaCallback {
|
||||||
|
public:
|
||||||
|
explicit CefQuotaCallbackImpl(
|
||||||
|
const content::QuotaPermissionContext::PermissionCallback& callback)
|
||||||
|
: callback_(callback) {
|
||||||
|
}
|
||||||
|
~CefQuotaCallbackImpl() {
|
||||||
|
if (!callback_.is_null()) {
|
||||||
|
// The callback is still pending. Cancel it now.
|
||||||
|
if (CEF_CURRENTLY_ON_IOT()) {
|
||||||
|
CancelNow(callback_);
|
||||||
|
} else {
|
||||||
|
CEF_POST_TASK(CEF_IOT,
|
||||||
|
base::Bind(&CefQuotaCallbackImpl::CancelNow, callback_));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void Continue(bool allow) OVERRIDE {
|
||||||
|
if (CEF_CURRENTLY_ON_IOT()) {
|
||||||
|
if (!callback_.is_null()) {
|
||||||
|
callback_.Run(allow ?
|
||||||
|
content::QuotaPermissionContext::QUOTA_PERMISSION_RESPONSE_ALLOW :
|
||||||
|
content::QuotaPermissionContext::QUOTA_PERMISSION_RESPONSE_DISALLOW);
|
||||||
|
callback_.Reset();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
CEF_POST_TASK(CEF_IOT,
|
||||||
|
base::Bind(&CefQuotaCallbackImpl::Continue, this, allow));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void Cancel() OVERRIDE {
|
||||||
|
if (CEF_CURRENTLY_ON_IOT()) {
|
||||||
|
if (!callback_.is_null()) {
|
||||||
|
CancelNow(callback_);
|
||||||
|
callback_.Reset();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
CEF_POST_TASK(CEF_IOT, base::Bind(&CefQuotaCallbackImpl::Cancel, this));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Disconnect() {
|
||||||
|
callback_.Reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
static void CancelNow(
|
||||||
|
const content::QuotaPermissionContext::PermissionCallback& callback) {
|
||||||
|
CEF_REQUIRE_IOT();
|
||||||
|
callback.Run(
|
||||||
|
content::QuotaPermissionContext::QUOTA_PERMISSION_RESPONSE_CANCELLED);
|
||||||
|
}
|
||||||
|
|
||||||
|
content::QuotaPermissionContext::PermissionCallback callback_;
|
||||||
|
|
||||||
|
IMPLEMENT_REFCOUNTING(CefQuotaCallbackImpl);
|
||||||
|
};
|
||||||
|
|
||||||
|
class CefQuotaPermissionContext : public content::QuotaPermissionContext {
|
||||||
|
public:
|
||||||
|
CefQuotaPermissionContext() {
|
||||||
|
}
|
||||||
|
|
||||||
|
// The callback will be dispatched on the IO thread.
|
||||||
|
virtual void RequestQuotaPermission(
|
||||||
|
const GURL& origin_url,
|
||||||
|
quota::StorageType type,
|
||||||
|
int64 new_quota,
|
||||||
|
int render_process_id,
|
||||||
|
int render_view_id,
|
||||||
|
const PermissionCallback& callback) OVERRIDE {
|
||||||
|
if (type != quota::kStorageTypePersistent) {
|
||||||
|
// To match Chrome behavior we only support requesting quota with this
|
||||||
|
// interface for Persistent storage type.
|
||||||
|
callback.Run(QUOTA_PERMISSION_RESPONSE_DISALLOW);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool handled = false;
|
||||||
|
|
||||||
|
CefRefPtr<CefBrowserHostImpl> browser =
|
||||||
|
CefBrowserHostImpl::GetBrowserByRoutingID(render_process_id,
|
||||||
|
render_view_id);
|
||||||
|
if (browser.get()) {
|
||||||
|
CefRefPtr<CefClient> client = browser->GetClient();
|
||||||
|
if (client.get()) {
|
||||||
|
CefRefPtr<CefRequestHandler> handler = client->GetRequestHandler();
|
||||||
|
if (handler.get()) {
|
||||||
|
CefRefPtr<CefQuotaCallbackImpl> callbackImpl(
|
||||||
|
new CefQuotaCallbackImpl(callback));
|
||||||
|
handled = handler->OnQuotaRequest(browser.get(), origin_url.spec(),
|
||||||
|
new_quota, callbackImpl.get());
|
||||||
|
if (!handled)
|
||||||
|
callbackImpl->Disconnect();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!handled) {
|
||||||
|
// Disallow the request by default.
|
||||||
|
callback.Run(QUOTA_PERMISSION_RESPONSE_DISALLOW);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
virtual ~CefQuotaPermissionContext() {
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
|
||||||
@ -140,6 +252,11 @@ void CefContentBrowserClient::AppendExtraCommandLineSwitches(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
content::QuotaPermissionContext*
|
||||||
|
CefContentBrowserClient::CreateQuotaPermissionContext() {
|
||||||
|
return new CefQuotaPermissionContext();
|
||||||
|
}
|
||||||
|
|
||||||
content::MediaObserver* CefContentBrowserClient::GetMediaObserver() {
|
content::MediaObserver* CefContentBrowserClient::GetMediaObserver() {
|
||||||
// TODO(cef): Return NULL once it's supported. See crbug.com/116113.
|
// TODO(cef): Return NULL once it's supported. See crbug.com/116113.
|
||||||
if (!media_observer_.get())
|
if (!media_observer_.get())
|
||||||
|
@ -37,6 +37,8 @@ class CefContentBrowserClient : public content::ContentBrowserClient {
|
|||||||
content::RenderProcessHost* host) OVERRIDE;
|
content::RenderProcessHost* host) OVERRIDE;
|
||||||
virtual void AppendExtraCommandLineSwitches(CommandLine* command_line,
|
virtual void AppendExtraCommandLineSwitches(CommandLine* command_line,
|
||||||
int child_process_id) OVERRIDE;
|
int child_process_id) OVERRIDE;
|
||||||
|
virtual content::QuotaPermissionContext*
|
||||||
|
CreateQuotaPermissionContext() OVERRIDE;
|
||||||
virtual content::MediaObserver* GetMediaObserver() OVERRIDE;
|
virtual content::MediaObserver* GetMediaObserver() OVERRIDE;
|
||||||
virtual content::AccessTokenStore* CreateAccessTokenStore() OVERRIDE;
|
virtual content::AccessTokenStore* CreateAccessTokenStore() OVERRIDE;
|
||||||
virtual void ResourceDispatcherHostCreated() OVERRIDE;
|
virtual void ResourceDispatcherHostCreated() OVERRIDE;
|
||||||
|
56
libcef_dll/cpptoc/quota_callback_cpptoc.cc
Normal file
56
libcef_dll/cpptoc/quota_callback_cpptoc.cc
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
// Copyright (c) 2012 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/quota_callback_cpptoc.h"
|
||||||
|
|
||||||
|
|
||||||
|
// MEMBER FUNCTIONS - Body may be edited by hand.
|
||||||
|
|
||||||
|
void CEF_CALLBACK quota_callback_cont(struct _cef_quota_callback_t* self,
|
||||||
|
int allow) {
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
DCHECK(self);
|
||||||
|
if (!self)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
CefQuotaCallbackCppToC::Get(self)->Continue(
|
||||||
|
allow?true:false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CEF_CALLBACK quota_callback_cancel(struct _cef_quota_callback_t* self) {
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
DCHECK(self);
|
||||||
|
if (!self)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
CefQuotaCallbackCppToC::Get(self)->Cancel();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// CONSTRUCTOR - Do not edit by hand.
|
||||||
|
|
||||||
|
CefQuotaCallbackCppToC::CefQuotaCallbackCppToC(CefQuotaCallback* cls)
|
||||||
|
: CefCppToC<CefQuotaCallbackCppToC, CefQuotaCallback, cef_quota_callback_t>(
|
||||||
|
cls) {
|
||||||
|
struct_.struct_.cont = quota_callback_cont;
|
||||||
|
struct_.struct_.cancel = quota_callback_cancel;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef NDEBUG
|
||||||
|
template<> long CefCppToC<CefQuotaCallbackCppToC, CefQuotaCallback,
|
||||||
|
cef_quota_callback_t>::DebugObjCt = 0;
|
||||||
|
#endif
|
||||||
|
|
37
libcef_dll/cpptoc/quota_callback_cpptoc.h
Normal file
37
libcef_dll/cpptoc/quota_callback_cpptoc.h
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
// Copyright (c) 2012 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_QUOTA_CALLBACK_CPPTOC_H_
|
||||||
|
#define CEF_LIBCEF_DLL_CPPTOC_QUOTA_CALLBACK_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_handler.h"
|
||||||
|
#include "include/capi/cef_request_handler_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 CefQuotaCallbackCppToC
|
||||||
|
: public CefCppToC<CefQuotaCallbackCppToC, CefQuotaCallback,
|
||||||
|
cef_quota_callback_t> {
|
||||||
|
public:
|
||||||
|
explicit CefQuotaCallbackCppToC(CefQuotaCallback* cls);
|
||||||
|
virtual ~CefQuotaCallbackCppToC() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // BUILDING_CEF_SHARED
|
||||||
|
#endif // CEF_LIBCEF_DLL_CPPTOC_QUOTA_CALLBACK_CPPTOC_H_
|
||||||
|
|
@ -16,6 +16,7 @@
|
|||||||
#include "libcef_dll/ctocpp/browser_ctocpp.h"
|
#include "libcef_dll/ctocpp/browser_ctocpp.h"
|
||||||
#include "libcef_dll/ctocpp/cookie_manager_ctocpp.h"
|
#include "libcef_dll/ctocpp/cookie_manager_ctocpp.h"
|
||||||
#include "libcef_dll/ctocpp/frame_ctocpp.h"
|
#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/request_ctocpp.h"
|
||||||
|
|
||||||
|
|
||||||
@ -167,6 +168,39 @@ int CEF_CALLBACK request_handler_get_auth_credentials(
|
|||||||
return _retval;
|
return _retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int CEF_CALLBACK request_handler_on_quota_request(
|
||||||
|
struct _cef_request_handler_t* self, cef_browser_t* browser,
|
||||||
|
const cef_string_t* origin_url, int64 new_size,
|
||||||
|
cef_quota_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: origin_url; type: string_byref_const
|
||||||
|
DCHECK(origin_url);
|
||||||
|
if (!origin_url)
|
||||||
|
return 0;
|
||||||
|
// Verify param: callback; type: refptr_diff
|
||||||
|
DCHECK(callback);
|
||||||
|
if (!callback)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
bool _retval = CefRequestHandlerCppToC::Get(self)->OnQuotaRequest(
|
||||||
|
CefBrowserCToCpp::Wrap(browser),
|
||||||
|
CefString(origin_url),
|
||||||
|
new_size,
|
||||||
|
CefQuotaCallbackCToCpp::Wrap(callback));
|
||||||
|
|
||||||
|
// Return type: bool
|
||||||
|
return _retval;
|
||||||
|
}
|
||||||
|
|
||||||
cef_cookie_manager_t* CEF_CALLBACK request_handler_get_cookie_manager(
|
cef_cookie_manager_t* CEF_CALLBACK request_handler_get_cookie_manager(
|
||||||
struct _cef_request_handler_t* self, cef_browser_t* browser,
|
struct _cef_request_handler_t* self, cef_browser_t* browser,
|
||||||
const cef_string_t* main_url) {
|
const cef_string_t* main_url) {
|
||||||
@ -241,6 +275,7 @@ CefRequestHandlerCppToC::CefRequestHandlerCppToC(CefRequestHandler* cls)
|
|||||||
struct_.struct_.get_resource_handler = request_handler_get_resource_handler;
|
struct_.struct_.get_resource_handler = request_handler_get_resource_handler;
|
||||||
struct_.struct_.on_resource_redirect = request_handler_on_resource_redirect;
|
struct_.struct_.on_resource_redirect = request_handler_on_resource_redirect;
|
||||||
struct_.struct_.get_auth_credentials = request_handler_get_auth_credentials;
|
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_.get_cookie_manager = request_handler_get_cookie_manager;
|
||||||
struct_.struct_.on_protocol_execution = request_handler_on_protocol_execution;
|
struct_.struct_.on_protocol_execution = request_handler_on_protocol_execution;
|
||||||
}
|
}
|
||||||
|
44
libcef_dll/ctocpp/quota_callback_ctocpp.cc
Normal file
44
libcef_dll/ctocpp/quota_callback_ctocpp.cc
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
// Copyright (c) 2012 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/quota_callback_ctocpp.h"
|
||||||
|
|
||||||
|
|
||||||
|
// VIRTUAL METHODS - Body may be edited by hand.
|
||||||
|
|
||||||
|
void CefQuotaCallbackCToCpp::Continue(bool allow) {
|
||||||
|
if (CEF_MEMBER_MISSING(struct_, cont))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
struct_->cont(struct_,
|
||||||
|
allow);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CefQuotaCallbackCToCpp::Cancel() {
|
||||||
|
if (CEF_MEMBER_MISSING(struct_, cancel))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
struct_->cancel(struct_);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef NDEBUG
|
||||||
|
template<> long CefCToCpp<CefQuotaCallbackCToCpp, CefQuotaCallback,
|
||||||
|
cef_quota_callback_t>::DebugObjCt = 0;
|
||||||
|
#endif
|
||||||
|
|
43
libcef_dll/ctocpp/quota_callback_ctocpp.h
Normal file
43
libcef_dll/ctocpp/quota_callback_ctocpp.h
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
// Copyright (c) 2012 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_QUOTA_CALLBACK_CTOCPP_H_
|
||||||
|
#define CEF_LIBCEF_DLL_CTOCPP_QUOTA_CALLBACK_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_handler.h"
|
||||||
|
#include "include/capi/cef_request_handler_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 CefQuotaCallbackCToCpp
|
||||||
|
: public CefCToCpp<CefQuotaCallbackCToCpp, CefQuotaCallback,
|
||||||
|
cef_quota_callback_t> {
|
||||||
|
public:
|
||||||
|
explicit CefQuotaCallbackCToCpp(cef_quota_callback_t* str)
|
||||||
|
: CefCToCpp<CefQuotaCallbackCToCpp, CefQuotaCallback,
|
||||||
|
cef_quota_callback_t>(str) {}
|
||||||
|
virtual ~CefQuotaCallbackCToCpp() {}
|
||||||
|
|
||||||
|
// CefQuotaCallback methods
|
||||||
|
virtual void Continue(bool allow) OVERRIDE;
|
||||||
|
virtual void Cancel() OVERRIDE;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // USING_CEF_SHARED
|
||||||
|
#endif // CEF_LIBCEF_DLL_CTOCPP_QUOTA_CALLBACK_CTOCPP_H_
|
||||||
|
|
@ -14,6 +14,7 @@
|
|||||||
#include "libcef_dll/cpptoc/browser_cpptoc.h"
|
#include "libcef_dll/cpptoc/browser_cpptoc.h"
|
||||||
#include "libcef_dll/cpptoc/cookie_manager_cpptoc.h"
|
#include "libcef_dll/cpptoc/cookie_manager_cpptoc.h"
|
||||||
#include "libcef_dll/cpptoc/frame_cpptoc.h"
|
#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/request_cpptoc.h"
|
||||||
#include "libcef_dll/ctocpp/request_handler_ctocpp.h"
|
#include "libcef_dll/ctocpp/request_handler_ctocpp.h"
|
||||||
#include "libcef_dll/ctocpp/resource_handler_ctocpp.h"
|
#include "libcef_dll/ctocpp/resource_handler_ctocpp.h"
|
||||||
@ -157,6 +158,38 @@ bool CefRequestHandlerCToCpp::GetAuthCredentials(CefRefPtr<CefBrowser> browser,
|
|||||||
return _retval?true:false;
|
return _retval?true:false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CefRequestHandlerCToCpp::OnQuotaRequest(CefRefPtr<CefBrowser> browser,
|
||||||
|
const CefString& origin_url, int64 new_size,
|
||||||
|
CefRefPtr<CefQuotaCallback> callback) {
|
||||||
|
if (CEF_MEMBER_MISSING(struct_, on_quota_request))
|
||||||
|
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: origin_url; type: string_byref_const
|
||||||
|
DCHECK(!origin_url.empty());
|
||||||
|
if (origin_url.empty())
|
||||||
|
return false;
|
||||||
|
// Verify param: callback; type: refptr_diff
|
||||||
|
DCHECK(callback.get());
|
||||||
|
if (!callback.get())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
int _retval = struct_->on_quota_request(struct_,
|
||||||
|
CefBrowserCppToC::Wrap(browser),
|
||||||
|
origin_url.GetStruct(),
|
||||||
|
new_size,
|
||||||
|
CefQuotaCallbackCppToC::Wrap(callback));
|
||||||
|
|
||||||
|
// Return type: bool
|
||||||
|
return _retval?true:false;
|
||||||
|
}
|
||||||
|
|
||||||
CefRefPtr<CefCookieManager> CefRequestHandlerCToCpp::GetCookieManager(
|
CefRefPtr<CefCookieManager> CefRequestHandlerCToCpp::GetCookieManager(
|
||||||
CefRefPtr<CefBrowser> browser, const CefString& main_url) {
|
CefRefPtr<CefBrowser> browser, const CefString& main_url) {
|
||||||
if (CEF_MEMBER_MISSING(struct_, get_cookie_manager))
|
if (CEF_MEMBER_MISSING(struct_, get_cookie_manager))
|
||||||
|
@ -46,6 +46,9 @@ class CefRequestHandlerCToCpp
|
|||||||
CefRefPtr<CefFrame> frame, bool isProxy, const CefString& host, int port,
|
CefRefPtr<CefFrame> frame, bool isProxy, const CefString& host, int port,
|
||||||
const CefString& realm, const CefString& scheme,
|
const CefString& realm, const CefString& scheme,
|
||||||
CefRefPtr<CefAuthCallback> callback) OVERRIDE;
|
CefRefPtr<CefAuthCallback> callback) OVERRIDE;
|
||||||
|
virtual bool OnQuotaRequest(CefRefPtr<CefBrowser> browser,
|
||||||
|
const CefString& origin_url, int64 new_size,
|
||||||
|
CefRefPtr<CefQuotaCallback> callback) OVERRIDE;
|
||||||
virtual CefRefPtr<CefCookieManager> GetCookieManager(
|
virtual CefRefPtr<CefCookieManager> GetCookieManager(
|
||||||
CefRefPtr<CefBrowser> browser, const CefString& main_url) OVERRIDE;
|
CefRefPtr<CefBrowser> browser, const CefString& main_url) OVERRIDE;
|
||||||
virtual void OnProtocolExecution(CefRefPtr<CefBrowser> browser,
|
virtual void OnProtocolExecution(CefRefPtr<CefBrowser> browser,
|
||||||
|
@ -49,6 +49,7 @@
|
|||||||
#include "libcef_dll/cpptoc/list_value_cpptoc.h"
|
#include "libcef_dll/cpptoc/list_value_cpptoc.h"
|
||||||
#include "libcef_dll/cpptoc/menu_model_cpptoc.h"
|
#include "libcef_dll/cpptoc/menu_model_cpptoc.h"
|
||||||
#include "libcef_dll/cpptoc/process_message_cpptoc.h"
|
#include "libcef_dll/cpptoc/process_message_cpptoc.h"
|
||||||
|
#include "libcef_dll/cpptoc/quota_callback_cpptoc.h"
|
||||||
#include "libcef_dll/cpptoc/scheme_registrar_cpptoc.h"
|
#include "libcef_dll/cpptoc/scheme_registrar_cpptoc.h"
|
||||||
#include "libcef_dll/cpptoc/stream_reader_cpptoc.h"
|
#include "libcef_dll/cpptoc/stream_reader_cpptoc.h"
|
||||||
#include "libcef_dll/cpptoc/stream_writer_cpptoc.h"
|
#include "libcef_dll/cpptoc/stream_writer_cpptoc.h"
|
||||||
@ -192,6 +193,7 @@ CEF_EXPORT void cef_shutdown() {
|
|||||||
DCHECK_EQ(CefMenuModelCppToC::DebugObjCt, 0);
|
DCHECK_EQ(CefMenuModelCppToC::DebugObjCt, 0);
|
||||||
DCHECK_EQ(CefProcessMessageCppToC::DebugObjCt, 0);
|
DCHECK_EQ(CefProcessMessageCppToC::DebugObjCt, 0);
|
||||||
DCHECK_EQ(CefProxyHandlerCToCpp::DebugObjCt, 0);
|
DCHECK_EQ(CefProxyHandlerCToCpp::DebugObjCt, 0);
|
||||||
|
DCHECK_EQ(CefQuotaCallbackCppToC::DebugObjCt, 0);
|
||||||
DCHECK_EQ(CefReadHandlerCToCpp::DebugObjCt, 0);
|
DCHECK_EQ(CefReadHandlerCToCpp::DebugObjCt, 0);
|
||||||
DCHECK_EQ(CefRenderProcessHandlerCToCpp::DebugObjCt, 0);
|
DCHECK_EQ(CefRenderProcessHandlerCToCpp::DebugObjCt, 0);
|
||||||
DCHECK_EQ(CefRequestHandlerCToCpp::DebugObjCt, 0);
|
DCHECK_EQ(CefRequestHandlerCToCpp::DebugObjCt, 0);
|
||||||
|
@ -78,6 +78,7 @@
|
|||||||
#include "libcef_dll/ctocpp/list_value_ctocpp.h"
|
#include "libcef_dll/ctocpp/list_value_ctocpp.h"
|
||||||
#include "libcef_dll/ctocpp/menu_model_ctocpp.h"
|
#include "libcef_dll/ctocpp/menu_model_ctocpp.h"
|
||||||
#include "libcef_dll/ctocpp/process_message_ctocpp.h"
|
#include "libcef_dll/ctocpp/process_message_ctocpp.h"
|
||||||
|
#include "libcef_dll/ctocpp/quota_callback_ctocpp.h"
|
||||||
#include "libcef_dll/ctocpp/scheme_registrar_ctocpp.h"
|
#include "libcef_dll/ctocpp/scheme_registrar_ctocpp.h"
|
||||||
#include "libcef_dll/ctocpp/stream_reader_ctocpp.h"
|
#include "libcef_dll/ctocpp/stream_reader_ctocpp.h"
|
||||||
#include "libcef_dll/ctocpp/stream_writer_ctocpp.h"
|
#include "libcef_dll/ctocpp/stream_writer_ctocpp.h"
|
||||||
@ -184,6 +185,7 @@ CEF_GLOBAL void CefShutdown() {
|
|||||||
DCHECK_EQ(CefMenuModelCToCpp::DebugObjCt, 0);
|
DCHECK_EQ(CefMenuModelCToCpp::DebugObjCt, 0);
|
||||||
DCHECK_EQ(CefProcessMessageCToCpp::DebugObjCt, 0);
|
DCHECK_EQ(CefProcessMessageCToCpp::DebugObjCt, 0);
|
||||||
DCHECK_EQ(CefProxyHandlerCppToC::DebugObjCt, 0);
|
DCHECK_EQ(CefProxyHandlerCppToC::DebugObjCt, 0);
|
||||||
|
DCHECK_EQ(CefQuotaCallbackCToCpp::DebugObjCt, 0);
|
||||||
DCHECK_EQ(CefReadHandlerCppToC::DebugObjCt, 0);
|
DCHECK_EQ(CefReadHandlerCppToC::DebugObjCt, 0);
|
||||||
DCHECK_EQ(CefRenderProcessHandlerCppToC::DebugObjCt, 0);
|
DCHECK_EQ(CefRenderProcessHandlerCppToC::DebugObjCt, 0);
|
||||||
DCHECK_EQ(CefRequestHandlerCppToC::DebugObjCt, 0);
|
DCHECK_EQ(CefRequestHandlerCppToC::DebugObjCt, 0);
|
||||||
|
@ -390,6 +390,17 @@ CefRefPtr<CefResourceHandler> ClientHandler::GetResourceHandler(
|
|||||||
return handler;
|
return handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ClientHandler::OnQuotaRequest(CefRefPtr<CefBrowser> browser,
|
||||||
|
const CefString& origin_url,
|
||||||
|
int64 new_size,
|
||||||
|
CefRefPtr<CefQuotaCallback> callback) {
|
||||||
|
static const int64 max_size = 1024 * 1024 * 20; // 20mb.
|
||||||
|
|
||||||
|
// Grant the quota request if the size is reasonable.
|
||||||
|
callback->Continue(new_size <= max_size);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void ClientHandler::OnProtocolExecution(CefRefPtr<CefBrowser> browser,
|
void ClientHandler::OnProtocolExecution(CefRefPtr<CefBrowser> browser,
|
||||||
const CefString& url,
|
const CefString& url,
|
||||||
bool& allow_os_execution) {
|
bool& allow_os_execution) {
|
||||||
|
@ -172,6 +172,10 @@ class ClientHandler : public CefClient,
|
|||||||
CefRefPtr<CefBrowser> browser,
|
CefRefPtr<CefBrowser> browser,
|
||||||
CefRefPtr<CefFrame> frame,
|
CefRefPtr<CefFrame> frame,
|
||||||
CefRefPtr<CefRequest> request) OVERRIDE;
|
CefRefPtr<CefRequest> request) OVERRIDE;
|
||||||
|
virtual bool OnQuotaRequest(CefRefPtr<CefBrowser> browser,
|
||||||
|
const CefString& origin_url,
|
||||||
|
int64 new_size,
|
||||||
|
CefRefPtr<CefQuotaCallback> callback) OVERRIDE;
|
||||||
virtual void OnProtocolExecution(CefRefPtr<CefBrowser> browser,
|
virtual void OnProtocolExecution(CefRefPtr<CefBrowser> browser,
|
||||||
const CefString& url,
|
const CefString& url,
|
||||||
bool& allow_os_execution) OVERRIDE;
|
bool& allow_os_execution) OVERRIDE;
|
||||||
|
Reference in New Issue
Block a user