mirror of
https://github.com/valinet/ExplorerPatcher.git
synced 2024-11-12 02:00:46 +01:00
Weather: Detect and break infinite loops on navigating to the error page
This commit is contained in:
parent
f7ffaca146
commit
aeb8e54b58
@ -1,6 +1,7 @@
|
|||||||
#ifndef _H_EP_WEATHER_ERROR_HTML_H_
|
#ifndef _H_EP_WEATHER_ERROR_HTML_H_
|
||||||
#define _H_EP_WEATHER_ERROR_HTML_H_
|
#define _H_EP_WEATHER_ERROR_HTML_H_
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
|
#include <tchar.h>
|
||||||
#define EP_WEATHER_ERROR_LEN 2000
|
#define EP_WEATHER_ERROR_LEN 2000
|
||||||
LPCWSTR ep_weather_error_html = L"\
|
LPCWSTR ep_weather_error_html = L"\
|
||||||
<!DOCTYPE html>\n\
|
<!DOCTYPE html>\n\
|
||||||
@ -8,7 +9,7 @@ LPCWSTR ep_weather_error_html = L"\
|
|||||||
<head>\n\
|
<head>\n\
|
||||||
<meta charset=\"utf-8\" />\n\
|
<meta charset=\"utf-8\" />\n\
|
||||||
<meta name=\"color-scheme\" content=\"light dark\">\n\
|
<meta name=\"color-scheme\" content=\"light dark\">\n\
|
||||||
<title>Weather</title>\n\
|
<title>" _T(CLSID_EPWeather_TEXT) L"_ErrorPage</title>\n\
|
||||||
<style>\n\
|
<style>\n\
|
||||||
html {\n\
|
html {\n\
|
||||||
background-color: transparent !important;\n\
|
background-color: transparent !important;\n\
|
||||||
|
@ -250,13 +250,21 @@ HRESULT STDMETHODCALLTYPE _epw_Weather_NavigateToError(EPWeather* _this)
|
|||||||
}
|
}
|
||||||
if (_this->pCoreWebView2)
|
if (_this->pCoreWebView2)
|
||||||
{
|
{
|
||||||
return _this->pCoreWebView2->lpVtbl->NavigateToString(_this->pCoreWebView2, ep_weather_error_html);
|
LPWSTR wszPageTitle = NULL;
|
||||||
}
|
if (SUCCEEDED(_this->pCoreWebView2->lpVtbl->get_DocumentTitle(_this->pCoreWebView2, &wszPageTitle)))
|
||||||
|
{
|
||||||
|
BOOL bIsOnErrorPage = !_wcsicmp(wszPageTitle, _T(CLSID_EPWeather_TEXT) L"_ErrorPage");
|
||||||
|
CoTaskMemFree(wszPageTitle);
|
||||||
|
if (!bIsOnErrorPage) return _this->pCoreWebView2->lpVtbl->NavigateToString(_this->pCoreWebView2, ep_weather_error_html);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return E_FAIL;
|
printf("[Browser] Already on the error page.\n");
|
||||||
|
return S_OK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
return E_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
HRESULT STDMETHODCALLTYPE _epw_Weather_NavigateToProvider(EPWeather* _this)
|
HRESULT STDMETHODCALLTYPE _epw_Weather_NavigateToProvider(EPWeather* _this)
|
||||||
{
|
{
|
||||||
@ -500,6 +508,7 @@ HRESULT STDMETHODCALLTYPE ICoreWebView2_NavigationCompleted(ICoreWebView2Navigat
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
printf("[Browser] Navigation completed with error, showing error page.\n");
|
||||||
_epw_Weather_NavigateToError(_this);
|
_epw_Weather_NavigateToError(_this);
|
||||||
}
|
}
|
||||||
_this->pCoreWebView2Controller->lpVtbl->put_IsVisible(_this->pCoreWebView2Controller, FALSE);
|
_this->pCoreWebView2Controller->lpVtbl->put_IsVisible(_this->pCoreWebView2Controller, FALSE);
|
||||||
|
Loading…
Reference in New Issue
Block a user