├── .gitattributes ├── .gitignore ├── LICENSE ├── README.md └── Src ├── RemoteComObject ├── ReadMe.txt ├── RemoteComObject.cpp ├── RemoteComObject.def ├── RemoteComObject.idl ├── RemoteComObject.rc ├── RemoteComObject.rgs ├── RemoteComObject.sln ├── RemoteComObject.vcxproj ├── RemoteComObject.vcxproj.filters ├── RemoteComObjectImpl.cpp ├── RemoteComObjectImpl.h ├── RemoteComObjectImpl.rgs ├── dllmain.cpp ├── dllmain.h ├── packages.config ├── resource.h ├── stdafx.cpp ├── stdafx.h ├── targetver.h ├── xdlldata.c └── xdlldata.h ├── WebView2.WinForms.Demo ├── App.config ├── Constants.cs ├── Content │ ├── commands.js │ ├── content_ui │ │ ├── favorites.html │ │ ├── favorites.js │ │ ├── history.css │ │ ├── history.html │ │ ├── history.js │ │ ├── img │ │ │ ├── close.png │ │ │ ├── favorites.png │ │ │ ├── history.png │ │ │ └── settings.png │ │ ├── items.css │ │ ├── settings.css │ │ ├── settings.html │ │ ├── settings.js │ │ └── styles.css │ └── controls_ui │ │ ├── address-bar.css │ │ ├── controls.css │ │ ├── default.css │ │ ├── default.html │ │ ├── default.js │ │ ├── favorites.js │ │ ├── history.js │ │ ├── img │ │ ├── cancel.png │ │ ├── favicon.png │ │ ├── favorite.png │ │ ├── favorited.png │ │ ├── goBack.png │ │ ├── goBack_disabled.png │ │ ├── goForward.png │ │ ├── goForward_disabled.png │ │ ├── insecure.png │ │ ├── neutral.png │ │ ├── options.png │ │ ├── reload.png │ │ ├── secure.png │ │ └── unknown.png │ │ ├── options.css │ │ ├── options.html │ │ ├── options.js │ │ ├── storage.js │ │ ├── strip.css │ │ ├── styles.css │ │ └── tabs.js ├── PopupForm.Designer.cs ├── PopupForm.cs ├── PopupForm.resx ├── Program.cs ├── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ ├── Resources.resx │ ├── Settings.Designer.cs │ └── Settings.settings ├── SafeNativeMethods.cs ├── Tab.cs ├── WebView2.WinForms.Demo.csproj ├── WebView2Browser.Designer.cs ├── WebView2Browser.cs ├── WebView2Browser.resx ├── app.ico ├── app.manifest └── packages.config ├── WebView2.WinForms.Sample ├── App.config ├── Components │ ├── ComponentBase.cs │ ├── ControlComponent.cs │ ├── FileComponent.cs │ ├── ProcessComponent.cs │ ├── ScriptComponent.cs │ ├── SettingsComponent.cs │ └── ViewComponent.cs ├── Controls │ ├── NavigationToolBar.Designer.cs │ ├── NavigationToolBar.cs │ └── NavigationToolBar.resx ├── Forms │ ├── AboutForm.Designer.cs │ ├── AboutForm.cs │ ├── AboutForm.resx │ ├── CommonDialogs.cs │ ├── TextInputDialog.Designer.cs │ ├── TextInputDialog.cs │ └── TextInputDialog.resx ├── MainForm.Designer.cs ├── MainForm.cs ├── MainForm.resx ├── Program.cs ├── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ ├── Resources.resx │ ├── Settings.Designer.cs │ └── Settings.settings ├── Scenarios │ ├── ScenarioAddRemoteObject.cs │ ├── ScenarioAddRemoteObject.html │ ├── ScenarioWebMessage.cs │ ├── ScenarioWebMessage.html │ ├── ScenarioWebViewEventMonitor.cs │ └── ScenarioWebViewEventMonitor.html ├── Utils │ ├── FileUtil.cs │ └── ProcessUtil.cs ├── WebView2.WinForms.Sample.csproj ├── comtest.vbs ├── packages.config └── small.ico ├── WebView2.WinForms ├── EventArgs │ └── BeforeEnvironmentCreatedEventArgs.cs ├── HandlerType.cs ├── OriginalInterop │ ├── Enums.cs │ ├── ISequentialStream.cs │ ├── IStream.cs │ ├── IWebView2AddScriptToExecuteOnDocumentCreatedCompletedHandler.cs │ ├── IWebView2CallDevToolsProtocolMethodCompletedHandler.cs │ ├── IWebView2CapturePreviewCompletedHandler.cs │ ├── IWebView2CreateWebView2EnvironmentCompletedHandler.cs │ ├── IWebView2CreateWebViewCompletedHandler.cs │ ├── IWebView2Deferral.cs │ ├── IWebView2DevToolsProtocolEventReceivedEventArgs.cs │ ├── IWebView2DevToolsProtocolEventReceivedEventHandler.cs │ ├── IWebView2DocumentStateChangedEventArgs.cs │ ├── IWebView2DocumentStateChangedEventHandler.cs │ ├── IWebView2Environment.cs │ ├── IWebView2Environment2.cs │ ├── IWebView2ExecuteScriptCompletedHandler.cs │ ├── IWebView2FocusChangedEventHandler.cs │ ├── IWebView2HttpHeadersCollectionIterator.cs │ ├── IWebView2HttpRequestHeaders.cs │ ├── IWebView2HttpResponseHeaders.cs │ ├── IWebView2MoveFocusRequestedEventArgs.cs │ ├── IWebView2MoveFocusRequestedEventHandler.cs │ ├── IWebView2NavigationCompletedEventArgs.cs │ ├── IWebView2NavigationCompletedEventHandler.cs │ ├── IWebView2NavigationStartingEventArgs.cs │ ├── IWebView2NavigationStartingEventHandler.cs │ ├── IWebView2PermissionRequestedEventArgs.cs │ ├── IWebView2PermissionRequestedEventHandler.cs │ ├── IWebView2ProcessFailedEventArgs.cs │ ├── IWebView2ProcessFailedEventHandler.cs │ ├── IWebView2ScriptDialogOpeningEventArgs.cs │ ├── IWebView2ScriptDialogOpeningEventHandler.cs │ ├── IWebView2Settings.cs │ ├── IWebView2WebMessageReceivedEventArgs.cs │ ├── IWebView2WebMessageReceivedEventHandler.cs │ ├── IWebView2WebResourceRequest.cs │ ├── IWebView2WebResourceRequestedEventArgs.cs │ ├── IWebView2WebResourceRequestedEventHandler.cs │ ├── IWebView2WebResourceResponse.cs │ ├── IWebView2WebView.cs │ ├── IWebView2ZoomFactorChangedEventHandler.cs │ └── Structs.cs ├── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ └── Resources.resx ├── WebView2.WinForms.csproj ├── WebView2Control.cs ├── WebView2ControlBase.cs └── packages.config ├── WebView2.Wpf.Demo ├── App.config ├── App.xaml ├── App.xaml.cs ├── Constants.cs ├── Content │ ├── commands.js │ ├── content_ui │ │ ├── favorites.html │ │ ├── favorites.js │ │ ├── history.css │ │ ├── history.html │ │ ├── history.js │ │ ├── img │ │ │ ├── close.png │ │ │ ├── favorites.png │ │ │ ├── history.png │ │ │ └── settings.png │ │ ├── items.css │ │ ├── settings.css │ │ ├── settings.html │ │ ├── settings.js │ │ └── styles.css │ └── controls_ui │ │ ├── address-bar.css │ │ ├── controls.css │ │ ├── default.css │ │ ├── default.html │ │ ├── default.js │ │ ├── favorites.js │ │ ├── history.js │ │ ├── img │ │ ├── cancel.png │ │ ├── favicon.png │ │ ├── favorite.png │ │ ├── favorited.png │ │ ├── goBack.png │ │ ├── goBack_disabled.png │ │ ├── goForward.png │ │ ├── goForward_disabled.png │ │ ├── insecure.png │ │ ├── neutral.png │ │ ├── options.png │ │ ├── reload.png │ │ ├── secure.png │ │ └── unknown.png │ │ ├── options.css │ │ ├── options.html │ │ ├── options.js │ │ ├── storage.js │ │ ├── strip.css │ │ ├── styles.css │ │ └── tabs.js ├── PopupWindow.xaml ├── PopupWindow.xaml.cs ├── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ ├── Resources.resx │ ├── Settings.Designer.cs │ └── Settings.settings ├── Tab.cs ├── ViewModels │ └── WebView2BrowserViewModel.cs ├── WebView2.Wpf.Demo.csproj ├── WebView2Browser.xaml ├── WebView2Browser.xaml.cs ├── app.ico └── packages.config ├── WebView2.Wpf.Sample ├── App.config ├── App.xaml ├── App.xaml.cs ├── AppCommands.cs ├── Components │ ├── ComponentBase.cs │ ├── ControlComponent.cs │ ├── FileComponent.cs │ ├── ProcessComponent.cs │ ├── ScriptComponent.cs │ ├── SettingsComponent.cs │ └── ViewComponent.cs ├── Controls │ ├── NavigationToolBar.Designer.cs │ ├── NavigationToolBar.cs │ ├── NavigationToolBar.resx │ ├── NavigationToolBar.xaml │ └── NavigationToolBar.xaml.cs ├── Forms │ ├── AboutWindow.xaml │ ├── AboutWindow.xaml.cs │ ├── CommonDialogs.cs │ ├── TextInputDialog.xaml │ └── TextInputDialog.xaml.cs ├── MainWindow.xaml ├── MainWindow.xaml.cs ├── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ ├── Resources.resx │ ├── Settings.Designer.cs │ └── Settings.settings ├── Scenarios │ ├── ScenarioAddRemoteObject.cs │ ├── ScenarioAddRemoteObject.html │ ├── ScenarioWebMessage.cs │ ├── ScenarioWebMessage.html │ ├── ScenarioWebViewEventMonitor.cs │ └── ScenarioWebViewEventMonitor.html ├── Utils │ ├── FileUtil.cs │ └── ProcessUtil.cs ├── WebView2.Wpf.Sample.csproj ├── packages.config └── small.ico ├── WebView2.Wpf ├── EventArgs │ └── BeforeEnvironmentCreatedEventArgs.cs ├── HandlerType.cs ├── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ ├── Resources.resx │ ├── Settings.Designer.cs │ └── Settings.settings ├── WebView2.Wpf.csproj ├── WebView2Control2.cs └── packages.config ├── WebView2.sln └── icon.png /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | *.sln merge=union 7 | *.csproj merge=union 8 | *.vbproj merge=union 9 | *.fsproj merge=union 10 | *.dbproj merge=union 11 | 12 | # Standard to msysgit 13 | *.doc diff=astextplain 14 | *.DOC diff=astextplain 15 | *.docx diff=astextplain 16 | *.DOCX diff=astextplain 17 | *.dot diff=astextplain 18 | *.DOT diff=astextplain 19 | *.pdf diff=astextplain 20 | *.PDF diff=astextplain 21 | *.rtf diff=astextplain 22 | *.RTF diff=astextplain -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 michael-russin 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Src/RemoteComObject/RemoteComObject.cpp: -------------------------------------------------------------------------------- 1 | // RemoteComObject.cpp : Implementation of DLL Exports. 2 | 3 | 4 | #include "stdafx.h" 5 | #include "resource.h" 6 | #include "RemoteComObject_i.h" 7 | #include "dllmain.h" 8 | #include "xdlldata.h" 9 | 10 | 11 | using namespace ATL; 12 | 13 | // Used to determine whether the DLL can be unloaded by OLE. 14 | STDAPI DllCanUnloadNow(void) 15 | { 16 | #ifdef _MERGE_PROXYSTUB 17 | HRESULT hr = PrxDllCanUnloadNow(); 18 | if (hr != S_OK) 19 | return hr; 20 | #endif 21 | return _AtlModule.DllCanUnloadNow(); 22 | } 23 | 24 | // Returns a class factory to create an object of the requested type. 25 | _Check_return_ 26 | STDAPI DllGetClassObject(_In_ REFCLSID rclsid, _In_ REFIID riid, _Outptr_ LPVOID* ppv) 27 | { 28 | #ifdef _MERGE_PROXYSTUB 29 | HRESULT hr = PrxDllGetClassObject(rclsid, riid, ppv); 30 | if (hr != CLASS_E_CLASSNOTAVAILABLE) 31 | return hr; 32 | #endif 33 | return _AtlModule.DllGetClassObject(rclsid, riid, ppv); 34 | } 35 | 36 | // DllRegisterServer - Adds entries to the system registry. 37 | STDAPI DllRegisterServer(void) 38 | { 39 | // registers object, typelib and all interfaces in typelib 40 | HRESULT hr = _AtlModule.DllRegisterServer(); 41 | #ifdef _MERGE_PROXYSTUB 42 | if (FAILED(hr)) 43 | return hr; 44 | hr = PrxDllRegisterServer(); 45 | #endif 46 | return hr; 47 | } 48 | 49 | // DllUnregisterServer - Removes entries from the system registry. 50 | STDAPI DllUnregisterServer(void) 51 | { 52 | HRESULT hr = _AtlModule.DllUnregisterServer(); 53 | #ifdef _MERGE_PROXYSTUB 54 | if (FAILED(hr)) 55 | return hr; 56 | hr = PrxDllRegisterServer(); 57 | if (FAILED(hr)) 58 | return hr; 59 | hr = PrxDllUnregisterServer(); 60 | #endif 61 | return hr; 62 | } 63 | 64 | // DllInstall - Adds/Removes entries to the system registry per user per machine. 65 | STDAPI DllInstall(BOOL bInstall, _In_opt_ LPCWSTR pszCmdLine) 66 | { 67 | HRESULT hr = E_FAIL; 68 | static const wchar_t szUserSwitch[] = L"user"; 69 | 70 | if (pszCmdLine != NULL) 71 | { 72 | if (_wcsnicmp(pszCmdLine, szUserSwitch, _countof(szUserSwitch)) == 0) 73 | { 74 | ATL::AtlSetPerUserRegistration(true); 75 | } 76 | } 77 | 78 | if (bInstall) 79 | { 80 | hr = DllRegisterServer(); 81 | if (FAILED(hr)) 82 | { 83 | DllUnregisterServer(); 84 | } 85 | } 86 | else 87 | { 88 | hr = DllUnregisterServer(); 89 | } 90 | 91 | return hr; 92 | } 93 | 94 | 95 | -------------------------------------------------------------------------------- /Src/RemoteComObject/RemoteComObject.def: -------------------------------------------------------------------------------- 1 | ; RemoteComObject.def : Declares the module parameters. 2 | 3 | LIBRARY 4 | 5 | EXPORTS 6 | DllCanUnloadNow PRIVATE 7 | DllGetClassObject PRIVATE 8 | DllRegisterServer PRIVATE 9 | DllUnregisterServer PRIVATE 10 | DllInstall PRIVATE 11 | -------------------------------------------------------------------------------- /Src/RemoteComObject/RemoteComObject.idl: -------------------------------------------------------------------------------- 1 | // RemoteComObject.idl : IDL source for RemoteComObject 2 | // 3 | 4 | // This file will be processed by the MIDL tool to 5 | // produce the type library (RemoteComObject.tlb) and marshalling code. 6 | 7 | import "oaidl.idl"; 8 | import "ocidl.idl"; 9 | 10 | [ 11 | object, 12 | uuid(BC4C0BCE-56F6-45BF-A9D4-6E314C9D2A4D), 13 | dual, 14 | nonextensible, 15 | pointer_default(unique) 16 | ] 17 | interface IRemoteComObjectImpl : IDispatch{ 18 | [propget, id(1)] HRESULT Property([out, retval] BSTR* pVal); 19 | [propput, id(1)] HRESULT Property([in] BSTR newVal); 20 | [id(2)] HRESULT MethodWithParametersAndReturnValue(BSTR stringParameter, INT integerParameter, [out, retval] BSTR* stringResult); 21 | [id(3)] HRESULT CallCallbackAsynchronously(IDispatch* callbackParameter); 22 | }; 23 | [ 24 | uuid(82003E2C-6641-4643-A5D6-11B8BB7497B8), 25 | version(1.0), 26 | ] 27 | library RemoteComObjectLib 28 | { 29 | importlib("stdole2.tlb"); 30 | [ 31 | uuid(3328FE46-65D4-431D-B356-E2FE2525C4B8) 32 | ] 33 | coclass RemoteComObjectImpl 34 | { 35 | [default] interface IRemoteComObjectImpl; 36 | }; 37 | }; 38 | 39 | -------------------------------------------------------------------------------- /Src/RemoteComObject/RemoteComObject.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michael-russin/webview2-control/d7de7403a7765eb50b0eda23dfa3656b049bd391/Src/RemoteComObject/RemoteComObject.rc -------------------------------------------------------------------------------- /Src/RemoteComObject/RemoteComObject.rgs: -------------------------------------------------------------------------------- 1 | HKCR 2 | { 3 | } 4 | -------------------------------------------------------------------------------- /Src/RemoteComObject/RemoteComObject.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.25420.1 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RemoteComObject", "RemoteComObject.vcxproj", "{DEA78F26-56AA-4E90-9017-14766742CE1F}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {DEA78F26-56AA-4E90-9017-14766742CE1F}.Debug|x64.ActiveCfg = Debug|x64 17 | {DEA78F26-56AA-4E90-9017-14766742CE1F}.Debug|x64.Build.0 = Debug|x64 18 | {DEA78F26-56AA-4E90-9017-14766742CE1F}.Debug|x86.ActiveCfg = Debug|Win32 19 | {DEA78F26-56AA-4E90-9017-14766742CE1F}.Debug|x86.Build.0 = Debug|Win32 20 | {DEA78F26-56AA-4E90-9017-14766742CE1F}.Release|x64.ActiveCfg = Release|x64 21 | {DEA78F26-56AA-4E90-9017-14766742CE1F}.Release|x64.Build.0 = Release|x64 22 | {DEA78F26-56AA-4E90-9017-14766742CE1F}.Release|x86.ActiveCfg = Release|Win32 23 | {DEA78F26-56AA-4E90-9017-14766742CE1F}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | EndGlobal 29 | -------------------------------------------------------------------------------- /Src/RemoteComObject/RemoteComObjectImpl.cpp: -------------------------------------------------------------------------------- 1 | // RemoteComObjectImpl.cpp : Implementation of CRemoteComObjectImpl 2 | 3 | #include "stdafx.h" 4 | #include "RemoteComObjectImpl.h" 5 | 6 | 7 | // CRemoteComObjectImpl 8 | 9 | 10 | 11 | STDMETHODIMP CRemoteComObjectImpl::get_Property(BSTR* pVal) 12 | { 13 | *pVal = SysAllocString(m_propertyValue.c_str()); 14 | return S_OK; 15 | } 16 | 17 | 18 | STDMETHODIMP CRemoteComObjectImpl::put_Property(BSTR newVal) 19 | { 20 | m_propertyValue = newVal; 21 | return S_OK; 22 | } 23 | 24 | 25 | STDMETHODIMP CRemoteComObjectImpl::MethodWithParametersAndReturnValue(BSTR stringParameter, INT integerParameter, BSTR* stringResult) 26 | { 27 | std::wstring result = L"MethodWithParametersAndReturnValue("; 28 | result += stringParameter; 29 | result += L", "; 30 | result += std::to_wstring(integerParameter); 31 | result += L") called."; 32 | *stringResult = SysAllocString(result.c_str()); 33 | return S_OK; 34 | } 35 | 36 | 37 | STDMETHODIMP CRemoteComObjectImpl::CallCallbackAsynchronously(IDispatch* callbackParameter) 38 | { 39 | wil::com_ptr callbackParameterForCapture = callbackParameter; 40 | 41 | auto release = std::async(std::launch::async, [callbackParameterForCapture] { 42 | callbackParameterForCapture->Invoke( 43 | DISPID_UNKNOWN, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, nullptr, nullptr, 44 | nullptr, nullptr); 45 | }); 46 | 47 | return S_OK; 48 | } 49 | -------------------------------------------------------------------------------- /Src/RemoteComObject/RemoteComObjectImpl.h: -------------------------------------------------------------------------------- 1 | // RemoteComObjectImpl.h : Declaration of the CRemoteComObjectImpl 2 | 3 | #pragma once 4 | #include "resource.h" // main symbols 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | #include "RemoteComObject_i.h" 11 | 12 | 13 | 14 | #if defined(_WIN32_WCE) && !defined(_CE_DCOM) && !defined(_CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA) 15 | #error "Single-threaded COM objects are not properly supported on Windows CE platform, such as the Windows Mobile platforms that do not include full DCOM support. Define _CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA to force ATL to support creating single-thread COM object's and allow use of it's single-threaded COM object implementations. The threading model in your rgs file was set to 'Free' as that is the only threading model supported in non DCOM Windows CE platforms." 16 | #endif 17 | 18 | using namespace ATL; 19 | 20 | 21 | // CRemoteComObjectImpl 22 | 23 | class ATL_NO_VTABLE CRemoteComObjectImpl : 24 | public CComObjectRootEx, 25 | public CComCoClass, 26 | public IDispatchImpl 27 | { 28 | public: 29 | CRemoteComObjectImpl() 30 | { 31 | m_propertyValue = L"Example Property String Value"; 32 | } 33 | 34 | DECLARE_REGISTRY_RESOURCEID(IDR_REMOTECOMOBJECTIMPL) 35 | 36 | 37 | BEGIN_COM_MAP(CRemoteComObjectImpl) 38 | COM_INTERFACE_ENTRY(IRemoteComObjectImpl) 39 | COM_INTERFACE_ENTRY(IDispatch) 40 | END_COM_MAP() 41 | 42 | 43 | 44 | DECLARE_PROTECT_FINAL_CONSTRUCT() 45 | 46 | HRESULT FinalConstruct() 47 | { 48 | return S_OK; 49 | } 50 | 51 | void FinalRelease() 52 | { 53 | } 54 | 55 | public: 56 | 57 | 58 | 59 | STDMETHOD(get_Property)(BSTR* pVal); 60 | STDMETHOD(put_Property)(BSTR newVal); 61 | STDMETHOD(MethodWithParametersAndReturnValue)(BSTR stringParameter, INT integerParameter, BSTR* stringResult); 62 | STDMETHOD(CallCallbackAsynchronously)(IDispatch* callbackParameter); 63 | 64 | private: 65 | std::wstring m_propertyValue; 66 | wil::com_ptr m_callback; 67 | wil::com_ptr m_typeLib; 68 | }; 69 | 70 | OBJECT_ENTRY_AUTO(__uuidof(RemoteComObjectImpl), CRemoteComObjectImpl) 71 | -------------------------------------------------------------------------------- /Src/RemoteComObject/RemoteComObjectImpl.rgs: -------------------------------------------------------------------------------- 1 | HKCR 2 | { 3 | RemoteComObjectImpl.1 = s 'RemoteComObjectImpl Class' 4 | { 5 | CLSID = s '{3328FE46-65D4-431D-B356-E2FE2525C4B8}' 6 | } 7 | RemoteComObjectImpl = s 'RemoteComObjectImpl Class' 8 | { 9 | CurVer = s 'RemoteComObjectImpl.1' 10 | } 11 | NoRemove CLSID 12 | { 13 | ForceRemove {3328FE46-65D4-431D-B356-E2FE2525C4B8} = s 'RemoteComObjectImpl Class' 14 | { 15 | ProgID = s 'RemoteComObjectImpl.1' 16 | VersionIndependentProgID = s 'RemoteComObjectImpl' 17 | ForceRemove Programmable 18 | InprocServer32 = s '%MODULE%' 19 | { 20 | val ThreadingModel = s 'Apartment' 21 | } 22 | TypeLib = s '{82003E2C-6641-4643-A5D6-11B8BB7497B8}' 23 | Version = s '1.0' 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Src/RemoteComObject/dllmain.cpp: -------------------------------------------------------------------------------- 1 | // dllmain.cpp : Implementation of DllMain. 2 | 3 | #include "stdafx.h" 4 | #include "resource.h" 5 | #include "RemoteComObject_i.h" 6 | #include "dllmain.h" 7 | #include "xdlldata.h" 8 | 9 | CRemoteComObjectModule _AtlModule; 10 | 11 | // DLL Entry Point 12 | extern "C" BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved) 13 | { 14 | #ifdef _MERGE_PROXYSTUB 15 | if (!PrxDllMain(hInstance, dwReason, lpReserved)) 16 | return FALSE; 17 | #endif 18 | hInstance; 19 | return _AtlModule.DllMain(dwReason, lpReserved); 20 | } 21 | -------------------------------------------------------------------------------- /Src/RemoteComObject/dllmain.h: -------------------------------------------------------------------------------- 1 | // dllmain.h : Declaration of module class. 2 | 3 | class CRemoteComObjectModule : public ATL::CAtlDllModuleT< CRemoteComObjectModule > 4 | { 5 | public : 6 | DECLARE_LIBID(LIBID_RemoteComObjectLib) 7 | DECLARE_REGISTRY_APPID_RESOURCEID(IDR_REMOTECOMOBJECT, "{55589A99-0146-4AA4-BEB2-5013185E5772}") 8 | }; 9 | 10 | extern class CRemoteComObjectModule _AtlModule; 11 | -------------------------------------------------------------------------------- /Src/RemoteComObject/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /Src/RemoteComObject/resource.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michael-russin/webview2-control/d7de7403a7765eb50b0eda23dfa3656b049bd391/Src/RemoteComObject/resource.h -------------------------------------------------------------------------------- /Src/RemoteComObject/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // RemoteComObject.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | -------------------------------------------------------------------------------- /Src/RemoteComObject/stdafx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, 3 | // but are changed infrequently 4 | 5 | #pragma once 6 | 7 | #ifndef STRICT 8 | #define STRICT 9 | #endif 10 | 11 | #include "targetver.h" 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | #define _ATL_APARTMENT_THREADED 21 | 22 | #define _ATL_NO_AUTOMATIC_NAMESPACE 23 | 24 | #define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit 25 | 26 | 27 | #define ATL_NO_ASSERT_ON_DESTROY_NONEXISTENT_WINDOW 28 | 29 | #include "resource.h" 30 | #include 31 | #include 32 | #include 33 | -------------------------------------------------------------------------------- /Src/RemoteComObject/targetver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Including SDKDDKVer.h defines the highest available Windows platform. 4 | 5 | // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and 6 | // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. 7 | 8 | #include 9 | -------------------------------------------------------------------------------- /Src/RemoteComObject/xdlldata.c: -------------------------------------------------------------------------------- 1 | // wrapper for dlldata.c 2 | 3 | #ifdef _MERGE_PROXYSTUB // merge proxy stub DLL 4 | 5 | #define REGISTER_PROXY_DLL //DllRegisterServer, etc. 6 | 7 | #define _WIN32_WINNT 0x0500 //for WinNT 4.0 or Win95 with DCOM 8 | #define USE_STUBLESS_PROXY //defined only with MIDL switch /Oicf 9 | 10 | #pragma comment(lib, "rpcns4.lib") 11 | #pragma comment(lib, "rpcrt4.lib") 12 | 13 | #define ENTRY_PREFIX Prx 14 | 15 | #include "dlldata.c" 16 | #include "RemoteComObject_p.c" 17 | 18 | #endif //_MERGE_PROXYSTUB 19 | -------------------------------------------------------------------------------- /Src/RemoteComObject/xdlldata.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifdef _MERGE_PROXYSTUB 4 | 5 | extern "C" 6 | { 7 | BOOL WINAPI PrxDllMain(HINSTANCE hInstance, DWORD dwReason, 8 | LPVOID lpReserved); 9 | STDAPI PrxDllCanUnloadNow(void); 10 | STDAPI PrxDllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv); 11 | STDAPI PrxDllRegisterServer(void); 12 | STDAPI PrxDllUnregisterServer(void); 13 | } 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /Src/WebView2.WinForms.Demo/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Src/WebView2.WinForms.Demo/Constants.cs: -------------------------------------------------------------------------------- 1 |  2 | 3 | namespace MtrDev.WebView2.WinForms.Demo 4 | { 5 | public enum Messages : int 6 | { 7 | MG_NAVIGATE=1, 8 | MG_UPDATE_URI=2, 9 | MG_GO_FORWARD=3, 10 | MG_GO_BACK=4, 11 | MG_NAV_STARTING=5, 12 | MG_NAV_COMPLETED=6, 13 | MG_RELOAD=7, 14 | MG_CANCEL=8, 15 | MG_CREATE_TAB=10, 16 | MG_UPDATE_TAB=11, 17 | MG_SWITCH_TAB=12, 18 | MG_CLOSE_TAB=13, 19 | MG_CLOSE_WINDOW=14, 20 | MG_SHOW_OPTIONS=15, 21 | MG_HIDE_OPTIONS=16, 22 | MG_OPTIONS_LOST_FOCUS=17, 23 | MG_OPTION_SELECTED=18, 24 | MG_SECURITY_UPDATE=19, 25 | MG_UPDATE_FAVICON=20, 26 | MG_GET_SETTINGS=21, 27 | MG_GET_FAVORITES=22, 28 | MG_REMOVE_FAVORITE=23, 29 | MG_CLEAR_CACHE=24, 30 | MG_CLEAR_COOKIES=25, 31 | MG_GET_HISTORY=26, 32 | MG_REMOVE_HISTORY_ITEM=27, 33 | MG_CLEAR_HISTORY=28, 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Src/WebView2.WinForms.Demo/Content/commands.js: -------------------------------------------------------------------------------- 1 | const commands = { 2 | MG_NAVIGATE: 1, 3 | MG_UPDATE_URI: 2, 4 | MG_GO_FORWARD: 3, 5 | MG_GO_BACK: 4, 6 | MG_NAV_STARTING: 5, 7 | MG_NAV_COMPLETED: 6, 8 | MG_RELOAD: 7, 9 | MG_CANCEL: 8, 10 | MG_CREATE_TAB: 10, 11 | MG_UPDATE_TAB: 11, 12 | MG_SWITCH_TAB: 12, 13 | MG_CLOSE_TAB: 13, 14 | MG_CLOSE_WINDOW: 14, 15 | MG_SHOW_OPTIONS: 15, 16 | MG_HIDE_OPTIONS: 16, 17 | MG_OPTIONS_LOST_FOCUS: 17, 18 | MG_OPTION_SELECTED: 18, 19 | MG_SECURITY_UPDATE: 19, 20 | MG_UPDATE_FAVICON: 20, 21 | MG_GET_SETTINGS: 21, 22 | MG_GET_FAVORITES: 22, 23 | MG_REMOVE_FAVORITE: 23, 24 | MG_CLEAR_CACHE: 24, 25 | MG_CLEAR_COOKIES: 25, 26 | MG_GET_HISTORY: 26, 27 | MG_REMOVE_HISTORY_ITEM: 27, 28 | MG_CLEAR_HISTORY: 28 29 | }; 30 | -------------------------------------------------------------------------------- /Src/WebView2.WinForms.Demo/Content/content_ui/favorites.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Favorites 4 | 5 | 6 | 7 | 8 | 9 |

