Beispiel #1
0
 protected CefRequestHandler()
 {
     _self = cef_request_handler_t.Alloc();
 
     _ds0 = new cef_request_handler_t.add_ref_delegate(add_ref);
     _self->_base._add_ref = Marshal.GetFunctionPointerForDelegate(_ds0);
     _ds1 = new cef_request_handler_t.release_delegate(release);
     _self->_base._release = Marshal.GetFunctionPointerForDelegate(_ds1);
     _ds2 = new cef_request_handler_t.has_one_ref_delegate(has_one_ref);
     _self->_base._has_one_ref = Marshal.GetFunctionPointerForDelegate(_ds2);
     _ds3 = new cef_request_handler_t.on_before_browse_delegate(on_before_browse);
     _self->_on_before_browse = Marshal.GetFunctionPointerForDelegate(_ds3);
     _ds4 = new cef_request_handler_t.on_before_resource_load_delegate(on_before_resource_load);
     _self->_on_before_resource_load = Marshal.GetFunctionPointerForDelegate(_ds4);
     _ds5 = new cef_request_handler_t.get_resource_handler_delegate(get_resource_handler);
     _self->_get_resource_handler = Marshal.GetFunctionPointerForDelegate(_ds5);
     _ds6 = new cef_request_handler_t.on_resource_redirect_delegate(on_resource_redirect);
     _self->_on_resource_redirect = Marshal.GetFunctionPointerForDelegate(_ds6);
     _ds7 = new cef_request_handler_t.get_auth_credentials_delegate(get_auth_credentials);
     _self->_get_auth_credentials = Marshal.GetFunctionPointerForDelegate(_ds7);
     _ds8 = new cef_request_handler_t.on_quota_request_delegate(on_quota_request);
     _self->_on_quota_request = Marshal.GetFunctionPointerForDelegate(_ds8);
     _ds9 = new cef_request_handler_t.on_protocol_execution_delegate(on_protocol_execution);
     _self->_on_protocol_execution = Marshal.GetFunctionPointerForDelegate(_ds9);
     _dsa = new cef_request_handler_t.on_certificate_error_delegate(on_certificate_error);
     _self->_on_certificate_error = Marshal.GetFunctionPointerForDelegate(_dsa);
     _dsb = new cef_request_handler_t.on_before_plugin_load_delegate(on_before_plugin_load);
     _self->_on_before_plugin_load = Marshal.GetFunctionPointerForDelegate(_dsb);
     _dsc = new cef_request_handler_t.on_plugin_crashed_delegate(on_plugin_crashed);
     _self->_on_plugin_crashed = Marshal.GetFunctionPointerForDelegate(_dsc);
     _dsd = new cef_request_handler_t.on_render_process_terminated_delegate(on_render_process_terminated);
     _self->_on_render_process_terminated = Marshal.GetFunctionPointerForDelegate(_dsd);
 }
Beispiel #2
0
 protected virtual void Dispose(bool disposing)
 {
     if (_self != null)
     {
         cef_request_handler_t.Free(_self);
         _self = null;
     }
 }
Beispiel #3
0
        private void on_render_view_ready(cef_request_handler_t *self, cef_browser_t *browser)
        {
            CheckSelf(self);

            var m_browser = CefBrowser.FromNative(browser);

            OnRenderViewReady(m_browser);
        }
Beispiel #4
0
 protected virtual void Dispose(bool disposing)
 {
     if (_self != null)
     {
         cef_request_handler_t.Free(_self);
         _self = null;
     }
 }
Beispiel #5
0
        private void on_render_process_terminated(cef_request_handler_t *self, cef_browser_t *browser, CefTerminationStatus status)
        {
            CheckSelf(self);

            var m_browser = CefBrowser.FromNative(browser);

            OnRenderProcessTerminated(m_browser, status);
        }
        private void on_document_available_in_main_frame(cef_request_handler_t *self, cef_browser_t *browser)
        {
            CheckSelf(self);

            var m_browser = CefBrowser.FromNative(browser);

            OnDocumentAvailableInMainFrame(m_browser);
        }
        private void on_plugin_crashed(cef_request_handler_t *self, cef_browser_t *browser, cef_string_t *plugin_path)
        {
            CheckSelf(self);

            var m_browser     = CefBrowser.FromNative(browser);
            var m_plugin_path = cef_string_t.ToString(plugin_path);

            OnPluginCrashed(m_browser, m_plugin_path);
        }
