Skip to content

Commit 5297f81

Browse files
Update projects to use latest WebView2 SDK 1.0.1369-prerelease (#149)
* Updates for Win32, WPF and WinForms sample apps from 106.0.1369.0 * Updated package version for Win32, WPF and WinForms sample apps to 1.0.1369-prerelease * add missing AppStartPage assets and entries Co-authored-by: WebView2 Github Bot <[email protected]>
1 parent 3a1973f commit 5297f81

17 files changed

+504
-60
lines changed

SampleApps/WebView2APISample/AppWindow.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -900,6 +900,30 @@ void AppWindow::InitializeWebView()
900900
if (!m_language.empty())
901901
CHECK_FAILURE(options->put_Language(m_language.c_str()));
902902

903+
//! [CoreWebView2CustomSchemeRegistration]
904+
Microsoft::WRL::ComPtr<ICoreWebView2ExperimentalEnvironmentOptions> optionsExperimental;
905+
if (options.As(&optionsExperimental) == S_OK)
906+
{
907+
const WCHAR* allowedOrigins[1] = {L"https://*.example.com"};
908+
909+
auto customSchemeRegistration =
910+
Microsoft::WRL::Make<CoreWebView2CustomSchemeRegistration>(L"custom-scheme");
911+
customSchemeRegistration->SetAllowedOrigins(1, allowedOrigins);
912+
auto customSchemeRegistration2 =
913+
Microsoft::WRL::Make<CoreWebView2CustomSchemeRegistration>(L"wv2rocks");
914+
customSchemeRegistration2->put_TreatAsSecure(TRUE);
915+
customSchemeRegistration2->SetAllowedOrigins(1, allowedOrigins);
916+
auto customSchemeRegistration3 =
917+
Microsoft::WRL::Make<CoreWebView2CustomSchemeRegistration>(
918+
L"custom-scheme-not-in-allowed-origins");
919+
ICoreWebView2ExperimentalCustomSchemeRegistration* registrations[3] = {
920+
customSchemeRegistration.Get(), customSchemeRegistration2.Get(),
921+
customSchemeRegistration3.Get()};
922+
optionsExperimental->SetCustomSchemeRegistrations(
923+
2, static_cast<ICoreWebView2ExperimentalCustomSchemeRegistration**>(registrations));
924+
}
925+
//! [CoreWebView2CustomSchemeRegistration]
926+
903927
HRESULT hr = CreateCoreWebView2EnvironmentWithOptions(
904928
subFolder, m_userDataFolder.c_str(), options.Get(),
905929
Callback<ICoreWebView2CreateCoreWebView2EnvironmentCompletedHandler>(

SampleApps/WebView2APISample/DropTarget.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ DropTarget::~DropTarget()
1717

1818
void DropTarget::Init(
1919
HWND window, ViewComponent* viewComponent,
20-
ICoreWebView2ExperimentalCompositionController3* webViewExperimentalCompositionController3)
20+
ICoreWebView2CompositionController3* webViewCompositionController3)
2121
{
22-
m_webViewExperimentalCompositionController3 = webViewExperimentalCompositionController3;
22+
m_webViewCompositionController3 = webViewCompositionController3;
2323
m_viewComponent = viewComponent;
2424
m_window = window;
2525
::RegisterDragDrop(m_window, this);
@@ -32,8 +32,7 @@ HRESULT DropTarget::DragEnter(
3232
POINT point = {cursorPosition.x, cursorPosition.y};
3333
// Convert the screen point to client coordinates add the WebView's offset.
3434
m_viewComponent->OffsetPointToWebView(&point);
35-
return m_webViewExperimentalCompositionController3->DragEnter(
36-
dataObject, keyState, point, effect);
35+
return m_webViewCompositionController3->DragEnter(dataObject, keyState, point, effect);
3736
}
3837
//! [DragEnter]
3938

@@ -44,15 +43,14 @@ HRESULT DropTarget::DragOver(DWORD keyState, POINTL cursorPosition, DWORD* effec
4443
// Convert the screen point to client coordinates add the WebView's offset.
4544
// This returns whether the resultant point is over the WebView visual.
4645
m_viewComponent->OffsetPointToWebView(&point);
47-
return m_webViewExperimentalCompositionController3->DragOver(
48-
keyState, point, effect);
46+
return m_webViewCompositionController3->DragOver(keyState, point, effect);
4947
}
5048
//! [DragOver]
5149

5250
//! [DragLeave]
5351
HRESULT DropTarget::DragLeave()
5452
{
55-
return m_webViewExperimentalCompositionController3->DragLeave();
53+
return m_webViewCompositionController3->DragLeave();
5654
}
5755
//! [DragLeave]
5856

@@ -64,6 +62,6 @@ HRESULT DropTarget::Drop(
6462
// Convert the screen point to client coordinates add the WebView's offset.
6563
// This returns whether the resultant point is over the WebView visual.
6664
m_viewComponent->OffsetPointToWebView(&point);
67-
return m_webViewExperimentalCompositionController3->Drop(dataObject, keyState, point, effect);
65+
return m_webViewCompositionController3->Drop(dataObject, keyState, point, effect);
6866
}
6967
//! [Drop]

SampleApps/WebView2APISample/DropTarget.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class DropTarget : public Microsoft::WRL::RuntimeClass<
1919
// Initialize the drop target by associating it with the given HWND.
2020
void Init(
2121
HWND window, ViewComponent* viewComponent,
22-
ICoreWebView2ExperimentalCompositionController3* webViewExperimentalCompositionController3);
22+
ICoreWebView2CompositionController3* webViewCompositionController3);
2323

2424
// IDropTarget implementation:
2525
HRESULT __stdcall DragEnter(IDataObject* dataObject,
@@ -45,6 +45,5 @@ class DropTarget : public Microsoft::WRL::RuntimeClass<
4545
// mouse events that are sent to the renderer notifying various drag states.
4646
HWND m_window;
4747

48-
wil::com_ptr<ICoreWebView2ExperimentalCompositionController3>
49-
m_webViewExperimentalCompositionController3;
48+
wil::com_ptr<ICoreWebView2CompositionController3> m_webViewCompositionController3;
5049
};

SampleApps/WebView2APISample/ScriptComponent.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
#include <sstream>
99
#include <string>
1010

11+
#include <commdlg.h>
12+
#include <sstream>
13+
1114
#include "ProcessComponent.h"
1215
#include "ScriptComponent.h"
1316

SampleApps/WebView2APISample/ViewComponent.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,8 @@ ViewComponent::ViewComponent(
207207
&m_cursorChangedToken));
208208
//! [CursorChanged]
209209

210-
wil::com_ptr<ICoreWebView2ExperimentalCompositionController3> compositionController3 =
211-
m_controller.query<ICoreWebView2ExperimentalCompositionController3>();
210+
wil::com_ptr<ICoreWebView2CompositionController3> compositionController3 =
211+
m_controller.query<ICoreWebView2CompositionController3>();
212212
m_dropTarget = Make<DropTarget>();
213213
m_dropTarget->Init(
214214
m_appWindow->GetMainWindow(), this, compositionController3.get());

SampleApps/WebView2APISample/WebView2APISample.rc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,10 +300,10 @@ CAPTION "Input"
300300
FONT 8, "MS Shell Dlg", 400, 0, 0x1
301301
BEGIN
302302
GROUPBOX "Static",IDC_STATIC_LABEL,7,7,295,121
303-
EDITTEXT IDC_EDIT_INPUT,14,55,281,69,ES_MULTILINE | ES_AUTOHSCROLL
303+
EDITTEXT IDC_EDIT_INPUT,14,55,281,69,ES_MULTILINE | ES_AUTOHSCROLL
304304
DEFPUSHBUTTON "OK",IDOK,198,130,50,14
305305
PUSHBUTTON "Cancel",IDCANCEL,252,130,50,14
306-
EDITTEXT IDC_EDIT_DESCRIPTION,14,18,281,33,ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY
306+
EDITTEXT IDC_EDIT_DESCRIPTION,14,18,281,33,ES_MULTILINE | ES_AUTOHSCROLL | ES_READONLY | ES_AUTOVSCROLL | WS_VSCROLL
307307
END
308308

309309
IDD_CERTIFICATE_DIALOG DIALOGEX 0, 0, 375, 175

SampleApps/WebView2APISample/WebView2APISample.vcxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -555,13 +555,13 @@
555555
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
556556
<ImportGroup Label="ExtensionTargets">
557557
<Import Project="..\packages\Microsoft.Windows.ImplementationLibrary.1.0.191107.2\build\native\Microsoft.Windows.ImplementationLibrary.targets" Condition="Exists('..\packages\Microsoft.Windows.ImplementationLibrary.1.0.191107.2\build\native\Microsoft.Windows.ImplementationLibrary.targets')" />
558-
<Import Project="..\packages\Microsoft.Web.WebView2.1.0.1340-prerelease\build\native\Microsoft.Web.WebView2.targets" Condition="Exists('..\packages\Microsoft.Web.WebView2.1.0.1340-prerelease\build\native\Microsoft.Web.WebView2.targets')" />
558+
<Import Project="..\packages\Microsoft.Web.WebView2.1.0.1369-prerelease\build\native\Microsoft.Web.WebView2.targets" Condition="Exists('..\packages\Microsoft.Web.WebView2.1.0.1369-prerelease\build\native\Microsoft.Web.WebView2.targets')" />
559559
</ImportGroup>
560560
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
561561
<PropertyGroup>
562562
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
563563
</PropertyGroup>
564564
<Error Condition="!Exists('..\packages\Microsoft.Windows.ImplementationLibrary.1.0.191107.2\build\native\Microsoft.Windows.ImplementationLibrary.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Windows.ImplementationLibrary.1.0.191107.2\build\native\Microsoft.Windows.ImplementationLibrary.targets'))" />
565-
<Error Condition="!Exists('..\packages\Microsoft.Web.WebView2.1.0.1340-prerelease\build\native\Microsoft.Web.WebView2.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Web.WebView2.1.0.1340-prerelease\build\native\Microsoft.Web.WebView2.targets'))" />
565+
<Error Condition="!Exists('..\packages\Microsoft.Web.WebView2.1.0.1369-prerelease\build\native\Microsoft.Web.WebView2.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Web.WebView2.1.0.1369-prerelease\build\native\Microsoft.Web.WebView2.targets'))" />
566566
</Target>
567567
</Project>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
3-
<package id="Microsoft.Web.WebView2" version="1.0.1340-prerelease" targetFramework="native" />
3+
<package id="Microsoft.Web.WebView2" version="1.0.1369-prerelease" targetFramework="native" />
44
<package id="Microsoft.Windows.ImplementationLibrary" version="1.0.191107.2" targetFramework="native" />
55
</packages>

SampleApps/WebView2WindowsFormsBrowser/WebView2WindowsFormsBrowser.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<PlatformTarget>AnyCPU</PlatformTarget>
2020
</PropertyGroup>
2121
<ItemGroup>
22-
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.1340-prerelease" />
22+
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.1369-prerelease" />
2323
</ItemGroup>
2424
<ItemGroup>
2525
<None Update="assets\EdgeWebView2-80.jpg">
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<Window x:Class="WebView2WpfBrowser.Extensions"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
5+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
6+
xmlns:local="clr-namespace:WebView2WpfBrowser"
7+
mc:Ignorable="d"
8+
Title="Extensions" Height="450" Width="800">
9+
<Grid>
10+
<Grid.ColumnDefinitions>
11+
<ColumnDefinition Width="*"/>
12+
<ColumnDefinition Width="Auto"/>
13+
<ColumnDefinition Width="Auto"/>
14+
<ColumnDefinition Width="Auto"/>
15+
</Grid.ColumnDefinitions>
16+
<Grid.RowDefinitions>
17+
<RowDefinition Height="Auto"/>
18+
<RowDefinition Height="*"/>
19+
<RowDefinition Height="Auto"/>
20+
</Grid.RowDefinitions>
21+
<TextBlock Text="Extensions" Grid.Column="0" Grid.ColumnSpan="4" Grid.Row="0" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"/>
22+
<ListView x:Name="ExtensionsList" Grid.ColumnSpan="4" Grid.Row="1" Grid.Column="0" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"></ListView>
23+
<Button Click="ExtensionsToggleEnabled" Grid.Column="1" Grid.Row="2" Width="80">Disable</Button>
24+
<Button Click="ExtensionsAdd" Grid.Column="2" Grid.Row="2" Width="80">Add</Button>
25+
<Button Click="ExtensionsRemove" Grid.Column="3" Grid.Row="2" Width="80">Remove</Button>
26+
</Grid>
27+
</Window>

0 commit comments

Comments
 (0)