2017-01-27 16:37:51 +01:00
|
|
|
unit uCEFUrlRequest;
|
|
|
|
|
2018-05-12 14:50:54 +02:00
|
|
|
{$IFDEF FPC}
|
|
|
|
{$MODE OBJFPC}{$H+}
|
|
|
|
{$ENDIF}
|
|
|
|
|
2017-02-05 20:56:46 +01:00
|
|
|
{$I cef.inc}
|
|
|
|
|
2022-02-19 18:56:41 +01:00
|
|
|
{$IFNDEF TARGET_64BITS}{$ALIGN ON}{$ENDIF}
|
|
|
|
{$MINENUMSIZE 4}
|
|
|
|
|
2017-01-27 16:37:51 +01:00
|
|
|
interface
|
|
|
|
|
|
|
|
uses
|
2017-03-16 19:09:42 +01:00
|
|
|
uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes;
|
2017-01-27 16:37:51 +01:00
|
|
|
|
|
|
|
type
|
2017-03-16 19:09:42 +01:00
|
|
|
TCefUrlRequestRef = class(TCefBaseRefCountedRef, ICefUrlRequest)
|
2017-01-27 16:37:51 +01:00
|
|
|
protected
|
2018-03-29 20:02:04 +02:00
|
|
|
function GetRequest: ICefRequest;
|
2023-08-07 20:21:42 +02:00
|
|
|
function GetClient: ICefUrlrequestClient;
|
2018-03-29 20:02:04 +02:00
|
|
|
function GetRequestStatus: TCefUrlRequestStatus;
|
|
|
|
function GetRequestError: Integer;
|
|
|
|
function GetResponse: ICefResponse;
|
|
|
|
function GetResponseWasCached: boolean;
|
2017-01-27 16:37:51 +01:00
|
|
|
procedure Cancel;
|
2018-03-29 20:02:04 +02:00
|
|
|
|
2017-01-27 16:37:51 +01:00
|
|
|
public
|
|
|
|
class function UnWrap(data: Pointer): ICefUrlRequest;
|
2018-03-29 20:02:04 +02:00
|
|
|
class function New(const request: ICefRequest; const client: ICefUrlRequestClient; const requestContext: ICefRequestContext): ICefUrlRequest;
|
2017-01-27 16:37:51 +01:00
|
|
|
end;
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
|
|
|
uses
|
2023-08-07 20:21:42 +02:00
|
|
|
uCEFMiscFunctions, uCEFLibFunctions, uCEFRequest, uCEFResponse, uCEFUrlrequestClient;
|
2017-01-27 16:37:51 +01:00
|
|
|
|
|
|
|
procedure TCefUrlRequestRef.Cancel;
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
PCefUrlRequest(FData)^.cancel(PCefUrlRequest(FData));
|
2017-01-27 16:37:51 +01:00
|
|
|
end;
|
|
|
|
|
2018-03-29 20:02:04 +02:00
|
|
|
class function TCefUrlRequestRef.New(const request : ICefRequest;
|
|
|
|
const client : ICefUrlRequestClient;
|
|
|
|
const requestContext : ICefRequestContext): ICefUrlRequest;
|
2017-01-27 16:37:51 +01:00
|
|
|
begin
|
|
|
|
Result := UnWrap(cef_urlrequest_create(CefGetData(request), CefGetData(client), CefGetData(requestContext)));
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefUrlRequestRef.GetRequest: ICefRequest;
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := TCefRequestRef.UnWrap(PCefUrlRequest(FData)^.get_request(PCefUrlRequest(FData)));
|
2017-01-27 16:37:51 +01:00
|
|
|
end;
|
|
|
|
|
2023-08-07 20:21:42 +02:00
|
|
|
function TCefUrlRequestRef.GetClient: ICefUrlrequestClient;
|
|
|
|
begin
|
|
|
|
Result := TCefUrlrequestClientRef.UnWrap(PCefUrlRequest(FData)^.get_client(PCefUrlRequest(FData)));
|
|
|
|
end;
|
|
|
|
|
2017-01-27 16:37:51 +01:00
|
|
|
function TCefUrlRequestRef.GetRequestError: Integer;
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := PCefUrlRequest(FData)^.get_request_error(PCefUrlRequest(FData));
|
2017-01-27 16:37:51 +01:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefUrlRequestRef.GetRequestStatus: TCefUrlRequestStatus;
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := PCefUrlRequest(FData)^.get_request_status(PCefUrlRequest(FData));
|
2017-01-27 16:37:51 +01:00
|
|
|
end;
|
|
|
|
|
2018-01-05 11:59:25 +01:00
|
|
|
function TCefUrlRequestRef.GetResponseWasCached: boolean;
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := PCefUrlRequest(FData)^.response_was_cached(PCefUrlRequest(FData)) <> 0;
|
2018-01-05 11:59:25 +01:00
|
|
|
end;
|
|
|
|
|
2017-01-27 16:37:51 +01:00
|
|
|
function TCefUrlRequestRef.GetResponse: ICefResponse;
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := TCefResponseRef.UnWrap(PCefUrlRequest(FData)^.get_response(PCefUrlRequest(FData)));
|
2017-01-27 16:37:51 +01:00
|
|
|
end;
|
|
|
|
|
|
|
|
class function TCefUrlRequestRef.UnWrap(data: Pointer): ICefUrlRequest;
|
|
|
|
begin
|
2018-01-05 11:59:25 +01:00
|
|
|
if (data <> nil) then
|
|
|
|
Result := Create(data) as ICefUrlRequest
|
|
|
|
else
|
2017-01-27 16:37:51 +01:00
|
|
|
Result := nil;
|
|
|
|
end;
|
|
|
|
|
|
|
|
end.
|