Beispiel #8
0
        /// <summary>
        /// Called on the IO thread to retrieve the cookie manager. |main_url| is the
        /// URL of the top-level frame. Cookies managers can be unique per browser or
        /// shared across multiple browsers. The global cookie manager will be used if
        /// this method returns NULL.
        /// </summary>
        private cef_cookie_manager_t *get_cookie_manager(cef_request_handler_t *self, cef_browser_t *browser, /*const*/ cef_string_t *main_url)
        {
            ThrowIfObjectDisposed();

            var m_browser = CefBrowser.From(browser);
            var m_mainUrl = cef_string_t.ToString(main_url);

            var cookieManager = this.GetCookieManager(m_browser, m_mainUrl);

            return(cookieManager != null?cookieManager.GetNativePointerAndAddRef() : null);
        }
 private void add_ref(cef_request_handler_t *self)
 {
     lock (SyncRoot)
     {
         var result = ++_refct;
         if (result == 1)
         {
             lock (_roots) { _roots.Add((IntPtr)_self, this); }
         }
     }
 }
Beispiel #10
0
        public CefRequestHandler(CefClient ownerClient)
        {
            Client = ownerClient;

            cef_request_handler_t *self = FixedPtr;

            self->get_resource_request_handler = holder_get_resource_request_handler;
            self->on_certificate_error         = holder_on_certificate_error;
            self->on_before_browse             = holder_on_before_browse;
            self->on_open_urlfrom_tab          = holder_on_open_urlfrom_tab;
        }
Beispiel #11
0
        private cef_cookie_manager_t *get_cookie_manager(cef_request_handler_t *self, cef_browser_t *browser, cef_string_t *main_url)
        {
            CheckSelf(self);

            var m_browser = CefBrowser.FromNative(browser);
            var m_mainUrl = cef_string_t.ToString(main_url);

            var manager = GetCookieManager(m_browser, m_mainUrl);

            return(manager != null?manager.ToNative() : null);
        }
        private int on_certificate_error(cef_request_handler_t *self, CefErrorCode cert_error, cef_string_t *request_url, cef_allow_certificate_error_callback_t *callback)
        {
            CheckSelf(self);

            var m_request_url = cef_string_t.ToString(request_url);
            var m_callback    = CefAllowCertificateErrorCallback.FromNativeOrNull(callback);

            var result = OnCertificateError(cert_error, m_request_url, m_callback);

            return(result ? 1 : 0);
        }
Beispiel #13
0
        private void on_resource_load_complete(cef_request_handler_t *self, cef_browser_t *browser, cef_frame_t *frame, cef_request_t *request, cef_response_t *response, CefUrlRequestStatus status, long received_content_length)
        {
            CheckSelf(self);

            var mBrowser  = CefBrowser.FromNative(browser);
            var mFrame    = CefFrame.FromNative(frame);
            var mRequest  = CefRequest.FromNative(request);
            var mResponse = CefResponse.FromNative(response);

            OnResourceLoadComplete(mBrowser, mFrame, mRequest, mResponse, status, received_content_length);
        }
