mirror of
https://github.com/servo/servo.git
synced 2025-09-10 15:08:21 +01:00
update cef embedding interfaces to latest cef
This commit is contained in:
parent
49aed6555d
commit
4679fc77b0
57 changed files with 3731 additions and 738 deletions
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved.
|
||||
// Copyright (c) 2015 Marshall A. Greenblatt. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
|
@ -58,26 +58,28 @@ pub struct _cef_cookie_manager_t {
|
|||
|
||||
//
|
||||
// Set the schemes supported by this manager. By default only "http" and
|
||||
// "https" schemes are supported. Must be called before any cookies are
|
||||
// accessed.
|
||||
// "https" schemes are supported. If |callback| is non-NULL it will be
|
||||
// executed asnychronously on the IO thread after the change has been applied.
|
||||
// Must be called before any cookies are accessed.
|
||||
//
|
||||
pub set_supported_schemes: Option<extern "C" fn(
|
||||
this: *mut cef_cookie_manager_t, schemes: types::cef_string_list_t) -> (
|
||||
)>,
|
||||
this: *mut cef_cookie_manager_t, schemes: types::cef_string_list_t,
|
||||
callback: *mut interfaces::cef_completion_callback_t) -> ()>,
|
||||
|
||||
//
|
||||
// Visit all cookies. The returned cookies are ordered by longest path, then
|
||||
// by earliest creation date. Returns false (0) if cookies cannot be accessed.
|
||||
// Visit all cookies on the IO thread. The returned cookies are ordered by
|
||||
// longest path, then by earliest creation date. Returns false (0) if cookies
|
||||
// cannot be accessed.
|
||||
//
|
||||
pub visit_all_cookies: Option<extern "C" fn(this: *mut cef_cookie_manager_t,
|
||||
visitor: *mut interfaces::cef_cookie_visitor_t) -> libc::c_int>,
|
||||
|
||||
//
|
||||
// Visit a subset of cookies. The results are filtered by the given url
|
||||
// scheme, host, domain and path. If |includeHttpOnly| is true (1) HTTP-only
|
||||
// cookies will also be included in the results. The returned cookies are
|
||||
// ordered by longest path, then by earliest creation date. Returns false (0)
|
||||
// if cookies cannot be accessed.
|
||||
// Visit a subset of cookies on the IO thread. The results are filtered by the
|
||||
// given url scheme, host, domain and path. If |includeHttpOnly| is true (1)
|
||||
// HTTP-only cookies will also be included in the results. The returned
|
||||
// cookies are ordered by longest path, then by earliest creation date.
|
||||
// Returns false (0) if cookies cannot be accessed.
|
||||
//
|
||||
pub visit_url_cookies: Option<extern "C" fn(this: *mut cef_cookie_manager_t,
|
||||
url: *const types::cef_string_t, includeHttpOnly: libc::c_int,
|
||||
|
@ -87,26 +89,29 @@ pub struct _cef_cookie_manager_t {
|
|||
// Sets a cookie given a valid URL and explicit user-provided cookie
|
||||
// attributes. This function expects each attribute to be well-formed. It will
|
||||
// check for disallowed characters (e.g. the ';' character is disallowed
|
||||
// within the cookie value attribute) and will return false (0) without
|
||||
// setting the cookie if such characters are found. This function must be
|
||||
// called on the IO thread.
|
||||
// within the cookie value attribute) and fail without setting the cookie if
|
||||
// such characters are found. If |callback| is non-NULL it will be executed
|
||||
// asnychronously on the IO thread after the cookie has been set. Returns
|
||||
// false (0) if an invalid URL is specified or if cookies cannot be accessed.
|
||||
//
|
||||
pub set_cookie: Option<extern "C" fn(this: *mut cef_cookie_manager_t,
|
||||
url: *const types::cef_string_t,
|
||||
cookie: *const interfaces::cef_cookie_t) -> libc::c_int>,
|
||||
url: *const types::cef_string_t, cookie: *const interfaces::cef_cookie_t,
|
||||
callback: *mut interfaces::cef_set_cookie_callback_t) -> libc::c_int>,
|
||||
|
||||
//
|
||||
// Delete all cookies that match the specified parameters. If both |url| and
|
||||
// values |cookie_name| are specified all host and domain cookies matching
|
||||
// |cookie_name| values are specified all host and domain cookies matching
|
||||
// both will be deleted. If only |url| is specified all host cookies (but not
|
||||
// domain cookies) irrespective of path will be deleted. If |url| is NULL all
|
||||
// cookies for all hosts and domains will be deleted. Returns false (0) if a
|
||||
// non- NULL invalid URL is specified or if cookies cannot be accessed. This
|
||||
// function must be called on the IO thread.
|
||||
// cookies for all hosts and domains will be deleted. If |callback| is non-
|
||||
// NULL it will be executed asnychronously on the IO thread after the cookies
|
||||
// have been deleted. Returns false (0) if a non-NULL invalid URL is specified
|
||||
// or if cookies cannot be accessed. Cookies can alternately be deleted using
|
||||
// the Visit*Cookies() functions.
|
||||
//
|
||||
pub delete_cookies: Option<extern "C" fn(this: *mut cef_cookie_manager_t,
|
||||
url: *const types::cef_string_t,
|
||||
cookie_name: *const types::cef_string_t) -> libc::c_int>,
|
||||
url: *const types::cef_string_t, cookie_name: *const types::cef_string_t,
|
||||
callback: *mut interfaces::cef_delete_cookies_callback_t) -> libc::c_int>,
|
||||
|
||||
//
|
||||
// Sets the directory path that will be used for storing cookie data. If
|
||||
|
@ -114,17 +119,18 @@ pub struct _cef_cookie_manager_t {
|
|||
// stored at the specified |path|. To persist session cookies (cookies without
|
||||
// an expiry date or validity interval) set |persist_session_cookies| to true
|
||||
// (1). Session cookies are generally intended to be transient and most Web
|
||||
// browsers do not persist them. Returns false (0) if cookies cannot be
|
||||
// accessed.
|
||||
// browsers do not persist them. If |callback| is non-NULL it will be executed
|
||||
// asnychronously on the IO thread after the manager's storage has been
|
||||
// initialized. Returns false (0) if cookies cannot be accessed.
|
||||
//
|
||||
pub set_storage_path: Option<extern "C" fn(this: *mut cef_cookie_manager_t,
|
||||
path: *const types::cef_string_t,
|
||||
persist_session_cookies: libc::c_int) -> libc::c_int>,
|
||||
path: *const types::cef_string_t, persist_session_cookies: libc::c_int,
|
||||
callback: *mut interfaces::cef_completion_callback_t) -> libc::c_int>,
|
||||
|
||||
//
|
||||
// Flush the backing store (if any) to disk and execute the specified
|
||||
// |callback| on the IO thread when done. Returns false (0) if cookies cannot
|
||||
// be accessed.
|
||||
// Flush the backing store (if any) to disk. If |callback| is non-NULL it will
|
||||
// be executed asnychronously on the IO thread after the flush is complete.
|
||||
// Returns false (0) if cookies cannot be accessed.
|
||||
//
|
||||
pub flush_store: Option<extern "C" fn(this: *mut cef_cookie_manager_t,
|
||||
callback: *mut interfaces::cef_completion_callback_t) -> libc::c_int>,
|
||||
|
@ -212,10 +218,12 @@ impl CefCookieManager {
|
|||
|
||||
//
|
||||
// Set the schemes supported by this manager. By default only "http" and
|
||||
// "https" schemes are supported. Must be called before any cookies are
|
||||
// accessed.
|
||||
// "https" schemes are supported. If |callback| is non-NULL it will be
|
||||
// executed asnychronously on the IO thread after the change has been applied.
|
||||
// Must be called before any cookies are accessed.
|
||||
//
|
||||
pub fn set_supported_schemes(&self, schemes: Vec<String>) -> () {
|
||||
pub fn set_supported_schemes(&self, schemes: Vec<String>,
|
||||
callback: interfaces::CefCompletionCallback) -> () {
|
||||
if self.c_object.is_null() {
|
||||
panic!("called a CEF method on a null object")
|
||||
}
|
||||
|
@ -223,13 +231,15 @@ impl CefCookieManager {
|
|||
CefWrap::to_rust(
|
||||
((*self.c_object).set_supported_schemes.unwrap())(
|
||||
self.c_object,
|
||||
CefWrap::to_c(schemes)))
|
||||
CefWrap::to_c(schemes),
|
||||
CefWrap::to_c(callback)))
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Visit all cookies. The returned cookies are ordered by longest path, then
|
||||
// by earliest creation date. Returns false (0) if cookies cannot be accessed.
|
||||
// Visit all cookies on the IO thread. The returned cookies are ordered by
|
||||
// longest path, then by earliest creation date. Returns false (0) if cookies
|
||||
// cannot be accessed.
|
||||
//
|
||||
pub fn visit_all_cookies(&self,
|
||||
visitor: interfaces::CefCookieVisitor) -> libc::c_int {
|
||||
|
@ -245,11 +255,11 @@ impl CefCookieManager {
|
|||
}
|
||||
|
||||
//
|
||||
// Visit a subset of cookies. The results are filtered by the given url
|
||||
// scheme, host, domain and path. If |includeHttpOnly| is true (1) HTTP-only
|
||||
// cookies will also be included in the results. The returned cookies are
|
||||
// ordered by longest path, then by earliest creation date. Returns false (0)
|
||||
// if cookies cannot be accessed.
|
||||
// Visit a subset of cookies on the IO thread. The results are filtered by the
|
||||
// given url scheme, host, domain and path. If |includeHttpOnly| is true (1)
|
||||
// HTTP-only cookies will also be included in the results. The returned
|
||||
// cookies are ordered by longest path, then by earliest creation date.
|
||||
// Returns false (0) if cookies cannot be accessed.
|
||||
//
|
||||
pub fn visit_url_cookies(&self, url: &[u16], includeHttpOnly: libc::c_int,
|
||||
visitor: interfaces::CefCookieVisitor) -> libc::c_int {
|
||||
|
@ -270,12 +280,13 @@ impl CefCookieManager {
|
|||
// Sets a cookie given a valid URL and explicit user-provided cookie
|
||||
// attributes. This function expects each attribute to be well-formed. It will
|
||||
// check for disallowed characters (e.g. the ';' character is disallowed
|
||||
// within the cookie value attribute) and will return false (0) without
|
||||
// setting the cookie if such characters are found. This function must be
|
||||
// called on the IO thread.
|
||||
// within the cookie value attribute) and fail without setting the cookie if
|
||||
// such characters are found. If |callback| is non-NULL it will be executed
|
||||
// asnychronously on the IO thread after the cookie has been set. Returns
|
||||
// false (0) if an invalid URL is specified or if cookies cannot be accessed.
|
||||
//
|
||||
pub fn set_cookie(&self, url: &[u16],
|
||||
cookie: &interfaces::CefCookie) -> libc::c_int {
|
||||
pub fn set_cookie(&self, url: &[u16], cookie: &interfaces::CefCookie,
|
||||
callback: interfaces::CefSetCookieCallback) -> libc::c_int {
|
||||
if self.c_object.is_null() {
|
||||
panic!("called a CEF method on a null object")
|
||||
}
|
||||
|
@ -284,21 +295,24 @@ impl CefCookieManager {
|
|||
((*self.c_object).set_cookie.unwrap())(
|
||||
self.c_object,
|
||||
CefWrap::to_c(url),
|
||||
CefWrap::to_c(cookie)))
|
||||
CefWrap::to_c(cookie),
|
||||
CefWrap::to_c(callback)))
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Delete all cookies that match the specified parameters. If both |url| and
|
||||
// values |cookie_name| are specified all host and domain cookies matching
|
||||
// |cookie_name| values are specified all host and domain cookies matching
|
||||
// both will be deleted. If only |url| is specified all host cookies (but not
|
||||
// domain cookies) irrespective of path will be deleted. If |url| is NULL all
|
||||
// cookies for all hosts and domains will be deleted. Returns false (0) if a
|
||||
// non- NULL invalid URL is specified or if cookies cannot be accessed. This
|
||||
// function must be called on the IO thread.
|
||||
// cookies for all hosts and domains will be deleted. If |callback| is non-
|
||||
// NULL it will be executed asnychronously on the IO thread after the cookies
|
||||
// have been deleted. Returns false (0) if a non-NULL invalid URL is specified
|
||||
// or if cookies cannot be accessed. Cookies can alternately be deleted using
|
||||
// the Visit*Cookies() functions.
|
||||
//
|
||||
pub fn delete_cookies(&self, url: &[u16],
|
||||
cookie_name: &[u16]) -> libc::c_int {
|
||||
pub fn delete_cookies(&self, url: &[u16], cookie_name: &[u16],
|
||||
callback: interfaces::CefDeleteCookiesCallback) -> libc::c_int {
|
||||
if self.c_object.is_null() {
|
||||
panic!("called a CEF method on a null object")
|
||||
}
|
||||
|
@ -307,7 +321,8 @@ impl CefCookieManager {
|
|||
((*self.c_object).delete_cookies.unwrap())(
|
||||
self.c_object,
|
||||
CefWrap::to_c(url),
|
||||
CefWrap::to_c(cookie_name)))
|
||||
CefWrap::to_c(cookie_name),
|
||||
CefWrap::to_c(callback)))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -317,11 +332,13 @@ impl CefCookieManager {
|
|||
// stored at the specified |path|. To persist session cookies (cookies without
|
||||
// an expiry date or validity interval) set |persist_session_cookies| to true
|
||||
// (1). Session cookies are generally intended to be transient and most Web
|
||||
// browsers do not persist them. Returns false (0) if cookies cannot be
|
||||
// accessed.
|
||||
// browsers do not persist them. If |callback| is non-NULL it will be executed
|
||||
// asnychronously on the IO thread after the manager's storage has been
|
||||
// initialized. Returns false (0) if cookies cannot be accessed.
|
||||
//
|
||||
pub fn set_storage_path(&self, path: &[u16],
|
||||
persist_session_cookies: libc::c_int) -> libc::c_int {
|
||||
persist_session_cookies: libc::c_int,
|
||||
callback: interfaces::CefCompletionCallback) -> libc::c_int {
|
||||
if self.c_object.is_null() {
|
||||
panic!("called a CEF method on a null object")
|
||||
}
|
||||
|
@ -330,14 +347,15 @@ impl CefCookieManager {
|
|||
((*self.c_object).set_storage_path.unwrap())(
|
||||
self.c_object,
|
||||
CefWrap::to_c(path),
|
||||
CefWrap::to_c(persist_session_cookies)))
|
||||
CefWrap::to_c(persist_session_cookies),
|
||||
CefWrap::to_c(callback)))
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Flush the backing store (if any) to disk and execute the specified
|
||||
// |callback| on the IO thread when done. Returns false (0) if cookies cannot
|
||||
// be accessed.
|
||||
// Flush the backing store (if any) to disk. If |callback| is non-NULL it will
|
||||
// be executed asnychronously on the IO thread after the flush is complete.
|
||||
// Returns false (0) if cookies cannot be accessed.
|
||||
//
|
||||
pub fn flush_store(&self,
|
||||
callback: interfaces::CefCompletionCallback) -> libc::c_int {
|
||||
|
@ -354,13 +372,18 @@ impl CefCookieManager {
|
|||
|
||||
//
|
||||
// Returns the global cookie manager. By default data will be stored at
|
||||
// CefSettings.cache_path if specified or in memory otherwise.
|
||||
// CefSettings.cache_path if specified or in memory otherwise. If |callback|
|
||||
// is non-NULL it will be executed asnychronously on the IO thread after the
|
||||
// manager's storage has been initialized. Using this function is equivalent
|
||||
// to calling cef_request_tContext::cef_request_context_get_global_context()->
|
||||
// get_default_cookie_manager().
|
||||
//
|
||||
pub fn get_global_manager() -> interfaces::CefCookieManager {
|
||||
pub fn get_global_manager(
|
||||
callback: interfaces::CefCompletionCallback) -> interfaces::CefCookieManager {
|
||||
unsafe {
|
||||
CefWrap::to_rust(
|
||||
::cookie::cef_cookie_manager_get_global_manager(
|
||||
))
|
||||
CefWrap::to_c(callback)))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -370,15 +393,17 @@ impl CefCookieManager {
|
|||
// persist session cookies (cookies without an expiry date or validity
|
||||
// interval) set |persist_session_cookies| to true (1). Session cookies are
|
||||
// generally intended to be transient and most Web browsers do not persist
|
||||
// them. Returns NULL if creation fails.
|
||||
// them. If |callback| is non-NULL it will be executed asnychronously on the
|
||||
// IO thread after the manager's storage has been initialized.
|
||||
//
|
||||
pub fn create_manager(path: &[u16],
|
||||
persist_session_cookies: libc::c_int) -> interfaces::CefCookieManager {
|
||||
pub fn create_manager(path: &[u16], persist_session_cookies: libc::c_int,
|
||||
callback: interfaces::CefCompletionCallback) -> interfaces::CefCookieManager {
|
||||
unsafe {
|
||||
CefWrap::to_rust(
|
||||
::cookie::cef_cookie_manager_create_manager(
|
||||
CefWrap::to_c(path),
|
||||
CefWrap::to_c(persist_session_cookies)))
|
||||
CefWrap::to_c(persist_session_cookies),
|
||||
CefWrap::to_c(callback)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -559,3 +584,286 @@ impl CefWrap<*mut cef_cookie_visitor_t> for Option<CefCookieVisitor> {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Structure to implement to be notified of asynchronous completion via
|
||||
// cef_cookie_manager_t::set_cookie().
|
||||
//
|
||||
#[repr(C)]
|
||||
pub struct _cef_set_cookie_callback_t {
|
||||
//
|
||||
// Base structure.
|
||||
//
|
||||
pub base: types::cef_base_t,
|
||||
|
||||
//
|
||||
// Method that will be called upon completion. |success| will be true (1) if
|
||||
// the cookie was set successfully.
|
||||
//
|
||||
pub on_complete: Option<extern "C" fn(this: *mut cef_set_cookie_callback_t,
|
||||
success: libc::c_int) -> ()>,
|
||||
|
||||
//
|
||||
// The reference count. This will only be present for Rust instances!
|
||||
//
|
||||
pub ref_count: usize,
|
||||
|
||||
//
|
||||
// Extra data. This will only be present for Rust instances!
|
||||
//
|
||||
pub extra: u8,
|
||||
}
|
||||
|
||||
pub type cef_set_cookie_callback_t = _cef_set_cookie_callback_t;
|
||||
|
||||
|
||||
//
|
||||
// Structure to implement to be notified of asynchronous completion via
|
||||
// cef_cookie_manager_t::set_cookie().
|
||||
//
|
||||
pub struct CefSetCookieCallback {
|
||||
c_object: *mut cef_set_cookie_callback_t,
|
||||
}
|
||||
|
||||
impl Clone for CefSetCookieCallback {
|
||||
fn clone(&self) -> CefSetCookieCallback{
|
||||
unsafe {
|
||||
if !self.c_object.is_null() {
|
||||
((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base);
|
||||
}
|
||||
CefSetCookieCallback {
|
||||
c_object: self.c_object,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for CefSetCookieCallback {
|
||||
fn drop(&mut self) {
|
||||
unsafe {
|
||||
if !self.c_object.is_null() {
|
||||
((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl CefSetCookieCallback {
|
||||
pub unsafe fn from_c_object(c_object: *mut cef_set_cookie_callback_t) -> CefSetCookieCallback {
|
||||
CefSetCookieCallback {
|
||||
c_object: c_object,
|
||||
}
|
||||
}
|
||||
|
||||
pub unsafe fn from_c_object_addref(c_object: *mut cef_set_cookie_callback_t) -> CefSetCookieCallback {
|
||||
if !c_object.is_null() {
|
||||
((*c_object).base.add_ref.unwrap())(&mut (*c_object).base);
|
||||
}
|
||||
CefSetCookieCallback {
|
||||
c_object: c_object,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn c_object(&self) -> *mut cef_set_cookie_callback_t {
|
||||
self.c_object
|
||||
}
|
||||
|
||||
pub fn c_object_addrefed(&self) -> *mut cef_set_cookie_callback_t {
|
||||
unsafe {
|
||||
if !self.c_object.is_null() {
|
||||
eutil::add_ref(self.c_object as *mut types::cef_base_t);
|
||||
}
|
||||
self.c_object
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_null_cef_object(&self) -> bool {
|
||||
self.c_object.is_null()
|
||||
}
|
||||
pub fn is_not_null_cef_object(&self) -> bool {
|
||||
!self.c_object.is_null()
|
||||
}
|
||||
|
||||
//
|
||||
// Method that will be called upon completion. |success| will be true (1) if
|
||||
// the cookie was set successfully.
|
||||
//
|
||||
pub fn on_complete(&self, success: libc::c_int) -> () {
|
||||
if self.c_object.is_null() {
|
||||
panic!("called a CEF method on a null object")
|
||||
}
|
||||
unsafe {
|
||||
CefWrap::to_rust(
|
||||
((*self.c_object).on_complete.unwrap())(
|
||||
self.c_object,
|
||||
CefWrap::to_c(success)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl CefWrap<*mut cef_set_cookie_callback_t> for CefSetCookieCallback {
|
||||
fn to_c(rust_object: CefSetCookieCallback) -> *mut cef_set_cookie_callback_t {
|
||||
rust_object.c_object_addrefed()
|
||||
}
|
||||
unsafe fn to_rust(c_object: *mut cef_set_cookie_callback_t) -> CefSetCookieCallback {
|
||||
CefSetCookieCallback::from_c_object_addref(c_object)
|
||||
}
|
||||
}
|
||||
impl CefWrap<*mut cef_set_cookie_callback_t> for Option<CefSetCookieCallback> {
|
||||
fn to_c(rust_object: Option<CefSetCookieCallback>) -> *mut cef_set_cookie_callback_t {
|
||||
match rust_object {
|
||||
None => ptr::null_mut(),
|
||||
Some(rust_object) => rust_object.c_object_addrefed(),
|
||||
}
|
||||
}
|
||||
unsafe fn to_rust(c_object: *mut cef_set_cookie_callback_t) -> Option<CefSetCookieCallback> {
|
||||
if c_object.is_null() {
|
||||
None
|
||||
} else {
|
||||
Some(CefSetCookieCallback::from_c_object_addref(c_object))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Structure to implement to be notified of asynchronous completion via
|
||||
// cef_cookie_manager_t::delete_cookies().
|
||||
//
|
||||
#[repr(C)]
|
||||
pub struct _cef_delete_cookies_callback_t {
|
||||
//
|
||||
// Base structure.
|
||||
//
|
||||
pub base: types::cef_base_t,
|
||||
|
||||
//
|
||||
// Method that will be called upon completion. |num_deleted| will be the
|
||||
// number of cookies that were deleted or -1 if unknown.
|
||||
//
|
||||
pub on_complete: Option<extern "C" fn(
|
||||
this: *mut cef_delete_cookies_callback_t, num_deleted: libc::c_int) -> (
|
||||
)>,
|
||||
|
||||
//
|
||||
// The reference count. This will only be present for Rust instances!
|
||||
//
|
||||
pub ref_count: usize,
|
||||
|
||||
//
|
||||
// Extra data. This will only be present for Rust instances!
|
||||
//
|
||||
pub extra: u8,
|
||||
}
|
||||
|
||||
pub type cef_delete_cookies_callback_t = _cef_delete_cookies_callback_t;
|
||||
|
||||
|
||||
//
|
||||
// Structure to implement to be notified of asynchronous completion via
|
||||
// cef_cookie_manager_t::delete_cookies().
|
||||
//
|
||||
pub struct CefDeleteCookiesCallback {
|
||||
c_object: *mut cef_delete_cookies_callback_t,
|
||||
}
|
||||
|
||||
impl Clone for CefDeleteCookiesCallback {
|
||||
fn clone(&self) -> CefDeleteCookiesCallback{
|
||||
unsafe {
|
||||
if !self.c_object.is_null() {
|
||||
((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base);
|
||||
}
|
||||
CefDeleteCookiesCallback {
|
||||
c_object: self.c_object,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for CefDeleteCookiesCallback {
|
||||
fn drop(&mut self) {
|
||||
unsafe {
|
||||
if !self.c_object.is_null() {
|
||||
((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl CefDeleteCookiesCallback {
|
||||
pub unsafe fn from_c_object(c_object: *mut cef_delete_cookies_callback_t) -> CefDeleteCookiesCallback {
|
||||
CefDeleteCookiesCallback {
|
||||
c_object: c_object,
|
||||
}
|
||||
}
|
||||
|
||||
pub unsafe fn from_c_object_addref(c_object: *mut cef_delete_cookies_callback_t) -> CefDeleteCookiesCallback {
|
||||
if !c_object.is_null() {
|
||||
((*c_object).base.add_ref.unwrap())(&mut (*c_object).base);
|
||||
}
|
||||
CefDeleteCookiesCallback {
|
||||
c_object: c_object,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn c_object(&self) -> *mut cef_delete_cookies_callback_t {
|
||||
self.c_object
|
||||
}
|
||||
|
||||
pub fn c_object_addrefed(&self) -> *mut cef_delete_cookies_callback_t {
|
||||
unsafe {
|
||||
if !self.c_object.is_null() {
|
||||
eutil::add_ref(self.c_object as *mut types::cef_base_t);
|
||||
}
|
||||
self.c_object
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_null_cef_object(&self) -> bool {
|
||||
self.c_object.is_null()
|
||||
}
|
||||
pub fn is_not_null_cef_object(&self) -> bool {
|
||||
!self.c_object.is_null()
|
||||
}
|
||||
|
||||
//
|
||||
// Method that will be called upon completion. |num_deleted| will be the
|
||||
// number of cookies that were deleted or -1 if unknown.
|
||||
//
|
||||
pub fn on_complete(&self, num_deleted: libc::c_int) -> () {
|
||||
if self.c_object.is_null() {
|
||||
panic!("called a CEF method on a null object")
|
||||
}
|
||||
unsafe {
|
||||
CefWrap::to_rust(
|
||||
((*self.c_object).on_complete.unwrap())(
|
||||
self.c_object,
|
||||
CefWrap::to_c(num_deleted)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl CefWrap<*mut cef_delete_cookies_callback_t> for CefDeleteCookiesCallback {
|
||||
fn to_c(rust_object: CefDeleteCookiesCallback) -> *mut cef_delete_cookies_callback_t {
|
||||
rust_object.c_object_addrefed()
|
||||
}
|
||||
unsafe fn to_rust(c_object: *mut cef_delete_cookies_callback_t) -> CefDeleteCookiesCallback {
|
||||
CefDeleteCookiesCallback::from_c_object_addref(c_object)
|
||||
}
|
||||
}
|
||||
impl CefWrap<*mut cef_delete_cookies_callback_t> for Option<CefDeleteCookiesCallback> {
|
||||
fn to_c(rust_object: Option<CefDeleteCookiesCallback>) -> *mut cef_delete_cookies_callback_t {
|
||||
match rust_object {
|
||||
None => ptr::null_mut(),
|
||||
Some(rust_object) => rust_object.c_object_addrefed(),
|
||||
}
|
||||
}
|
||||
unsafe fn to_rust(c_object: *mut cef_delete_cookies_callback_t) -> Option<CefDeleteCookiesCallback> {
|
||||
if c_object.is_null() {
|
||||
None
|
||||
} else {
|
||||
Some(CefDeleteCookiesCallback::from_c_object_addref(c_object))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue