/// <summary> /// Creates the underlying CfxBrowser with the given CfxRequestContext. /// This method should only be called if this ChromiumWebBrowser /// was instanciated with createImmediately == false. /// </summary> public void CreateBrowser(CfxRequestContext requestContext) { // avoid illegal cross-thread calls if (InvokeRequired) { Invoke((MethodInvoker)(() => CreateBrowser(requestContext))); return; } var windowInfo = new CfxWindowInfo(); windowInfo.SetAsChild(Handle, 0, 0, Height > 0 ? Height : 500, Width > 0 ? Width : 500); if (!CfxBrowserHost.CreateBrowser(windowInfo, client, initialUrl, HtmlUILauncher.DefaultBrowserSettings, requestContext)) throw new HtmlUIException("Failed to create browser instance."); }
internal static CfxRequestContext Wrap(IntPtr nativePtr) { if(nativePtr == IntPtr.Zero) return null; lock(weakCache) { var wrapper = (CfxRequestContext)weakCache.Get(nativePtr); if(wrapper == null) { wrapper = new CfxRequestContext(nativePtr); weakCache.Add(wrapper); } else { CfxApi.cfx_release(nativePtr); } return wrapper; } }
/// <summary> /// Creates the underlying CfxBrowser with the given /// CfxRequestContext and initial URL. /// This method should only be called if this ChromiumWebBrowser /// was instanciated with createImmediately == false. /// </summary> public void CreateBrowser(string initialUrl, CfxRequestContext requestContext) { this.initialUrl = initialUrl; CreateBrowser(requestContext); }
/// <summary> /// Returns true (1) if this object is pointing to the same context as |that| /// object. /// </summary> /// <remarks> /// See also the original CEF documentation in /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_request_context_capi.h">cef/include/capi/cef_request_context_capi.h</see>. /// </remarks> public bool IsSame(CfxRequestContext other) { return 0 != CfxApi.cfx_request_context_is_same(NativePtr, CfxRequestContext.Unwrap(other)); }
/// <summary> /// Returns true (1) if this object is sharing the same storage as |that| /// object. /// </summary> /// <remarks> /// See also the original CEF documentation in /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_request_context_capi.h">cef/include/capi/cef_request_context_capi.h</see>. /// </remarks> public bool IsSharingWith(CfxRequestContext other) { return 0 != CfxApi.cfx_request_context_is_sharing_with(NativePtr, CfxRequestContext.Unwrap(other)); }
/// <summary> /// Create a new URL request. Only GET, POST, HEAD, DELETE and PUT request /// functions are supported. Multiple post data elements are not supported and /// elements of type PDE_TYPE_FILE are only supported for requests originating /// from the browser process. Requests originating from the render process will /// receive the same handling as requests originating from Web content -- if the /// response contains Content-Disposition or Mime-Type header values that would /// not normally be rendered then the response may receive special handling /// inside the browser (for example, via the file download code path instead of /// the URL request code path). The |request| object will be marked as read-only /// after calling this function. In the browser process if |requestContext| is /// NULL the global request context will be used. In the render process /// |requestContext| must be NULL and the context associated with the current /// renderer process' browser will be used. /// </summary> /// <remarks> /// See also the original CEF documentation in /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_urlrequest_capi.h">cef/include/capi/cef_urlrequest_capi.h</see>. /// </remarks> public static CfxUrlRequest Create(CfxRequest request, CfxUrlRequestClient client, CfxRequestContext requestContext) { return(CfxUrlRequest.Wrap(CfxApi.UrlRequest.cfx_urlrequest_create(CfxRequest.Unwrap(request), CfxUrlRequestClient.Unwrap(client), CfxRequestContext.Unwrap(requestContext)))); }
/// <summary> /// Create a new browser window using the window parameters specified by /// |windowInfo|. If |requestContext| is NULL the global request context will be /// used. This function can only be called on the browser process UI thread. /// </summary> /// <remarks> /// See also the original CEF documentation in /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_browser_capi.h">cef/include/capi/cef_browser_capi.h</see>. /// </remarks> public static CfxBrowser CreateBrowserSync(CfxWindowInfo windowInfo, CfxClient client, string url, CfxBrowserSettings settings, CfxRequestContext requestContext) { var url_pinned = new PinnedString(url); var __retval = CfxApi.cfx_browser_host_create_browser_sync(CfxWindowInfo.Unwrap(windowInfo), CfxClient.Unwrap(client), url_pinned.Obj.PinnedPtr, url_pinned.Length, CfxBrowserSettings.Unwrap(settings), CfxRequestContext.Unwrap(requestContext)); url_pinned.Obj.Free(); return CfxBrowser.Wrap(__retval); }
/// <summary> /// Create a new browser window using the window parameters specified by /// |windowInfo|. All values will be copied internally and the actual window will /// be created on the UI thread. If |requestContext| is NULL the global request /// context will be used. This function can be called on any browser process /// thread and will not block. /// </summary> /// <remarks> /// See also the original CEF documentation in /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_browser_capi.h">cef/include/capi/cef_browser_capi.h</see>. /// </remarks> public static bool CreateBrowser(CfxWindowInfo windowInfo, CfxClient client, string url, CfxBrowserSettings settings, CfxRequestContext requestContext) { var url_pinned = new PinnedString(url); var __retval = CfxApi.cfx_browser_host_create_browser(CfxWindowInfo.Unwrap(windowInfo), CfxClient.Unwrap(client), url_pinned.Obj.PinnedPtr, url_pinned.Length, CfxBrowserSettings.Unwrap(settings), CfxRequestContext.Unwrap(requestContext)); url_pinned.Obj.Free(); return(0 != __retval); }
/// <summary> /// Returns the global context object. /// </summary> /// <remarks> /// See also the original CEF documentation in /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_request_context_capi.h">cef/include/capi/cef_request_context_capi.h</see>. /// </remarks> public static CfxRequestContext GetGlobalContext() { return(CfxRequestContext.Wrap(CfxApi.cfx_request_context_get_global_context())); }
/// <summary> /// Returns true (1) if this object is sharing the same storage as |that| /// object. /// </summary> /// <remarks> /// See also the original CEF documentation in /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_request_context_capi.h">cef/include/capi/cef_request_context_capi.h</see>. /// </remarks> public bool IsSharingWith(CfxRequestContext other) { return(0 != CfxApi.cfx_request_context_is_sharing_with(NativePtr, CfxRequestContext.Unwrap(other))); }
/// <summary> /// Returns true (1) if this object is pointing to the same context as |that| /// object. /// </summary> /// <remarks> /// See also the original CEF documentation in /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_request_context_capi.h">cef/include/capi/cef_request_context_capi.h</see>. /// </remarks> public bool IsSame(CfxRequestContext other) { return(0 != CfxApi.cfx_request_context_is_same(NativePtr, CfxRequestContext.Unwrap(other))); }
/// <summary> /// Creates a new context object with the specified |settings| and optional /// |handler|. /// </summary> /// <remarks> /// See also the original CEF documentation in /// <see href="https://bitbucket.org/chromiumfx/chromiumfx/src/tip/cef/include/capi/cef_request_context_capi.h">cef/include/capi/cef_request_context_capi.h</see>. /// </remarks> public static CfxRequestContext CreateContext(CfxRequestContextSettings settings, CfxRequestContextHandler handler) { return(CfxRequestContext.Wrap(CfxApi.cfx_request_context_create_context(CfxRequestContextSettings.Unwrap(settings), CfxRequestContextHandler.Unwrap(handler)))); }