Beispiel #14
0
        private int on_open_urlfrom_tab(cef_request_handler_t *self, cef_browser_t *browser, cef_frame_t *frame, cef_string_t *target_url, CefWindowOpenDisposition target_disposition, int user_gesture)
        {
            CheckSelf(self);

            var m_browser    = CefBrowser.FromNative(browser);
            var m_frame      = CefFrame.FromNative(frame);
            var m_target_url = cef_string_t.ToString(target_url);

            var result = OnOpenUrlFromTab(m_browser, m_frame, m_target_url, target_disposition, user_gesture);

            return(result ? 1 : 0);
        }
 private int release(cef_request_handler_t *self)
 {
     lock (SyncRoot)
     {
         var result = --_refct;
         if (result == 0)
         {
             lock (_roots) { _roots.Remove((IntPtr)_self); }
         }
         return(result);
     }
 }
        private int on_quota_request(cef_request_handler_t *self, cef_browser_t *browser, cef_string_t *origin_url, long new_size, cef_quota_callback_t *callback)
        {
            CheckSelf(self);

            var m_browser    = CefBrowser.FromNative(browser);
            var m_origin_url = cef_string_t.ToString(origin_url);
            var m_callback   = CefQuotaCallback.FromNative(callback);

            var result = OnQuotaRequest(m_browser, m_origin_url, new_size, m_callback);

            return(result ? 1 : 0);
        }
Beispiel #17
0
        private int can_get_cookies(cef_request_handler_t *self, cef_browser_t *browser, cef_frame_t *frame, cef_request_t *request)
        {
            CheckSelf(self);

            var mBrowser = CefBrowser.FromNative(browser);
            var mFrame   = CefFrame.FromNative(frame);
            var mRequest = CefRequest.FromNative(request);

            var mResult = CanGetCookies(mBrowser, mFrame, mRequest);

            return(mResult ? 1 : 0);
        }
        private void on_protocol_execution(cef_request_handler_t *self, cef_browser_t *browser, cef_string_t *url, int *allow_os_execution)
        {
            CheckSelf(self);

            var  m_browser = CefBrowser.FromNative(browser);
            var  m_url     = cef_string_t.ToString(url);
            bool m_allow_os_execution;

            OnProtocolExecution(m_browser, m_url, out m_allow_os_execution);

            *allow_os_execution = m_allow_os_execution ? 1 : 0;
        }
Beispiel #19
0
        private int on_certificate_error(cef_request_handler_t *self, cef_browser_t *browser, CefErrorCode cert_error, cef_string_t *request_url, cef_sslinfo_t *ssl_info, cef_request_callback_t *callback)
        {
            CheckSelf(self);

            var m_browser     = CefBrowser.FromNative(browser);
            var m_request_url = cef_string_t.ToString(request_url);
            var m_ssl_info    = CefSslInfo.FromNative(ssl_info);
            var m_callback    = CefRequestCallback.FromNativeOrNull(callback);

            var result = OnCertificateError(m_browser, cert_error, m_request_url, m_ssl_info, m_callback);

            return(result ? 1 : 0);
        }
Beispiel #20
0
        private int on_resource_response(cef_request_handler_t *self, cef_browser_t *browser, cef_frame_t *frame, cef_request_t *request, cef_response_t *response)
        {
            CheckSelf(self);

            var m_browser  = CefBrowser.FromNative(browser);
            var m_frame    = CefFrame.FromNative(frame);
            var m_request  = CefRequest.FromNative(request);
            var m_response = CefResponse.FromNative(response);

            var m_result = OnResourceResponse(m_browser, m_frame, m_request, m_response);

            return(m_result ? 1 : 0);
        }
        private int on_before_browse(cef_request_handler_t *self, cef_browser_t *browser, cef_frame_t *frame, cef_request_t *request, int is_redirect)
        {
            CheckSelf(self);

            var m_browser    = CefBrowser.FromNative(browser);
            var m_frame      = CefFrame.FromNative(frame);
            var m_request    = CefRequest.FromNative(request);
            var m_isRedirect = is_redirect != 0;

            var result = OnBeforeBrowse(m_browser, m_frame, m_request, m_isRedirect);

            return(result ? 1 : 0);
        }
