diff --git a/SampleApps/WebView2APISample/AppWindow.cpp b/SampleApps/WebView2APISample/AppWindow.cpp index f2a7b346..1bb95c0f 100644 --- a/SampleApps/WebView2APISample/AppWindow.cpp +++ b/SampleApps/WebView2APISample/AppWindow.cpp @@ -95,7 +95,7 @@ DWORD WINAPI DownloadAndInstallWV2RT(_In_ LPVOID lpParameter) if (ShellExecuteEx(&shExInfo)) { - returnCode = 0; // Install successfull + returnCode = 0; // Install successful } else { @@ -1313,10 +1313,10 @@ void AppWindow::InitializeWebView() options5->put_EnableTrackingPrevention(m_TrackingPreventionEnabled ? TRUE : FALSE)); } - Microsoft::WRL::ComPtr optionsExperimental; - if (options.As(&optionsExperimental) == S_OK) + Microsoft::WRL::ComPtr options6; + if (options.As(&options6) == S_OK) { - CHECK_FAILURE(optionsExperimental->put_AreBrowserExtensionsEnabled(TRUE)); + CHECK_FAILURE(options6->put_AreBrowserExtensionsEnabled(TRUE)); } HRESULT hr = CreateCoreWebView2EnvironmentWithOptions( @@ -1874,41 +1874,31 @@ void AppWindow::RegisterEventHandlers() .Get(), nullptr)); //! [NewBrowserVersionAvailable] + //! [ProfileDeleted] auto webView2_13 = m_webView.try_query(); - if (webView2_13) - { - wil::com_ptr webView2ProfileBase; - webView2_13->get_Profile(&webView2ProfileBase); - if (webView2ProfileBase) - { - auto webView2Profile = - webView2ProfileBase.try_query(); - if (webView2Profile) + CHECK_FEATURE_RETURN_EMPTY(webView2_13); + wil::com_ptr webView2Profile; + CHECK_FAILURE(webView2_13->get_Profile(&webView2Profile)); + CHECK_FEATURE_RETURN_EMPTY(webView2Profile); + auto webView2Profile8 = webView2Profile.try_query(); + CHECK_FEATURE_RETURN_EMPTY(webView2Profile8); + CHECK_FAILURE(webView2Profile8->add_Deleted( + Microsoft::WRL::Callback( + [this](ICoreWebView2Profile* sender, IUnknown* args) { - CHECK_FAILURE(webView2Profile->add_Deleted( - Microsoft::WRL::Callback< - ICoreWebView2ExperimentalProfileDeletedEventHandler>( - [this](ICoreWebView2Profile* sender, IUnknown* args) - { - RunAsync( - [this]() - { - std::wstring message = - L"The profile has been marked for deletion. Any " - L"associated webview2 objects will be closed."; - MessageBox( - m_mainWindow, message.c_str(), L"webview2 closed", - MB_OK); - CloseAppWindow(); - }); - return S_OK; - }) - .Get(), - nullptr)); - } - } - } + RunAsync( + [this]() + { + std::wstring message = L"The profile has been marked for deletion. Any " + L"associated webview2 objects will be closed."; + MessageBox(m_mainWindow, message.c_str(), L"webview2 closed", MB_OK); + CloseAppWindow(); + }); + return S_OK; + }) + .Get(), + nullptr)); //! [ProfileDeleted] } diff --git a/SampleApps/WebView2APISample/ScenarioExtensionsManagement.cpp b/SampleApps/WebView2APISample/ScenarioExtensionsManagement.cpp index efb97003..392a4708 100644 --- a/SampleApps/WebView2APISample/ScenarioExtensionsManagement.cpp +++ b/SampleApps/WebView2APISample/ScenarioExtensionsManagement.cpp @@ -32,19 +32,17 @@ void ScenarioExtensionsManagement::InstallDefaultExtensions() CHECK_FEATURE_RETURN_EMPTY(webView2_13); wil::com_ptr webView2Profile; CHECK_FAILURE(webView2_13->get_Profile(&webView2Profile)); - auto webView2ExperimentalProfile12 = - webView2Profile.try_query(); - CHECK_FEATURE_RETURN_EMPTY(webView2ExperimentalProfile12); + auto profile7 = webView2Profile.try_query(); + CHECK_FEATURE_RETURN_EMPTY(profile7); std::wstring extension_path_file = m_appWindow->GetLocalUri(c_samplePath, false); // Remove "file:///" from the beginning of extension_path_file std::wstring extension_path = extension_path_file.substr(8); - webView2ExperimentalProfile12->GetBrowserExtensions( - Callback( - [this, webView2ExperimentalProfile12, extension_path]( - HRESULT error, - ICoreWebView2ExperimentalBrowserExtensionList* extensions) -> HRESULT + profile7->GetBrowserExtensions( + Callback( + [this, profile7, extension_path]( + HRESULT error, ICoreWebView2BrowserExtensionList* extensions) -> HRESULT { std::wstring extensionIdString; bool extensionInstalled = false; @@ -53,7 +51,7 @@ void ScenarioExtensionsManagement::InstallDefaultExtensions() for (UINT index = 0; index < extensionsCount; ++index) { - wil::com_ptr extension; + wil::com_ptr extension; extensions->GetValueAtIndex(index, &extension); wil::unique_cotaskmem_string id; @@ -79,8 +77,7 @@ void ScenarioExtensionsManagement::InstallDefaultExtensions() message += L" but was disabled."; extension->Enable( !enabled, - Callback< - ICoreWebView2ExperimentalBrowserExtensionEnableCompletedHandler>( + Callback( [](HRESULT error) -> HRESULT { if (error != S_OK) @@ -99,12 +96,11 @@ void ScenarioExtensionsManagement::InstallDefaultExtensions() if (!extensionInstalled) { - CHECK_FAILURE(webView2ExperimentalProfile12->AddBrowserExtension( + CHECK_FAILURE(profile7->AddBrowserExtension( extension_path.c_str(), - Callback< - ICoreWebView2ExperimentalProfileAddBrowserExtensionCompletedHandler>( + Callback( [](HRESULT error, - ICoreWebView2ExperimentalBrowserExtension* extension) -> HRESULT + ICoreWebView2BrowserExtension* extension) -> HRESULT { if (error != S_OK) { @@ -135,14 +131,12 @@ void ScenarioExtensionsManagement::OffloadDefaultExtensionsIfExtraExtensionsInst CHECK_FEATURE_RETURN_EMPTY(webView2_13); wil::com_ptr webView2Profile; CHECK_FAILURE(webView2_13->get_Profile(&webView2Profile)); - auto webView2ExperimentalProfile12 = - webView2Profile.try_query(); - CHECK_FEATURE_RETURN_EMPTY(webView2ExperimentalProfile12); - - webView2ExperimentalProfile12->GetBrowserExtensions( - Callback( - [this](HRESULT error, ICoreWebView2ExperimentalBrowserExtensionList* extensions) - -> HRESULT + auto profile7 = webView2Profile.try_query(); + CHECK_FEATURE_RETURN_EMPTY(profile7); + + profile7->GetBrowserExtensions( + Callback( + [this](HRESULT error, ICoreWebView2BrowserExtensionList* extensions) -> HRESULT { std::wstring extensionIdString; UINT extensionsCount = 0; @@ -152,7 +146,7 @@ void ScenarioExtensionsManagement::OffloadDefaultExtensionsIfExtraExtensionsInst { for (UINT index = 0; index < extensionsCount; ++index) { - wil::com_ptr extension; + wil::com_ptr extension; extensions->GetValueAtIndex(index, &extension); wil::unique_cotaskmem_string id; @@ -162,8 +156,7 @@ void ScenarioExtensionsManagement::OffloadDefaultExtensionsIfExtraExtensionsInst if (extensionIdString.compare(m_extensionId) == 0) { extension->Remove( - Callback< - ICoreWebView2ExperimentalBrowserExtensionRemoveCompletedHandler>( + Callback( [extension](HRESULT error) -> HRESULT { if (error != S_OK) diff --git a/SampleApps/WebView2APISample/ScriptComponent.cpp b/SampleApps/WebView2APISample/ScriptComponent.cpp index ff1d15f8..25823eb8 100644 --- a/SampleApps/WebView2APISample/ScriptComponent.cpp +++ b/SampleApps/WebView2APISample/ScriptComponent.cpp @@ -179,8 +179,8 @@ void ScriptComponent::AddBrowserExtension() auto webView2_13 = m_webView.try_query(); wil::com_ptr webView2Profile; CHECK_FAILURE(webView2_13->get_Profile(&webView2Profile)); - auto webView2ExperimentalProfile12 = - webView2Profile.try_query(); + auto profile7 = webView2Profile.try_query(); + CHECK_FEATURE_RETURN_EMPTY(profile7); OPENFILENAME openFileName = {}; openFileName.lStructSize = sizeof(openFileName); @@ -196,11 +196,10 @@ void ScriptComponent::AddBrowserExtension() { // Remove the filename part of the path. *wcsrchr(fileName, L'\\') = L'\0'; - webView2ExperimentalProfile12->AddBrowserExtension( + profile7->AddBrowserExtension( fileName, - Callback( - [](HRESULT error, - ICoreWebView2ExperimentalBrowserExtension* extension) -> HRESULT + Callback( + [](HRESULT error, ICoreWebView2BrowserExtension* extension) -> HRESULT { if (error != S_OK) { @@ -231,14 +230,13 @@ void ScriptComponent::RemoveOrDisableBrowserExtension(const bool remove) auto webView2_13 = m_webView.try_query(); wil::com_ptr webView2Profile; CHECK_FAILURE(webView2_13->get_Profile(&webView2Profile)); - auto webView2ExperimentalProfile12 = - webView2Profile.try_query(); - - webView2ExperimentalProfile12->GetBrowserExtensions( - Callback( - [this, webView2ExperimentalProfile12, remove]( - HRESULT error, - ICoreWebView2ExperimentalBrowserExtensionList* extensions) -> HRESULT + auto profile7 = webView2Profile.try_query(); + CHECK_FEATURE_RETURN_EMPTY(profile7); + + profile7->GetBrowserExtensions( + Callback( + [this, profile7, + remove](HRESULT error, ICoreWebView2BrowserExtensionList* extensions) -> HRESULT { std::wstring extensionIdString; UINT extensionsCount = 0; @@ -246,7 +244,7 @@ void ScriptComponent::RemoveOrDisableBrowserExtension(const bool remove) for (UINT index = 0; index < extensionsCount; ++index) { - wil::com_ptr extension; + wil::com_ptr extension; extensions->GetValueAtIndex(index, &extension); wil::unique_cotaskmem_string id; @@ -279,7 +277,7 @@ void ScriptComponent::RemoveOrDisableBrowserExtension(const bool remove) { for (UINT index = 0; index < extensionsCount; ++index) { - wil::com_ptr extension; + wil::com_ptr extension; extensions->GetValueAtIndex(index, &extension); wil::unique_cotaskmem_string id; @@ -292,7 +290,7 @@ void ScriptComponent::RemoveOrDisableBrowserExtension(const bool remove) { extension->Remove( Callback< - ICoreWebView2ExperimentalBrowserExtensionRemoveCompletedHandler>( + ICoreWebView2BrowserExtensionRemoveCompletedHandler>( [](HRESULT error) -> HRESULT { if (error != S_OK) @@ -313,7 +311,7 @@ void ScriptComponent::RemoveOrDisableBrowserExtension(const bool remove) extension->Enable( !enabled, Callback< - ICoreWebView2ExperimentalBrowserExtensionEnableCompletedHandler>( + ICoreWebView2BrowserExtensionEnableCompletedHandler>( [](HRESULT error) -> HRESULT { if (error != S_OK) diff --git a/SampleApps/WebView2APISample/SettingsComponent.cpp b/SampleApps/WebView2APISample/SettingsComponent.cpp index 8e9fd728..e7f80003 100644 --- a/SampleApps/WebView2APISample/SettingsComponent.cpp +++ b/SampleApps/WebView2APISample/SettingsComponent.cpp @@ -789,8 +789,7 @@ bool SettingsComponent::HandleWindowMessage( wil::com_ptr webView2ProfileBase; m_webView2_13->get_Profile(&webView2ProfileBase); CHECK_FEATURE_RETURN(webView2ProfileBase); - auto webView2Profile = - webView2ProfileBase.try_query(); + auto webView2Profile = webView2ProfileBase.try_query(); CHECK_FEATURE_RETURN(webView2Profile); webView2Profile->Delete(); //! [DeleteProfile] diff --git a/SampleApps/WebView2APISample/WebView2APISample.vcxproj b/SampleApps/WebView2APISample/WebView2APISample.vcxproj index 3b26458a..dc4f6515 100644 --- a/SampleApps/WebView2APISample/WebView2APISample.vcxproj +++ b/SampleApps/WebView2APISample/WebView2APISample.vcxproj @@ -425,13 +425,13 @@ - + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + diff --git a/SampleApps/WebView2APISample/assets/ScenarioNonClientRegionSupport.html b/SampleApps/WebView2APISample/assets/ScenarioNonClientRegionSupport.html index cf534a80..95aa7a58 100644 --- a/SampleApps/WebView2APISample/assets/ScenarioNonClientRegionSupport.html +++ b/SampleApps/WebView2APISample/assets/ScenarioNonClientRegionSupport.html @@ -24,17 +24,63 @@ text-align: center; app-region: no-drag; } + + #textarea { + app-region: drag; + } + + #textarea:hover { + border: 1px solid red; + } + + #button { + app-region: drag; + } + + #button:hover { + border: 1px solid red; + }

Non-Client Region Support

-
+

Draggable Region

-

+

Note: This site will always have non-client region support enabled. Upon navigating away from this site, non-client region support will be disabled.

+

Interactive Elements

+

+ This shows how app-region drag can work with interactive elements +

+ + +

Click counter: 0

+ + \ No newline at end of file diff --git a/SampleApps/WebView2APISample/packages.config b/SampleApps/WebView2APISample/packages.config index 05d0b86e..c32cfbf7 100644 --- a/SampleApps/WebView2APISample/packages.config +++ b/SampleApps/WebView2APISample/packages.config @@ -1,5 +1,5 @@  - + \ No newline at end of file diff --git a/SampleApps/WebView2WindowsFormsBrowser/WebView2WindowsFormsBrowser.csproj b/SampleApps/WebView2WindowsFormsBrowser/WebView2WindowsFormsBrowser.csproj index 02c7fb55..3899c974 100644 --- a/SampleApps/WebView2WindowsFormsBrowser/WebView2WindowsFormsBrowser.csproj +++ b/SampleApps/WebView2WindowsFormsBrowser/WebView2WindowsFormsBrowser.csproj @@ -25,7 +25,7 @@ AnyCPU - + diff --git a/SampleApps/WebView2WpfBrowser/MainWindow.xaml.cs b/SampleApps/WebView2WpfBrowser/MainWindow.xaml.cs index 4f716e9d..589c8f0f 100644 --- a/SampleApps/WebView2WpfBrowser/MainWindow.xaml.cs +++ b/SampleApps/WebView2WpfBrowser/MainWindow.xaml.cs @@ -1283,7 +1283,16 @@ void SwipeNavigationCmdExecuted(object target, ExecutedRoutedEventArgs e) void DeleteProfileExecuted(object target, ExecutedRoutedEventArgs e) { + try + { + WebViewProfile.Delete(); + } + catch (NotImplementedException exception) + { + MessageBox.Show(this, "Delete profile Failed: " + exception.Message, "Profile Delete"); + } } + void NonClientRegionSupportCmdExecuted(object target, ExecutedRoutedEventArgs e) { } @@ -2031,6 +2040,8 @@ void WebView_CoreWebView2InitializationCompleted(object sender, CoreWebView2Init webView.CoreWebView2.FrameCreated += WebView_HandleIFrames; SetDefaultDownloadDialogPosition(); + WebViewProfile.Deleted += WebViewProfile_Deleted; + OnWebViewFirstInitialized?.Invoke(); webView.CoreWebView2.NewWindowRequested += delegate ( diff --git a/SampleApps/WebView2WpfBrowser/WebView2WpfBrowser.csproj b/SampleApps/WebView2WpfBrowser/WebView2WpfBrowser.csproj index b0c6a1a5..416d3865 100644 --- a/SampleApps/WebView2WpfBrowser/WebView2WpfBrowser.csproj +++ b/SampleApps/WebView2WpfBrowser/WebView2WpfBrowser.csproj @@ -61,7 +61,7 @@ - +