Skip to content

Commit

Permalink
Update to WebView2 NuGet 1.0.1245.22
Browse files Browse the repository at this point in the history
  • Loading branch information
salvadordf committed Jun 18, 2022
1 parent f212eb6 commit 82e47cc
Show file tree
Hide file tree
Showing 35 changed files with 1,267 additions and 300 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ WebView4Delphi is an open source project created by Salvador Díaz Fau to embed

WebView4Delphi only supports Windows. If you need to embed a web browser in Linux, Windows or MacOS consider using [CEF4Delphi](https://github.com/salvadordf/CEF4Delphi) instead.

WebView4Delphi uses the [Microsoft Edge WebView2 Runtime](https://docs.microsoft.com/en-us/microsoft-edge/webview2/) and [Microsoft.Web.WebView2 NuGet package version 1.0.1210.39](https://www.nuget.org/packages/Microsoft.Web.WebView2) to embed a web browser.
WebView4Delphi uses the [Microsoft Edge WebView2 Runtime](https://docs.microsoft.com/en-us/microsoft-edge/webview2/) and [Microsoft.Web.WebView2 NuGet package version 1.0.1245.22](https://www.nuget.org/packages/Microsoft.Web.WebView2) to embed a web browser.

WebView4Delphi was developed and tested on Delphi 11.1, Delphi XE2 and Lazarus 2.2.0/FPC 3.2.2.
WebView4Delphi was developed and tested on Delphi 11.1, Delphi XE2 and Lazarus 2.2.2/FPC 3.2.2.

WebView4Delphi includes VCL, FireMonkey (FMX) and Lazarus components.

Expand Down
Binary file modified bin32/WebView2Loader.dll
Binary file not shown.
Binary file modified bin64/WebView2Loader.dll
Binary file not shown.
2 changes: 1 addition & 1 deletion demos/Delphi_VCL/MiniBrowser/MiniBrowser.dproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<MainSource>MiniBrowser.dpr</MainSource>
<Base>True</Base>
<Config Condition="'$(Config)'==''">Debug</Config>
<Platform Condition="'$(Platform)'==''">Win32</Platform>
<Platform Condition="'$(Platform)'==''">Win64</Platform>
<TargetedPlatforms>3</TargetedPlatforms>
<AppType>Application</AppType>
</PropertyGroup>
Expand Down
7 changes: 6 additions & 1 deletion demos/Delphi_VCL/MiniBrowser/uMiniBrowser.dfm
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ object MiniBrowserFrm: TMiniBrowserFrm
'https://frames-per-second.appspot.com/'
'https://badssl.com/'
'https://www.httpwatch.com/httpgallery/authentication/'

'https://www.sede.fnmt.gob.es/certificados/persona-fisica/verific' +
'ar-estado'
'https://badssl.com/'
'edge://flags/'
'edge://gpu/'
'edge://about/')
Expand Down Expand Up @@ -238,9 +242,10 @@ object MiniBrowserFrm: TMiniBrowserFrm
OnRetrieveHTMLCompleted = WVBrowser1RetrieveHTMLCompleted
OnRetrieveTextCompleted = WVBrowser1RetrieveTextCompleted
OnRetrieveMHTMLCompleted = WVBrowser1RetrieveMHTMLCompleted
OnClearDataForOriginCompleted = WVBrowser1ClearDataForOriginCompleted
OnBasicAuthenticationRequested = WVBrowser1BasicAuthenticationRequested
OnStatusBarTextChanged = WVBrowser1StatusBarTextChanged
OnClearBrowsingDataCompleted = WVBrowser1ClearBrowsingDataCompleted
OnServerCertificateErrorDetected = WVBrowser1ServerCertificateErrorDetected
Left = 48
Top = 64
end
Expand Down
44 changes: 38 additions & 6 deletions demos/Delphi_VCL/MiniBrowser/uMiniBrowser.pas
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,13 @@ TMiniBrowserFrm = class(TForm)
procedure WVBrowser1RetrieveMHTMLCompleted(Sender: TObject; aResult: Boolean; const aMHTML: wvstring);
procedure WVBrowser1BasicAuthenticationRequested(Sender: TObject; const aWebView: ICoreWebView2; const aArgs: ICoreWebView2BasicAuthenticationRequestedEventArgs);
procedure WVBrowser1StatusBarTextChanged(Sender: TObject; const aWebView: ICoreWebView2);
procedure WVBrowser1ClearDataForOriginCompleted(Sender: TObject; aResult: Boolean);
procedure WVBrowser1WebResourceResponseViewGetContentCompleted(Sender: TObject; aErrorCode: HRESULT; const aContents: IStream; aResourceID: Integer);
procedure Saveresourceas1Click(Sender: TObject);
procedure WVBrowser1ClearBrowsingDataCompleted(Sender: TObject;
aErrorCode: HRESULT);
procedure WVBrowser1ServerCertificateErrorDetected(Sender: TObject;
const aWebView: ICoreWebView2;
const aArgs: ICoreWebView2ServerCertificateErrorDetectedEventArgs);

protected
FDownloadOperation : TCoreWebView2DownloadOperation;
Expand Down Expand Up @@ -278,7 +282,7 @@ procedure TMiniBrowserFrm.Clearcache1Click(Sender: TObject);

procedure TMiniBrowserFrm.Cleatallstorage1Click(Sender: TObject);
begin
WVBrowser1.ClearDataForOrigin('*');
WVBrowser1.ClearBrowsingDataAll;
end;

procedure TMiniBrowserFrm.ConfigBtnClick(Sender: TObject);
Expand Down Expand Up @@ -457,6 +461,9 @@ procedure TMiniBrowserFrm.WVBrowser1AfterCreated(Sender: TObject);
// We need to a filter to enable the TWVBrowser.OnWebResourceRequested event
WVBrowser1.AddWebResourceRequestedFilter('*', COREWEBVIEW2_WEB_RESOURCE_CONTEXT_IMAGE);
WVBrowser1.AddWebResourceRequestedFilter('*', COREWEBVIEW2_WEB_RESOURCE_CONTEXT_MEDIA);

WVBrowser1.CoreWebView2PrintSettings.HeaderTitle := 'Tituloooooo';
WVBrowser1.CoreWebView2PrintSettings.ShouldPrintHeaderAndFooter := True;
end;

procedure TMiniBrowserFrm.WVBrowser1BasicAuthenticationRequested(
Expand Down Expand Up @@ -485,10 +492,10 @@ procedure TMiniBrowserFrm.WVBrowser1CapturePreviewCompleted(
FreeAndNil(FFileStream);
end;

procedure TMiniBrowserFrm.WVBrowser1ClearDataForOriginCompleted(
Sender: TObject; aResult: Boolean);
procedure TMiniBrowserFrm.WVBrowser1ClearBrowsingDataCompleted(
Sender: TObject; aErrorCode: HRESULT);
begin
if aResult then
if succeeded(aErrorCode) then
showmessage('Browser data cleared successfully!')
else
showmessage('There was an error clearing the browser data');
Expand Down Expand Up @@ -579,9 +586,15 @@ procedure TMiniBrowserFrm.WVBrowser1InitializationError(Sender: TObject;
end;

procedure TMiniBrowserFrm.WVBrowser1NavigationCompleted(Sender: TObject; const aWebView: ICoreWebView2; const aArgs: ICoreWebView2NavigationCompletedEventArgs);
var
TempArgs : TCoreWebView2NavigationCompletedEventArgs;
TempStatus : integer;
begin
TempArgs := TCoreWebView2NavigationCompletedEventArgs.Create(aArgs);
TempStatus := TempArgs.HttpStatusCode;
TempArgs.Free;
UpdateNavButtons(False);
StatusBar1.Panels[0].Text := 'Navigation completed.';
StatusBar1.Panels[0].Text := 'Navigation completed. HTTP Status code: ' + inttostr(TempStatus);
end;

procedure TMiniBrowserFrm.WVBrowser1NavigationStarting(Sender: TObject; const aWebView: ICoreWebView2; const aArgs: ICoreWebView2NavigationStartingEventArgs);
Expand Down Expand Up @@ -679,6 +692,20 @@ procedure TMiniBrowserFrm.WVBrowser1RetrieveTextCompleted(Sender: TObject;
SaveAsTextFile(SaveDialog1.FileName, aText);
end;

procedure TMiniBrowserFrm.WVBrowser1ServerCertificateErrorDetected(
Sender: TObject; const aWebView: ICoreWebView2;
const aArgs: ICoreWebView2ServerCertificateErrorDetectedEventArgs);
var
TempArgs : TCoreWebView2ServerCertificateErrorDetectedEventArgs;
begin
StatusBar1.Panels[0].Text := 'Server certificate error detected';

// This will override the safety warning and allow the bad server certificate
TempArgs := TCoreWebView2ServerCertificateErrorDetectedEventArgs.Create(aArgs);
TempArgs.Action := COREWEBVIEW2_SERVER_CERTIFICATE_ERROR_ACTION_ALWAYS_ALLOW;
TempArgs.Free;
end;

procedure TMiniBrowserFrm.WVBrowser1SourceChanged(Sender: TObject; const aWebView: ICoreWebView2; const aArgs: ICoreWebView2SourceChangedEventArgs);
begin
URLCbx.Text := WVBrowser1.Source;
Expand Down Expand Up @@ -847,9 +874,14 @@ procedure TMiniBrowserFrm.ShowUserAuthMsg(var aMessage : TMessage);
initialization
GlobalWebView2Loader := TWVLoader.Create(nil);
GlobalWebView2Loader.UserDataFolder := ExtractFileDir(Application.ExeName) + '\CustomCache';

// Set GlobalWebView2Loader.BrowserExecPath if you don't want to use the evergreen version of WebView Runtime
//GlobalWebView2Loader.BrowserExecPath := 'c:\WVRuntime';

// Uncomment these lines to enable the debug log in 'CustomCache\EBWebView\chrome_debug.log'
//GlobalWebView2Loader.DebugLog := TWV2DebugLog.dlEnabled;
//GlobalWebView2Loader.DebugLogLevel := TWV2DebugLogLevel.dllInfo;

GlobalWebView2Loader.StartWebView2;

end.
3 changes: 3 additions & 0 deletions demos/Lazarus/MiniBrowser/MiniBrowser.lpi
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@
</SyntaxOptions>
</Parsing>
<Linking>
<Debugging>
<DebugInfoType Value="dsDwarf2Set"/>
</Debugging>
<Options>
<Win32>
<GraphicApplication Value="True"/>
Expand Down
Loading

0 comments on commit 82e47cc

Please sign in to comment.