browser_window_core/
browser_window.rs

1pub mod c;
2
3use std::borrow::Cow;
4
5pub use c::BrowserWindowImpl;
6pub use c::JsEvaluationError;
7
8use super::{
9	application::ApplicationImpl,
10	cookie::CookieJarImpl,
11	window::{WindowImpl, WindowOptions}
12};
13
14use browser_window_c::*;
15
16
17
18pub type BrowserWindowOptions = cbw_BrowserWindowOptions;
19pub type Source = cbw_BrowserWindowSource;
20
21pub type CreationCallbackFn = unsafe fn( bw: BrowserWindowImpl, data: *mut () );
22pub type EvalJsCallbackFn = unsafe fn( bw: BrowserWindowImpl, data: *mut (), result: Result<String, JsEvaluationError> ); 
23pub type ExternalInvocationHandlerFn = unsafe fn( bw: BrowserWindowImpl, cmd: &str, args: Vec<String> );
24
25pub trait BrowserWindowExt: Copy {
26
27	fn cookie_jar(&self) -> CookieJarImpl;
28
29	/// Executes the given JavaScript string.
30	/// The result will be provided by invoking the callback function.
31	fn eval_js( &self, js: &str, callback: EvalJsCallbackFn, callback_data: *mut () );
32	
33	/// Like `eval_js`, except it can be called from any thread.
34	fn eval_js_threadsafe( &self, js: &str, callback: EvalJsCallbackFn, callback_data: *mut () );
35
36	/// Causes the browser to navigate to the given URI.
37	fn navigate( &self, uri: &str );
38
39	/// Creates a new browser window asynchronously.
40	/// The `BrowserWindowImpl` handle to the new browser window will be passed via a callback.
41	///
42	/// # Arguments
43	/// `app` - The application handle
44	/// `parent` - An handle for another window that this window will be a child of. Use WindowImpl::default() for no parent.
45	/// `source` - The content that will be displayed by the browser.
46	/// `title` - The title that the window will have.
47	/// `width` - The width of the window.
48	/// `height` - The height of the window.
49	/// `window_options` - Options for the window.
50	/// `browser_window_options` - Some extra browser related options.
51	/// `handler` - A handler function that can be invoked from within JavaScript code.
52	/// `user_data` - Could be set to point to some extra data that this browser window will store.
53	/// `creation_callback` - Will be invoked when the browser window is created. It provided the `BrowserWindowImpl` handle.
54	/// `callback_data` - The data that will be provided to the `creation_callback`.
55	fn new(
56		app: ApplicationImpl,
57		parent: WindowImpl,
58		source: Source,
59		title: &str,
60		width: Option<u32>,
61		height: Option<u32>,
62		window_options: &WindowOptions,
63		browser_window_options: &BrowserWindowOptions,
64		handler: ExternalInvocationHandlerFn,
65		user_data: *mut (),
66		creation_callback: CreationCallbackFn,
67		callback_data: *mut ()
68	);
69
70	fn user_data( &self ) -> *mut ();
71
72	fn url<'a>(&'a self) -> Cow<'a, str>;
73
74	/// Gives a handle to the underlying window.
75	fn window( &self ) -> WindowImpl;
76}