forked from NSTechBytes/WebView2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlugin.h
More file actions
69 lines (56 loc) · 1.85 KB
/
Plugin.h
File metadata and controls
69 lines (56 loc) · 1.85 KB
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
64
65
66
67
// Copyright (C) 2025 nstechbytes. All rights reserved.
#pragma once
#include <Windows.h>
#include <string>
#include <map>
#include <wrl.h>
#include <wil/com.h>
#include <WebView2.h>
using namespace Microsoft::WRL;
// Global TypeLib for COM objects
extern wil::com_ptr<ITypeLib> g_typeLib;
// Measure structure containing WebView2 state
struct Measure
{
void* rm;
void* skin;
HWND skinWindow;
LPCWSTR measureName;
std::wstring url;
std::wstring currentUrl;
int width;
int height;
int x;
int y;
double zoomFactor;
bool visible;
bool initialized;
bool clickthrough;
bool isCreationInProgress = false;
bool isFirstLoad = true;
bool allowDualControl;
bool isAllowDualControlInjected = false;
std::wstring onWebViewLoadAction;
std::wstring onWebViewFailAction;
std::wstring onPageFirstLoadAction;
std::wstring onPageLoadStartAction;
std::wstring onPageLoadingAction;
std::wstring onPageLoadFinishAction;
std::wstring onPageReloadAction;
wil::com_ptr<ICoreWebView2Controller> webViewController;
wil::com_ptr<ICoreWebView2> webView;
EventRegistrationToken webMessageToken;
std::wstring buffer; // Buffer for section variable return values
std::wstring callbackResult; // Stores return value from OnInitialize/OnUpdate callbacks
std::map<std::wstring, std::wstring> jsResults; // Cache for CallJS results
Measure();
~Measure();
// Member callback functions for WebView2 creation
HRESULT CreateEnvironmentHandler(HRESULT result, ICoreWebView2Environment* env);
HRESULT CreateControllerHandler(HRESULT result, ICoreWebView2Controller* controller);
};
// WebView2 functions
void CreateWebView2(Measure* measure);
void UpdateClickthrough(Measure* measure);
void InjectAllowDualControl(Measure* measure);
void UpdateAllowDualControl(Measure* measure);