Beispiel #22
0
        /// <summary>
        /// Called on the IO thread when a resource load is redirected. The
        /// |old_url| parameter will contain the old URL. The |new_url| parameter
        /// will contain the new URL and can be changed if desired.
        /// </summary>
        private void on_resource_redirect(cef_request_handler_t *self, cef_browser_t *browser, /*const*/ cef_string_t *old_url, cef_string_t *new_url)
        {
            ThrowIfObjectDisposed();

            var m_browser = CefBrowser.From(browser);

            string oldUrl = "", newUrl = "";

            cef_string_t.Copy(oldUrl, old_url);
            cef_string_t.Copy(newUrl, new_url);

            this.OnResourceRedirect(m_browser, oldUrl, newUrl);
        }
        private int on_before_plugin_load(cef_request_handler_t *self, cef_browser_t *browser, cef_string_t *url, cef_string_t *policy_url, cef_web_plugin_info_t *info)
        {
            CheckSelf(self);

            var m_browser    = CefBrowser.FromNative(browser);
            var m_url        = cef_string_t.ToString(url);
            var m_policy_url = cef_string_t.ToString(policy_url);
            var m_info       = CefWebPluginInfo.FromNative(info);

            var result = OnBeforePluginLoad(m_browser, m_url, m_policy_url, m_info);

            return(result ? 1 : 0);
        }
Beispiel #24
0
        /// <summary>
        /// Called on the UI thread before browser navigation. Return true to
        /// cancel the navigation or false to allow the navigation to proceed.
        /// </summary>
        private int on_before_browse(cef_request_handler_t *self, cef_browser_t *browser, cef_frame_t *frame, cef_request_t *request, cef_handler_navtype_t navType, int isRedirect)
        {
            ThrowIfObjectDisposed();

            var m_browser    = CefBrowser.From(browser);
            var m_frame      = CefFrame.From(frame);
            var m_request    = CefRequest.From(request);
            var m_navType    = (CefHandlerNavType)navType;
            var m_isRedirect = isRedirect != 0;

            var handled = this.OnBeforeBrowse(m_browser, m_frame, m_request, m_navType, m_isRedirect);

            return(handled ? 1 : 0);
        }
        private cef_resource_handler_t *get_resource_handler(cef_request_handler_t *self, cef_browser_t *browser, cef_frame_t *frame, cef_request_t *request)
        {
            CheckSelf(self);

            var m_browser = CefBrowser.FromNative(browser);
            var m_frame   = CefFrame.FromNative(frame);
            var m_request = CefRequest.FromNative(request);

            var handler = GetResourceHandler(m_browser, m_frame, m_request);

            m_request.Dispose();

            return(handler != null?handler.ToNative() : null);
        }
        private int on_before_resource_load(cef_request_handler_t *self, cef_browser_t *browser, cef_frame_t *frame, cef_request_t *request)
        {
            CheckSelf(self);

            var m_browser = CefBrowser.FromNative(browser);
            var m_frame   = CefFrame.FromNative(frame);
            var m_request = CefRequest.FromNative(request);

            var result = OnBeforeResourceLoad(m_browser, m_frame, m_request);

            m_request.Dispose();

            return(result ? 1 : 0);
        }
Beispiel #27
0
        private CefReturnValue on_before_resource_load(cef_request_handler_t *self, cef_browser_t *browser, cef_frame_t *frame, cef_request_t *request, cef_request_callback_t *callback)
        {
            CheckSelf(self);

            var m_browser  = CefBrowser.FromNative(browser);
            var m_frame    = CefFrame.FromNative(frame);
            var m_request  = CefRequest.FromNative(request);
            var m_callback = CefRequestCallback.FromNative(callback);
            var result     = OnBeforeResourceLoad(m_browser, m_frame, m_request, m_callback);

            m_request.Dispose();

            return(result);
        }
