electron_sys/class/
session.rs

1use crate::{
2    class::WebRequest,
3    interface::{
4        ClearStorageDataOptions,
5        CreateInterruptedDownloadOptions,
6        EnableNetworkEmulationOptions,
7        FromPartitionOptions,
8        NetLog,
9        PreconnectOptions,
10        Protocol,
11        RemoveClientCertificate,
12        RemovePassword,
13        SetProxyOptions,
14    },
15};
16use js_sys::{Function, Promise};
17use node_sys::events::EventEmitter;
18use wasm_bindgen::prelude::*;
19
20#[wasm_bindgen(module = "electron")]
21extern {
22    #[wasm_bindgen(extends = EventEmitter)]
23    #[derive(Clone, Debug)]
24    /// Docs: http://electronjs.org/docs/api/session
25    pub type Session;
26
27    //****************//
28    // Static Methods //
29    //****************//
30
31    #[wasm_bindgen(static_method_of = Session, js_name = "fromPartition")]
32    pub fn from_partition(partition: &str, options: Option<FromPartitionOptions>) -> Session;
33
34    //*******************//
35    // Static Properties //
36    //*******************//
37
38    #[wasm_bindgen(static_method_of = Session, getter, js_name = "defaultSession")]
39    pub fn default_session() -> Session;
40
41    //******************//
42    // Instance Methods //
43    //******************//
44
45    #[wasm_bindgen(method, js_name = "allowNTLMCredentialsForDomains")]
46    pub fn allow_ntlm_credentials_for_domains(this: &Session, domains: &str);
47
48    #[must_use]
49    #[wasm_bindgen(method, js_name = "clear_auth_cache")]
50    pub fn clear_auth_cache_and_remove_password(this: &Session, options: RemovePassword) -> Promise;
51
52    #[must_use]
53    #[wasm_bindgen(method, js_name = "clear_auth_cache")]
54    pub fn clear_auth_cache_and_remove_client_certificate(this: &Session, options: RemoveClientCertificate) -> Promise;
55
56    #[must_use]
57    #[wasm_bindgen(method, js_name = "clearCache")]
58    pub fn clear_cache(this: &Session) -> Promise;
59
60    #[must_use]
61    #[wasm_bindgen(method, js_name = "clearHostResolverCache")]
62    pub fn clear_host_resolver_cache(this: &Session) -> Promise;
63
64    #[must_use]
65    #[wasm_bindgen(method, js_name = "clearStorageData")]
66    pub fn clear_storage_data(this: &Session, options: Option<ClearStorageDataOptions>) -> Promise;
67
68    #[wasm_bindgen(method, js_name = "createInterruptedDownload")]
69    pub fn create_interrupted_download(this: &Session, options: CreateInterruptedDownloadOptions);
70
71    #[wasm_bindgen(method, js_name = "disableNetworkEmulation")]
72    pub fn disable_network_emulation(this: &Session);
73
74    #[wasm_bindgen(method, js_name = "downloadURL")]
75    pub fn download_url(this: &Session, url: &str);
76
77    #[wasm_bindgen(method, js_name = "enableNetworkEmulation")]
78    pub fn enable_network_emulation(this: &Session, options: EnableNetworkEmulationOptions);
79
80    #[wasm_bindgen(method, js_name = "flushStorageData")]
81    pub fn flush_storage_data(this: &Session);
82
83    #[must_use]
84    #[wasm_bindgen(method, js_name = "getBlobData")]
85    pub fn get_blob_data(this: &Session, identifier: &str) -> Promise;
86
87    #[must_use]
88    #[wasm_bindgen(method, js_name = "getCacheSize")]
89    pub fn get_cache_size(this: &Session) -> Promise;
90
91    #[wasm_bindgen(method, js_name = "getPreloads")]
92    pub fn get_preloads(this: &Session) -> Box<[JsValue]>;
93
94    #[wasm_bindgen(method, js_name = "getSpellCheckerLanguages")]
95    pub fn get_spell_checker_languages(this: &Session) -> Box<[JsValue]>;
96
97    #[wasm_bindgen(method, js_name = "getUserAgent")]
98    pub fn get_user_agent(this: &Session) -> Box<[JsValue]>;
99
100    #[wasm_bindgen(method)]
101    pub fn preconnect(this: &Session, options: PreconnectOptions) -> Box<[JsValue]>;
102
103    #[must_use]
104    #[wasm_bindgen(method, js_name = "resolveProxy")]
105    pub fn resolve_proxy(this: &Session, url: &str) -> Promise;
106
107    #[wasm_bindgen(method, js_name = "setCertificateVerifyProc")]
108    pub fn set_certificate_verify_proc(this: &Session, proc: Option<&Function>);
109
110    #[wasm_bindgen(method, js_name = "setDownloadPath")]
111    pub fn set_download_path(this: &Session, path: &str);
112
113    #[wasm_bindgen(method, js_name = "setPermissionCheckHandler")]
114    pub fn set_permission_check_handler(this: &Session, handler: Option<&Function>);
115
116    #[wasm_bindgen(method, js_name = "setPermissionRequestHandler")]
117    pub fn set_permission_request_handler(this: &Session, handler: Option<&Function>);
118
119    #[wasm_bindgen(method, js_name = "setPreloads")]
120    pub fn set_preloads(this: &Session, preloads: Box<[JsValue]>);
121
122    #[must_use]
123    #[wasm_bindgen(method, js_name = "setProxy")]
124    pub fn set_proxy(this: &Session, options: SetProxyOptions) -> Promise;
125
126    #[wasm_bindgen(method, js_name = "setSpellCheckerDictionaryDownloadURL")]
127    pub fn set_spell_checker_dictionary_download_url(this: &Session, url: &str);
128
129    #[wasm_bindgen(method, js_name = "setSpellCheckerLanguages")]
130    pub fn set_spell_checker_languages(this: &Session, languages: Box<[JsValue]>);
131
132    #[wasm_bindgen(method, js_name = "setUserAgent")]
133    pub fn set_user_agent(this: &Session, user_agent: &str, accept_languages: Option<&str>);
134
135    //*********************//
136    // Instance Properties //
137    //*********************//
138
139    #[wasm_bindgen(method, getter, js_name = "availableSpellCheckerLanguages")] // readonly
140    pub fn available_spell_checker_languages(this: &Session) -> Box<[JsValue]>;
141
142    #[wasm_bindgen(method, getter)] // readonly
143    pub fn cookies(this: &Session) -> Box<[JsValue]>;
144
145    #[wasm_bindgen(method, getter, js_name = "netLog")] // readonly
146    pub fn net_log(this: &Session) -> NetLog;
147
148    #[wasm_bindgen(method, getter)] // readonly
149    pub fn protocol(this: &Session) -> Protocol;
150
151    #[wasm_bindgen(method, getter, js_name = "webRequest")] // readonly
152    pub fn web_request(this: &Session) -> WebRequest;
153}