_cef_frame_handler_t

Struct _cef_frame_handler_t 

Source
#[repr(C)]
pub struct _cef_frame_handler_t { pub base: cef_base_ref_counted_t, pub on_frame_created: Option<unsafe extern "C" fn(self_: *mut _cef_frame_handler_t, browser: *mut _cef_browser_t, frame: *mut _cef_frame_t)>, pub on_frame_destroyed: Option<unsafe extern "C" fn(self_: *mut _cef_frame_handler_t, browser: *mut _cef_browser_t, frame: *mut _cef_frame_t)>, pub on_frame_attached: Option<unsafe extern "C" fn(self_: *mut _cef_frame_handler_t, browser: *mut _cef_browser_t, frame: *mut _cef_frame_t, reattached: c_int)>, pub on_frame_detached: Option<unsafe extern "C" fn(self_: *mut _cef_frame_handler_t, browser: *mut _cef_browser_t, frame: *mut _cef_frame_t)>, pub on_main_frame_changed: Option<unsafe extern "C" fn(self_: *mut _cef_frame_handler_t, browser: *mut _cef_browser_t, old_frame: *mut _cef_frame_t, new_frame: *mut _cef_frame_t)>, }
Expand description

Implement this structure to handle events related to cef_frame_t life span. The order of callbacks is:

(1) During initial cef_browser_host_t creation and navigation of the main frame:

  • cef_frame_handler_t::OnFrameCreated => The initial main frame object has been created. Any commands will be queued until the frame is attached.
  • cef_frame_handler_t::OnMainFrameChanged => The initial main frame object has been assigned to the browser.
  • cef_life_span_handler_t::OnAfterCreated => The browser is now valid and can be used.
  • cef_frame_handler_t::OnFrameAttached => The initial main frame object is now connected to its peer in the renderer process. Commands can be routed.

(2) During further cef_browser_host_t navigation/loading of the main frame and/or sub-frames:

  • cef_frame_handler_t::OnFrameCreated => A new main frame or sub-frame object has been created. Any commands will be queued until the frame is attached.
  • cef_frame_handler_t::OnFrameAttached => A new main frame or sub-frame object is now connected to its peer in the renderer process. Commands can be routed.
  • cef_frame_handler_t::OnFrameDetached => An existing main frame or sub- frame object has lost its connection to the renderer process. If multiple objects are detached at the same time then notifications will be sent for any sub-frame objects before the main frame object. Commands can no longer be routed and will be discarded.
  • CefFremeHadler::OnFrameDestroyed => An existing main frame or sub-frame object has been destroyed.
  • cef_frame_handler_t::OnMainFrameChanged => A new main frame object has been assigned to the browser. This will only occur with cross-origin navigation or re-navigation after renderer process termination (due to crashes, etc).

(3) During final cef_browser_host_t destruction of the main frame:

  • cef_frame_handler_t::OnFrameDetached => Any sub-frame objects have lost their connection to the renderer process. Commands can no longer be routed and will be discarded.
  • CefFreameHandler::OnFrameDestroyed => Any sub-frame objects have been destroyed.
  • cef_life_span_handler_t::OnBeforeClose => The browser has been destroyed.
  • cef_frame_handler_t::OnFrameDetached => The main frame object have lost its connection to the renderer process. Notifications will be sent for any sub-frame objects before the main frame object. Commands can no longer be routed and will be discarded.
  • CefFreameHandler::OnFrameDestroyed => The main frame object has been destroyed.
  • cef_frame_handler_t::OnMainFrameChanged => The final main frame object has been removed from the browser.

Special handling applies for cross-origin loading on creation/navigation of sub-frames, and cross-origin loading on creation of new popup browsers. A temporary frame will first be created in the parent frame’s renderer process. This temporary frame will never attach and will be discarded after the real cross-origin frame is created in the new/target renderer process. The client will receive creation callbacks for the temporary frame, followed by cross-origin navigation callbacks (2) for the transition from the temporary frame to the real frame. The temporary frame will not receive or execute commands during this transitional period (any sent commands will be discarded).