Beispiel #28
0
        /// <summary>
        /// Called on the IO thread to handle requests for URLs with an unknown
        /// protocol component. Return true to indicate that the request should
        /// succeed because it was handled externally. Set |allowOSExecution| to
        /// true and return false to attempt execution via the registered OS
        /// protocol handler, if any. If false is returned and either
        /// |allow_os_execution| is false or OS protocol handler execution fails
        /// then the request will fail with an error condition. SECURITY WARNING:
        /// YOU SHOULD USE THIS METHOD TO ENFORCE RESTRICTIONS BASED ON SCHEME,
        /// HOST OR OTHER URL ANALYSIS BEFORE ALLOWING OS EXECUTION.
        /// </summary>
        private int on_protocol_execution(cef_request_handler_t *self, cef_browser_t *browser, /*const*/ cef_string_t *url, int *allowOSExecution)
        {
            ThrowIfObjectDisposed();

            var  m_browser = CefBrowser.From(browser);
            var  m_url     = cef_string_t.ToString(url);
            bool m_allowOSExecution;

            var handled = this.OnProtocolExecution(m_browser, m_url, out m_allowOSExecution);

            *allowOSExecution = m_allowOSExecution ? 1 : 0;

            return(handled ? 1 : 0);
        }
        protected CefRequestHandler()
        {
            _self = cef_request_handler_t.Alloc();

            _ds0 = new cef_request_handler_t.add_ref_delegate(add_ref);
            _self->_base._add_ref = Marshal.GetFunctionPointerForDelegate(_ds0);
            _ds1 = new cef_request_handler_t.release_delegate(release);
            _self->_base._release = Marshal.GetFunctionPointerForDelegate(_ds1);
            _ds2 = new cef_request_handler_t.has_one_ref_delegate(has_one_ref);
            _self->_base._has_one_ref = Marshal.GetFunctionPointerForDelegate(_ds2);
            _ds3 = new cef_request_handler_t.has_at_least_one_ref_delegate(has_at_least_one_ref);
            _self->_base._has_at_least_one_ref = Marshal.GetFunctionPointerForDelegate(_ds3);
            _ds4 = new cef_request_handler_t.on_before_browse_delegate(on_before_browse);
            _self->_on_before_browse = Marshal.GetFunctionPointerForDelegate(_ds4);
            _ds5 = new cef_request_handler_t.on_open_urlfrom_tab_delegate(on_open_urlfrom_tab);
            _self->_on_open_urlfrom_tab = Marshal.GetFunctionPointerForDelegate(_ds5);
            _ds6 = new cef_request_handler_t.on_before_resource_load_delegate(on_before_resource_load);
            _self->_on_before_resource_load = Marshal.GetFunctionPointerForDelegate(_ds6);
            _ds7 = new cef_request_handler_t.get_resource_handler_delegate(get_resource_handler);
            _self->_get_resource_handler = Marshal.GetFunctionPointerForDelegate(_ds7);
            _ds8 = new cef_request_handler_t.on_resource_redirect_delegate(on_resource_redirect);
            _self->_on_resource_redirect = Marshal.GetFunctionPointerForDelegate(_ds8);
            _ds9 = new cef_request_handler_t.on_resource_response_delegate(on_resource_response);
            _self->_on_resource_response = Marshal.GetFunctionPointerForDelegate(_ds9);
            _dsa = new cef_request_handler_t.get_resource_response_filter_delegate(get_resource_response_filter);
            _self->_get_resource_response_filter = Marshal.GetFunctionPointerForDelegate(_dsa);
            _dsb = new cef_request_handler_t.on_resource_load_complete_delegate(on_resource_load_complete);
            _self->_on_resource_load_complete = Marshal.GetFunctionPointerForDelegate(_dsb);
            _dsc = new cef_request_handler_t.get_auth_credentials_delegate(get_auth_credentials);
            _self->_get_auth_credentials = Marshal.GetFunctionPointerForDelegate(_dsc);
            _dsd = new cef_request_handler_t.can_get_cookies_delegate(can_get_cookies);
            _self->_can_get_cookies = Marshal.GetFunctionPointerForDelegate(_dsd);
            _dse = new cef_request_handler_t.can_set_cookie_delegate(can_set_cookie);
            _self->_can_set_cookie = Marshal.GetFunctionPointerForDelegate(_dse);
            _dsf = new cef_request_handler_t.on_quota_request_delegate(on_quota_request);
            _self->_on_quota_request = Marshal.GetFunctionPointerForDelegate(_dsf);
            _ds10 = new cef_request_handler_t.on_protocol_execution_delegate(on_protocol_execution);
            _self->_on_protocol_execution = Marshal.GetFunctionPointerForDelegate(_ds10);
            _ds11 = new cef_request_handler_t.on_certificate_error_delegate(on_certificate_error);
            _self->_on_certificate_error = Marshal.GetFunctionPointerForDelegate(_ds11);
            _ds12 = new cef_request_handler_t.on_select_client_certificate_delegate(on_select_client_certificate);
            _self->_on_select_client_certificate = Marshal.GetFunctionPointerForDelegate(_ds12);
            _ds13 = new cef_request_handler_t.on_plugin_crashed_delegate(on_plugin_crashed);
            _self->_on_plugin_crashed = Marshal.GetFunctionPointerForDelegate(_ds13);
            _ds14 = new cef_request_handler_t.on_render_view_ready_delegate(on_render_view_ready);
            _self->_on_render_view_ready = Marshal.GetFunctionPointerForDelegate(_ds14);
            _ds15 = new cef_request_handler_t.on_render_process_terminated_delegate(on_render_process_terminated);
            _self->_on_render_process_terminated = Marshal.GetFunctionPointerForDelegate(_ds15);
        }
        private int get_auth_credentials(cef_request_handler_t *self, cef_browser_t *browser, cef_frame_t *frame, int isProxy, cef_string_t *host, int port, cef_string_t *realm, cef_string_t *scheme, cef_auth_callback_t *callback)
        {
            CheckSelf(self);

            var m_browser  = CefBrowser.FromNative(browser);
            var m_frame    = CefFrame.FromNative(frame);
            var m_host     = cef_string_t.ToString(host);
            var m_realm    = cef_string_t.ToString(realm);
            var m_scheme   = cef_string_t.ToString(scheme);
            var m_callback = CefAuthCallback.FromNative(callback);

            var result = GetAuthCredentials(m_browser, m_frame, isProxy != 0, m_host, port, m_realm, m_scheme, m_callback);

            return(result ? 1 : 0);
        }
