1 // Copyright (c) 2022 Marshall A. Greenblatt. All rights reserved. 2 // 3 // Redistribution and use in source and binary forms, with or without 4 // modification, are permitted provided that the following conditions are 5 // met: 6 // 7 // * Redistributions of source code must retain the above copyright 8 // notice, this list of conditions and the following disclaimer. 9 // * Redistributions in binary form must reproduce the above 10 // copyright notice, this list of conditions and the following disclaimer 11 // in the documentation and/or other materials provided with the 12 // distribution. 13 // * Neither the name of Google Inc. nor the name Chromium Embedded 14 // Framework nor the names of its contributors may be used to endorse 15 // or promote products derived from this software without specific prior 16 // written permission. 17 // 18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 // 30 // --------------------------------------------------------------------------- 31 // 32 // This file was generated by the CEF translator tool and should not edited 33 // by hand. See the translator.README.txt file in the tools directory for 34 // more information. 35 // 36 // $hash=89e64a2db658ad560e85ea5d3e564a6505d4e914$ 37 // 38 39 #ifndef CEF_INCLUDE_CAPI_CEF_REQUEST_CONTEXT_CAPI_H_ 40 #define CEF_INCLUDE_CAPI_CEF_REQUEST_CONTEXT_CAPI_H_ 41 #pragma once 42 43 #include "include/capi/cef_callback_capi.h" 44 #include "include/capi/cef_cookie_capi.h" 45 #include "include/capi/cef_extension_capi.h" 46 #include "include/capi/cef_extension_handler_capi.h" 47 #include "include/capi/cef_media_router_capi.h" 48 #include "include/capi/cef_values_capi.h" 49 50 #ifdef __cplusplus 51 extern "C" { 52 #endif 53 54 struct _cef_request_context_handler_t; 55 struct _cef_scheme_handler_factory_t; 56 57 /// 58 // Callback structure for cef_request_context_t::ResolveHost. 59 /// 60 typedef struct _cef_resolve_callback_t { 61 /// 62 // Base structure. 63 /// 64 cef_base_ref_counted_t base; 65 66 /// 67 // Called on the UI thread after the ResolveHost request has completed. 68 // |result| will be the result code. |resolved_ips| will be the list of 69 // resolved IP addresses or NULL if the resolution failed. 70 /// 71 void(CEF_CALLBACK* on_resolve_completed)(struct _cef_resolve_callback_t* self, 72 cef_errorcode_t result, 73 cef_string_list_t resolved_ips); 74 } cef_resolve_callback_t; 75 76 /// 77 // A request context provides request handling for a set of related browser or 78 // URL request objects. A request context can be specified when creating a new 79 // browser via the cef_browser_host_t static factory functions or when creating 80 // a new URL request via the cef_urlrequest_t static factory functions. Browser 81 // objects with different request contexts will never be hosted in the same 82 // render process. Browser objects with the same request context may or may not 83 // be hosted in the same render process depending on the process model. Browser 84 // objects created indirectly via the JavaScript window.open function or 85 // targeted links will share the same render process and the same request 86 // context as the source browser. When running in single-process mode there is 87 // only a single render process (the main process) and so all browsers created 88 // in single-process mode will share the same request context. This will be the 89 // first request context passed into a cef_browser_host_t static factory 90 // function and all other request context objects will be ignored. 91 /// 92 typedef struct _cef_request_context_t { 93 /// 94 // Base structure. 95 /// 96 cef_base_ref_counted_t base; 97 98 /// 99 // Returns true (1) if this object is pointing to the same context as |that| 100 // object. 101 /// 102 int(CEF_CALLBACK* is_same)(struct _cef_request_context_t* self, 103 struct _cef_request_context_t* other); 104 105 /// 106 // Returns true (1) if this object is sharing the same storage as |that| 107 // object. 108 /// 109 int(CEF_CALLBACK* is_sharing_with)(struct _cef_request_context_t* self, 110 struct _cef_request_context_t* other); 111 112 /// 113 // Returns true (1) if this object is the global context. The global context 114 // is used by default when creating a browser or URL request with a NULL 115 // context argument. 116 /// 117 int(CEF_CALLBACK* is_global)(struct _cef_request_context_t* self); 118 119 /// 120 // Returns the handler for this context if any. 121 /// 122 struct _cef_request_context_handler_t*(CEF_CALLBACK* get_handler)( 123 struct _cef_request_context_t* self); 124 125 /// 126 // Returns the cache path for this object. If NULL an "incognito mode" in- 127 // memory cache is being used. 128 /// 129 // The resulting string must be freed by calling cef_string_userfree_free(). 130 cef_string_userfree_t(CEF_CALLBACK* get_cache_path)( 131 struct _cef_request_context_t* self); 132 133 /// 134 // Returns the cookie manager for this object. If |callback| is non-NULL it 135 // will be executed asnychronously on the UI thread after the manager's 136 // storage has been initialized. 137 /// 138 struct _cef_cookie_manager_t*(CEF_CALLBACK* get_cookie_manager)( 139 struct _cef_request_context_t* self, 140 struct _cef_completion_callback_t* callback); 141 142 /// 143 // Register a scheme handler factory for the specified |scheme_name| and 144 // optional |domain_name|. An NULL |domain_name| value for a standard scheme 145 // will cause the factory to match all domain names. The |domain_name| value 146 // will be ignored for non-standard schemes. If |scheme_name| is a built-in 147 // scheme and no handler is returned by |factory| then the built-in scheme 148 // handler factory will be called. If |scheme_name| is a custom scheme then 149 // you must also implement the cef_app_t::on_register_custom_schemes() 150 // function in all processes. This function may be called multiple times to 151 // change or remove the factory that matches the specified |scheme_name| and 152 // optional |domain_name|. Returns false (0) if an error occurs. This function 153 // may be called on any thread in the browser process. 154 /// 155 int(CEF_CALLBACK* register_scheme_handler_factory)( 156 struct _cef_request_context_t* self, 157 const cef_string_t* scheme_name, 158 const cef_string_t* domain_name, 159 struct _cef_scheme_handler_factory_t* factory); 160 161 /// 162 // Clear all registered scheme handler factories. Returns false (0) on error. 163 // This function may be called on any thread in the browser process. 164 /// 165 int(CEF_CALLBACK* clear_scheme_handler_factories)( 166 struct _cef_request_context_t* self); 167 168 /// 169 // Returns true (1) if a preference with the specified |name| exists. This 170 // function must be called on the browser process UI thread. 171 /// 172 int(CEF_CALLBACK* has_preference)(struct _cef_request_context_t* self, 173 const cef_string_t* name); 174 175 /// 176 // Returns the value for the preference with the specified |name|. Returns 177 // NULL if the preference does not exist. The returned object contains a copy 178 // of the underlying preference value and modifications to the returned object 179 // will not modify the underlying preference value. This function must be 180 // called on the browser process UI thread. 181 /// 182 struct _cef_value_t*(CEF_CALLBACK* get_preference)( 183 struct _cef_request_context_t* self, 184 const cef_string_t* name); 185 186 /// 187 // Returns all preferences as a dictionary. If |include_defaults| is true (1) 188 // then preferences currently at their default value will be included. The 189 // returned object contains a copy of the underlying preference values and 190 // modifications to the returned object will not modify the underlying 191 // preference values. This function must be called on the browser process UI 192 // thread. 193 /// 194 struct _cef_dictionary_value_t*(CEF_CALLBACK* get_all_preferences)( 195 struct _cef_request_context_t* self, 196 int include_defaults); 197 198 /// 199 // Returns true (1) if the preference with the specified |name| can be 200 // modified using SetPreference. As one example preferences set via the 201 // command-line usually cannot be modified. This function must be called on 202 // the browser process UI thread. 203 /// 204 int(CEF_CALLBACK* can_set_preference)(struct _cef_request_context_t* self, 205 const cef_string_t* name); 206 207 /// 208 // Set the |value| associated with preference |name|. Returns true (1) if the 209 // value is set successfully and false (0) otherwise. If |value| is NULL the 210 // preference will be restored to its default value. If setting the preference 211 // fails then |error| will be populated with a detailed description of the 212 // problem. This function must be called on the browser process UI thread. 213 /// 214 int(CEF_CALLBACK* set_preference)(struct _cef_request_context_t* self, 215 const cef_string_t* name, 216 struct _cef_value_t* value, 217 cef_string_t* error); 218 219 /// 220 // Clears all certificate exceptions that were added as part of handling 221 // cef_request_handler_t::on_certificate_error(). If you call this it is 222 // recommended that you also call close_all_connections() or you risk not 223 // being prompted again for server certificates if you reconnect quickly. If 224 // |callback| is non-NULL it will be executed on the UI thread after 225 // completion. 226 /// 227 void(CEF_CALLBACK* clear_certificate_exceptions)( 228 struct _cef_request_context_t* self, 229 struct _cef_completion_callback_t* callback); 230 231 /// 232 // Clears all HTTP authentication credentials that were added as part of 233 // handling GetAuthCredentials. If |callback| is non-NULL it will be executed 234 // on the UI thread after completion. 235 /// 236 void(CEF_CALLBACK* clear_http_auth_credentials)( 237 struct _cef_request_context_t* self, 238 struct _cef_completion_callback_t* callback); 239 240 /// 241 // Clears all active and idle connections that Chromium currently has. This is 242 // only recommended if you have released all other CEF objects but don't yet 243 // want to call cef_shutdown(). If |callback| is non-NULL it will be executed 244 // on the UI thread after completion. 245 /// 246 void(CEF_CALLBACK* close_all_connections)( 247 struct _cef_request_context_t* self, 248 struct _cef_completion_callback_t* callback); 249 250 /// 251 // Attempts to resolve |origin| to a list of associated IP addresses. 252 // |callback| will be executed on the UI thread after completion. 253 /// 254 void(CEF_CALLBACK* resolve_host)(struct _cef_request_context_t* self, 255 const cef_string_t* origin, 256 struct _cef_resolve_callback_t* callback); 257 258 /// 259 // Load an extension. 260 // 261 // If extension resources will be read from disk using the default load 262 // implementation then |root_directory| should be the absolute path to the 263 // extension resources directory and |manifest| should be NULL. If extension 264 // resources will be provided by the client (e.g. via cef_request_handler_t 265 // and/or cef_extension_handler_t) then |root_directory| should be a path 266 // component unique to the extension (if not absolute this will be internally 267 // prefixed with the PK_DIR_RESOURCES path) and |manifest| should contain the 268 // contents that would otherwise be read from the "manifest.json" file on 269 // disk. 270 // 271 // The loaded extension will be accessible in all contexts sharing the same 272 // storage (HasExtension returns true (1)). However, only the context on which 273 // this function was called is considered the loader (DidLoadExtension returns 274 // true (1)) and only the loader will receive cef_request_context_handler_t 275 // callbacks for the extension. 276 // 277 // cef_extension_handler_t::OnExtensionLoaded will be called on load success 278 // or cef_extension_handler_t::OnExtensionLoadFailed will be called on load 279 // failure. 280 // 281 // If the extension specifies a background script via the "background" 282 // manifest key then cef_extension_handler_t::OnBeforeBackgroundBrowser will 283 // be called to create the background browser. See that function for 284 // additional information about background scripts. 285 // 286 // For visible extension views the client application should evaluate the 287 // manifest to determine the correct extension URL to load and then pass that 288 // URL to the cef_browser_host_t::CreateBrowser* function after the extension 289 // has loaded. For example, the client can look for the "browser_action" 290 // manifest key as documented at 291 // https://developer.chrome.com/extensions/browserAction. Extension URLs take 292 // the form "chrome-extension://<extension_id>/<path>". 293 // 294 // Browsers that host extensions differ from normal browsers as follows: 295 // - Can access chrome.* JavaScript APIs if allowed by the manifest. Visit 296 // chrome://extensions-support for the list of extension APIs currently 297 // supported by CEF. 298 // - Main frame navigation to non-extension content is blocked. 299 // - Pinch-zooming is disabled. 300 // - CefBrowserHost::GetExtension returns the hosted extension. 301 // - CefBrowserHost::IsBackgroundHost returns true for background hosts. 302 // 303 // See https://developer.chrome.com/extensions for extension implementation 304 // and usage documentation. 305 /// 306 void(CEF_CALLBACK* load_extension)(struct _cef_request_context_t* self, 307 const cef_string_t* root_directory, 308 struct _cef_dictionary_value_t* manifest, 309 struct _cef_extension_handler_t* handler); 310 311 /// 312 // Returns true (1) if this context was used to load the extension identified 313 // by |extension_id|. Other contexts sharing the same storage will also have 314 // access to the extension (see HasExtension). This function must be called on 315 // the browser process UI thread. 316 /// 317 int(CEF_CALLBACK* did_load_extension)(struct _cef_request_context_t* self, 318 const cef_string_t* extension_id); 319 320 /// 321 // Returns true (1) if this context has access to the extension identified by 322 // |extension_id|. This may not be the context that was used to load the 323 // extension (see DidLoadExtension). This function must be called on the 324 // browser process UI thread. 325 /// 326 int(CEF_CALLBACK* has_extension)(struct _cef_request_context_t* self, 327 const cef_string_t* extension_id); 328 329 /// 330 // Retrieve the list of all extensions that this context has access to (see 331 // HasExtension). |extension_ids| will be populated with the list of extension 332 // ID values. Returns true (1) on success. This function must be called on the 333 // browser process UI thread. 334 /// 335 int(CEF_CALLBACK* get_extensions)(struct _cef_request_context_t* self, 336 cef_string_list_t extension_ids); 337 338 /// 339 // Returns the extension matching |extension_id| or NULL if no matching 340 // extension is accessible in this context (see HasExtension). This function 341 // must be called on the browser process UI thread. 342 /// 343 struct _cef_extension_t*(CEF_CALLBACK* get_extension)( 344 struct _cef_request_context_t* self, 345 const cef_string_t* extension_id); 346 347 /// 348 // Returns the MediaRouter object associated with this context. If |callback| 349 // is non-NULL it will be executed asnychronously on the UI thread after the 350 // manager's context has been initialized. 351 /// 352 struct _cef_media_router_t*(CEF_CALLBACK* get_media_router)( 353 struct _cef_request_context_t* self, 354 struct _cef_completion_callback_t* callback); 355 } cef_request_context_t; 356 357 /// 358 // Returns the global context object. 359 /// 360 CEF_EXPORT cef_request_context_t* cef_request_context_get_global_context(); 361 362 /// 363 // Creates a new context object with the specified |settings| and optional 364 // |handler|. 365 /// 366 CEF_EXPORT cef_request_context_t* cef_request_context_create_context( 367 const struct _cef_request_context_settings_t* settings, 368 struct _cef_request_context_handler_t* handler); 369 370 /// 371 // Creates a new context object that shares storage with |other| and uses an 372 // optional |handler|. 373 /// 374 CEF_EXPORT cef_request_context_t* cef_create_context_shared( 375 cef_request_context_t* other, 376 struct _cef_request_context_handler_t* handler); 377 378 #ifdef __cplusplus 379 } 380 #endif 381 382 #endif // CEF_INCLUDE_CAPI_CEF_REQUEST_CONTEXT_CAPI_H_ 383