When the main frame navigates to a different origin the OnMainFrameChanged callback (2) will be executed with the old and new main frame objects.

Callbacks will not be executed for placeholders that may be created during pre-commit navigation for sub-frames that do not yet exist in the renderer process. Placeholders will have cef_frame_t::get_identifier() == -4.

The functions of this structure will be called on the UI thread unless otherwise indicated.

NOTE: This struct is allocated client-side.

Fields§

§base: cef_base_ref_counted_t

Base structure.

§on_frame_created: Option<unsafe extern "C" fn(self_: *mut _cef_frame_handler_t, browser: *mut _cef_browser_t, frame: *mut _cef_frame_t)>

Called when a new frame is created. This will be the first notification that references |frame|. Any commands that require transport to the associated renderer process (LoadRequest, SendProcessMessage, GetSource, etc.) will be queued. The queued commands will be sent before OnFrameAttached or discarded before OnFrameDestroyed if the frame never attaches.

§on_frame_destroyed: Option<unsafe extern "C" fn(self_: *mut _cef_frame_handler_t, browser: *mut _cef_browser_t, frame: *mut _cef_frame_t)>

Called when an existing frame is destroyed. This will be the last notification that references |frame| and cef_frame_t::is_valid() will return false (0) for |frame|. If called during browser destruction and after cef_life_span_handler_t::on_before_close() then cef_browser_t::is_valid() will return false (0) for |browser|. Any queued commands that have not been sent will be discarded before this callback.

§on_frame_attached: Option<unsafe extern "C" fn(self_: *mut _cef_frame_handler_t, browser: *mut _cef_browser_t, frame: *mut _cef_frame_t, reattached: c_int)>

Called when a frame can begin routing commands to/from the associated renderer process. |reattached| will be true (1) if the frame was re- attached after exiting the BackForwardCache or after encountering a recoverable connection error. Any queued commands will now have been dispatched. This function will not be called for temporary frames created during cross-origin navigation.

§on_frame_detached: Option<unsafe extern "C" fn(self_: *mut _cef_frame_handler_t, browser: *mut _cef_browser_t, frame: *mut _cef_frame_t)>

Called when a frame loses its connection to the renderer process. This may occur when a frame is destroyed, enters the BackForwardCache, or encounters a rare connection error. In the case of frame destruction this call will be followed by a (potentially async) call to OnFrameDestroyed. If frame destruction is occuring synchronously then cef_frame_t::is_valid() will return false (0) for |frame|. If called during browser destruction and after cef_life_span_handler_t::on_before_close() then cef_browser_t::is_valid() will return false (0) for |browser|. If, in the non-destruction case, the same frame later exits the BackForwardCache or recovers from a connection error then there will be a follow-up call to OnFrameAttached. This function will not be called for temporary frames created during cross- origin navigation.

§on_main_frame_changed: Option<unsafe extern "C" fn(self_: *mut _cef_frame_handler_t, browser: *mut _cef_browser_t, old_frame: *mut _cef_frame_t, new_frame: *mut _cef_frame_t)>

Called when the main frame changes due to (a) initial browser creation, (b) final browser destruction, (c) cross-origin navigation or (d) re- navigation after renderer process termination (due to crashes, etc). |old_frame| will be NULL and |new_frame| will be non-NULL when a main frame is assigned to |browser| for the first time. |old_frame| will be non-NULL and |new_frame| will be NULL when a main frame is removed from |browser| for the last time. Both |old_frame| and |new_frame| will be non- NULL for cross-origin navigations or re-navigation after renderer process termination. This function will be called after on_frame_created() for |new_frame| and/or after on_frame_destroyed() for |old_frame|. If called during browser destruction and after cef_life_span_handler_t::on_before_close() then cef_browser_t::is_valid() will return false (0) for |browser|.

Trait Implementations§

Source§

impl Clone for _cef_frame_handler_t

Source§

fn clone(&self) -> _cef_frame_handler_t

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for _cef_frame_handler_t

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Copy for _cef_frame_handler_t

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.