MCPcopy Create free account
hub / github.com/MicrosoftEdge/WebView2Samples / ClearBrowsingData

Method ClearBrowsingData

SampleApps/WebView2APISample/AppWindow.cpp:1049–1071  ·  view source on GitHub ↗

[ClearBrowsingData]

Source from the content-addressed store, hash-verified

1047}
1048//! [ClearBrowsingData]
1049bool AppWindow::ClearBrowsingData(COREWEBVIEW2_BROWSING_DATA_KINDS dataKinds)
1050{
1051 auto webView2_13 = m_webView.try_query<ICoreWebView2_13>();
1052 CHECK_FEATURE_RETURN(webView2_13);
1053 wil::com_ptr<ICoreWebView2Profile> webView2Profile;
1054 CHECK_FAILURE(webView2_13->get_Profile(&webView2Profile));
1055 CHECK_FEATURE_RETURN(webView2Profile);
1056 auto webView2Profile2 = webView2Profile.try_query<ICoreWebView2Profile2>();
1057 CHECK_FEATURE_RETURN(webView2Profile2);
1058 // Clear the browsing data from the last hour.
1059 double endTime = (double)std::time(nullptr);
1060 double startTime = endTime - 3600.0;
1061 CHECK_FAILURE(webView2Profile2->ClearBrowsingDataInTimeRange(
1062 dataKinds, startTime, endTime,
1063 Callback<ICoreWebView2ClearBrowsingDataCompletedHandler>(
1064 [this](HRESULT error) -> HRESULT
1065 {
1066 AsyncMessageBox(L"Completed", L"Clear Browsing Data");
1067 return S_OK;
1068 })
1069 .Get()));
1070 return true;
1071}
1072//! [ClearBrowsingData]
1073
1074//! [ClearCustomDataPartition]

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected