Skip to content

Commit bd07ad2

Browse files
authored
Merge pull request #234 from MicrosoftEdge/smoketest/1.0.2357-testing
Update projects to use latest WebView2 SDK 1.0.2357-prerelease
2 parents c7c43e5 + f03e5ff commit bd07ad2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+935
-150
lines changed

SampleApps/WebView2APISample/AppWindow.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
#include "ScenarioExtensionsManagement.h"
4040
#include "ScenarioIFrameDevicePermission.h"
4141
#include "ScenarioNavigateWithWebResourceRequest.h"
42+
#include "ScenarioNonClientRegionSupport.h"
43+
#include "ScenarioAcceleratorKeyPressed.h"
4244
#include "ScenarioNotificationReceived.h"
4345
#include "ScenarioPermissionManagement.h"
4446
#include "ScenarioSharedBuffer.h"
@@ -182,9 +184,9 @@ AppWindow::AppWindow(
182184
UINT creationModeId, const WebViewCreateOption& opt, const std::wstring& initialUri,
183185
const std::wstring& userDataFolderParam, bool isMainWindow,
184186
std::function<void()> webviewCreatedCallback, bool customWindowRect, RECT windowRect,
185-
bool shouldHaveToolbar)
187+
bool shouldHaveToolbar, bool isPopup)
186188
: m_creationModeId(creationModeId), m_webviewOption(opt), m_initialUri(initialUri),
187-
m_onWebViewFirstInitialized(webviewCreatedCallback)
189+
m_onWebViewFirstInitialized(webviewCreatedCallback), m_isPopupWindow(isPopup)
188190
{
189191
// Initialize COM as STA.
190192
CHECK_FAILURE(OleInitialize(NULL));
@@ -651,6 +653,16 @@ bool AppWindow::ExecuteWebViewCommands(WPARAM wParam, LPARAM lParam)
651653
{
652654
return PrintToPdfStream();
653655
}
656+
case IDM_SCENARIO_NON_CLIENT_REGION_SUPPORT:
657+
{
658+
NewComponent<ScenarioNonClientRegionSupport>(this);
659+
return true;
660+
}
661+
case IDM_SCENARIO_ACCELERATOR_KEY_PRESSED:
662+
{
663+
NewComponent<ScenarioAcceleratorKeyPressed>(this);
664+
return true;
665+
}
654666
}
655667
return false;
656668
}

SampleApps/WebView2APISample/AppWindow.h

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -87,15 +87,11 @@ class AppWindow
8787
{
8888
public:
8989
AppWindow(
90-
UINT creationModeId,
91-
const WebViewCreateOption& opt,
92-
const std::wstring& initialUri = L"",
93-
const std::wstring& userDataFolderParam = L"",
94-
bool isMainWindow = false,
95-
std::function<void()> webviewCreatedCallback = nullptr,
96-
bool customWindowRect = false,
97-
RECT windowRect = { 0 },
98-
bool shouldHaveToolbar = true);
90+
UINT creationModeId, const WebViewCreateOption& opt,
91+
const std::wstring& initialUri = L"", const std::wstring& userDataFolderParam = L"",
92+
bool isMainWindow = false, std::function<void()> webviewCreatedCallback = nullptr,
93+
bool customWindowRect = false, RECT windowRect = {0}, bool shouldHaveToolbar = true,
94+
bool isPopup = false);
9995

10096
~AppWindow();
10197

@@ -293,6 +289,7 @@ class AppWindow
293289
RECT m_appBackgroundImageRect;
294290
};
295291