Favorites

10 |
11 | You don't have any favorites. 12 |
13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /Src/WebView2.WinForms.Demo/Content/content_ui/history.css: -------------------------------------------------------------------------------- 1 | .header-date { 2 | font-weight: 400; 3 | font-size: 14px; 4 | color: rgb(16, 16, 16); 5 | line-height: 20px; 6 | padding-top: 10px; 7 | padding-bottom: 4px; 8 | margin: 0; 9 | } 10 | 11 | #btn-clear { 12 | font-size: 14px; 13 | color: rgb(0, 97, 171); 14 | cursor: pointer; 15 | line-height: 20px; 16 | } 17 | 18 | #btn-clear.hidden { 19 | display: none; 20 | } 21 | 22 | #overlay { 23 | position: fixed; 24 | top: 0; 25 | left: 0; 26 | height: 100%; 27 | width: 100%; 28 | background-color: rgba(0, 0, 0, 0.2); 29 | } 30 | 31 | #overlay.hidden { 32 | display: none; 33 | } 34 | 35 | #prompt-box { 36 | display: flex; 37 | box-sizing: border-box; 38 | flex-direction: column; 39 | position: fixed; 40 | left: calc(50% - 130px); 41 | top: calc(50% - 70px); 42 | width: 260px; 43 | height: 140px; 44 | padding: 20px; 45 | border-radius: 5px; 46 | background-color: white; 47 | 48 | box-shadow: rgba(0, 0, 0, 0.13) 0px 1.6px 20px, rgba(0, 0, 0, 0.11) 0px 0.3px 10px; 49 | } 50 | 51 | #prompt-options { 52 | flex: 1; 53 | display: flex; 54 | justify-content: flex-end; 55 | 56 | user-select: none; 57 | } 58 | 59 | .prompt-btn { 60 | flex: 1; 61 | flex-grow: 0; 62 | align-self: flex-end; 63 | cursor: pointer; 64 | font-family: 'system-ui', sans-serif; 65 | display: inline-block; 66 | padding: 2px 7px; 67 | font-size: 14px; 68 | line-height: 20px; 69 | border-radius: 3px; 70 | font-weight: 400; 71 | } 72 | 73 | #prompt-true { 74 | background-color: rgb(0, 112, 198); 75 | color: white; 76 | } 77 | 78 | #prompt-false { 79 | background-color: rgb(210, 210, 210); 80 | margin-right: 5px; 81 | } 82 | -------------------------------------------------------------------------------- /Src/WebView2.WinForms.Demo/Content/content_ui/history.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | History 4 | 5 | 6 | 7 | 8 | 9 | 10 | 19 |

History

20 |
21 | 22 |
23 |
24 | Loading... 25 |
26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /Src/WebView2.WinForms.Demo/Content/content_ui/img/close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michael-russin/webview2-control/d7de7403a7765eb50b0eda23dfa3656b049bd391/Src/WebView2.WinForms.Demo/Content/content_ui/img/close.png -------------------------------------------------------------------------------- /Src/WebView2.WinForms.Demo/Content/content_ui/img/favorites.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michael-russin/webview2-control/d7de7403a7765eb50b0eda23dfa3656b049bd391/Src/WebView2.WinForms.Demo/Content/content_ui/img/favorites.png -------------------------------------------------------------------------------- /Src/WebView2.WinForms.Demo/Content/content_ui/img/history.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michael-russin/webview2-control/d7de7403a7765eb50b0eda23dfa3656b049bd391/Src/WebView2.WinForms.Demo/Content/content_ui/img/history.png -------------------------------------------------------------------------------- /Src/WebView2.WinForms.Demo/Content/content_ui/img/settings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michael-russin/webview2-control/d7de7403a7765eb50b0eda23dfa3656b049bd391/Src/WebView2.WinForms.Demo/Content/content_ui/img/settings.png -------------------------------------------------------------------------------- /Src/WebView2.WinForms.Demo/Content/content_ui/items.css: -------------------------------------------------------------------------------- 1 | .item-container { 2 | box-sizing: border-box; 3 | padding: 4px 0; 4 | height: 48px; 5 | } 6 | 7 | .item { 8 | display: flex; 9 | width: 100%; 10 | max-width: 820px; 11 | height: 40px; 12 | width: 100%; 13 | border-radius: 4px; 14 | box-sizing: border-box; 15 | box-shadow: rgba(0, 0, 0, 0.13) 0px 1.6px 3.6px, rgba(0, 0, 0, 0.11) 0px 0.3px 0.9px; 16 | align-items: center; 17 | background: rgb(255, 255, 255); 18 | } 19 | 20 | .item:hover { 21 | box-shadow: 0px 4.8px 10.8px rgba(0,0,0,0.13), 0px 0.9px 2.7px rgba(0,0,0,0.11); 22 | } 23 | 24 | .favicon { 25 | display: flex; 26 | height: 40px; 27 | width: 40px; 28 | justify-content: center; 29 | align-items: center; 30 | } 31 | 32 | .favicon img { 33 | width: 16px; 34 | height: 16px; 35 | } 36 | 37 | .label-title, .label-uri { 38 | display: flex; 39 | flex: 1; 40 | min-width: 0; 41 | height: 40px; 42 | align-items: center; 43 | } 44 | 45 | .label-title a { 46 | cursor: pointer; 47 | display: inline-block; 48 | white-space: nowrap; 49 | text-overflow: ellipsis; 50 | font-weight: 600; 51 | font-size: 12px; 52 | line-height: 16px; 53 | color: rgb(16, 16, 16); 54 | border-width: initial; 55 | border-style: none; 56 | border-color: initial; 57 | border-image: initial; 58 | overflow: hidden; 59 | background: none; 60 | text-decoration: none; 61 | } 62 | 63 | .label-title a:hover { 64 | text-decoration: underline; 65 | } 66 | 67 | .label-uri, .label-time { 68 | margin: 0 6px; 69 | line-height: 16px; 70 | font-size: 12px; 71 | color: rgb(115, 115, 115); 72 | } 73 | 74 | .label-uri p, .label-time p { 75 | display: block; 76 | white-space: nowrap; 77 | overflow: hidden; 78 | text-overflow: ellipsis; 79 | } 80 | 81 | .btn-close { 82 | height: 28px; 83 | width: 28px; 84 | margin: 6px; 85 | border-radius: 2px; 86 | background-image: url('img/close.png'); 87 | background-size: 100%; 88 | } 89 | 90 | .btn-close:hover { 91 | background-color: rgb(243, 243, 243); 92 | } 93 | -------------------------------------------------------------------------------- /Src/WebView2.WinForms.Demo/Content/content_ui/settings.css: -------------------------------------------------------------------------------- 1 | .settings-entry { 2 | display: block; 3 | height: 48px; 4 | width: 100%; 5 | max-width: 500px; 6 | 7 | background: none; 8 | border: none; 9 | padding: 4px 0; 10 | font: inherit; 11 | cursor: pointer; 12 | } 13 | 14 | #entry-script, #entry-popups { 15 | display: none; 16 | } 17 | 18 | .entry { 19 | display: block; 20 | height: 100%; 21 | text-align: left; 22 | border-radius: 5px; 23 | } 24 | 25 | .entry:hover { 26 | background-color: rgb(220, 220, 220); 27 | } 28 | 29 | .entry:focus { 30 | outline: none; 31 | } 32 | 33 | .entry-name, .entry-value { 34 | display: inline-flex; 35 | height: 100%; 36 | vertical-align: middle; 37 | } 38 | 39 | .entry-name span, .entry-value span { 40 | flex: 1; 41 | align-self: center; 42 | } 43 | 44 | .entry-name { 45 | padding-left: 10px; 46 | } 47 | 48 | .entry-value { 49 | float: right; 50 | vertical-align: middle; 51 | margin: 0 15px; 52 | font-size: 0.8em; 53 | color: gray; 54 | } 55 | -------------------------------------------------------------------------------- /Src/WebView2.WinForms.Demo/Content/content_ui/settings.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Settings 4 | 5 | 6 | 7 | 8 | 9 |

Settings