Beispiel #31
0
        public CefRequestHandler()
        {
            cef_request_handler_t *self = this.NativeInstance;

            self->on_before_browse             = (void *)Marshal.GetFunctionPointerForDelegate(fnOnBeforeBrowse);
            self->on_open_urlfrom_tab          = (void *)Marshal.GetFunctionPointerForDelegate(fnOnOpenUrlFromTab);
            self->get_resource_request_handler = (void *)Marshal.GetFunctionPointerForDelegate(fnGetResourceRequestHandler);
            self->get_auth_credentials         = (void *)Marshal.GetFunctionPointerForDelegate(fnGetAuthCredentials);
            self->on_quota_request             = (void *)Marshal.GetFunctionPointerForDelegate(fnOnQuotaRequest);
            self->on_certificate_error         = (void *)Marshal.GetFunctionPointerForDelegate(fnOnCertificateError);
            self->on_select_client_certificate = (void *)Marshal.GetFunctionPointerForDelegate(fnOnSelectClientCertificate);
            self->on_plugin_crashed            = (void *)Marshal.GetFunctionPointerForDelegate(fnOnPluginCrashed);
            self->on_render_view_ready         = (void *)Marshal.GetFunctionPointerForDelegate(fnOnRenderViewReady);
            self->on_render_process_terminated = (void *)Marshal.GetFunctionPointerForDelegate(fnOnRenderProcessTerminated);
        }
Beispiel #32
0
        /// <summary>
        /// Called on the UI thread after a response to the resource request is
        /// received. Set |filter| if response content needs to be monitored
        /// and/or modified as it arrives.
        /// </summary>
        private void on_resource_response(cef_request_handler_t *self, cef_browser_t *browser, /*const*/ cef_string_t *url, cef_response_t *response, cef_content_filter_t **filter)
        {
            ThrowIfObjectDisposed();

            var m_browser  = CefBrowser.From(browser);
            var m_url      = cef_string_t.ToString(url);
            var m_response = CefResponse.From(response);
            CefContentFilter m_filter;

            this.OnResourceResponse(m_browser, m_url, m_response, out m_filter);

            if (m_filter != null)
            {
                *filter = m_filter.GetNativePointerAndAddRef();
            }
        }