Skip to content

Commit e75555b

Browse files
committed
Added ignoreCache parameter to loadBrowserURL
Also ignoring cache by default if testmode is enabled
1 parent f0495f7 commit e75555b

File tree

6 files changed

+15
-10
lines changed

6 files changed

+15
-10
lines changed

MTA10/core/CWebView.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ void CWebView::CloseBrowser ()
7979
m_pWebView->GetHost ()->CloseBrowser ( true );
8080
}
8181

82-
bool CWebView::LoadURL ( const SString& strURL, bool bFilterEnabled, const SString& strPostData, bool bURLEncoded )
82+
bool CWebView::LoadURL ( const SString& strURL, bool bFilterEnabled, const SString& strPostData, bool bURLEncoded, bool bIgnoreCache )
8383
{
8484
if ( !m_pWebView )
8585
return false;
@@ -97,6 +97,10 @@ bool CWebView::LoadURL ( const SString& strURL, bool bFilterEnabled, const SStri
9797
if ( strPostData.empty () )
9898
{
9999
pFrame->LoadURL ( strURL );
100+
101+
// Reload immediately and flush the cache if either requested or test mode is enabled
102+
if ( bIgnoreCache || g_pCore->GetWebCore ()->IsTestModeEnabled () )
103+
m_pWebView->ReloadIgnoreCache ();
100104
}
101105
else
102106
{

MTA10/core/CWebView.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class CWebView : public CWebViewInterface, private CefClient, private CefRenderH
4343
void SetBeingDestroyed ( bool state ) { m_bBeingDestroyed = state; }
4444

4545
// Exported methods
46-
bool LoadURL ( const SString& strURL, bool bFilterEnabled = true, const SString& strPostData = SString(), bool bURLEncoded = true );
46+
bool LoadURL ( const SString& strURL, bool bFilterEnabled = true, const SString& strPostData = SString(), bool bURLEncoded = true, bool bIgnoreCache = false );
4747
bool IsLoading ();
4848
void GetURL ( SString& outURL );
4949
void GetTitle ( SString& outTitle );

MTA10/mods/shared_logic/CClientWebBrowser.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ bool CClientWebBrowser::IsLoading ()
5151
return m_pWebView->IsLoading ();
5252
}
5353

54-
bool CClientWebBrowser::LoadURL ( const SString& strURL, bool bFilterEnabled, const SString& strPostData, bool bURLEncoded )
54+
bool CClientWebBrowser::LoadURL ( const SString& strURL, bool bFilterEnabled, const SString& strPostData, bool bURLEncoded, bool bIgnoreCache )
5555
{
56-
return m_pWebView->LoadURL ( strURL, bFilterEnabled, strPostData, bURLEncoded );
56+
return m_pWebView->LoadURL ( strURL, bFilterEnabled, strPostData, bURLEncoded, bIgnoreCache );
5757
}
5858

5959
void CClientWebBrowser::GetTitle ( SString& outPageTitle )

MTA10/mods/shared_logic/CClientWebBrowser.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class CClientWebBrowser : public CClientTexture, public CWebBrowserEventsInterfa
2828
inline CWebViewInterface* GetWebView () { return m_pWebView; }
2929

3030
bool IsLoading ();
31-
bool LoadURL ( const SString& strURL, bool bFilterEnabled = true, const SString& strPostData = SString(), bool bURLEncoded = true );
31+
bool LoadURL ( const SString& strURL, bool bFilterEnabled = true, const SString& strPostData = SString(), bool bURLEncoded = true, bool bIgnoreCache = false );
3232
void GetTitle ( SString& outPageTitle );
3333
void GetURL ( SString& outURL );
3434
void SetRenderingPaused ( bool bPaused );

MTA10/mods/shared_logic/lua/CLuaFunctionDefs.Browser.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,14 +111,15 @@ int CLuaFunctionDefs::RequestBrowserDomains ( lua_State* luaVM )
111111

112112
int CLuaFunctionDefs::LoadBrowserURL ( lua_State* luaVM )
113113
{
114-
// bool loadBrowserURL ( browser webBrowser, string url [, string postData = "", bool postURLEncoded = true ] )
115-
CClientWebBrowser* pWebBrowser; SString strURL; SString strPostData; bool bURLEncoded;
114+
// bool loadBrowserURL ( browser webBrowser, string url [, string postData = "", bool postURLEncoded = true, bool ignoreCache = false ] )
115+
CClientWebBrowser* pWebBrowser; SString strURL; SString strPostData; bool bURLEncoded; bool bIgnoreCache;
116116

117117
CScriptArgReader argStream ( luaVM );
118118
argStream.ReadUserData ( pWebBrowser );
119119
argStream.ReadString ( strURL );
120120
argStream.ReadString ( strPostData, "" );
121121
argStream.ReadBool ( bURLEncoded, true );
122+
argStream.ReadBool ( bIgnoreCache, false );
122123

123124
if ( !argStream.HasErrors () )
124125
{
@@ -132,7 +133,7 @@ int CLuaFunctionDefs::LoadBrowserURL ( lua_State* luaVM )
132133
return 1;
133134
}
134135

135-
lua_pushboolean ( luaVM, pWebBrowser->LoadURL ( strURL, !isLocalURL, strPostData, bURLEncoded ) );
136+
lua_pushboolean ( luaVM, pWebBrowser->LoadURL ( strURL, !isLocalURL, strPostData, bURLEncoded, bIgnoreCache ) );
136137
return 1;
137138
}
138139

@@ -149,7 +150,7 @@ int CLuaFunctionDefs::LoadBrowserURL ( lua_State* luaVM )
149150
m_pScriptDebugging->LogWarning ( luaVM, "This URL scheme is deprecated and may not work in future versions. Please consider using http://mta/* instead. See https://wiki.mtasa.com/wiki/LoadBrowserURL for details" );
150151

151152
pWebBrowser->SetTempURL ( strURL );
152-
lua_pushboolean ( luaVM, pWebBrowser->LoadURL ( "mtalocal://" + strURL, false, strPostData, bURLEncoded ) );
153+
lua_pushboolean ( luaVM, pWebBrowser->LoadURL ( "mtalocal://" + strURL, false, strPostData, bURLEncoded, bIgnoreCache ) );
153154
return 1;
154155
}
155156
}

MTA10/sdk/core/CWebViewInterface.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class CWebViewInterface
2020
public:
2121
virtual void Initialise () = 0;
2222
virtual void SetWebBrowserEvents( CWebBrowserEventsInterface* pInterface ) = 0;
23-
virtual bool LoadURL ( const SString& strURL, bool bFilterEnabled = true, const SString& strPostData = SString(), bool bURLEncoded = true ) = 0;
23+
virtual bool LoadURL ( const SString& strURL, bool bFilterEnabled = true, const SString& strPostData = SString(), bool bURLEncoded = true, bool bIgnoreCache = false ) = 0;
2424
virtual bool IsLoading () = 0;
2525
virtual void SetBeingDestroyed ( bool state ) = 0;
2626

0 commit comments

Comments
 (0)