10 |
11 | 21 | 31 | 41 | 51 |
52 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /Src/WebView2.WinForms.Demo/Content/content_ui/styles.css: -------------------------------------------------------------------------------- 1 | html, body { 2 | margin: 0; 3 | border: none; 4 | padding: 0; 5 | 6 | font-family: Arial, Helvetica, sans-serif; 7 | background-color: rgb(240, 240, 242); 8 | } 9 | 10 | p { 11 | margin: 0; 12 | } 13 | 14 | body { 15 | padding: 32px 50px; 16 | font-family: 'system-ui', sans-serif; 17 | } 18 | 19 | .main-title { 20 | display: block; 21 | margin-bottom: 18px; 22 | font-size: 24px; 23 | font-weight: 600; 24 | color: rgb(16, 16, 16); 25 | } 26 | -------------------------------------------------------------------------------- /Src/WebView2.WinForms.Demo/Content/controls_ui/controls.css: -------------------------------------------------------------------------------- 1 | #controls-bar { 2 | display: flex; 3 | justify-content: space-between; 4 | flex-direction: row; 5 | height: 40px; 6 | background-color: rgb(230, 230, 230); 7 | } 8 | 9 | .btn, .btn-disabled, .btn-cancel, .btn-active { 10 | display: inline-block; 11 | border: none; 12 | margin: 5px 0; 13 | border-radius: 5px; 14 | outline: none; 15 | height: 30px; 16 | width: 30px; 17 | 18 | background-size: 100%; 19 | } 20 | 21 | #btn-forward { 22 | background-image: url('img/goForward.png'); 23 | } 24 | 25 | .btn-disabled#btn-forward { 26 | background-image: url('img/goForward_disabled.png'); 27 | } 28 | 29 | #btn-back { 30 | background-image: url('img/goBack.png'); 31 | } 32 | 33 | .btn-disabled#btn-back { 34 | background-image: url('img/goBack_disabled.png'); 35 | } 36 | 37 | #btn-reload { 38 | background-image: url('img/reload.png'); 39 | } 40 | 41 | .btn-cancel#btn-reload { 42 | background-image: url('img/cancel.png'); 43 | } 44 | 45 | #btn-options { 46 | background-image: url('img/options.png'); 47 | } 48 | 49 | .controls-group { 50 | display: inline-block; 51 | height: 40px; 52 | } 53 | 54 | #nav-controls-container { 55 | align-self: flex-start; 56 | padding-left: 10px; 57 | } 58 | 59 | #manage-controls-container { 60 | align-self: flex-end; 61 | padding-right: 10px; 62 | } 63 | 64 | .btn:hover, .btn-cancel:hover, .btn-active { 65 | background-color: rgb(200, 200, 200); 66 | } 67 | -------------------------------------------------------------------------------- /Src/WebView2.WinForms.Demo/Content/controls_ui/default.css: -------------------------------------------------------------------------------- 1 | html, body { 2 | height: 70px; 3 | } 4 | -------------------------------------------------------------------------------- /Src/WebView2.WinForms.Demo/Content/controls_ui/default.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /Src/WebView2.WinForms.Demo/Content/controls_ui/favorites.js: -------------------------------------------------------------------------------- 1 | function isFavorite(uri, callback) { 2 | queryDB((db) => { 3 | let transaction = db.transaction(['favorites']); 4 | let favoritesStore = transaction.objectStore('favorites'); 5 | let favoriteStatusRequest = favoritesStore.get(uri); 6 | 7 | favoriteStatusRequest.onerror = function(event) { 8 | console.log(`Could not query for ${uri}: ${event.target.error.message}`); 9 | }; 10 | 11 | favoriteStatusRequest.onsuccess = function() { 12 | callback(favoriteStatusRequest.result); 13 | }; 14 | }); 15 | } 16 | 17 | function addFavorite(favorite, callback) { 18 | queryDB((db) => { 19 | let transaction = db.transaction(['favorites'], 'readwrite'); 20 | let favoritesStore = transaction.objectStore('favorites'); 21 | let addFavoriteRequest = favoritesStore.add(favorite); 22 | 23 | addFavoriteRequest.onerror = function(event) { 24 | console.log(`Could not add favorite with key: ${favorite.uri}`); 25 | console.log(event.target.error.message); 26 | }; 27 | 28 | addFavoriteRequest.onsuccess = function(event) { 29 | if (callback) { 30 | callback(); 31 | } 32 | }; 33 | }); 34 | } 35 | 36 | function removeFavorite(key, callback) { 37 | queryDB((db) => { 38 | let transaction = db.transaction(['favorites'], 'readwrite'); 39 | let favoritesStore = transaction.objectStore('favorites'); 40 | let removeFavoriteRequest = favoritesStore.delete(key); 41 | 42 | removeFavoriteRequest.onerror = function(event) { 43 | console.log(`Could not remove favorite with key: ${key}`); 44 | console.log(event.target.error.message); 45 | }; 46 | 47 | removeFavoriteRequest.onsuccess = function(event) { 48 | if (callback) { 49 | callback(); 50 | } 51 | }; 52 | }); 53 | } 54 | 55 | function getFavoritesAsJson(callback) { 56 | queryDB((db) => { 57 | let transaction = db.transaction(['favorites']); 58 | let favoritesStore = transaction.objectStore('favorites'); 59 | let getFavoritesRequest = favoritesStore.getAll(); 60 | 61 | getFavoritesRequest.onerror = function(event) { 62 | console.log(`Could retrieve favorites`); 63 | console.log(event.target.error.message); 64 | }; 65 | 66 | getFavoritesRequest.onsuccess = function(event) { 67 | if (callback) { 68 | callback(getFavoritesRequest.result); 69 | } 70 | }; 71 | }); 72 | } 73 | -------------------------------------------------------------------------------- /Src/WebView2.WinForms.Demo/Content/controls_ui/img/cancel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michael-russin/webview2-control/d7de7403a7765eb50b0eda23dfa3656b049bd391/Src/WebView2.WinForms.Demo/Content/controls_ui/img/cancel.png -------------------------------------------------------------------------------- /Src/WebView2.WinForms.Demo/Content/controls_ui/img/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michael-russin/webview2-control/d7de7403a7765eb50b0eda23dfa3656b049bd391/Src/WebView2.WinForms.Demo/Content/controls_ui/img/favicon.png -------------------------------------------------------------------------------- /Src/WebView2.WinForms.Demo/Content/controls_ui/img/favorite.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michael-russin/webview2-control/d7de7403a7765eb50b0eda23dfa3656b049bd391/Src/WebView2.WinForms.Demo/Content/controls_ui/img/favorite.png -------------------------------------------------------------------------------- /Src/WebView2.WinForms.Demo/Content/controls_ui/img/favorited.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michael-russin/webview2-control/d7de7403a7765eb50b0eda23dfa3656b049bd391/Src/WebView2.WinForms.Demo/Content/controls_ui/img/favorited.png -------------------------------------------------------------------------------- /Src/WebView2.WinForms.Demo/Content/controls_ui/img/goBack.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michael-russin/webview2-control/d7de7403a7765eb50b0eda23dfa3656b049bd391/Src/WebView2.WinForms.Demo/Content/controls_ui/img/goBack.png -------------------------------------------------------------------------------- /Src/WebView2.WinForms.Demo/Content/controls_ui/img/goBack_disabled.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michael-russin/webview2-control/d7de7403a7765eb50b0eda23dfa3656b049bd391/Src/WebView2.WinForms.Demo/Content/controls_ui/img/goBack_disabled.png -------------------------------------------------------------------------------- /Src/WebView2.WinForms.Demo/Content/controls_ui/img/goForward.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michael-russin/webview2-control/d7de7403a7765eb50b0eda23dfa3656b049bd391/Src/WebView2.WinForms.Demo/Content/controls_ui/img/goForward.png -------------------------------------------------------------------------------- /Src/WebView2.WinForms.Demo/Content/controls_ui/img/goForward_disabled.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michael-russin/webview2-control/d7de7403a7765eb50b0eda23dfa3656b049bd391/Src/WebView2.WinForms.Demo/Content/controls_ui/img/goForward_disabled.png -------------------------------------------------------------------------------- /Src/WebView2.WinForms.Demo/Content/controls_ui/img/insecure.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michael-russin/webview2-control/d7de7403a7765eb50b0eda23dfa3656b049bd391/Src/WebView2.WinForms.Demo/Content/controls_ui/img/insecure.png -------------------------------------------------------------------------------- /Src/WebView2.WinForms.Demo/Content/controls_ui/img/neutral.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michael-russin/webview2-control/d7de7403a7765eb50b0eda23dfa3656b049bd391/Src/WebView2.WinForms.Demo/Content/controls_ui/img/neutral.png -------------------------------------------------------------------------------- /Src/WebView2.WinForms.Demo/Content/controls_ui/img/options.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michael-russin/webview2-control/d7de7403a7765eb50b0eda23dfa3656b049bd391/Src/WebView2.WinForms.Demo/Content/controls_ui/img/options.png -------------------------------------------------------------------------------- /Src/WebView2.WinForms.Demo/Content/controls_ui/img/reload.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michael-russin/webview2-control/d7de7403a7765eb50b0eda23dfa3656b049bd391/Src/WebView2.WinForms.Demo/Content/controls_ui/img/reload.png -------------------------------------------------------------------------------- /Src/WebView2.WinForms.Demo/Content/controls_ui/img/secure.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michael-russin/webview2-control/d7de7403a7765eb50b0eda23dfa3656b049bd391/Src/WebView2.WinForms.Demo/Content/controls_ui/img/secure.png -------------------------------------------------------------------------------- /Src/WebView2.WinForms.Demo/Content/controls_ui/img/unknown.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michael-russin/webview2-control/d7de7403a7765eb50b0eda23dfa3656b049bd391/Src/WebView2.WinForms.Demo/Content/controls_ui/img/unknown.png -------------------------------------------------------------------------------- /Src/WebView2.WinForms.Demo/Content/controls_ui/options.css: -------------------------------------------------------------------------------- 1 | html, body { 2 | width: 200px; 3 | height: 107px; 4 | } 5 | 6 | #dropdown-wrapper { 7 | width: calc(100% - 2px); 8 | height: calc(100% - 2px); 9 | border: 1px solid gray; 10 | } 11 | 12 | .dropdown-item { 13 | background-color: rgb(240, 240, 240); 14 | } 15 | 16 | .dropdown-item:hover { 17 | background-color: rgb(220, 220, 220); 18 | } 19 | 20 | .item-label { 21 | display: flex; 22 | height: 35px; 23 | text-align: center; 24 | vertical-align: middle; 25 | 26 | white-space: nowrap; 27 | overflow: hidden; 28 | } 29 | 30 | .item-label span { 31 | font-family: Arial; 32 | font-size: 0.8em; 33 | vertical-align: middle; 34 | flex: 1; 35 | align-self: center; 36 | text-align: left; 37 | padding-left: 10px; 38 | } 39 | -------------------------------------------------------------------------------- /Src/WebView2.WinForms.Demo/Content/controls_ui/options.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /Src/WebView2.WinForms.Demo/Content/controls_ui/options.js: -------------------------------------------------------------------------------- 1 | function navigateToBrowserPage(path) { 2 | const navMessage = { 3 | message: commands.MG_NAVIGATE, 4 | args: { 5 | uri: `browser://${path}` 6 | } 7 | }; 8 | 9 | window.chrome.webview.postMessage(navMessage); 10 | } 11 | 12 | // Add listener for the options menu entries 13 | function addItemsListeners() { 14 | 15 | // Close dropdown when item is selected 16 | (() => { 17 | const dropdownItems = Array.from(document.getElementsByClassName('dropdown-item')); 18 | dropdownItems.map(item => { 19 | item.addEventListener('click', function(e) { 20 | const closeMessage = { 21 | message: commands.MG_OPTION_SELECTED, 22 | args: {} 23 | }; 24 | window.chrome.webview.postMessage(closeMessage); 25 | }); 26 | 27 | // Navigate to browser page 28 | let entry = item.id.split('-')[1]; 29 | switch (entry) { 30 | case 'settings': 31 | case 'history': 32 | case 'favorites': 33 | item.addEventListener('click', function(e) { 34 | navigateToBrowserPage(entry); 35 | }); 36 | break; 37 | } 38 | }); 39 | })(); 40 | } 41 | 42 | function init() { 43 | addItemsListeners(); 44 | } 45 | 46 | init(); 47 | -------------------------------------------------------------------------------- /Src/WebView2.WinForms.Demo/Content/controls_ui/storage.js: -------------------------------------------------------------------------------- 1 | function handleUpgradeEvent(event) { 2 | console.log('Creating DB'); 3 | let newDB = event.target.result; 4 | 5 | newDB.onerror = function(event) { 6 | console.log('Something went wrong'); 7 | console.log(event); 8 | }; 9 | 10 | let newFavoritesStore = newDB.createObjectStore('favorites', { 11 | keyPath: 'uri' 12 | }); 13 | 14 | newFavoritesStore.transaction.oncomplete = function(event) { 15 | console.log('Object stores created'); 16 | }; 17 | 18 | let newHistoryStore = newDB.createObjectStore('history', { 19 | autoIncrement: true 20 | }); 21 | 22 | newHistoryStore.createIndex('timestamp', 'timestamp', { 23 | unique: false 24 | }); 25 | 26 | newHistoryStore.createIndex('stampedURI', ['uri', 'timestamp'], { 27 | unique: false 28 | }); 29 | } 30 | 31 | function queryDB(query) { 32 | let request = window.indexedDB.open('WVBrowser'); 33 | 34 | request.onerror = function(event) { 35 | console.log('Failed to open database'); 36 | }; 37 | 38 | request.onsuccess = function(event) { 39 | let db = event.target.result; 40 | query(db); 41 | }; 42 | 43 | request.onupgradeneeded = handleUpgradeEvent; 44 | } 45 | -------------------------------------------------------------------------------- /Src/WebView2.WinForms.Demo/Content/controls_ui/strip.css: -------------------------------------------------------------------------------- 1 | #tabs-strip { 2 | display: flex; 3 | height: 28px; 4 | 5 | border-top: 1px solid rgb(200, 200, 200); 6 | border-bottom: 1px solid rgb(200, 200, 200); 7 | background-color: rgb(230, 230, 230); 8 | } 9 | 10 | .tab, .tab-active { 11 | display: flex; 12 | flex: 1; 13 | height: 100%; 14 | border-right: 1px solid rgb(200, 200, 200); 15 | overflow: hidden; 16 | max-width: 250px; 17 | } 18 | 19 | .tab-active { 20 | background-color: rgb(240, 240, 240); 21 | } 22 | 23 | #btn-new-tab { 24 | display: flex; 25 | height: 100%; 26 | width: 30px; 27 | } 28 | 29 | #btn-new-tab:hover, .btn-tab-close:hover { 30 | background-color: rgb(200, 200, 200); 31 | } 32 | 33 | #plus-label { 34 | display: block; 35 | flex: 1; 36 | align-self: center; 37 | line-height: 30px; 38 | width: 30px; 39 | text-align: center; 40 | } 41 | 42 | .btn-tab-close { 43 | display: inline-block; 44 | align-self: center; 45 | min-width: 16px; 46 | width: 16px; 47 | height: 16px; 48 | margin: 0 5px; 49 | border-radius: 4px; 50 | 51 | background-size: 100%; 52 | background-image: url('img/cancel.png'); 53 | } 54 | 55 | .tab-label { 56 | display: flex; 57 | flex: 1; 58 | padding: 5px; 59 | padding-left: 10px; 60 | height: calc(100% - 10px); 61 | vertical-align: middle; 62 | 63 | white-space:nowrap; 64 | overflow:hidden; 65 | } 66 | 67 | .tab-label span { 68 | font-family: Arial; 69 | font-size: 0.8em; 70 | flex: 1; 71 | align-self: center; 72 | } 73 | -------------------------------------------------------------------------------- /Src/WebView2.WinForms.Demo/Content/controls_ui/styles.css: -------------------------------------------------------------------------------- 1 | html, body { 2 | margin: 0; 3 | border: none; 4 | padding: 0; 5 | } 6 | 7 | p { 8 | margin: 0; 9 | } 10 | 11 | * { 12 | user-select: none; 13 | } 14 | -------------------------------------------------------------------------------- /Src/WebView2.WinForms.Demo/PopupForm.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace MtrDev.WebView2.WinForms.Demo 2 | { 3 | partial class PopupForm 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(PopupForm)); 32 | this.SuspendLayout(); 33 | // 34 | // PopupForm 35 | // 36 | this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); 37 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 38 | this.ClientSize = new System.Drawing.Size(800, 450); 39 | this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); 40 | this.Name = "PopupForm"; 41 | this.Text = "Popup"; 42 | this.Load += new System.EventHandler(this.PopupForm_Load); 43 | this.ResumeLayout(false); 44 | 45 | } 46 | 47 | #endregion 48 | } 49 | } -------------------------------------------------------------------------------- /Src/WebView2.WinForms.Demo/PopupForm.cs: -------------------------------------------------------------------------------- 1 | using MtrDev.WebView2.Interop; 2 | using MtrDev.WebView2.Winforms; 3 | using MtrDev.WebView2.Wrapper; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.ComponentModel; 7 | using System.Data; 8 | using System.Drawing; 9 | using System.Linq; 10 | using System.Text; 11 | using System.Threading.Tasks; 12 | using System.Windows.Forms; 13 | 14 | namespace MtrDev.WebView2.WinForms.Demo 15 | { 16 | public partial class PopupForm : Form 17 | { 18 | private WebView2Control _childWebView; 19 | private WebView2Environment _environment; 20 | private NewWindowRequestedEventArgs _args; 21 | private IWebView2Deferral _deferral; 22 | 23 | public PopupForm() 24 | { 25 | InitializeComponent(); 26 | } 27 | 28 | public PopupForm(WebView2Environment environment, NewWindowRequestedEventArgs args) 29 | { 30 | // Save the environment so we can create the webview 31 | _environment = environment; 32 | _args = args; 33 | 34 | // Get a deferral since we have to wait for the window creation to finish 35 | _deferral = _args.GetDeferral(); 36 | InitializeComponent(); 37 | } 38 | 39 | private void PopupForm_Load(object sender, EventArgs e) 40 | { 41 | // Start the webview2 creation 42 | _childWebView = new WebView2Control(_environment); 43 | _childWebView.BrowserCreated += _childWebView_BrowserCreated; 44 | _childWebView.DocumentTitleChanged += _childWebView_DocumentTitleChanged; 45 | _childWebView.Dock = DockStyle.Fill; 46 | Controls.Add(_childWebView); 47 | } 48 | 49 | private void _childWebView_DocumentTitleChanged(object sender, DocumentTitleChangedEventArgs e) 50 | { 51 | Text = string.Format("Popup {0}", _childWebView.DocumentTitle); 52 | } 53 | 54 | private void _childWebView_BrowserCreated(object sender, EventArgs e) 55 | { 56 | 57 | IWebView2WebView wv = null; 58 | wv = (IWebView2WebView)_childWebView.InnerWebView2WebView; 59 | _args.NewWindow = wv; 60 | _args.Handled = true; 61 | _deferral.Complete(); 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /Src/WebView2.WinForms.Demo/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using System.Windows.Forms; 6 | using static MtrDev.WebView2.WinForms.Demo.SafeNativeMethods; 7 | 8 | namespace MtrDev.WebView2.WinForms.Demo 9 | { 10 | static class Program 11 | { 12 | /// 13 | /// The main entry point for the application. 14 | /// 15 | [STAThread] 16 | static void Main() 17 | { 18 | SetProcessDpiAwarenessContext(DpiAwarenessContext.PER_MONITOR_AWARE_V2); 19 | Application.EnableVisualStyles(); 20 | Application.SetCompatibleTextRenderingDefault(false); 21 | Application.Run(new WebView2Browser()); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Src/WebView2.WinForms.Demo/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("WinForms.WebView2.Demo")] 9 | [assembly: AssemblyDescription("Demo for WinForms WebView2 Control")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("MtrDev")] 12 | [assembly: AssemblyProduct("WebView2Sharp.Demo.WinForms")] 13 | [assembly: AssemblyCopyright("Copyright © 2019")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("6b529903-1191-450f-bf2c-bd001ecc221f")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.2")] 36 | [assembly: AssemblyFileVersion("1.0.0.2")] 37 | -------------------------------------------------------------------------------- /Src/WebView2.WinForms.Demo/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace MtrDev.WebView2.WinForms.Demo.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.3.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Src/WebView2.WinForms.Demo/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Src/WebView2.WinForms.Demo/SafeNativeMethods.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Runtime.InteropServices; 5 | using System.Security; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace MtrDev.WebView2.WinForms.Demo 10 | { 11 | [SuppressUnmanagedCodeSecurity] 12 | internal static class SafeNativeMethods 13 | { 14 | public static class DpiAwarenessContext 15 | { 16 | public const int UNAWARE = -1; 17 | public const int SYSTEM_AWARE = -2; 18 | public const int PER_MONITOR_AWARE = -3; 19 | public const int PER_MONITOR_AWARE_V2 = -4; 20 | public const int UNAWARE_GDISCALED = -5; 21 | } 22 | 23 | // for Windows 10 version RS2 and above 24 | [DllImport("user32.dll", SetLastError = true)] 25 | public static extern bool SetProcessDpiAwarenessContext(int dpiFlag); 26 | 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Src/WebView2.WinForms.Demo/app.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michael-russin/webview2-control/d7de7403a7765eb50b0eda23dfa3656b049bd391/Src/WebView2.WinForms.Demo/app.ico -------------------------------------------------------------------------------- /Src/WebView2.WinForms.Demo/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Src/WebView2.WinForms.Sample/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Src/WebView2.WinForms.Sample/Components/ComponentBase.cs: -------------------------------------------------------------------------------- 1 |  2 | namespace MtrDev.WebView2.WinForms.Sample.Components 3 | { 4 | public abstract class ComponentBase 5 | { 6 | public abstract void CleanUp(); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /Src/WebView2.WinForms.Sample/Components/FileComponent.cs: -------------------------------------------------------------------------------- 1 | using MtrDev.WebView2.Interop; 2 | using MtrDev.WebView2.Winforms; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.IO; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows.Forms; 10 | 11 | namespace MtrDev.WebView2.WinForms.Sample.Components 12 | { 13 | public class FileComponent 14 | { 15 | private WebView2Control _webView2; 16 | private MainForm _parent; 17 | 18 | public FileComponent(MainForm parent, WebView2Control webView2) 19 | { 20 | _parent = parent; 21 | _webView2 = webView2; 22 | 23 | _webView2.DocumentTitleChanged += WebView2DocumentTitleChanged; 24 | } 25 | 26 | public void CleanUp() 27 | { 28 | _webView2.DocumentTitleChanged -= WebView2DocumentTitleChanged; 29 | _webView2 = null; 30 | _parent = null; 31 | } 32 | 33 | private void WebView2DocumentTitleChanged(object sender, Wrapper.DocumentTitleChangedEventArgs e) 34 | { 35 | string title = _webView2.DocumentTitle; 36 | _parent.Text = title; 37 | } 38 | 39 | public void SaveScreenshot() 40 | { 41 | SaveFileDialog saveFileDialog = new SaveFileDialog(); 42 | saveFileDialog.FileName = "WebView2_Screenshot.png"; 43 | saveFileDialog.Filter = "PNG File | *.png"; 44 | saveFileDialog.OverwritePrompt = true; 45 | saveFileDialog.CheckFileExists = false; 46 | saveFileDialog.CheckPathExists = true; 47 | if (saveFileDialog.ShowDialog() == DialogResult.OK) 48 | { 49 | using (FileStream file = new FileStream(saveFileDialog.FileName, FileMode.OpenOrCreate)) 50 | { 51 | _webView2.CapturePreview(WEBVIEW2_CAPTURE_PREVIEW_IMAGE_FORMAT.WEBVIEW2_CAPTURE_PREVIEW_IMAGE_FORMAT_PNG, file, (e) => 52 | { 53 | MessageBox.Show("Preview Captured", "Preview Captured", MessageBoxButtons.OK, MessageBoxIcon.Information); 54 | }); 55 | } 56 | } 57 | } 58 | 59 | public void ShowTitle() 60 | { 61 | string title = _webView2.DocumentTitle; 62 | MessageBox.Show(title, "Document Title", MessageBoxButtons.OK); 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /Src/WebView2.WinForms.Sample/Components/ProcessComponent.cs: -------------------------------------------------------------------------------- 1 | using MtrDev.WebView2.Interop; 2 | using MtrDev.WebView2.Winforms; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | using System.Windows.Forms; 9 | 10 | namespace MtrDev.WebView2.WinForms.Sample.Components 11 | { 12 | public class ProcessComponent 13 | { 14 | private WebView2Control _webView2; 15 | private MainForm _parent; 16 | 17 | public ProcessComponent(MainForm parent, WebView2Control webView2) 18 | { 19 | _parent = parent; 20 | _webView2 = webView2; 21 | 22 | _webView2.ProcessFailed += WebView2ProcessFailed; 23 | } 24 | 25 | public void CleanUp() 26 | { 27 | _webView2.ProcessFailed -= WebView2ProcessFailed; 28 | _webView2 = null; 29 | _parent = null; 30 | } 31 | 32 | private void WebView2ProcessFailed(object sender, Wrapper.ProcessFailedEventArgs e) 33 | { 34 | WEBVIEW2_PROCESS_FAILED_KIND failureType = e.ProcessFailedKind; 35 | if (failureType == WEBVIEW2_PROCESS_FAILED_KIND.WEBVIEW2_PROCESS_FAILED_KIND_BROWSER_PROCESS_EXITED) 36 | { 37 | DialogResult button = MessageBox.Show( 38 | "Browser process exited unexpectedly. Recreate webview?", 39 | "Browser process exited", 40 | MessageBoxButtons.YesNo); 41 | if (button == DialogResult.Yes) 42 | { 43 | _parent.ReinitializeWebView(); 44 | } 45 | } 46 | } 47 | 48 | public void ShowBrowserProcessInfo() 49 | { 50 | uint processId = _webView2.BrowserProcessId; 51 | 52 | string message = string.Format("Process ID: {0}", processId); 53 | MessageBox.Show(message, "Process Info", MessageBoxButtons.OK); 54 | } 55 | 56 | public void CrashBrowserProcess() 57 | { 58 | // Crash the browser's process on command, to test crash handlers. 59 | _webView2.Navigate("edge://inducebrowsercrashforrealz"); 60 | } 61 | 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /Src/WebView2.WinForms.Sample/Components/ViewComponent.cs: -------------------------------------------------------------------------------- 1 | using MtrDev.WebView2.Winforms; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Drawing; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | using System.Windows.Forms; 9 | 10 | namespace MtrDev.WebView2.WinForms.Sample.Components 11 | { 12 | public class ViewComponent 13 | { 14 | private MainForm _parent; 15 | private WebView2Control _webView2; 16 | private bool _isVisible = true; 17 | private float _webViewRatio = 1.0f; 18 | private float _webViewZoomFactor = 1.0f; 19 | 20 | public ViewComponent(MainForm parent, WebView2Control webView2) 21 | { 22 | _parent = parent; 23 | _webView2 = webView2; 24 | _webView2.ZoomFactorChanged += WebView2ZoomFactorChanged; 25 | } 26 | 27 | public void CleanUp() 28 | { 29 | _webView2.ZoomFactorChanged -= WebView2ZoomFactorChanged; 30 | _webView2 = null; 31 | _parent = null; 32 | } 33 | 34 | /// 35 | /// Register a handler for the ZoomFactorChanged event. 36 | /// This handler just announces the new level of zoom on the window's title bar. 37 | /// 38 | /// 39 | /// 40 | private void WebView2ZoomFactorChanged(object sender, Wrapper.ZoomFactorCompletedEventArgs e) 41 | { 42 | double zoomFactor = _webView2.ZoomFactor; 43 | 44 | string message = string.Format("WebView2APISample (Zoom: {0}%)", (int)(zoomFactor *100)); 45 | _parent.Text = message; 46 | } 47 | 48 | public void ToggleVisibility() 49 | { 50 | bool visible = _webView2.Visible; 51 | _isVisible = !visible; 52 | _webView2.Visible = _isVisible; 53 | } 54 | 55 | public void SetSizeRatio(float ratio) 56 | { 57 | _webViewRatio = ratio; 58 | } 59 | 60 | public void SetZoomFactor(float zoom) 61 | { 62 | _webViewZoomFactor = zoom; 63 | _webView2.ZoomFactor = _webViewZoomFactor; 64 | } 65 | 66 | public void ShowWebViewBounds() 67 | { 68 | Rectangle bounds = _webView2.Bounds; 69 | string message = string.Format(" Left:\t {0} \n Top:\t {1} \n Right:\t {2} \n Bottom:\t {3} \n", 70 | bounds.Left, bounds.Top, bounds.Right, bounds.Bottom); 71 | MessageBox.Show(message, "WebView Bounds", MessageBoxButtons.OK); 72 | } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /Src/WebView2.WinForms.Sample/Controls/NavigationToolBar.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Drawing; 5 | using System.Data; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows.Forms; 10 | 11 | namespace MtrDev.WebView2.WinForms.Sample.Controls 12 | { 13 | public partial class NavigationToolBar : UserControl 14 | { 15 | public NavigationToolBar() 16 | { 17 | InitializeComponent(); 18 | } 19 | 20 | public bool CanGoBack 21 | { 22 | get => buttonBack.Enabled; 23 | set => buttonBack.Enabled = value; 24 | } 25 | 26 | public bool CanGoForward 27 | { 28 | get => buttonForward.Enabled; 29 | set => buttonForward.Enabled = value; 30 | } 31 | 32 | public bool CanCancel 33 | { 34 | get => buttonCancel.Enabled; 35 | set => buttonCancel.Enabled = value; 36 | } 37 | 38 | public string Url 39 | { 40 | get => textBoxUrl.Text; 41 | set => textBoxUrl.Text = value; 42 | } 43 | 44 | public event EventHandler GoClicked; 45 | public event EventHandler BackClicked; 46 | public event EventHandler ForwardClicked; 47 | public event EventHandler CancelClicked; 48 | public event EventHandler ReloadClicked; 49 | 50 | private void buttonGo_Click(object sender, EventArgs e) 51 | { 52 | EventHandler handler = GoClicked; 53 | if (handler != null) 54 | { 55 | handler(this, new EventArgs()); 56 | } 57 | } 58 | 59 | private void buttonBack_Click(object sender, EventArgs e) 60 | { 61 | EventHandler handler = BackClicked; 62 | if (handler != null) 63 | { 64 | handler(this, new EventArgs()); 65 | } 66 | } 67 | 68 | private void buttonForward_Click(object sender, EventArgs e) 69 | { 70 | EventHandler handler = ForwardClicked; 71 | if (handler != null) 72 | { 73 | handler(this, new EventArgs()); 74 | } 75 | } 76 | 77 | private void buttonReload_Click(object sender, EventArgs e) 78 | { 79 | EventHandler handler = ReloadClicked; 80 | if (handler != null) 81 | { 82 | handler(this, new EventArgs()); 83 | } 84 | } 85 | 86 | private void buttonCancel_Click(object sender, EventArgs e) 87 | { 88 | EventHandler handler = CancelClicked; 89 | if (handler != null) 90 | { 91 | handler(this, new EventArgs()); 92 | } 93 | } 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /Src/WebView2.WinForms.Sample/Forms/AboutForm.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows.Forms; 10 | 11 | namespace MtrDev.WebView2.WinForms.Sample.Forms 12 | { 13 | public partial class AboutForm : Form 14 | { 15 | public AboutForm() 16 | { 17 | InitializeComponent(); 18 | } 19 | 20 | private void button1_Click(object sender, EventArgs e) 21 | { 22 | Close(); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Src/WebView2.WinForms.Sample/Forms/CommonDialogs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows.Forms; 7 | 8 | namespace MtrDev.WebView2.WinForms.Sample.Forms 9 | { 10 | public class CommonDialogs 11 | { 12 | public static void ShowFailure(int hr, string message) 13 | { 14 | string formattedMessage = message + " " + hr.ToString("X"); 15 | MessageBox.Show(formattedMessage, "Erorr", MessageBoxButtons.OK); 16 | } 17 | 18 | public static void ShowError(string message) 19 | { 20 | MessageBox.Show(message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Src/WebView2.WinForms.Sample/Forms/TextInputDialog.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows.Forms; 10 | 11 | namespace MtrDev.WebView2.WinForms.Sample.Forms 12 | { 13 | public partial class TextInputDialog : Form 14 | { 15 | public TextInputDialog(string title, string prompt, string description, string defaultText, bool readOnly) 16 | { 17 | InitializeComponent(); 18 | 19 | Text = title; 20 | labelStatic.Text = prompt; 21 | labelDescription.Text = description; 22 | textBoxInput.Text = defaultText; 23 | if (readOnly) 24 | { 25 | textBoxInput.ReadOnly = readOnly; 26 | } 27 | } 28 | 29 | public string Input 30 | { 31 | get 32 | { 33 | return textBoxInput.Text; 34 | } 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Src/WebView2.WinForms.Sample/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using System.Windows.Forms; 6 | 7 | namespace MtrDev.WebView2.WinForms.Sample 8 | { 9 | static class Program 10 | { 11 | /// 12 | /// The main entry point for the application. 13 | /// 14 | [STAThread] 15 | static void Main() 16 | { 17 | Application.EnableVisualStyles(); 18 | Application.SetCompatibleTextRenderingDefault(false); 19 | Application.Run(new MainForm("https://www.bing.com", null)); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Src/WebView2.WinForms.Sample/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("WebView2.WinForms.Sample")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("WebView2.WinForms.Sample")] 13 | [assembly: AssemblyCopyright("Copyright © 2019")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("32acf230-7992-4833-8a91-54d8276085e5")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Src/WebView2.WinForms.Sample/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace MtrDev.WebView2.WinForms.Sample.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.9.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Src/WebView2.WinForms.Sample/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Src/WebView2.WinForms.Sample/Scenarios/ScenarioWebMessage.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ScenarioWebMessage 5 | 26 | 27 | 28 |

