-
Notifications
You must be signed in to change notification settings - Fork 517
Expand file tree
/
Copy pathSettingsComponent.h
More file actions
82 lines (72 loc) · 3.3 KB
/
SettingsComponent.h
File metadata and controls
82 lines (72 loc) · 3.3 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
// 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"
// 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<ICoreWebView2ExperimentalContextMenuItemCollection> 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 CompleteScriptDialogDeferral();
void EnableCustomClientCertificateSelection();
~SettingsComponent() override;
private:
AppWindow* m_appWindow = nullptr;
wil::com_ptr<ICoreWebView2Environment> m_webViewEnvironment;
wil::com_ptr<ICoreWebView2> m_webView;
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<ICoreWebView2_5> m_webView2_5;
wil::com_ptr<ICoreWebView2Controller> m_controller;
wil::com_ptr<ICoreWebView2Controller3> m_controller3;
wil::com_ptr<ICoreWebView2Experimental5> m_webViewExperimental5;
wil::com_ptr<ICoreWebView2Experimental6> m_webViewExperimental6;
wil::com_ptr<ICoreWebView2ExperimentalContextMenuItem> m_displayPageUrlContextSubMenuItem;
bool m_blockImages = false;
bool m_replaceImages = false;
bool m_deferScriptDialogs = 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;
std::function<void()> m_completeDeferredDialog;
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 = {};
};