forked from MicrosoftEdge/WebView2Samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProcessComponent.h
63 lines (51 loc) · 2.3 KB
/
ProcessComponent.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// Copyright (C) Microsoft Corporation. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#pragma once
#include "stdafx.h"
#include "AppWindow.h"
#include "ComponentBase.h"
// This component handles commands from the Process menu, as well as some miscellaneous
// functions for managing the browser process.
class ProcessComponent : public ComponentBase
{
public:
ProcessComponent(AppWindow* appWindow);
static bool IsAppContentUri(const std::wstring& source);
bool HandleWindowMessage(
HWND hWnd,
UINT message,
WPARAM wParam,
LPARAM lParam,
LRESULT* result) override;
void ShowBrowserProcessInfo();
std::wstring ProcessFailedKindToString(const COREWEBVIEW2_PROCESS_FAILED_KIND kind);
std::wstring ProcessFailedReasonToString(const COREWEBVIEW2_PROCESS_FAILED_REASON reason);
std::wstring ProcessKindToString(const COREWEBVIEW2_PROCESS_KIND kind);
void CrashBrowserProcess();
void CrashRenderProcess();
void PerformanceInfo();
void ShowProcessExtendedInfo();
~ProcessComponent() override;
// Wait for process to exit for timeoutMs, then force quit it if it hasn't.
static void EnsureProcessIsClosed(UINT processId, int timeoutMs);
private:
void ScheduleReinitIfSelectedByUser(
const std::wstring& message, const std::wstring& caption);
void ScheduleReloadIfSelectedByUser(
const std::wstring& message, const std::wstring& caption);
AppWindow* m_appWindow = nullptr;
wil::com_ptr<ICoreWebView2> m_webView;
wil::com_ptr<ICoreWebView2Environment> m_webViewEnvironment;
UINT m_browserProcessId = 0;
wil::com_ptr<ICoreWebView2ProcessInfoCollection> m_processCollection;
EventRegistrationToken m_processFailedToken = {};
EventRegistrationToken m_processInfosChangedToken = {};
void AppendFrameInfo(
wil::com_ptr<ICoreWebView2FrameInfo> frameInfo, std::wstringstream& result);
wil::com_ptr<ICoreWebView2FrameInfo> GetAncestorMainFrameDirectChildFrameInfo(
wil::com_ptr<ICoreWebView2FrameInfo> frameInfo);
wil::com_ptr<ICoreWebView2FrameInfo> GetAncestorMainFrameInfo(
wil::com_ptr<ICoreWebView2FrameInfo> frameInfo);
std::wstring FrameKindToString(const COREWEBVIEW2_FRAME_KIND kind);
};