WebMessage sample page

29 |

This page demonstrates basic interaction between the host app and the webview by 30 | means of Web Messages.

31 | 32 |

Posting Messages

33 |

Messages can be posted from the host app to the webview using the 34 | functions ICoreWebView2::PostWebMessageAsJson and 35 | ICoreWebView2::PostWebMessageAsString. Try using the menu item 36 | "Script->Post Message JSON" to send the message {"SetColor":"blue"}. 37 | It should change the text color of this paragraph.

38 | 39 |

Receiving Messages

40 |

The host app can receive messages by registering an event handler with 41 | ICoreWebView2::add_WebMessageReceived. If you enter text and click 42 | "Send", this page will send a message to the host app which will change the text of 43 | the title bar.

44 | 45 | 46 | 47 |

Round trip

48 |

The host app can send messages back in response to received messages. If you click 49 | "Get window bounds", the host app will report back the bounds of its window, which will 50 | appear in the text box.

51 |
52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /Src/WebView2.WinForms.Sample/Utils/FileUtil.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Reflection; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace MtrDev.WebView2.WinForms.Sample.Utils 10 | { 11 | public class FileUtil 12 | { 13 | public static string GetLocalUri(string relativePath) 14 | { 15 | string path = GetLocalPath(relativePath); 16 | 17 | Uri uri = new Uri(path); 18 | 19 | return uri.AbsoluteUri; 20 | } 21 | 22 | public static string GetLocalPath(string relativePath) 23 | { 24 | var location = new Uri(Assembly.GetEntryAssembly().GetName().CodeBase); 25 | string fulllName = new FileInfo(location.AbsolutePath).Directory.FullName; 26 | 27 | return Path.Combine(fulllName, relativePath); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Src/WebView2.WinForms.Sample/Utils/ProcessUtil.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Diagnostics; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace MtrDev.WebView2.WinForms.Sample.Utils 9 | { 10 | internal class ProcessUtil 11 | { 12 | internal static void EnsureProcessIsClosed(uint processId, int timeoutMs) 13 | { 14 | if (processId != 0) 15 | { 16 | Process process = Process.GetProcessById((int)processId); 17 | if (process != null) 18 | { 19 | if (!process.WaitForExit(timeoutMs)) 20 | { 21 | // Force kill the process if it doesn't exit by itself 22 | process.Kill(); 23 | } 24 | } 25 | } 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Src/WebView2.WinForms.Sample/comtest.vbs: -------------------------------------------------------------------------------- 1 | dim objTest, intResult 2 | Set objTest = WScript.CreateObject ("RemoteComObjectImpl.1") 3 | 4 | intResult = objTest.Property 5 | Wscript.echo "Result = " & intResult 6 | 7 | objTest.Property = "Good Morning" 8 | intResult = objTest.Property 9 | Wscript.echo "Result = " & intResult -------------------------------------------------------------------------------- /Src/WebView2.WinForms.Sample/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /Src/WebView2.WinForms.Sample/small.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michael-russin/webview2-control/d7de7403a7765eb50b0eda23dfa3656b049bd391/Src/WebView2.WinForms.Sample/small.ico -------------------------------------------------------------------------------- /Src/WebView2.WinForms/EventArgs/BeforeEnvironmentCreatedEventArgs.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | // Copyright (c) 2019 Michael T. Russin 3 | // 4 | // Permission is hereby granted, free of charge, to any person 5 | // obtaining a copy of this software and associated documentation 6 | // files (the "Software"), to deal in the Software without 7 | // restriction, including without limitation the rights to use, 8 | // copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the 10 | // Software is furnished to do so, subject to the following 11 | // conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be 14 | // included in all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | // OTHER DEALINGS IN THE SOFTWARE. 24 | #endregion 25 | using System; 26 | 27 | namespace MtrDev.WebView2.Winforms 28 | { 29 | /// 30 | /// 31 | /// 32 | public class BeforeEnvironmentCreatedEventArgs : EventArgs 33 | { 34 | public string BrowserExecutableFolder { get; set; } 35 | 36 | public string UserDataFolder { get; set; } 37 | 38 | public string BrowserArguments { get; set; } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Src/WebView2.WinForms/HandlerType.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | // Copyright (c) 2019 Michael T. Russin 3 | // 4 | // Permission is hereby granted, free of charge, to any person 5 | // obtaining a copy of this software and associated documentation 6 | // files (the "Software"), to deal in the Software without 7 | // restriction, including without limitation the rights to use, 8 | // copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the 10 | // Software is furnished to do so, subject to the following 11 | // conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be 14 | // included in all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | // OTHER DEALINGS IN THE SOFTWARE. 24 | #endregion 25 | 26 | using System; 27 | 28 | namespace MtrDev.WebView2.Winforms 29 | { 30 | internal enum HandlerType 31 | { 32 | NavigationStarting = 0, 33 | NavigationComplete = 1, 34 | ZoomFactorChanged = 2, 35 | WebMessageReceived = 3, 36 | [Obsolete] 37 | DocumentStateChanged = 4, 38 | LostFocus = 5, 39 | FrameNavigationStarting = 6, 40 | MoveFocusRequested = 7, 41 | GotFocus = 8, 42 | WebResourceRequested = 9, 43 | ScriptDialogOpening = 10, 44 | PermissionRequested = 11, 45 | ProcessFailed = 12, 46 | TitleChanged = 13, 47 | NewWindow = 14, 48 | AcceleratorKeyPressed = 15, 49 | FullScreenElement = 16, 50 | ContentLoading = 17, 51 | SourceChanged = 18, 52 | HistoryChanged = 19, 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /Src/WebView2.WinForms/OriginalInterop/ISequentialStream.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Runtime.CompilerServices; 5 | using System.Runtime.InteropServices; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace WebView2Sharp.Interop 10 | { 11 | [Guid("0C733A30-2A1C-11CE-ADE5-00AA0044773D")] 12 | [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] 13 | public interface ISequentialStream 14 | { 15 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 16 | void RemoteRead(out byte pv, [In] uint cb, out uint pcbRead); 17 | 18 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 19 | void RemoteWrite([In] ref byte pv, [In] uint cb, out uint pcbWritten); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Src/WebView2.WinForms/OriginalInterop/IStream.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Runtime.CompilerServices; 5 | using System.Runtime.InteropServices; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace WebView2Sharp.Interop 10 | { 11 | [Guid("0000000C-0000-0000-C000-000000000046")] 12 | [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] 13 | public interface IStream : ISequentialStream 14 | { 15 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 16 | void Clone(out IStream ppstm); 17 | 18 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 19 | void Commit([In] uint grfCommitFlags); 20 | 21 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 22 | void LockRegion([In] _ULARGE_INTEGER libOffset, [In] _ULARGE_INTEGER cb, [In] uint dwLockType); 23 | 24 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 25 | void RemoteCopyTo([In] IStream pstm, [In] _ULARGE_INTEGER cb, out _ULARGE_INTEGER pcbRead, out _ULARGE_INTEGER pcbWritten); 26 | 27 | // [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 28 | // void RemoteRead(out byte pv, [In] uint cb, out uint pcbRead); 29 | 30 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 31 | void RemoteSeek([In] _LARGE_INTEGER dlibMove, [In] uint dwOrigin, out _ULARGE_INTEGER plibNewPosition); 32 | 33 | // [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 34 | // void RemoteWrite([In] ref byte pv, [In] uint cb, out uint pcbWritten); 35 | 36 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 37 | void Revert(); 38 | 39 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 40 | void SetSize([In] _ULARGE_INTEGER libNewSize); 41 | 42 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 43 | void Stat(out tagSTATSTG pstatstg, [In] uint grfStatFlag); 44 | 45 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 46 | void UnlockRegion([In] _ULARGE_INTEGER libOffset, [In] _ULARGE_INTEGER cb, [In] uint dwLockType); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /Src/WebView2.WinForms/OriginalInterop/IWebView2AddScriptToExecuteOnDocumentCreatedCompletedHandler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Runtime.CompilerServices; 5 | using System.Runtime.InteropServices; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace WebView2Sharp.Interop 10 | { 11 | [Guid("EE07AA7F-5DAF-4C00-9C0B-5F736213C92D")] 12 | [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] 13 | public interface IWebView2AddScriptToExecuteOnDocumentCreatedCompletedHandler 14 | { 15 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 16 | void Invoke([In] int errorCode, [In] string id); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Src/WebView2.WinForms/OriginalInterop/IWebView2CallDevToolsProtocolMethodCompletedHandler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Runtime.CompilerServices; 5 | using System.Runtime.InteropServices; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace WebView2Sharp.Interop 10 | { 11 | [Guid("6EA28F62-FEC5-48EA-9669-67979B50579E")] 12 | [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] 13 | public interface IWebView2CallDevToolsProtocolMethodCompletedHandler 14 | { 15 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 16 | void Invoke([In] int errorCode, [In] string returnObjectAsJson); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Src/WebView2.WinForms/OriginalInterop/IWebView2CapturePreviewCompletedHandler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Runtime.CompilerServices; 5 | using System.Runtime.InteropServices; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace WebView2Sharp.Interop 10 | { 11 | [Guid("5755B27A-3FCD-4E01-B368-06834A5AFCDC")] 12 | [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] 13 | public interface IWebView2CapturePreviewCompletedHandler 14 | { 15 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 16 | void Invoke([In] int result); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Src/WebView2.WinForms/OriginalInterop/IWebView2CreateWebView2EnvironmentCompletedHandler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Runtime.CompilerServices; 5 | using System.Runtime.InteropServices; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace WebView2Sharp.Interop 10 | { 11 | [Guid("A8346945-51C2-4CE6-8B4C-6F3C4391828B")] 12 | [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] 13 | public interface IWebView2CreateWebView2EnvironmentCompletedHandler 14 | { 15 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 16 | void Invoke(int result, IWebView2Environment webViewEnvironment); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Src/WebView2.WinForms/OriginalInterop/IWebView2CreateWebViewCompletedHandler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Runtime.CompilerServices; 5 | using System.Runtime.InteropServices; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace WebView2Sharp.Interop 10 | { 11 | [Guid("E0618CDD-4947-4F58-802C-FC1F20BD4274")] 12 | [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] 13 | public interface IWebView2CreateWebViewCompletedHandler 14 | { 15 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 16 | void Invoke(int result, IWebView2WebView webview); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Src/WebView2.WinForms/OriginalInterop/IWebView2Deferral.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Runtime.CompilerServices; 5 | using System.Runtime.InteropServices; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace WebView2Sharp.Interop 10 | { 11 | [Guid("BD478C19-4706-4B1D-88B6-76DD39ACB7B1")] 12 | [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] 13 | public interface IWebView2Deferral 14 | { 15 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 16 | void Complete(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Src/WebView2.WinForms/OriginalInterop/IWebView2DevToolsProtocolEventReceivedEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Runtime.CompilerServices; 5 | using System.Runtime.InteropServices; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace WebView2Sharp.Interop 10 | { 11 | [Guid("BF0F875F-8EB0-4211-9B80-2892F7276BB9")] 12 | [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] 13 | public interface IWebView2DevToolsProtocolEventReceivedEventArgs 14 | { 15 | [DispId(1610678272)] 16 | string ParameterObjectAsJson 17 | { 18 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 19 | get; 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Src/WebView2.WinForms/OriginalInterop/IWebView2DevToolsProtocolEventReceivedEventHandler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Runtime.CompilerServices; 5 | using System.Runtime.InteropServices; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace WebView2Sharp.Interop 10 | { 11 | [Guid("37D087EA-12F6-4856-81D8-5596C708CA59")] 12 | [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] 13 | public interface IWebView2DevToolsProtocolEventReceivedEventHandler 14 | { 15 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 16 | void Invoke([In] IWebView2WebView webview, [In] IWebView2DevToolsProtocolEventReceivedEventArgs args); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Src/WebView2.WinForms/OriginalInterop/IWebView2DocumentStateChangedEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Runtime.CompilerServices; 5 | using System.Runtime.InteropServices; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace WebView2Sharp.Interop 10 | { 11 | [Guid("3A38CB7F-EFC1-41B4-87FC-5AFCEE27C8ED")] 12 | [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] 13 | public interface IWebView2DocumentStateChangedEventArgs 14 | { 15 | [DispId(1610678273)] 16 | int IsErrorPage 17 | { 18 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 19 | get; 20 | } 21 | 22 | [DispId(1610678272)] 23 | int IsNewDocument 24 | { 25 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 26 | get; 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Src/WebView2.WinForms/OriginalInterop/IWebView2DocumentStateChangedEventHandler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Runtime.CompilerServices; 5 | using System.Runtime.InteropServices; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace WebView2Sharp.Interop 10 | { 11 | [Guid("88E66305-3A5A-4E7F-9C76-2EBFC138CAFD")] 12 | [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] 13 | public interface IWebView2DocumentStateChangedEventHandler 14 | { 15 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 16 | void Invoke([In] IWebView2WebView webview, [In] IWebView2DocumentStateChangedEventArgs args); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Src/WebView2.WinForms/OriginalInterop/IWebView2Environment.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Runtime.CompilerServices; 5 | using System.Runtime.InteropServices; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace WebView2Sharp.Interop 10 | { 11 | [Guid("33D17ECE-82FA-47D9-8978-CD17FF3C3CC6")] 12 | [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] 13 | public interface IWebView2Environment 14 | { 15 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 16 | void CreateWebResourceResponse(IStream Content, int StatusCode, string ReasonPhrase, string Headers, ref IWebView2WebResourceResponse Response); 17 | 18 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 19 | void CreateWebView([ComAliasName("WebView2.Interop.wireHWND")] ref _RemotableHandle parentWindow, IWebView2CreateWebViewCompletedHandler handler); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Src/WebView2.WinForms/OriginalInterop/IWebView2Environment2.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Runtime.CompilerServices; 5 | using System.Runtime.InteropServices; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace WebView2Sharp.Interop 10 | { 11 | [Guid("013124F3-02FD-4DFF-8911-06016AF1E3EE")] 12 | [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] 13 | public interface IWebView2Environment2 : IWebView2Environment 14 | { 15 | [DispId(1610743808)] 16 | string BrowserVersionInfo 17 | { 18 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 19 | get; 20 | } 21 | 22 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 23 | void CreateWebResourceResponse(IStream Content, int StatusCode, string ReasonPhrase, string Headers, ref IWebView2WebResourceResponse Response); 24 | 25 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 26 | void CreateWebView([ComAliasName("WebView2.Interop.wireHWND")] ref _RemotableHandle parentWindow, IWebView2CreateWebViewCompletedHandler handler); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Src/WebView2.WinForms/OriginalInterop/IWebView2ExecuteScriptCompletedHandler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Runtime.CompilerServices; 5 | using System.Runtime.InteropServices; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace WebView2Sharp.Interop 10 | { 11 | [Guid("F5AC0E3B-8B92-45E5-ABEF-DB8518EFFF27")] 12 | [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] 13 | public interface IWebView2ExecuteScriptCompletedHandler 14 | { 15 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 16 | void Invoke([In] int errorCode, [In] string resultObjectAsJson); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Src/WebView2.WinForms/OriginalInterop/IWebView2FocusChangedEventHandler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Runtime.CompilerServices; 5 | using System.Runtime.InteropServices; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace WebView2Sharp.Interop 10 | { 11 | [Guid("76BDBECE-02CC-4E56-AD81-5F808E8572A6")] 12 | [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] 13 | public interface IWebView2FocusChangedEventHandler 14 | { 15 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 16 | void Invoke([In] IWebView2WebView webview, [In] object args); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Src/WebView2.WinForms/OriginalInterop/IWebView2HttpHeadersCollectionIterator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Runtime.CompilerServices; 5 | using System.Runtime.InteropServices; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace WebView2Sharp.Interop 10 | { 11 | [Guid("66A215E4-CA41-490B-884A-411FFB17CD1C")] 12 | [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] 13 | public interface IWebView2HttpHeadersCollectionIterator 14 | { 15 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 16 | void GetCurrentHeader(out string name, out string value); 17 | 18 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 19 | void MoveNext(out int has_next); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Src/WebView2.WinForms/OriginalInterop/IWebView2HttpRequestHeaders.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Runtime.CompilerServices; 5 | using System.Runtime.InteropServices; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace WebView2Sharp.Interop 10 | { 11 | [Guid("982BE490-0252-44F3-9F33-376C04885A6D")] 12 | [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] 13 | public interface IWebView2HttpRequestHeaders 14 | { 15 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 16 | int Contains([In] string name); 17 | 18 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 19 | void GetHeader([In] string name, out string value); 20 | 21 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 22 | void GetIterator(out IWebView2HttpHeadersCollectionIterator iterator); 23 | 24 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 25 | void RemoveHeader([In] string name); 26 | 27 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 28 | void SetHeader([In] string name, [In] string value); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Src/WebView2.WinForms/OriginalInterop/IWebView2HttpResponseHeaders.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Runtime.CompilerServices; 5 | using System.Runtime.InteropServices; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace WebView2Sharp.Interop 10 | { 11 | [Guid("6D1A13A6-C677-41AA-852F-827B53F35301")] 12 | [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] 13 | public interface IWebView2HttpResponseHeaders 14 | { 15 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 16 | void AppendHeader([In] string name, [In] string value); 17 | 18 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 19 | int Contains([In] string name); 20 | 21 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 22 | void GetHeaders([In] string name, out IWebView2HttpHeadersCollectionIterator iterator); 23 | 24 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 25 | void GetIterator(out IWebView2HttpHeadersCollectionIterator iterator); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Src/WebView2.WinForms/OriginalInterop/IWebView2MoveFocusRequestedEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Runtime.CompilerServices; 5 | using System.Runtime.InteropServices; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace WebView2Sharp.Interop 10 | { 11 | [Guid("64AF5AE3-27A1-47E0-8901-95119C1BA95B")] 12 | [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] 13 | public interface IWebView2MoveFocusRequestedEventArgs 14 | { 15 | [DispId(1610678273)] 16 | int Handled 17 | { 18 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 19 | get; 20 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 21 | set; 22 | } 23 | 24 | [DispId(1610678272)] 25 | WEBVIEW2_MOVE_FOCUS_REASON reason 26 | { 27 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 28 | get; 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Src/WebView2.WinForms/OriginalInterop/IWebView2MoveFocusRequestedEventHandler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Runtime.CompilerServices; 5 | using System.Runtime.InteropServices; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace WebView2Sharp.Interop 10 | { 11 | [Guid("F3A49DD0-EA49-469C-8B7A-8CC5E8E4EF27")] 12 | [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] 13 | public interface IWebView2MoveFocusRequestedEventHandler 14 | { 15 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 16 | void Invoke([In] IWebView2WebView webview, [In] IWebView2MoveFocusRequestedEventArgs args); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Src/WebView2.WinForms/OriginalInterop/IWebView2NavigationCompletedEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Runtime.CompilerServices; 5 | using System.Runtime.InteropServices; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace WebView2Sharp.Interop 10 | { 11 | [Guid("48655B1F-3F52-4835-B7AA-7D95F7D7587E")] 12 | [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] 13 | public interface IWebView2NavigationCompletedEventArgs 14 | { 15 | [DispId(1610678272)] 16 | int IsSuccess 17 | { 18 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 19 | get; 20 | } 21 | 22 | [DispId(1610678273)] 23 | WEBVIEW2_WEB_ERROR_STATUS WebErrorStatus 24 | { 25 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 26 | get; 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Src/WebView2.WinForms/OriginalInterop/IWebView2NavigationCompletedEventHandler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Runtime.CompilerServices; 5 | using System.Runtime.InteropServices; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace WebView2Sharp.Interop 10 | { 11 | [Guid("DCEB3A27-C8C0-4DE7-889D-AF3DE80EDB3C")] 12 | [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] 13 | public interface IWebView2NavigationCompletedEventHandler 14 | { 15 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 16 | void Invoke([In] IWebView2WebView webview, [In] IWebView2NavigationCompletedEventArgs args); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Src/WebView2.WinForms/OriginalInterop/IWebView2NavigationStartingEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Runtime.CompilerServices; 5 | using System.Runtime.InteropServices; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace WebView2Sharp.Interop 10 | { 11 | [Guid("9D7A1F73-8211-48C0-9119-686D1FB1AE02")] 12 | [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] 13 | public interface IWebView2NavigationStartingEventArgs 14 | { 15 | [DispId(1610678276)] 16 | int Cancel 17 | { 18 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 19 | get; 20 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 21 | set; 22 | } 23 | 24 | [DispId(1610678274)] 25 | int IsRedirected 26 | { 27 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 28 | get; 29 | } 30 | 31 | [DispId(1610678273)] 32 | int IsUserInitiated 33 | { 34 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 35 | get; 36 | } 37 | 38 | [DispId(1610678275)] 39 | IWebView2HttpRequestHeaders RequestHeaders 40 | { 41 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 42 | get; 43 | } 44 | 45 | [DispId(1610678272)] 46 | string uri 47 | { 48 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 49 | get; 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /Src/WebView2.WinForms/OriginalInterop/IWebView2NavigationStartingEventHandler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Runtime.CompilerServices; 5 | using System.Runtime.InteropServices; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace WebView2Sharp.Interop 10 | { 11 | [Guid("34896570-DC04-40F9-A2DA-8582551A707D")] 12 | [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] 13 | public interface IWebView2NavigationStartingEventHandler 14 | { 15 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 16 | void Invoke([In] IWebView2WebView webview, [In] IWebView2NavigationStartingEventArgs args); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Src/WebView2.WinForms/OriginalInterop/IWebView2PermissionRequestedEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Runtime.CompilerServices; 5 | using System.Runtime.InteropServices; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace WebView2Sharp.Interop 10 | { 11 | [Guid("8D8DA0E4-A071-486F-85AA-31B4B2BADC61")] 12 | [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] 13 | public interface IWebView2PermissionRequestedEventArgs 14 | { 15 | [DispId(1610678274)] 16 | int IsUserInitiated 17 | { 18 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 19 | get; 20 | } 21 | 22 | [DispId(1610678273)] 23 | WEBVIEW2_PERMISSION_TYPE PermissionType 24 | { 25 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 26 | get; 27 | } 28 | 29 | [DispId(1610678275)] 30 | WEBVIEW2_PERMISSION_STATE State 31 | { 32 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 33 | get; 34 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 35 | set; 36 | } 37 | 38 | [DispId(1610678272)] 39 | string uri 40 | { 41 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 42 | get; 43 | } 44 | 45 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 46 | IWebView2Deferral GetDeferral(); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /Src/WebView2.WinForms/OriginalInterop/IWebView2PermissionRequestedEventHandler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Runtime.CompilerServices; 5 | using System.Runtime.InteropServices; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace WebView2Sharp.Interop 10 | { 11 | [Guid("C5DA3C20-95AC-4345-B3C9-5FCA3B92C9DB")] 12 | [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] 13 | public interface IWebView2PermissionRequestedEventHandler 14 | { 15 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 16 | void Invoke([In] IWebView2WebView webview, [In] IWebView2PermissionRequestedEventArgs args); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Src/WebView2.WinForms/OriginalInterop/IWebView2ProcessFailedEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Runtime.CompilerServices; 5 | using System.Runtime.InteropServices; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace WebView2Sharp.Interop 10 | { 11 | [Guid("6DABCFB8-8C7D-4515-893B-9766766900DA")] 12 | [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] 13 | public interface IWebView2ProcessFailedEventArgs 14 | { 15 | [DispId(1610678272)] 16 | WEBVIEW2_PROCESS_FAILED_KIND ProcessFailedKind 17 | { 18 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 19 | get; 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Src/WebView2.WinForms/OriginalInterop/IWebView2ProcessFailedEventHandler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Runtime.CompilerServices; 5 | using System.Runtime.InteropServices; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace WebView2Sharp.Interop 10 | { 11 | [Guid("011EC830-5DAF-4767-A099-C43DE1A925F4")] 12 | [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] 13 | public interface IWebView2ProcessFailedEventHandler 14 | { 15 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 16 | void Invoke([In] IWebView2WebView webview, [In] IWebView2ProcessFailedEventArgs args); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Src/WebView2.WinForms/OriginalInterop/IWebView2ScriptDialogOpeningEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Runtime.CompilerServices; 5 | using System.Runtime.InteropServices; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace WebView2Sharp.Interop 10 | { 11 | [Guid("ABB0484E-8D4F-4BEA-9058-B0287221A976")] 12 | [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] 13 | public interface IWebView2ScriptDialogOpeningEventArgs 14 | { 15 | [DispId(1610678276)] 16 | string DefaultText 17 | { 18 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 19 | get; 20 | } 21 | 22 | [DispId(1610678273)] 23 | WEBVIEW2_SCRIPT_DIALOG_KIND Kind 24 | { 25 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 26 | get; 27 | } 28 | 29 | [DispId(1610678274)] 30 | string Message 31 | { 32 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 33 | get; 34 | } 35 | 36 | [DispId(1610678277)] 37 | string ResultText 38 | { 39 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 40 | get; 41 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 42 | set; 43 | } 44 | 45 | [DispId(1610678272)] 46 | string uri 47 | { 48 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 49 | get; 50 | } 51 | 52 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 53 | void Accept(); 54 | 55 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 56 | IWebView2Deferral GetDeferral(); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /Src/WebView2.WinForms/OriginalInterop/IWebView2ScriptDialogOpeningEventHandler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Runtime.CompilerServices; 5 | using System.Runtime.InteropServices; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace WebView2Sharp.Interop 10 | { 11 | [Guid("8EAF9A50-2AF9-45DA-9AC5-F80F4147180E")] 12 | [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] 13 | public interface IWebView2ScriptDialogOpeningEventHandler 14 | { 15 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 16 | void Invoke([In] IWebView2WebView webview, [In] IWebView2ScriptDialogOpeningEventArgs args); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Src/WebView2.WinForms/OriginalInterop/IWebView2Settings.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Runtime.CompilerServices; 5 | using System.Runtime.InteropServices; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace WebView2Sharp.Interop 10 | { 11 | [Guid("A28CD108-3234-4B45-B390-7E871B504A96")] 12 | [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] 13 | public interface IWebView2Settings 14 | { 15 | [DispId(1610678276)] 16 | int AreDefaultScriptDialogsEnabled 17 | { 18 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 19 | get; 20 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 21 | set; 22 | } 23 | 24 | [DispId(1610678282)] 25 | int AreDevToolsEnabled 26 | { 27 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 28 | get; 29 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 30 | set; 31 | } 32 | 33 | [DispId(1610678278)] 34 | int IsFullscreenAllowed 35 | { 36 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 37 | get; 38 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 39 | set; 40 | } 41 | 42 | [DispId(1610678272)] 43 | int IsScriptEnabled 44 | { 45 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 46 | get; 47 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 48 | set; 49 | } 50 | 51 | [DispId(1610678280)] 52 | int IsStatusBarEnabled 53 | { 54 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 55 | get; 56 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 57 | set; 58 | } 59 | 60 | [DispId(1610678274)] 61 | int IsWebMessageEnabled 62 | { 63 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 64 | get; 65 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 66 | set; 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /Src/WebView2.WinForms/OriginalInterop/IWebView2WebMessageReceivedEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Runtime.CompilerServices; 5 | using System.Runtime.InteropServices; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace WebView2Sharp.Interop 10 | { 11 | [Guid("E32C6167-14F1-42EA-8743-B014EF6AD27F")] 12 | [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] 13 | public interface IWebView2WebMessageReceivedEventArgs 14 | { 15 | [DispId(1610678272)] 16 | string Source 17 | { 18 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 19 | get; 20 | } 21 | 22 | [DispId(1610678273)] 23 | string webMessageAsJson 24 | { 25 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 26 | get; 27 | } 28 | 29 | [DispId(1610678274)] 30 | string webMessageAsString 31 | { 32 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 33 | get; 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Src/WebView2.WinForms/OriginalInterop/IWebView2WebMessageReceivedEventHandler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Runtime.CompilerServices; 5 | using System.Runtime.InteropServices; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace WebView2Sharp.Interop 10 | { 11 | [Guid("0E682B9A-B686-4327-9A56-E0305705A3DB")] 12 | [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] 13 | public interface IWebView2WebMessageReceivedEventHandler 14 | { 15 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 16 | void Invoke([In] IWebView2WebView webview, [In] IWebView2WebMessageReceivedEventArgs args); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Src/WebView2.WinForms/OriginalInterop/IWebView2WebResourceRequest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Runtime.CompilerServices; 5 | using System.Runtime.InteropServices; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace WebView2Sharp.Interop 10 | { 11 | [Guid("1B3F4122-34A0-4F5D-9089-AF63C3AFE375")] 12 | [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] 13 | public interface IWebView2WebResourceRequest 14 | { 15 | [DispId(1610678276)] 16 | IStream Content 17 | { 18 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 19 | get; 20 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 21 | set; 22 | } 23 | 24 | [DispId(1610678278)] 25 | IWebView2HttpRequestHeaders Headers 26 | { 27 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 28 | get; 29 | } 30 | 31 | [DispId(1610678274)] 32 | string Method 33 | { 34 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 35 | get; 36 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 37 | set; 38 | } 39 | 40 | [DispId(1610678272)] 41 | string uri 42 | { 43 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 44 | get; 45 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 46 | set; 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Src/WebView2.WinForms/OriginalInterop/IWebView2WebResourceRequestedEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Runtime.CompilerServices; 5 | using System.Runtime.InteropServices; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace WebView2Sharp.Interop 10 | { 11 | [Guid("D8B1DD71-B9AD-4EEB-ABE3-87E7EFC5D37F")] 12 | [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] 13 | public interface IWebView2WebResourceRequestedEventArgs 14 | { 15 | [DispId(1610678272)] 16 | IWebView2WebResourceRequest Request 17 | { 18 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 19 | get; 20 | } 21 | 22 | [DispId(1610678273)] 23 | IWebView2WebResourceResponse Response 24 | { 25 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 26 | get; 27 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 28 | set; 29 | } 30 | 31 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 32 | IWebView2Deferral GetDeferral(); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Src/WebView2.WinForms/OriginalInterop/IWebView2WebResourceRequestedEventHandler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Runtime.CompilerServices; 5 | using System.Runtime.InteropServices; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace WebView2Sharp.Interop 10 | { 11 | [Guid("E2AE08C1-4F67-4348-AE05-C89CB14C2ADD")] 12 | [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] 13 | public interface IWebView2WebResourceRequestedEventHandler 14 | { 15 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 16 | void Invoke([In] IWebView2WebView webview, [In] IWebView2WebResourceRequestedEventArgs args); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Src/WebView2.WinForms/OriginalInterop/IWebView2WebResourceResponse.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Runtime.CompilerServices; 5 | using System.Runtime.InteropServices; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace WebView2Sharp.Interop 10 | { 11 | [Guid("297886A6-5FDF-472D-A97A-E336ECFE1352")] 12 | [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] 13 | public interface IWebView2WebResourceResponse 14 | { 15 | [DispId(1610678272)] 16 | IStream Content 17 | { 18 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 19 | get; 20 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 21 | set; 22 | } 23 | 24 | [DispId(1610678274)] 25 | IWebView2HttpResponseHeaders Headers 26 | { 27 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 28 | get; 29 | } 30 | 31 | [DispId(1610678277)] 32 | string ReasonPhrase 33 | { 34 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 35 | get; 36 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 37 | set; 38 | } 39 | 40 | [DispId(1610678275)] 41 | int StatusCode 42 | { 43 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 44 | get; 45 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 46 | set; 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Src/WebView2.WinForms/OriginalInterop/IWebView2ZoomFactorChangedEventHandler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Runtime.CompilerServices; 5 | using System.Runtime.InteropServices; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace WebView2Sharp.Interop 10 | { 11 | [Guid("A5C0B08B-25D7-4BAC-AD06-11783393088E")] 12 | [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] 13 | public interface IWebView2ZoomFactorChangedEventHandler 14 | { 15 | [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] 16 | void Invoke([In] IWebView2WebView webview, [In] object args); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Src/WebView2.WinForms/OriginalInterop/Structs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Runtime.InteropServices; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace WebView2Sharp.Interop 9 | { 10 | public struct __MIDL___MIDL_itf_webview22Elibrary_formatted_0007_0001_0001 11 | { 12 | public uint Data1; 13 | 14 | public ushort Data2; 15 | 16 | public ushort Data3; 17 | 18 | public byte[] Data4; 19 | } 20 | 21 | [StructLayout(LayoutKind.Explicit)] 22 | public struct __MIDL_IWinTypes_0009 23 | { 24 | [FieldOffset(0)] 25 | public int hInproc; 26 | 27 | [FieldOffset(0)] 28 | public int hRemote; 29 | } 30 | 31 | public struct _FILETIME 32 | { 33 | public uint dwLowDateTime; 34 | 35 | public uint dwHighDateTime; 36 | } 37 | 38 | public struct _LARGE_INTEGER 39 | { 40 | public long QuadPart; 41 | } 42 | 43 | public struct _RemotableHandle 44 | { 45 | public int fContext; 46 | 47 | public __MIDL_IWinTypes_0009 u; 48 | } 49 | 50 | public struct _ULARGE_INTEGER 51 | { 52 | public ulong QuadPart; 53 | } 54 | 55 | public struct EventRegistrationToken 56 | { 57 | public long @value; 58 | } 59 | public struct GUID 60 | { 61 | public uint Data1; 62 | 63 | public ushort Data2; 64 | 65 | public ushort Data3; 66 | 67 | public byte[] Data4; 68 | } 69 | 70 | public struct tagRECT 71 | { 72 | public int left; 73 | 74 | public int top; 75 | 76 | public int right; 77 | 78 | public int bottom; 79 | } 80 | 81 | public struct tagSTATSTG 82 | { 83 | public string pwcsName; 84 | 85 | public uint type; 86 | 87 | public _ULARGE_INTEGER cbSize; 88 | 89 | public _FILETIME mtime; 90 | 91 | public _FILETIME ctime; 92 | 93 | public _FILETIME atime; 94 | 95 | public uint grfMode; 96 | 97 | public uint grfLocksSupported; 98 | 99 | [ComAliasName("WebView2.Interop.GUID")] 100 | public GUID clsid; 101 | 102 | public uint grfStateBits; 103 | 104 | public uint reserved; 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /Src/WebView2.WinForms/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("MtrDev.WinForms.WebView2")] 9 | [assembly: AssemblyDescription("Windows Forms Implementation of WebView2 browser")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("MtrDev")] 12 | [assembly: AssemblyProduct("MtrDev.WinForms.WebView2")] 13 | [assembly: AssemblyCopyright("Copyright © 2020")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("69207D32-2ACF-4c54-85B2-995A54AABB72")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.9.430.4")] 36 | [assembly: AssemblyFileVersion("1.9.430.4")] 37 | -------------------------------------------------------------------------------- /Src/WebView2.WinForms/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /Src/WebView2.Wpf.Demo/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Src/WebView2.Wpf.Demo/App.xaml: -------------------------------------------------------------------------------- 1 |  6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /Src/WebView2.Wpf.Demo/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Configuration; 4 | using System.Data; 5 | using System.Linq; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | 9 | namespace WebView2.Wpf.Demo 10 | { 11 | /// 12 | /// Interaction logic for App.xaml 13 | /// 14 | public partial class App : Application 15 | { 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Src/WebView2.Wpf.Demo/Constants.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace WebView2.Wpf.Demo 8 | { 9 | public enum Messages : int 10 | { 11 | MG_NAVIGATE = 1, 12 | MG_UPDATE_URI = 2, 13 | MG_GO_FORWARD = 3, 14 | MG_GO_BACK = 4, 15 | MG_NAV_STARTING = 5, 16 | MG_NAV_COMPLETED = 6, 17 | MG_RELOAD = 7, 18 | MG_CANCEL = 8, 19 | MG_CREATE_TAB = 10, 20 | MG_UPDATE_TAB = 11, 21 | MG_SWITCH_TAB = 12, 22 | MG_CLOSE_TAB = 13, 23 | MG_CLOSE_WINDOW = 14, 24 | MG_SHOW_OPTIONS = 15, 25 | MG_HIDE_OPTIONS = 16, 26 | MG_OPTIONS_LOST_FOCUS = 17, 27 | MG_OPTION_SELECTED = 18, 28 | MG_SECURITY_UPDATE = 19, 29 | MG_UPDATE_FAVICON = 20, 30 | MG_GET_SETTINGS = 21, 31 | MG_GET_FAVORITES = 22, 32 | MG_REMOVE_FAVORITE = 23, 33 | MG_CLEAR_CACHE = 24, 34 | MG_CLEAR_COOKIES = 25, 35 | MG_GET_HISTORY = 26, 36 | MG_REMOVE_HISTORY_ITEM = 27, 37 | MG_CLEAR_HISTORY = 28, 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Src/WebView2.Wpf.Demo/Content/commands.js: -------------------------------------------------------------------------------- 1 | const commands = { 2 | MG_NAVIGATE: 1, 3 | MG_UPDATE_URI: 2, 4 | MG_GO_FORWARD: 3, 5 | MG_GO_BACK: 4, 6 | MG_NAV_STARTING: 5, 7 | MG_NAV_COMPLETED: 6, 8 | MG_RELOAD: 7, 9 | MG_CANCEL: 8, 10 | MG_CREATE_TAB: 10, 11 | MG_UPDATE_TAB: 11, 12 | MG_SWITCH_TAB: 12, 13 | MG_CLOSE_TAB: 13, 14 | MG_CLOSE_WINDOW: 14, 15 | MG_SHOW_OPTIONS: 15, 16 | MG_HIDE_OPTIONS: 16, 17 | MG_OPTIONS_LOST_FOCUS: 17, 18 | MG_OPTION_SELECTED: 18, 19 | MG_SECURITY_UPDATE: 19, 20 | MG_UPDATE_FAVICON: 20, 21 | MG_GET_SETTINGS: 21, 22 | MG_GET_FAVORITES: 22, 23 | MG_REMOVE_FAVORITE: 23, 24 | MG_CLEAR_CACHE: 24, 25 | MG_CLEAR_COOKIES: 25, 26 | MG_GET_HISTORY: 26, 27 | MG_REMOVE_HISTORY_ITEM: 27, 28 | MG_CLEAR_HISTORY: 28 29 | }; 30 | -------------------------------------------------------------------------------- /Src/WebView2.Wpf.Demo/Content/content_ui/favorites.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Favorites 4 | 5 | 6 | 7 | 8 | 9 |

Favorites

10 |
11 | You don't have any favorites. 12 |
13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /Src/WebView2.Wpf.Demo/Content/content_ui/history.css: -------------------------------------------------------------------------------- 1 | .header-date { 2 | font-weight: 400; 3 | font-size: 14px; 4 | color: rgb(16, 16, 16); 5 | line-height: 20px; 6 | padding-top: 10px; 7 | padding-bottom: 4px; 8 | margin: 0; 9 | } 10 | 11 | #btn-clear { 12 | font-size: 14px; 13 | color: rgb(0, 97, 171); 14 | cursor: pointer; 15 | line-height: 20px; 16 | } 17 | 18 | #btn-clear.hidden { 19 | display: none; 20 | } 21 | 22 | #overlay { 23 | position: fixed; 24 | top: 0; 25 | left: 0; 26 | height: 100%; 27 | width: 100%; 28 | background-color: rgba(0, 0, 0, 0.2); 29 | } 30 | 31 | #overlay.hidden { 32 | display: none; 33 | } 34 | 35 | #prompt-box { 36 | display: flex; 37 | box-sizing: border-box; 38 | flex-direction: column; 39 | position: fixed; 40 | left: calc(50% - 130px); 41 | top: calc(50% - 70px); 42 | width: 260px; 43 | height: 140px; 44 | padding: 20px; 45 | border-radius: 5px; 46 | background-color: white; 47 | 48 | box-shadow: rgba(0, 0, 0, 0.13) 0px 1.6px 20px, rgba(0, 0, 0, 0.11) 0px 0.3px 10px; 49 | } 50 | 51 | #prompt-options { 52 | flex: 1; 53 | display: flex; 54 | justify-content: flex-end; 55 | 56 | user-select: none; 57 | } 58 | 59 | .prompt-btn { 60 | flex: 1; 61 | flex-grow: 0; 62 | align-self: flex-end; 63 | cursor: pointer; 64 | font-family: 'system-ui', sans-serif; 65 | display: inline-block; 66 | padding: 2px 7px; 67 | font-size: 14px; 68 | line-height: 20px; 69 | border-radius: 3px; 70 | font-weight: 400; 71 | } 72 | 73 | #prompt-true { 74 | background-color: rgb(0, 112, 198); 75 | color: white; 76 | } 77 | 78 | #prompt-false { 79 | background-color: rgb(210, 210, 210); 80 | margin-right: 5px; 81 | } 82 | -------------------------------------------------------------------------------- /Src/WebView2.Wpf.Demo/Content/content_ui/history.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | History 4 | 5 | 6 | 7 | 8 | 9 | 10 | 19 |

History

20 |
21 | 22 |
23 |
24 | Loading... 25 |
26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /Src/WebView2.Wpf.Demo/Content/content_ui/img/close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michael-russin/webview2-control/d7de7403a7765eb50b0eda23dfa3656b049bd391/Src/WebView2.Wpf.Demo/Content/content_ui/img/close.png -------------------------------------------------------------------------------- /Src/WebView2.Wpf.Demo/Content/content_ui/img/favorites.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michael-russin/webview2-control/d7de7403a7765eb50b0eda23dfa3656b049bd391/Src/WebView2.Wpf.Demo/Content/content_ui/img/favorites.png -------------------------------------------------------------------------------- /Src/WebView2.Wpf.Demo/Content/content_ui/img/history.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michael-russin/webview2-control/d7de7403a7765eb50b0eda23dfa3656b049bd391/Src/WebView2.Wpf.Demo/Content/content_ui/img/history.png -------------------------------------------------------------------------------- /Src/WebView2.Wpf.Demo/Content/content_ui/img/settings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michael-russin/webview2-control/d7de7403a7765eb50b0eda23dfa3656b049bd391/Src/WebView2.Wpf.Demo/Content/content_ui/img/settings.png -------------------------------------------------------------------------------- /Src/WebView2.Wpf.Demo/Content/content_ui/items.css: -------------------------------------------------------------------------------- 1 | .item-container { 2 | box-sizing: border-box; 3 | padding: 4px 0; 4 | height: 48px; 5 | } 6 | 7 | .item { 8 | display: flex; 9 | width: 100%; 10 | max-width: 820px; 11 | height: 40px; 12 | width: 100%; 13 | border-radius: 4px; 14 | box-sizing: border-box; 15 | box-shadow: rgba(0, 0, 0, 0.13) 0px 1.6px 3.6px, rgba(0, 0, 0, 0.11) 0px 0.3px 0.9px; 16 | align-items: center; 17 | background: rgb(255, 255, 255); 18 | } 19 | 20 | .item:hover { 21 | box-shadow: 0px 4.8px 10.8px rgba(0,0,0,0.13), 0px 0.9px 2.7px rgba(0,0,0,0.11); 22 | } 23 | 24 | .favicon { 25 | display: flex; 26 | height: 40px; 27 | width: 40px; 28 | justify-content: center; 29 | align-items: center; 30 | } 31 | 32 | .favicon img { 33 | width: 16px; 34 | height: 16px; 35 | } 36 | 37 | .label-title, .label-uri { 38 | display: flex; 39 | flex: 1; 40 | min-width: 0; 41 | height: 40px; 42 | align-items: center; 43 | } 44 | 45 | .label-title a { 46 | cursor: pointer; 47 | display: inline-block; 48 | white-space: nowrap; 49 | text-overflow: ellipsis; 50 | font-weight: 600; 51 | font-size: 12px; 52 | line-height: 16px; 53 | color: rgb(16, 16, 16); 54 | border-width: initial; 55 | border-style: none; 56 | border-color: initial; 57 | border-image: initial; 58 | overflow: hidden; 59 | background: none; 60 | text-decoration: none; 61 | } 62 | 63 | .label-title a:hover { 64 | text-decoration: underline; 65 | } 66 | 67 | .label-uri, .label-time { 68 | margin: 0 6px; 69 | line-height: 16px; 70 | font-size: 12px; 71 | color: rgb(115, 115, 115); 72 | } 73 | 74 | .label-uri p, .label-time p { 75 | display: block; 76 | white-space: nowrap; 77 | overflow: hidden; 78 | text-overflow: ellipsis; 79 | } 80 | 81 | .btn-close { 82 | height: 28px; 83 | width: 28px; 84 | margin: 6px; 85 | border-radius: 2px; 86 | background-image: url('img/close.png'); 87 | background-size: 100%; 88 | } 89 | 90 | .btn-close:hover { 91 | background-color: rgb(243, 243, 243); 92 | } 93 | -------------------------------------------------------------------------------- /Src/WebView2.Wpf.Demo/Content/content_ui/settings.css: -------------------------------------------------------------------------------- 1 | .settings-entry { 2 | display: block; 3 | height: 48px; 4 | width: 100%; 5 | max-width: 500px; 6 | 7 | background: none; 8 | border: none; 9 | padding: 4px 0; 10 | font: inherit; 11 | cursor: pointer; 12 | } 13 | 14 | #entry-script, #entry-popups { 15 | display: none; 16 | } 17 | 18 | .entry { 19 | display: block; 20 | height: 100%; 21 | text-align: left; 22 | border-radius: 5px; 23 | } 24 | 25 | .entry:hover { 26 | background-color: rgb(220, 220, 220); 27 | } 28 | 29 | .entry:focus { 30 | outline: none; 31 | } 32 | 33 | .entry-name, .entry-value { 34 | display: inline-flex; 35 | height: 100%; 36 | vertical-align: middle; 37 | } 38 | 39 | .entry-name span, .entry-value span { 40 | flex: 1; 41 | align-self: center; 42 | } 43 | 44 | .entry-name { 45 | padding-left: 10px; 46 | } 47 | 48 | .entry-value { 49 | float: right; 50 | vertical-align: middle; 51 | margin: 0 15px; 52 | font-size: 0.8em; 53 | color: gray; 54 | } 55 | -------------------------------------------------------------------------------- /Src/WebView2.Wpf.Demo/Content/content_ui/settings.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Settings 4 | 5 | 6 | 7 | 8 | 9 |

Settings

10 |
11 | 21 | 31 | 41 | 51 |
52 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /Src/WebView2.Wpf.Demo/Content/content_ui/styles.css: -------------------------------------------------------------------------------- 1 | html, body { 2 | margin: 0; 3 | border: none; 4 | padding: 0; 5 | 6 | font-family: Arial, Helvetica, sans-serif; 7 | background-color: rgb(240, 240, 242); 8 | } 9 | 10 | p { 11 | margin: 0; 12 | } 13 | 14 | body { 15 | padding: 32px 50px; 16 | font-family: 'system-ui', sans-serif; 17 | } 18 | 19 | .main-title { 20 | display: block; 21 | margin-bottom: 18px; 22 | font-size: 24px; 23 | font-weight: 600; 24 | color: rgb(16, 16, 16); 25 | } 26 | -------------------------------------------------------------------------------- /Src/WebView2.Wpf.Demo/Content/controls_ui/address-bar.css: -------------------------------------------------------------------------------- 1 | #address-bar-container { 2 | display: flex; 3 | height: calc(100% - 10px); 4 | width: 80%; 5 | max-width: calc(100% - 160px); 6 | 7 | background-color: white; 8 | border: 1px solid gray; 9 | border-radius: 5px; 10 | 11 | position: relative; 12 | align-self: center; 13 | } 14 | 15 | #address-bar-container:focus-within { 16 | outline: none; 17 | box-shadow: 0 0 3px dodgerblue; 18 | } 19 | 20 | #address-bar-container:focus-within #btn-clear { 21 | display: block; 22 | } 23 | 24 | #security-label { 25 | display: inline-flex; 26 | height: 100%; 27 | margin-left: 2px; 28 | 29 | vertical-align: top; 30 | } 31 | 32 | #security-label span { 33 | font-family: Arial; 34 | font-size: 0.9em; 35 | color: gray; 36 | vertical-align: middle; 37 | flex: 1; 38 | align-self: center; 39 | text-align: left; 40 | padding-left: 5px; 41 | white-space: nowrap; 42 | } 43 | 44 | .icn { 45 | display: inline-block; 46 | margin: 2px 0; 47 | border-radius: 5px; 48 | top: 0; 49 | width: 26px; 50 | height: 26px; 51 | } 52 | 53 | #icn-lock { 54 | background-size: 100%; 55 | } 56 | 57 | #security-label.label-unknown .icn { 58 | background-image: url('img/unknown.png'); 59 | } 60 | 61 | #security-label.label-insecure .icn { 62 | background-image: url('img/insecure.png'); 63 | } 64 | 65 | #security-label.label-insecure span { 66 | color: rgb(192, 0, 0); 67 | } 68 | 69 | #security-label.label-neutral .icn { 70 | background-image: url('img/neutral.png'); 71 | } 72 | 73 | #security-label.label-secure .icn { 74 | background-image: url('img/secure.png'); 75 | } 76 | 77 | #security-label.label-secure span, #security-label.label-neutral span { 78 | display: none; 79 | } 80 | 81 | #icn-favicon { 82 | background-size: 100%; 83 | } 84 | 85 | #img-favicon { 86 | width: 18px; 87 | height: 18px; 88 | padding: 4px; 89 | } 90 | 91 | #address-form { 92 | margin: 0; 93 | } 94 | 95 | #address-field { 96 | flex: 1; 97 | padding: 0; 98 | border: none; 99 | border-radius: 5px; 100 | margin: 0; 101 | 102 | line-height: 30px; 103 | width: 100%; 104 | } 105 | 106 | #address-field:focus { 107 | outline: none; 108 | } 109 | 110 | #btn-fav { 111 | margin: 2px 5px; 112 | background-size: 100%; 113 | background-image: url('img/favorite.png'); 114 | } 115 | 116 | #btn-fav:hover, #btn-clear:hover { 117 | background-color: rgb(230, 230, 230); 118 | } 119 | 120 | #btn-fav.favorited { 121 | background-image: url('img/favorited.png'); 122 | } 123 | 124 | #btn-clear { 125 | display: none; 126 | width: 16px; 127 | height: 16px; 128 | border: none; 129 | align-self: center; 130 | background-color: transparent; 131 | background-image: url(img/cancel.png); 132 | background-size: 100%; 133 | border: none; 134 | border-radius: 8px; 135 | } 136 | -------------------------------------------------------------------------------- /Src/WebView2.Wpf.Demo/Content/controls_ui/controls.css: -------------------------------------------------------------------------------- 1 | #controls-bar { 2 | display: flex; 3 | justify-content: space-between; 4 | flex-direction: row; 5 | height: 40px; 6 | background-color: rgb(230, 230, 230); 7 | } 8 | 9 | .btn, .btn-disabled, .btn-cancel, .btn-active { 10 | display: inline-block; 11 | border: none; 12 | margin: 5px 0; 13 | border-radius: 5px; 14 | outline: none; 15 | height: 30px; 16 | width: 30px; 17 | 18 | background-size: 100%; 19 | } 20 | 21 | #btn-forward { 22 | background-image: url('img/goForward.png'); 23 | } 24 | 25 | .btn-disabled#btn-forward { 26 | background-image: url('img/goForward_disabled.png'); 27 | } 28 | 29 | #btn-back { 30 | background-image: url('img/goBack.png'); 31 | } 32 | 33 | .btn-disabled#btn-back { 34 | background-image: url('img/goBack_disabled.png'); 35 | } 36 | 37 | #btn-reload { 38 | background-image: url('img/reload.png'); 39 | } 40 | 41 | .btn-cancel#btn-reload { 42 | background-image: url('img/cancel.png'); 43 | } 44 | 45 | #btn-options { 46 | background-image: url('img/options.png'); 47 | } 48 | 49 | .controls-group { 50 | display: inline-block; 51 | height: 40px; 52 | } 53 | 54 | #nav-controls-container { 55 | align-self: flex-start; 56 | padding-left: 10px; 57 | } 58 | 59 | #manage-controls-container { 60 | align-self: flex-end; 61 | padding-right: 10px; 62 | } 63 | 64 | .btn:hover, .btn-cancel:hover, .btn-active { 65 | background-color: rgb(200, 200, 200); 66 | } 67 | -------------------------------------------------------------------------------- /Src/WebView2.Wpf.Demo/Content/controls_ui/default.css: -------------------------------------------------------------------------------- 1 | html, body { 2 | height: 70px; 3 | } 4 | -------------------------------------------------------------------------------- /Src/WebView2.Wpf.Demo/Content/controls_ui/default.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /Src/WebView2.Wpf.Demo/Content/controls_ui/favorites.js: -------------------------------------------------------------------------------- 1 | function isFavorite(uri, callback) { 2 | queryDB((db) => { 3 | let transaction = db.transaction(['favorites']); 4 | let favoritesStore = transaction.objectStore('favorites'); 5 | let favoriteStatusRequest = favoritesStore.get(uri); 6 | 7 | favoriteStatusRequest.onerror = function(event) { 8 | console.log(`Could not query for ${uri}: ${event.target.error.message}`); 9 | }; 10 | 11 | favoriteStatusRequest.onsuccess = function() { 12 | callback(favoriteStatusRequest.result); 13 | }; 14 | }); 15 | } 16 | 17 | function addFavorite(favorite, callback) { 18 | queryDB((db) => { 19 | let transaction = db.transaction(['favorites'], 'readwrite'); 20 | let favoritesStore = transaction.objectStore('favorites'); 21 | let addFavoriteRequest = favoritesStore.add(favorite); 22 | 23 | addFavoriteRequest.onerror = function(event) { 24 | console.log(`Could not add favorite with key: ${favorite.uri}`); 25 | console.log(event.target.error.message); 26 | }; 27 | 28 | addFavoriteRequest.onsuccess = function(event) { 29 | if (callback) { 30 | callback(); 31 | } 32 | }; 33 | }); 34 | } 35 | 36 | function removeFavorite(key, callback) { 37 | queryDB((db) => { 38 | let transaction = db.transaction(['favorites'], 'readwrite'); 39 | let favoritesStore = transaction.objectStore('favorites'); 40 | let removeFavoriteRequest = favoritesStore.delete(key); 41 | 42 | removeFavoriteRequest.onerror = function(event) { 43 | console.log(`Could not remove favorite with key: ${key}`); 44 | console.log(event.target.error.message); 45 | }; 46 | 47 | removeFavoriteRequest.onsuccess = function(event) { 48 | if (callback) { 49 | callback(); 50 | } 51 | }; 52 | }); 53 | } 54 | 55 | function getFavoritesAsJson(callback) { 56 | queryDB((db) => { 57 | let transaction = db.transaction(['favorites']); 58 | let favoritesStore = transaction.objectStore('favorites'); 59 | let getFavoritesRequest = favoritesStore.getAll(); 60 | 61 | getFavoritesRequest.onerror = function(event) { 62 | console.log(`Could retrieve favorites`); 63 | console.log(event.target.error.message); 64 | }; 65 | 66 | getFavoritesRequest.onsuccess = function(event) { 67 | if (callback) { 68 | callback(getFavoritesRequest.result); 69 | } 70 | }; 71 | }); 72 | } 73 | -------------------------------------------------------------------------------- /Src/WebView2.Wpf.Demo/Content/controls_ui/img/cancel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michael-russin/webview2-control/d7de7403a7765eb50b0eda23dfa3656b049bd391/Src/WebView2.Wpf.Demo/Content/controls_ui/img/cancel.png -------------------------------------------------------------------------------- /Src/WebView2.Wpf.Demo/Content/controls_ui/img/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michael-russin/webview2-control/d7de7403a7765eb50b0eda23dfa3656b049bd391/Src/WebView2.Wpf.Demo/Content/controls_ui/img/favicon.png -------------------------------------------------------------------------------- /Src/WebView2.Wpf.Demo/Content/controls_ui/img/favorite.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michael-russin/webview2-control/d7de7403a7765eb50b0eda23dfa3656b049bd391/Src/WebView2.Wpf.Demo/Content/controls_ui/img/favorite.png -------------------------------------------------------------------------------- /Src/WebView2.Wpf.Demo/Content/controls_ui/img/favorited.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michael-russin/webview2-control/d7de7403a7765eb50b0eda23dfa3656b049bd391/Src/WebView2.Wpf.Demo/Content/controls_ui/img/favorited.png -------------------------------------------------------------------------------- /Src/WebView2.Wpf.Demo/Content/controls_ui/img/goBack.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michael-russin/webview2-control/d7de7403a7765eb50b0eda23dfa3656b049bd391/Src/WebView2.Wpf.Demo/Content/controls_ui/img/goBack.png -------------------------------------------------------------------------------- /Src/WebView2.Wpf.Demo/Content/controls_ui/img/goBack_disabled.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michael-russin/webview2-control/d7de7403a7765eb50b0eda23dfa3656b049bd391/Src/WebView2.Wpf.Demo/Content/controls_ui/img/goBack_disabled.png -------------------------------------------------------------------------------- /Src/WebView2.Wpf.Demo/Content/controls_ui/img/goForward.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michael-russin/webview2-control/d7de7403a7765eb50b0eda23dfa3656b049bd391/Src/WebView2.Wpf.Demo/Content/controls_ui/img/goForward.png -------------------------------------------------------------------------------- /Src/WebView2.Wpf.Demo/Content/controls_ui/img/goForward_disabled.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michael-russin/webview2-control/d7de7403a7765eb50b0eda23dfa3656b049bd391/Src/WebView2.Wpf.Demo/Content/controls_ui/img/goForward_disabled.png -------------------------------------------------------------------------------- /Src/WebView2.Wpf.Demo/Content/controls_ui/img/insecure.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michael-russin/webview2-control/d7de7403a7765eb50b0eda23dfa3656b049bd391/Src/WebView2.Wpf.Demo/Content/controls_ui/img/insecure.png -------------------------------------------------------------------------------- /Src/WebView2.Wpf.Demo/Content/controls_ui/img/neutral.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michael-russin/webview2-control/d7de7403a7765eb50b0eda23dfa3656b049bd391/Src/WebView2.Wpf.Demo/Content/controls_ui/img/neutral.png -------------------------------------------------------------------------------- /Src/WebView2.Wpf.Demo/Content/controls_ui/img/options.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michael-russin/webview2-control/d7de7403a7765eb50b0eda23dfa3656b049bd391/Src/WebView2.Wpf.Demo/Content/controls_ui/img/options.png -------------------------------------------------------------------------------- /Src/WebView2.Wpf.Demo/Content/controls_ui/img/reload.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michael-russin/webview2-control/d7de7403a7765eb50b0eda23dfa3656b049bd391/Src/WebView2.Wpf.Demo/Content/controls_ui/img/reload.png -------------------------------------------------------------------------------- /Src/WebView2.Wpf.Demo/Content/controls_ui/img/secure.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michael-russin/webview2-control/d7de7403a7765eb50b0eda23dfa3656b049bd391/Src/WebView2.Wpf.Demo/Content/controls_ui/img/secure.png -------------------------------------------------------------------------------- /Src/WebView2.Wpf.Demo/Content/controls_ui/img/unknown.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michael-russin/webview2-control/d7de7403a7765eb50b0eda23dfa3656b049bd391/Src/WebView2.Wpf.Demo/Content/controls_ui/img/unknown.png -------------------------------------------------------------------------------- /Src/WebView2.Wpf.Demo/Content/controls_ui/options.css: -------------------------------------------------------------------------------- 1 | html, body { 2 | width: 200px; 3 | height: 107px; 4 | } 5 | 6 | #dropdown-wrapper { 7 | width: calc(100% - 2px); 8 | height: calc(100% - 2px); 9 | border: 1px solid gray; 10 | } 11 | 12 | .dropdown-item { 13 | background-color: rgb(240, 240, 240); 14 | } 15 | 16 | .dropdown-item:hover { 17 | background-color: rgb(220, 220, 220); 18 | } 19 | 20 | .item-label { 21 | display: flex; 22 | height: 35px; 23 | text-align: center; 24 | vertical-align: middle; 25 | 26 | white-space: nowrap; 27 | overflow: hidden; 28 | } 29 | 30 | .item-label span { 31 | font-family: Arial; 32 | font-size: 0.8em; 33 | vertical-align: middle; 34 | flex: 1; 35 | align-self: center; 36 | text-align: left; 37 | padding-left: 10px; 38 | } 39 | -------------------------------------------------------------------------------- /Src/WebView2.Wpf.Demo/Content/controls_ui/options.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /Src/WebView2.Wpf.Demo/Content/controls_ui/options.js: -------------------------------------------------------------------------------- 1 | function navigateToBrowserPage(path) { 2 | const navMessage = { 3 | message: commands.MG_NAVIGATE, 4 | args: { 5 | uri: `browser://${path}` 6 | } 7 | }; 8 | 9 | window.chrome.webview.postMessage(navMessage); 10 | } 11 | 12 | // Add listener for the options menu entries 13 | function addItemsListeners() { 14 | 15 | // Close dropdown when item is selected 16 | (() => { 17 | const dropdownItems = Array.from(document.getElementsByClassName('dropdown-item')); 18 | dropdownItems.map(item => { 19 | item.addEventListener('click', function(e) { 20 | const closeMessage = { 21 | message: commands.MG_OPTION_SELECTED, 22 | args: {} 23 | }; 24 | window.chrome.webview.postMessage(closeMessage); 25 | }); 26 | 27 | // Navigate to browser page 28 | let entry = item.id.split('-')[1]; 29 | switch (entry) { 30 | case 'settings': 31 | case 'history': 32 | case 'favorites': 33 | item.addEventListener('click', function(e) { 34 | navigateToBrowserPage(entry); 35 | }); 36 | break; 37 | } 38 | }); 39 | })(); 40 | } 41 | 42 | function init() { 43 | addItemsListeners(); 44 | } 45 | 46 | init(); 47 | -------------------------------------------------------------------------------- /Src/WebView2.Wpf.Demo/Content/controls_ui/storage.js: -------------------------------------------------------------------------------- 1 | function handleUpgradeEvent(event) { 2 | console.log('Creating DB'); 3 | let newDB = event.target.result; 4 | 5 | newDB.onerror = function(event) { 6 | console.log('Something went wrong'); 7 | console.log(event); 8 | }; 9 | 10 | let newFavoritesStore = newDB.createObjectStore('favorites', { 11 | keyPath: 'uri' 12 | }); 13 | 14 | newFavoritesStore.transaction.oncomplete = function(event) { 15 | console.log('Object stores created'); 16 | }; 17 | 18 | let newHistoryStore = newDB.createObjectStore('history', { 19 | autoIncrement: true 20 | }); 21 | 22 | newHistoryStore.createIndex('timestamp', 'timestamp', { 23 | unique: false 24 | }); 25 | 26 | newHistoryStore.createIndex('stampedURI', ['uri', 'timestamp'], { 27 | unique: false 28 | }); 29 | } 30 | 31 | function queryDB(query) { 32 | let request = window.indexedDB.open('WVBrowser'); 33 | 34 | request.onerror = function(event) { 35 | console.log('Failed to open database'); 36 | }; 37 | 38 | request.onsuccess = function(event) { 39 | let db = event.target.result; 40 | query(db); 41 | }; 42 | 43 | request.onupgradeneeded = handleUpgradeEvent; 44 | } 45 | -------------------------------------------------------------------------------- /Src/WebView2.Wpf.Demo/Content/controls_ui/strip.css: -------------------------------------------------------------------------------- 1 | #tabs-strip { 2 | display: flex; 3 | height: 28px; 4 | 5 | border-top: 1px solid rgb(200, 200, 200); 6 | border-bottom: 1px solid rgb(200, 200, 200); 7 | background-color: rgb(230, 230, 230); 8 | } 9 | 10 | .tab, .tab-active { 11 | display: flex; 12 | flex: 1; 13 | height: 100%; 14 | border-right: 1px solid rgb(200, 200, 200); 15 | overflow: hidden; 16 | max-width: 250px; 17 | } 18 | 19 | .tab-active { 20 | background-color: rgb(240, 240, 240); 21 | } 22 | 23 | #btn-new-tab { 24 | display: flex; 25 | height: 100%; 26 | width: 30px; 27 | } 28 | 29 | #btn-new-tab:hover, .btn-tab-close:hover { 30 | background-color: rgb(200, 200, 200); 31 | } 32 | 33 | #plus-label { 34 | display: block; 35 | flex: 1; 36 | align-self: center; 37 | line-height: 30px; 38 | width: 30px; 39 | text-align: center; 40 | } 41 | 42 | .btn-tab-close { 43 | display: inline-block; 44 | align-self: center; 45 | min-width: 16px; 46 | width: 16px; 47 | height: 16px; 48 | margin: 0 5px; 49 | border-radius: 4px; 50 | 51 | background-size: 100%; 52 | background-image: url('img/cancel.png'); 53 | } 54 | 55 | .tab-label { 56 | display: flex; 57 | flex: 1; 58 | padding: 5px; 59 | padding-left: 10px; 60 | height: calc(100% - 10px); 61 | vertical-align: middle; 62 | 63 | white-space:nowrap; 64 | overflow:hidden; 65 | } 66 | 67 | .tab-label span { 68 | font-family: Arial; 69 | font-size: 0.8em; 70 | flex: 1; 71 | align-self: center; 72 | } 73 | -------------------------------------------------------------------------------- /Src/WebView2.Wpf.Demo/Content/controls_ui/styles.css: -------------------------------------------------------------------------------- 1 | html, body { 2 | margin: 0; 3 | border: none; 4 | padding: 0; 5 | } 6 | 7 | p { 8 | margin: 0; 9 | } 10 | 11 | * { 12 | user-select: none; 13 | } 14 | -------------------------------------------------------------------------------- /Src/WebView2.Wpf.Demo/PopupWindow.xaml: -------------------------------------------------------------------------------- 1 |  9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Src/WebView2.Wpf.Demo/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Resources; 3 | using System.Runtime.CompilerServices; 4 | using System.Runtime.InteropServices; 5 | using System.Windows; 6 | 7 | // General Information about an assembly is controlled through the following 8 | // set of attributes. Change these attribute values to modify the information 9 | // associated with an assembly. 10 | [assembly: AssemblyTitle("WebView2.Wpf.Demo")] 11 | [assembly: AssemblyDescription("")] 12 | [assembly: AssemblyConfiguration("")] 13 | [assembly: AssemblyCompany("")] 14 | [assembly: AssemblyProduct("WebView2.Wpf.Demo")] 15 | [assembly: AssemblyCopyright("Copyright © 2019")] 16 | [assembly: AssemblyTrademark("")] 17 | [assembly: AssemblyCulture("")] 18 | 19 | // Setting ComVisible to false makes the types in this assembly not visible 20 | // to COM components. If you need to access a type in this assembly from 21 | // COM, set the ComVisible attribute to true on that type. 22 | [assembly: ComVisible(false)] 23 | 24 | //In order to begin building localizable applications, set 25 | //CultureYouAreCodingWith in your .csproj file 26 | //inside a . For example, if you are using US english 27 | //in your source files, set the to en-US. Then uncomment 28 | //the NeutralResourceLanguage attribute below. Update the "en-US" in 29 | //the line below to match the UICulture setting in the project file. 30 | 31 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] 32 | 33 | 34 | [assembly: ThemeInfo( 35 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located 36 | //(used if a resource is not found in the page, 37 | // or application resource dictionaries) 38 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located 39 | //(used if a resource is not found in the page, 40 | // app, or any theme specific resource dictionaries) 41 | )] 42 | 43 | 44 | // Version information for an assembly consists of the following four values: 45 | // 46 | // Major Version 47 | // Minor Version 48 | // Build Number 49 | // Revision 50 | // 51 | // You can specify all the values or you can default the Build and Revision Numbers 52 | // by using the '*' as shown below: 53 | // [assembly: AssemblyVersion("1.0.*")] 54 | [assembly: AssemblyVersion("1.0.0.0")] 55 | [assembly: AssemblyFileVersion("1.0.0.0")] 56 | -------------------------------------------------------------------------------- /Src/WebView2.Wpf.Demo/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace WebView2.Wpf.Demo.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// Returns the cached ResourceManager instance used by this class. 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("WebView2.Wpf.Demo.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// Overrides the current thread's CurrentUICulture property for all 51 | /// resource lookups using this strongly typed resource class. 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /Src/WebView2.Wpf.Demo/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace WebView2.Wpf.Demo.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.9.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Src/WebView2.Wpf.Demo/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Src/WebView2.Wpf.Demo/ViewModels/WebView2BrowserViewModel.cs: -------------------------------------------------------------------------------- 1 | using MvvmCross.ViewModels; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace WebView2.Wpf.Demo.ViewModels 9 | { 10 | public class WebView2BrowserViewModel : MvxViewModel 11 | { 12 | const int DEFAULT_DPI = 96; 13 | const int INVALID_TAB_ID = 0; 14 | const int UIBarHeight = 70; 15 | const int OptionsDropdownHeight = 108; 16 | const int OptionsDropdownWidth = 200; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Src/WebView2.Wpf.Demo/WebView2Browser.xaml: -------------------------------------------------------------------------------- 1 |  10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 25 | 31 | 33 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /Src/WebView2.Wpf.Demo/app.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michael-russin/webview2-control/d7de7403a7765eb50b0eda23dfa3656b049bd391/Src/WebView2.Wpf.Demo/app.ico -------------------------------------------------------------------------------- /Src/WebView2.Wpf.Demo/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Src/WebView2.Wpf.Sample/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Src/WebView2.Wpf.Sample/App.xaml: -------------------------------------------------------------------------------- 1 |  6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /Src/WebView2.Wpf.Sample/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Configuration; 4 | using System.Data; 5 | using System.Linq; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | 9 | namespace WebView2.Wpf.Sample 10 | { 11 | /// 12 | /// Interaction logic for App.xaml 13 | /// 14 | public partial class App : Application 15 | { 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Src/WebView2.Wpf.Sample/Components/ComponentBase.cs: -------------------------------------------------------------------------------- 1 |  2 | using System.Windows.Input; 3 | 4 | namespace MtrDev.WebView2.WinForms.Sample.Components 5 | { 6 | public abstract class ComponentBase 7 | { 8 | public abstract void CleanUp(); 9 | 10 | public abstract void RunCommand(ICommand command, ExecutedRoutedEventArgs args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Src/WebView2.Wpf.Sample/Components/ProcessComponent.cs: -------------------------------------------------------------------------------- 1 | using MtrDev.WebView2.Interop; 2 | using MtrDev.WebView2.Wpf; 3 | using MtrDev.WebView2.Wpf.Sample; 4 | using System.Windows; 5 | using System.Windows.Input; 6 | using WebView2.Wpf.Sample; 7 | 8 | namespace MtrDev.WebView2.WinForms.Sample.Components 9 | { 10 | public class ProcessComponent : ComponentBase 11 | { 12 | private WebView2Control _webView2; 13 | private MainWindow _parent; 14 | 15 | public ProcessComponent(MainWindow parent, WebView2Control webView2) 16 | { 17 | _parent = parent; 18 | _webView2 = webView2; 19 | 20 | _webView2.ProcessFailed += WebView2ProcessFailed; 21 | } 22 | 23 | public override void CleanUp() 24 | { 25 | _webView2.ProcessFailed -= WebView2ProcessFailed; 26 | _webView2 = null; 27 | _parent = null; 28 | } 29 | 30 | public override void RunCommand(ICommand command, ExecutedRoutedEventArgs args) 31 | { 32 | if (command == ProcessCommands.BrowserProcessInfo) 33 | { 34 | ShowBrowserProcessInfo(); 35 | } 36 | else if (command == ProcessCommands.CrashBrowserProcess) 37 | { 38 | CrashBrowserProcess(); 39 | } 40 | } 41 | 42 | private void WebView2ProcessFailed(object sender, Wrapper.ProcessFailedEventArgs e) 43 | { 44 | WEBVIEW2_PROCESS_FAILED_KIND failureType = e.ProcessFailedKind; 45 | if (failureType == WEBVIEW2_PROCESS_FAILED_KIND.WEBVIEW2_PROCESS_FAILED_KIND_BROWSER_PROCESS_EXITED) 46 | { 47 | MessageBoxResult button = MessageBox.Show( 48 | "Browser process exited unexpectedly. Recreate webview?", 49 | "Browser process exited", 50 | MessageBoxButton.YesNo); 51 | if (button == MessageBoxResult.Yes) 52 | { 53 | _parent.ReinitializeWebView(); 54 | } 55 | } 56 | } 57 | 58 | public void ShowBrowserProcessInfo() 59 | { 60 | uint processId = _webView2.BrowserProcessId; 61 | 62 | string message = string.Format("Process ID: {0}", processId); 63 | MessageBox.Show(message, "Process Info", MessageBoxButton.OK); 64 | } 65 | 66 | public void CrashBrowserProcess() 67 | { 68 | // Crash the browser's process on command, to test crash handlers. 69 | _webView2.Navigate("edge://inducebrowsercrashforrealz"); 70 | } 71 | 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /Src/WebView2.Wpf.Sample/Controls/NavigationToolBar.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Drawing; 5 | using System.Data; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows.Forms; 10 | using MtrDev.WebView2.Sample.Common.Controls; 11 | 12 | namespace MtrDev.WebView2.WinForms.Sample.Controls 13 | { 14 | public partial class NavigationToolBar : UserControl, INavigationToolBar 15 | { 16 | public NavigationToolBar() 17 | { 18 | InitializeComponent(); 19 | } 20 | 21 | public bool CanGoBack 22 | { 23 | get => buttonBack.Enabled; 24 | set => buttonBack.Enabled = value; 25 | } 26 | 27 | public bool CanGoForward 28 | { 29 | get => buttonForward.Enabled; 30 | set => buttonForward.Enabled = value; 31 | } 32 | 33 | public bool CanCancel 34 | { 35 | get => buttonCancel.Enabled; 36 | set => buttonCancel.Enabled = value; 37 | } 38 | 39 | public string Url 40 | { 41 | get => textBoxUrl.Text; 42 | set => textBoxUrl.Text = value; 43 | } 44 | 45 | public event EventHandler GoClicked; 46 | public event EventHandler BackClicked; 47 | public event EventHandler ForwardClicked; 48 | public event EventHandler CancelClicked; 49 | public event EventHandler ReloadClicked; 50 | 51 | private void buttonGo_Click(object sender, EventArgs e) 52 | { 53 | EventHandler handler = GoClicked; 54 | if (handler != null) 55 | { 56 | handler(this, new EventArgs()); 57 | } 58 | } 59 | 60 | private void buttonBack_Click(object sender, EventArgs e) 61 | { 62 | EventHandler handler = BackClicked; 63 | if (handler != null) 64 | { 65 | handler(this, new EventArgs()); 66 | } 67 | } 68 | 69 | private void buttonForward_Click(object sender, EventArgs e) 70 | { 71 | EventHandler handler = ForwardClicked; 72 | if (handler != null) 73 | { 74 | handler(this, new EventArgs()); 75 | } 76 | } 77 | 78 | private void buttonReload_Click(object sender, EventArgs e) 79 | { 80 | EventHandler handler = ReloadClicked; 81 | if (handler != null) 82 | { 83 | handler(this, new EventArgs()); 84 | } 85 | } 86 | 87 | private void buttonCancel_Click(object sender, EventArgs e) 88 | { 89 | EventHandler handler = CancelClicked; 90 | if (handler != null) 91 | { 92 | handler(this, new EventArgs()); 93 | } 94 | } 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /Src/WebView2.Wpf.Sample/Controls/NavigationToolBar.xaml: -------------------------------------------------------------------------------- 1 |  9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Src/WebView2.Wpf.Sample/Controls/NavigationToolBar.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows; 3 | using System.Windows.Controls; 4 | 5 | namespace MtrDev.WebView2.Wpf.Sample.Controls 6 | { 7 | /// 8 | /// Interaction logic for NavigationToolBar.xaml 9 | /// 10 | public partial class NavigationToolBar : UserControl 11 | { 12 | public NavigationToolBar() 13 | { 14 | InitializeComponent(); 15 | } 16 | 17 | public bool CanGoBack 18 | { 19 | get => buttonBack.IsEnabled; 20 | set => buttonBack.IsEnabled = value; 21 | } 22 | 23 | public bool CanGoForward 24 | { 25 | get => buttonForward.IsEnabled; 26 | set => buttonForward.IsEnabled = value; 27 | } 28 | 29 | public bool CanCancel 30 | { 31 | get => buttonCancel.IsEnabled; 32 | set => buttonCancel.IsEnabled = value; 33 | } 34 | 35 | public string Url 36 | { 37 | get => textBoxUrl.Text; 38 | set => textBoxUrl.Text = value; 39 | } 40 | 41 | public event EventHandler GoClicked; 42 | public event EventHandler BackClicked; 43 | public event EventHandler ForwardClicked; 44 | public event EventHandler CancelClicked; 45 | public event EventHandler ReloadClicked; 46 | 47 | private void buttonGo_Click(object sender, RoutedEventArgs e) 48 | { 49 | EventHandler handler = GoClicked; 50 | if (handler != null) 51 | { 52 | handler(this, new EventArgs()); 53 | } 54 | } 55 | 56 | private void buttonBack_Click(object sender, RoutedEventArgs e) 57 | { 58 | EventHandler handler = BackClicked; 59 | if (handler != null) 60 | { 61 | handler(this, new EventArgs()); 62 | } 63 | } 64 | 65 | private void buttonForward_Click(object sender, RoutedEventArgs e) 66 | { 67 | EventHandler handler = ForwardClicked; 68 | if (handler != null) 69 | { 70 | handler(this, new EventArgs()); 71 | } 72 | } 73 | 74 | private void buttonReload_Click(object sender, RoutedEventArgs e) 75 | { 76 | EventHandler handler = ReloadClicked; 77 | if (handler != null) 78 | { 79 | handler(this, new EventArgs()); 80 | } 81 | } 82 | 83 | private void buttonCancel_Click(object sender, RoutedEventArgs e) 84 | { 85 | EventHandler handler = CancelClicked; 86 | if (handler != null) 87 | { 88 | handler(this, new EventArgs()); 89 | } 90 | } 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /Src/WebView2.Wpf.Sample/Forms/AboutWindow.xaml: -------------------------------------------------------------------------------- 1 |  9 | 10 | 11 | 12 | 13 | 14 | 15 | WebView2APISample, Version 1.0 16 | Copyright (C) 2019 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /Src/WebView2.Wpf.Sample/Forms/AboutWindow.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | using System.Windows.Controls; 8 | using System.Windows.Data; 9 | using System.Windows.Documents; 10 | using System.Windows.Input; 11 | using System.Windows.Media; 12 | using System.Windows.Media.Imaging; 13 | using System.Windows.Shapes; 14 | 15 | namespace MtrDev.WebView2.Wpf.Sample.Forms 16 | { 17 | /// 18 | /// Interaction logic for AboutWindow.xaml 19 | /// 20 | public partial class AboutWindow : Window 21 | { 22 | public AboutWindow() 23 | { 24 | InitializeComponent(); 25 | } 26 | 27 | private void Button_Click(object sender, RoutedEventArgs e) 28 | { 29 | Close(); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Src/WebView2.Wpf.Sample/Forms/CommonDialogs.cs: -------------------------------------------------------------------------------- 1 |  2 | using System.Windows; 3 | 4 | namespace MtrDev.WebView2.WinForms.Sample.Forms 5 | { 6 | public class CommonDialogs 7 | { 8 | public static void ShowFailure(int hr, string message) 9 | { 10 | string formattedMessage = message + " " + hr.ToString("X"); 11 | MessageBox.Show(formattedMessage, "Error", MessageBoxButton.OK); 12 | } 13 | 14 | public static void ShowError(string message) 15 | { 16 | MessageBox.Show(message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Src/WebView2.Wpf.Sample/Forms/TextInputDialog.xaml: -------------------------------------------------------------------------------- 1 |  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 | -------------------------------------------------------------------------------- /Src/WebView2.Wpf.Sample/Forms/TextInputDialog.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | using System.Windows.Controls; 8 | using System.Windows.Data; 9 | using System.Windows.Documents; 10 | using System.Windows.Input; 11 | using System.Windows.Media; 12 | using System.Windows.Media.Imaging; 13 | using System.Windows.Shapes; 14 | 15 | namespace MtrDev.WebView2.Wpf.Sample.Forms 16 | { 17 | /// 18 | /// Interaction logic for TextInputDialog.xaml 19 | /// 20 | public partial class TextInputDialog : Window 21 | { 22 | public TextInputDialog() :this(string.Empty, string.Empty, string.Empty, string.Empty, true) 23 | { 24 | } 25 | 26 | public TextInputDialog(string title, string prompt, string description, string defaultText, bool readOnly) 27 | { 28 | InitializeComponent(); 29 | 30 | Title= title; 31 | labelStatic.Header = prompt; 32 | labelDescription.Text = description; 33 | textBoxInput.Text = defaultText; 34 | if (readOnly) 35 | { 36 | textBoxInput.IsReadOnly = readOnly; 37 | } 38 | } 39 | 40 | public string Input 41 | { 42 | get 43 | { 44 | return textBoxInput.Text; 45 | } 46 | } 47 | 48 | private void Ok_Click(object sender, RoutedEventArgs e) 49 | { 50 | DialogResult = true; 51 | Close(); 52 | } 53 | 54 | private void Cancel_Click(object sender, RoutedEventArgs e) 55 | { 56 | DialogResult = false; 57 | Close(); 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /Src/WebView2.Wpf.Sample/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Resources; 3 | using System.Runtime.CompilerServices; 4 | using System.Runtime.InteropServices; 5 | using System.Windows; 6 | 7 | // General Information about an assembly is controlled through the following 8 | // set of attributes. Change these attribute values to modify the information 9 | // associated with an assembly. 10 | [assembly: AssemblyTitle("WebView2.Wpf.Sample")] 11 | [assembly: AssemblyDescription("")] 12 | [assembly: AssemblyConfiguration("")] 13 | [assembly: AssemblyCompany("")] 14 | [assembly: AssemblyProduct("WebView2.Wpf.Sample")] 15 | [assembly: AssemblyCopyright("Copyright © 2020")] 16 | [assembly: AssemblyTrademark("")] 17 | [assembly: AssemblyCulture("")] 18 | 19 | // Setting ComVisible to false makes the types in this assembly not visible 20 | // to COM components. If you need to access a type in this assembly from 21 | // COM, set the ComVisible attribute to true on that type. 22 | [assembly: ComVisible(false)] 23 | 24 | //In order to begin building localizable applications, set 25 | //CultureYouAreCodingWith in your .csproj file 26 | //inside a . For example, if you are using US english 27 | //in your source files, set the to en-US. Then uncomment 28 | //the NeutralResourceLanguage attribute below. Update the "en-US" in 29 | //the line below to match the UICulture setting in the project file. 30 | 31 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] 32 | 33 | 34 | [assembly: ThemeInfo( 35 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located 36 | //(used if a resource is not found in the page, 37 | // or application resource dictionaries) 38 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located 39 | //(used if a resource is not found in the page, 40 | // app, or any theme specific resource dictionaries) 41 | )] 42 | 43 | 44 | // Version information for an assembly consists of the following four values: 45 | // 46 | // Major Version 47 | // Minor Version 48 | // Build Number 49 | // Revision 50 | // 51 | // You can specify all the values or you can default the Build and Revision Numbers 52 | // by using the '*' as shown below: 53 | // [assembly: AssemblyVersion("1.0.*")] 54 | [assembly: AssemblyVersion("1.0.0.0")] 55 | [assembly: AssemblyFileVersion("1.0.0.0")] 56 | -------------------------------------------------------------------------------- /Src/WebView2.Wpf.Sample/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace MtrDev.WebView2.Wpf.Sample.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.5.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Src/WebView2.Wpf.Sample/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Src/WebView2.Wpf.Sample/Scenarios/ScenarioWebMessage.cs: -------------------------------------------------------------------------------- 1 | using MtrDev.WebView2.WinForms.Sample.Components; 2 | using MtrDev.WebView2.WinForms.Sample.Utils; 3 | using MtrDev.WebView2.Wpf; 4 | using System; 5 | using System.Windows.Input; 6 | using WebView2.Wpf.Sample; 7 | 8 | namespace MtrDev.WebView2.WinForms.Sample.Scenarios 9 | { 10 | public class ScenarioWebMessage : ComponentBase 11 | { 12 | private MainWindow _parent; 13 | private WebView2Control _webView2; 14 | 15 | string _samplePath = "Scenarios\\ScenarioWebMessage.html"; 16 | string _sampleUri; 17 | 18 | public ScenarioWebMessage(MainWindow parent, WebView2Control webView2) 19 | { 20 | _parent = parent; 21 | _webView2 = webView2; 22 | 23 | _sampleUri = FileUtil.GetLocalUri(_samplePath); 24 | 25 | _webView2.IsWebMessageEnabled = true; 26 | 27 | _webView2.WebMessageRecieved += WebView2WebMessageRecieved; 28 | 29 | // Changes to IWebView2Settings::IsWebMessageEnabled apply to the next document 30 | // to which we navigate. 31 | _webView2.Navigate(_sampleUri); 32 | } 33 | 34 | public override void CleanUp() 35 | { 36 | _webView2.WebMessageRecieved -= WebView2WebMessageRecieved; 37 | 38 | _webView2 = null; 39 | _parent = null; 40 | } 41 | 42 | public override void RunCommand(ICommand command, ExecutedRoutedEventArgs args) 43 | { 44 | throw new NotImplementedException(); 45 | } 46 | 47 | private void WebView2WebMessageRecieved(object sender, Wrapper.WebMessageReceivedEventArgs e) 48 | { 49 | string url = _webView2.Source; 50 | 51 | // Always validate that the origin of the message is what you expect. 52 | if (url != _sampleUri) 53 | { 54 | return; 55 | } 56 | string message = e.WebMessageAsString; 57 | 58 | if (message.StartsWith("SetTitleText ")) 59 | { 60 | _parent.Title = message.Substring(13); 61 | } 62 | else if (message.StartsWith("GetWindowBounds")) 63 | { 64 | string reply = 65 | "{\"WindowBounds\":\"Left:" + "0" 66 | + "\\nTop:" + "0" 67 | + "\\nRight:" + _webView2.ActualWidth 68 | + "\\nBottom:" + _webView2.ActualHeight 69 | + "\"}"; 70 | _webView2.PostWebMessageAsJson(reply); 71 | } 72 | } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /Src/WebView2.Wpf.Sample/Scenarios/ScenarioWebMessage.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ScenarioWebMessage 5 | 26 | 27 | 28 |

WebMessage sample page

29 |

This page demonstrates basic interaction between the host app and the webview by 30 | means of Web Messages.

31 | 32 |

Posting Messages

33 |

Messages can be posted from the host app to the webview using the 34 | functions ICoreWebView2::PostWebMessageAsJson and 35 | ICoreWebView2::PostWebMessageAsString. Try using the menu item 36 | "Script->Post Message JSON" to send the message {"SetColor":"blue"}. 37 | It should change the text color of this paragraph.

38 | 39 |

Receiving Messages

40 |

The host app can receive messages by registering an event handler with 41 | ICoreWebView2::add_WebMessageReceived. If you enter text and click 42 | "Send", this page will send a message to the host app which will change the text of 43 | the title bar.

44 | 45 | 46 | 47 |

Round trip

48 |

The host app can send messages back in response to received messages. If you click 49 | "Get window bounds", the host app will report back the bounds of its window, which will 50 | appear in the text box.

51 |
52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /Src/WebView2.Wpf.Sample/Utils/FileUtil.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Reflection; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace MtrDev.WebView2.WinForms.Sample.Utils 10 | { 11 | public class FileUtil 12 | { 13 | public static string GetLocalUri(string relativePath) 14 | { 15 | string path = GetLocalPath(relativePath); 16 | 17 | Uri uri = new Uri(path); 18 | 19 | return uri.AbsoluteUri; 20 | } 21 | 22 | public static string GetLocalPath(string relativePath) 23 | { 24 | var location = new Uri(Assembly.GetEntryAssembly().GetName().CodeBase); 25 | string fulllName = new FileInfo(location.AbsolutePath).Directory.FullName; 26 | 27 | return Path.Combine(fulllName, relativePath); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Src/WebView2.Wpf.Sample/Utils/ProcessUtil.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Diagnostics; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace MtrDev.WebView2.WinForms.Sample.Utils 9 | { 10 | internal class ProcessUtil 11 | { 12 | internal static void EnsureProcessIsClosed(uint processId, int timeoutMs) 13 | { 14 | if (processId != 0) 15 | { 16 | Process process = Process.GetProcessById((int)processId); 17 | if (process != null) 18 | { 19 | if (!process.WaitForExit(timeoutMs)) 20 | { 21 | // Force kill the process if it doesn't exit by itself 22 | process.Kill(); 23 | } 24 | } 25 | } 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Src/WebView2.Wpf.Sample/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /Src/WebView2.Wpf.Sample/small.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michael-russin/webview2-control/d7de7403a7765eb50b0eda23dfa3656b049bd391/Src/WebView2.Wpf.Sample/small.ico -------------------------------------------------------------------------------- /Src/WebView2.Wpf/EventArgs/BeforeEnvironmentCreatedEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace MtrDev.WebView2.Wpf 8 | { 9 | /// 10 | /// 11 | /// 12 | public class BeforeEnvironmentCreatedEventArgs : EventArgs 13 | { 14 | public string BrowserExecutableFolder { get; set; } 15 | 16 | public string UserDataFolder { get; set; } 17 | 18 | public string BrowserArguments { get; set; } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Src/WebView2.Wpf/HandlerType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace MtrDev.WebView2.Wpf 8 | { 9 | internal enum HandlerType 10 | { 11 | NavigationStarting = 0, 12 | NavigationComplete = 1, 13 | ZoomFactorChanged = 2, 14 | WebMessageReceived = 3, 15 | [Obsolete] 16 | DocumentStateChanged = 4, 17 | LostFocus = 5, 18 | FrameNavigationStarting = 6, 19 | MoveFocusRequested = 7, 20 | GotFocus = 8, 21 | WebResourceRequested = 9, 22 | ScriptDialogOpening = 10, 23 | PermissionRequested = 11, 24 | ProcessFailed = 12, 25 | TitleChanged = 13, 26 | NewWindow = 14, 27 | AcceleratorKeyPressed = 15, 28 | FullScreenElement = 16, 29 | ContentLoading = 17, 30 | SourceChanged = 18, 31 | HistoryChanged = 19, 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Src/WebView2.Wpf/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Resources; 3 | using System.Runtime.CompilerServices; 4 | using System.Runtime.InteropServices; 5 | using System.Windows; 6 | 7 | // General Information about an assembly is controlled through the following 8 | // set of attributes. Change these attribute values to modify the information 9 | // associated with an assembly. 10 | [assembly: AssemblyTitle("MtrDev.Wpf.WebView2")] 11 | [assembly: AssemblyDescription("Wpf Implementation of WebView2 browser")] 12 | [assembly: AssemblyConfiguration("")] 13 | [assembly: AssemblyCompany("MtrDev")] 14 | [assembly: AssemblyProduct("MtrDev.Wpf.WebView2")] 15 | [assembly: AssemblyCopyright("Copyright © 2020")] 16 | [assembly: AssemblyTrademark("")] 17 | [assembly: AssemblyCulture("")] 18 | 19 | // Setting ComVisible to false makes the types in this assembly not visible 20 | // to COM components. If you need to access a type in this assembly from 21 | // COM, set the ComVisible attribute to true on that type. 22 | [assembly: ComVisible(false)] 23 | 24 | //In order to begin building localizable applications, set 25 | //CultureYouAreCodingWith in your .csproj file 26 | //inside a . For example, if you are using US english 27 | //in your source files, set the to en-US. Then uncomment 28 | //the NeutralResourceLanguage attribute below. Update the "en-US" in 29 | //the line below to match the UICulture setting in the project file. 30 | 31 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] 32 | 33 | 34 | [assembly:ThemeInfo( 35 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located 36 | //(used if a resource is not found in the page, 37 | // or application resource dictionaries) 38 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located 39 | //(used if a resource is not found in the page, 40 | // app, or any theme specific resource dictionaries) 41 | )] 42 | 43 | 44 | // Version information for an assembly consists of the following four values: 45 | // 46 | // Major Version 47 | // Minor Version 48 | // Build Number 49 | // Revision 50 | // 51 | // You can specify all the values or you can default the Build and Revision Numbers 52 | // by using the '*' as shown below: 53 | // [assembly: AssemblyVersion("1.0.*")] 54 | [assembly: AssemblyVersion("1.9.430.4")] 55 | [assembly: AssemblyFileVersion("1.9.430.4")] 56 | -------------------------------------------------------------------------------- /Src/WebView2.Wpf/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace MtrDev.WebView2.Wpf.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// Returns the cached ResourceManager instance used by this class. 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("MtrDev.WebView2.Wpf.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// Overrides the current thread's CurrentUICulture property for all 51 | /// resource lookups using this strongly typed resource class. 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /Src/WebView2.Wpf/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace MtrDev.WebView2.Wpf.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.5.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Src/WebView2.Wpf/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Src/WebView2.Wpf/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /Src/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/michael-russin/webview2-control/d7de7403a7765eb50b0eda23dfa3656b049bd391/Src/icon.png --------------------------------------------------------------------------------