-
Notifications
You must be signed in to change notification settings - Fork 517
Expand file tree
/
Copy pathSettingsComponent.h
More file actions
111 lines (96 loc) · 4.42 KB
/
SettingsComponent.h
File metadata and controls
111 lines (96 loc) · 4.42 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
// 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 <functional>
#include <string>
#include <vector>
#include "AppWindow.h"
#include "ComponentBase.h"
#include "CustomStatusBar.h"
// Some utility functions
wil::unique_bstr GetDomainOfUri(PWSTR uri);
// This component handles commands from the Settings menu. It also handles the
// NavigationStarting, FrameNavigationStarting, WebResourceRequested, ScriptDialogOpening,
// and PermissionRequested events.
class SettingsComponent : public ComponentBase
{
public:
SettingsComponent(
AppWindow* appWindow, ICoreWebView2Environment* environment,
SettingsComponent* old = nullptr);
bool HandleWindowMessage(
HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, LRESULT* result) override;
void AddMenuItems(
HMENU hPopupMenu, wil::com_ptr<ICoreWebView2ContextMenuItemCollection> items);
void ChangeBlockedSites();
bool ShouldBlockUri(PWSTR uri);
bool ShouldBlockScriptForUri(PWSTR uri);
void SetBlockImages(bool blockImages);
void SetReplaceImages(bool replaceImages);
void ChangeUserAgent();
void SetUserAgent(const std::wstring& userAgent);
void EnableCustomClientCertificateSelection();
void ToggleCustomServerCertificateSupport();
void SetCustomDataPartitionId();
void SetTrackingPreventionLevel(COREWEBVIEW2_TRACKING_PREVENTION_LEVEL value);
void SetEnhancedSecurityModeLevel(COREWEBVIEW2_ENHANCED_SECURITY_MODE_LEVEL value);
~SettingsComponent() override;
private:
HRESULT OnPermissionRequested(
ICoreWebView2* sender, ICoreWebView2PermissionRequestedEventArgs* args);
AppWindow* m_appWindow = nullptr;
wil::com_ptr<ICoreWebView2> m_webView;
wil::com_ptr<ICoreWebView2_5> m_webView2_5;
wil::com_ptr<ICoreWebView2_11> m_webView2_11;
wil::com_ptr<ICoreWebView2_12> m_webView2_12;
wil::com_ptr<ICoreWebView2_13> m_webView2_13;
wil::com_ptr<ICoreWebView2_14> m_webView2_14;
wil::com_ptr<ICoreWebView2_15> m_webView2_15;
wil::com_ptr<ICoreWebView2_18> m_webView2_18;
wil::com_ptr<ICoreWebView2_22> m_webView2_22;
wil::com_ptr<ICoreWebView2Settings> m_settings;
wil::com_ptr<ICoreWebView2Settings2> m_settings2;
wil::com_ptr<ICoreWebView2Settings3> m_settings3;
wil::com_ptr<ICoreWebView2Settings4> m_settings4;
wil::com_ptr<ICoreWebView2Settings5> m_settings5;
wil::com_ptr<ICoreWebView2Settings6> m_settings6;
wil::com_ptr<ICoreWebView2Settings7> m_settings7;
wil::com_ptr<ICoreWebView2Settings8> m_settings8;
wil::com_ptr<ICoreWebView2Controller> m_controller;
wil::com_ptr<ICoreWebView2Controller3> m_controller3;
wil::com_ptr<ICoreWebView2Environment> m_webViewEnvironment;
wil::com_ptr<ICoreWebView2ContextMenuItem> m_displayPageUrlContextSubMenuItem;
bool m_blockImages = false;
bool m_replaceImages = false;
bool m_changeUserAgent = false;
bool m_isScriptEnabled = true;
bool m_blockedSitesSet = false;
bool m_raiseClientCertificate = false;
BOOL m_allowCustomMenus = false;
std::map<std::tuple<std::wstring, COREWEBVIEW2_PERMISSION_KIND, BOOL>, bool>
m_cached_permissions;
std::vector<std::wstring> m_blockedSites;
std::wstring m_overridingUserAgent;
ULONG_PTR gdiplusToken_;
bool m_faviconChanged = false;
wil::unique_hicon m_favicon;
CustomStatusBar m_statusBar;
bool m_customStatusBar = false;
bool m_raiseServerCertificateError = false;
bool m_launchingExternalUriScheme = false;
EventRegistrationToken m_navigationStartingToken = {};
EventRegistrationToken m_frameNavigationStartingToken = {};
EventRegistrationToken m_webResourceRequestedTokenForImageBlocking = {};
EventRegistrationToken m_webResourceRequestedTokenForImageReplacing = {};
EventRegistrationToken m_webResourceRequestedTokenForUserAgent = {};
EventRegistrationToken m_scriptDialogOpeningToken = {};
EventRegistrationToken m_permissionRequestedToken = {};
EventRegistrationToken m_ClientCertificateRequestedToken = {};
EventRegistrationToken m_contextMenuRequestedToken = {};
EventRegistrationToken m_faviconChangedToken = {};
EventRegistrationToken m_statusBarTextChangedToken = {};
EventRegistrationToken m_ServerCertificateErrorToken = {};
EventRegistrationToken m_launchingExternalUriSchemeToken = {};
};