292+
// Creates and registers a component on this `AppWindow`.
296293
template <class ComponentType, class... Args> void AppWindow::NewComponent(Args&&... args)
297294
{
298295
m_components.emplace_back(new ComponentType(std::forward<Args>(args)...));

SampleApps/WebView2APISample/CheckFailure.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,13 @@ void FeatureNotAvailable();
3535

3636
// Returns nothing, which is different from CHECK_FEATURE_RETURN
3737
#define CHECK_FEATURE_RETURN_EMPTY(feature) { if (!feature) { FeatureNotAvailable(); return; } }
38+
39+
// Returns S_OK, which is different from CHECK_FEATURE_RETURN
40+
#define CHECK_FEATURE_RETURN_HRESULT(feature) \
41+
{ \
42+
if (!feature) \
43+
{ \
44+
FeatureNotAvailable(); \
45+
return S_OK; \
46+
} \
47+
}

SampleApps/WebView2APISample/ComponentBase.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,18 @@
66

77
#include "stdafx.h"
88

9+
// A component is meant to encapsulate all details required for a specific
10+
// capability of the AppWindow, typically demonstrating usage of a WebView2 API.
11+
//
12+
// Component instances are owned by an AppWindow, which will give each of its
13+
// components a chance to handle any messages it gets. AppWindow deletes all its
14+
// components when WebView is closed.
15+
//
16+
// Components are meant to be created and registered by AppWindow itself,
17+
// through `AppWindow::NewComponent<TComponent>(...)`. For example, the
18+
// AppWindow might create a new component upon selection of a menu item by the
19+
// user. Components typically take and keep a pointer to their owning AppWindow
20+
// so they can control the WebView.
921
class ComponentBase
1022
{
1123
public:
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Copyright (C) Microsoft Corporation. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
#include "stdafx.h"
6+
7+
#include "DiscardsComponent.h"
8+
9+
DiscardsComponent::DiscardsComponent(AppWindow* appWindow) : m_appWindow(appWindow)
10+
{
11+
m_appWindowDiscardsView = new AppWindow(
12+
IDM_CREATION_MODE_WINDOWED, appWindow->GetWebViewOption(), L"edge://discards/graph",
13+
appWindow->GetUserDataFolder(), false /* isMainWindow */,
14+
nullptr /* webviewCreatedCallback */, true /* customWindowRect */, {100, 100, 900, 900},
15+
false /* shouldHaveToolbar */);
16+
17+
m_appWindowDiscardsView->SetOnAppWindowClosing([&] { m_appWindow->DeleteComponent(this); });
18+
}
19+
20+
DiscardsComponent::~DiscardsComponent()
21+
{
22+
m_appWindowDiscardsView->SetOnAppWindowClosing(nullptr);
23+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Copyright (C) Microsoft Corporation. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
#pragma once
6+
7+
#include "stdafx.h"
8+
9+
#include "AppWindow.h"
10+
#include "ComponentBase.h"
11+
12+
class DiscardsComponent : public ComponentBase
13+
{
14+
public:
15+
DiscardsComponent(AppWindow* appWindow);
16+
~DiscardsComponent() override;
17+
18+
private:
19+
AppWindow* m_appWindow = nullptr;
20+
21+
// The AppWindow showing discards.
22+
AppWindow* m_appWindowDiscardsView;
23+
};

SampleApps/WebView2APISample/ProcessComponent.cpp

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -244,26 +244,26 @@ void ProcessComponent::AppendFrameInfo(
244244
CHECK_FAILURE(frameInfo->get_Source(&sourceRaw));
245245
std::wstring source = sourceRaw.get()[0] ? sourceRaw.get() : L"none";
246246

247-
wil::com_ptr<ICoreWebView2ExperimentalFrameInfo> frameInfoExperimental;
248-
CHECK_FAILURE(frameInfo->QueryInterface(IID_PPV_ARGS(&frameInfoExperimental)));
249-
frameInfoExperimental->get_FrameId(&frameId);
250-
frameInfoExperimental->get_FrameKind(&frameKind);
247+
wil::com_ptr<ICoreWebView2FrameInfo2> frameInfo2;
248+
CHECK_FAILURE(frameInfo->QueryInterface(IID_PPV_ARGS(&frameInfo2)));
249+
frameInfo2->get_FrameId(&frameId);
250+
frameInfo2->get_FrameKind(&frameKind);
251251

252252
wil::com_ptr<ICoreWebView2FrameInfo> parentFrameInfo;
253-
CHECK_FAILURE(frameInfoExperimental->get_ParentFrameInfo(&parentFrameInfo));
253+
CHECK_FAILURE(frameInfo2->get_ParentFrameInfo(&parentFrameInfo));
254254
if (parentFrameInfo)
255255
{
256-
CHECK_FAILURE(parentFrameInfo->QueryInterface(IID_PPV_ARGS(&frameInfoExperimental)));
257-
CHECK_FAILURE(frameInfoExperimental->get_FrameId(&parentFrameId));
256+
CHECK_FAILURE(parentFrameInfo->QueryInterface(IID_PPV_ARGS(&frameInfo2)));
257+
CHECK_FAILURE(frameInfo2->get_FrameId(&parentFrameId));
258258
}
259259

260260
wil::com_ptr<ICoreWebView2FrameInfo> mainFrameInfo = GetAncestorMainFrameInfo(frameInfo);
261261
if (mainFrameInfo == frameInfo)
262262
{
263263
type = L"main frame";
264264
}
265-
CHECK_FAILURE(mainFrameInfo->QueryInterface(IID_PPV_ARGS(&frameInfoExperimental)));
266-
CHECK_FAILURE(frameInfoExperimental->get_FrameId(&mainFrameId));
265+
CHECK_FAILURE(mainFrameInfo->QueryInterface(IID_PPV_ARGS(&frameInfo2)));
266+
CHECK_FAILURE(frameInfo2->get_FrameId(&mainFrameId));
267267

268268
wil::com_ptr<ICoreWebView2FrameInfo> childFrameInfo =
269269
GetAncestorMainFrameDirectChildFrameInfo(frameInfo);
@@ -273,8 +273,8 @@ void ProcessComponent::AppendFrameInfo(
273273
}
274274
if (childFrameInfo)
275275
{
276-
CHECK_FAILURE(childFrameInfo->QueryInterface(IID_PPV_ARGS(&frameInfoExperimental)));
277-
CHECK_FAILURE(frameInfoExperimental->get_FrameId(&childFrameId));
276+
CHECK_FAILURE(childFrameInfo->QueryInterface(IID_PPV_ARGS(&frameInfo2)));
277+
CHECK_FAILURE(frameInfo2->get_FrameId(&childFrameId));
278278
}
279279

280280
result << L"{frame name:" << name << L" | frame Id:" << frameId << L" | parent frame Id:"
@@ -293,12 +293,12 @@ wil::com_ptr<ICoreWebView2FrameInfo> ProcessComponent::GetAncestorMainFrameInfo(
293293
wil::com_ptr<ICoreWebView2FrameInfo> frameInfo)
294294
{
295295
wil::com_ptr<ICoreWebView2FrameInfo> mainFrameInfo;
296-
wil::com_ptr<ICoreWebView2ExperimentalFrameInfo> frameInfoExperimental;
296+
wil::com_ptr<ICoreWebView2FrameInfo2> frameInfo2;
297297
while (frameInfo)
298298
{
299299
mainFrameInfo = frameInfo;
300-
CHECK_FAILURE(frameInfo->QueryInterface(IID_PPV_ARGS(&frameInfoExperimental)));
301-
CHECK_FAILURE(frameInfoExperimental->get_ParentFrameInfo(&frameInfo));
300+
CHECK_FAILURE(frameInfo->QueryInterface(IID_PPV_ARGS(&frameInfo2)));
301+
CHECK_FAILURE(frameInfo2->get_ParentFrameInfo(&frameInfo));
302302
}
303303
return mainFrameInfo;
304304
}
@@ -320,30 +320,28 @@ wil::com_ptr<ICoreWebView2FrameInfo> ProcessComponent::GetAncestorMainFrameDirec
320320
{
321321
wil::com_ptr<ICoreWebView2FrameInfo> mainFrameInfo;
322322
wil::com_ptr<ICoreWebView2FrameInfo> childFrameInfo;
323-
wil::com_ptr<ICoreWebView2ExperimentalFrameInfo> frameInfoExperimental;
323+
wil::com_ptr<ICoreWebView2FrameInfo2> frameInfo2;
324324
while (frameInfo)
325325
{
326326
childFrameInfo = mainFrameInfo;
327327
mainFrameInfo = frameInfo;
328-
CHECK_FAILURE(frameInfo->QueryInterface(IID_PPV_ARGS(&frameInfoExperimental)));
329-
CHECK_FAILURE(frameInfoExperimental->get_ParentFrameInfo(&frameInfo));
328+
CHECK_FAILURE(frameInfo->QueryInterface(IID_PPV_ARGS(&frameInfo2)));
329+
CHECK_FAILURE(frameInfo2->get_ParentFrameInfo(&frameInfo));
330330
}
331331
return childFrameInfo;
332332
}
333333

334334
void ProcessComponent::ShowProcessExtendedInfo()
335335
{
336-
auto environmentExperimental13 =
337-
m_webViewEnvironment.try_query<ICoreWebView2ExperimentalEnvironment13>();
338-
if (environmentExperimental13)
336+
auto environment13 = m_webViewEnvironment.try_query<ICoreWebView2Environment13>();
337+
if (environment13)
339338
{
340339
//! [GetProcessExtendedInfos]
341-
CHECK_FAILURE(environmentExperimental13->GetProcessExtendedInfos(
342-
Callback<ICoreWebView2ExperimentalGetProcessExtendedInfosCompletedHandler>(
340+
CHECK_FAILURE(environment13->GetProcessExtendedInfos(
341+
Callback<ICoreWebView2GetProcessExtendedInfosCompletedHandler>(
343342
[this](
344343
HRESULT error,
345-
ICoreWebView2ExperimentalProcessExtendedInfoCollection* processCollection)
346-
-> HRESULT
344+
ICoreWebView2ProcessExtendedInfoCollection* processCollection) -> HRESULT
347345
{
348346
UINT32 processCount = 0;
349347
UINT32 rendererProcessCount = 0;
@@ -352,7 +350,7 @@ void ProcessComponent::ShowProcessExtendedInfo()
352350
std::wstringstream rendererProcessInfos;
353351
for (UINT32 i = 0; i < processCount; i++)
354352
{
355-
Microsoft::WRL::ComPtr<ICoreWebView2ExperimentalProcessExtendedInfo>
353+
Microsoft::WRL::ComPtr<ICoreWebView2ProcessExtendedInfo>
356354
processExtendedInfo;
357355
CHECK_FAILURE(
358356
processCollection->GetValueAtIndex(i, &processExtendedInfo));

0 commit comments

Comments
 (0)