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=768e2436e54cceb2675ddd03ebdc61b5c0785bdc$ 37 // 38 39 #ifndef CEF_INCLUDE_CAPI_CEF_EXTENSION_HANDLER_CAPI_H_ 40 #define CEF_INCLUDE_CAPI_CEF_EXTENSION_HANDLER_CAPI_H_ 41 #pragma once 42 43 #include "include/capi/cef_base_capi.h" 44 #include "include/capi/cef_browser_capi.h" 45 #include "include/capi/cef_extension_capi.h" 46 #include "include/capi/cef_stream_capi.h" 47 48 #ifdef __cplusplus 49 extern "C" { 50 #endif 51 52 struct _cef_client_t; 53 54 /// 55 // Callback structure used for asynchronous continuation of 56 // cef_extension_handler_t::GetExtensionResource. 57 /// 58 typedef struct _cef_get_extension_resource_callback_t { 59 /// 60 // Base structure. 61 /// 62 cef_base_ref_counted_t base; 63 64 /// 65 // Continue the request. Read the resource contents from |stream|. 66 /// 67 void(CEF_CALLBACK* cont)(struct _cef_get_extension_resource_callback_t* self, 68 struct _cef_stream_reader_t* stream); 69 70 /// 71 // Cancel the request. 72 /// 73 void(CEF_CALLBACK* cancel)( 74 struct _cef_get_extension_resource_callback_t* self); 75 } cef_get_extension_resource_callback_t; 76 77 /// 78 // Implement this structure to handle events related to browser extensions. The 79 // functions of this structure will be called on the UI thread. See 80 // cef_request_context_t::LoadExtension for information about extension loading. 81 /// 82 typedef struct _cef_extension_handler_t { 83 /// 84 // Base structure. 85 /// 86 cef_base_ref_counted_t base; 87 88 /// 89 // Called if the cef_request_context_t::LoadExtension request fails. |result| 90 // will be the error code. 91 /// 92 void(CEF_CALLBACK* on_extension_load_failed)( 93 struct _cef_extension_handler_t* self, 94 cef_errorcode_t result); 95 96 /// 97 // Called if the cef_request_context_t::LoadExtension request succeeds. 98 // |extension| is the loaded extension. 99 /// 100 void(CEF_CALLBACK* on_extension_loaded)(struct _cef_extension_handler_t* self, 101 struct _cef_extension_t* extension); 102 103 /// 104 // Called after the cef_extension_t::Unload request has completed. 105 /// 106 void(CEF_CALLBACK* on_extension_unloaded)( 107 struct _cef_extension_handler_t* self, 108 struct _cef_extension_t* extension); 109 110 /// 111 // Called when an extension needs a browser to host a background script 112 // specified via the "background" manifest key. The browser will have no 113 // visible window and cannot be displayed. |extension| is the extension that 114 // is loading the background script. |url| is an internally generated 115 // reference to an HTML page that will be used to load the background script 116 // via a <script> src attribute. To allow creation of the browser optionally 117 // modify |client| and |settings| and return false (0). To cancel creation of 118 // the browser (and consequently cancel load of the background script) return 119 // true (1). Successful creation will be indicated by a call to 120 // cef_life_span_handler_t::OnAfterCreated, and 121 // cef_browser_host_t::IsBackgroundHost will return true (1) for the resulting 122 // browser. See https://developer.chrome.com/extensions/event_pages for more 123 // information about extension background script usage. 124 /// 125 int(CEF_CALLBACK* on_before_background_browser)( 126 struct _cef_extension_handler_t* self, 127 struct _cef_extension_t* extension, 128 const cef_string_t* url, 129 struct _cef_client_t** client, 130 struct _cef_browser_settings_t* settings); 131 132 /// 133 // Called when an extension API (e.g. chrome.tabs.create) requests creation of 134 // a new browser. |extension| and |browser| are the source of the API call. 135 // |active_browser| may optionally be specified via the windowId property or 136 // returned via the get_active_browser() callback and provides the default 137 // |client| and |settings| values for the new browser. |index| is the position 138 // value optionally specified via the index property. |url| is the URL that 139 // will be loaded in the browser. |active| is true (1) if the new browser 140 // should be active when opened. To allow creation of the browser optionally 141 // modify |windowInfo|, |client| and |settings| and return false (0). To 142 // cancel creation of the browser return true (1). Successful creation will be 143 // indicated by a call to cef_life_span_handler_t::OnAfterCreated. Any 144 // modifications to |windowInfo| will be ignored if |active_browser| is 145 // wrapped in a cef_browser_view_t. 146 /// 147 int(CEF_CALLBACK* on_before_browser)( 148 struct _cef_extension_handler_t* self, 149 struct _cef_extension_t* extension, 150 struct _cef_browser_t* browser, 151 struct _cef_browser_t* active_browser, 152 int index, 153 const cef_string_t* url, 154 int active, 155 struct _cef_window_info_t* windowInfo, 156 struct _cef_client_t** client, 157 struct _cef_browser_settings_t* settings); 158 159 /// 160 // Called when no tabId is specified to an extension API call that accepts a 161 // tabId parameter (e.g. chrome.tabs.*). |extension| and |browser| are the 162 // source of the API call. Return the browser that will be acted on by the API 163 // call or return NULL to act on |browser|. The returned browser must share 164 // the same cef_request_context_t as |browser|. Incognito browsers should not 165 // be considered unless the source extension has incognito access enabled, in 166 // which case |include_incognito| will be true (1). 167 /// 168 struct _cef_browser_t*(CEF_CALLBACK* get_active_browser)( 169 struct _cef_extension_handler_t* self, 170 struct _cef_extension_t* extension, 171 struct _cef_browser_t* browser, 172 int include_incognito); 173 174 /// 175 // Called when the tabId associated with |target_browser| is specified to an 176 // extension API call that accepts a tabId parameter (e.g. chrome.tabs.*). 177 // |extension| and |browser| are the source of the API call. Return true (1) 178 // to allow access of false (0) to deny access. Access to incognito browsers 179 // should not be allowed unless the source extension has incognito access 180 // enabled, in which case |include_incognito| will be true (1). 181 /// 182 int(CEF_CALLBACK* can_access_browser)(struct _cef_extension_handler_t* self, 183 struct _cef_extension_t* extension, 184 struct _cef_browser_t* browser, 185 int include_incognito, 186 struct _cef_browser_t* target_browser); 187 188 /// 189 // Called to retrieve an extension resource that would normally be loaded from 190 // disk (e.g. if a file parameter is specified to chrome.tabs.executeScript). 191 // |extension| and |browser| are the source of the resource request. |file| is 192 // the requested relative file path. To handle the resource request return 193 // true (1) and execute |callback| either synchronously or asynchronously. For 194 // the default behavior which reads the resource from the extension directory 195 // on disk return false (0). Localization substitutions will not be applied to 196 // resources handled via this function. 197 /// 198 int(CEF_CALLBACK* get_extension_resource)( 199 struct _cef_extension_handler_t* self, 200 struct _cef_extension_t* extension, 201 struct _cef_browser_t* browser, 202 const cef_string_t* file, 203 struct _cef_get_extension_resource_callback_t* callback); 204 } cef_extension_handler_t; 205 206 #ifdef __cplusplus 207 } 208 #endif 209 210 #endif // CEF_INCLUDE_CAPI_CEF_EXTENSION_HANDLER_CAPI_H_ 211