Skip to content

Commit 9637463

Browse files
committed
Disable CEF on XP and Vista
Chromium is no longer supported on XP and Vista. See: https://chrome.googleblog.com/2015/11/updates-to-chrome-platform-support.html
1 parent 4785c9c commit 9637463

File tree

8 files changed

+114
-64
lines changed

8 files changed

+114
-64
lines changed

MTA10/core/CCore.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@ CCore::CCore ( void )
129129
m_pGraphics = new CGraphics ( m_pLocalGUI );
130130
g_pGraphics = m_pGraphics;
131131
m_pGUI = NULL;
132-
m_pWebCore = NULL;
133132

134133
// Create the mod manager
135134
m_pModManager = new CModManager;
@@ -226,7 +225,7 @@ CCore::~CCore ( void )
226225
delete m_pGraphics;
227226

228227
// Delete the web
229-
delete m_pWebCore;
228+
SAFE_DELETE ( m_pWebCore );
230229

231230
// Delete lazy subsystems
232231
DestroyGUI ();
@@ -1152,7 +1151,8 @@ void CCore::DestroyNetwork ( )
11521151
void CCore::InitialiseWeb ()
11531152
{
11541153
// Don't initialise webcore twice
1155-
if ( m_pWebCore )
1154+
// Also disable webbrowser stuff if this PC still uses deprecated, vulnerable software e.g. XP
1155+
if ( m_pWebCore || !IsWindows7OrGreater() )
11561156
return;
11571157

11581158
// Ensure DllDirectory has not been changed
@@ -1367,7 +1367,8 @@ void CCore::OnModUnload ( )
13671367
m_uiClientScriptFrameRateLimit = 0;
13681368

13691369
// Clear web whitelist
1370-
m_pWebCore->ResetFilter ();
1370+
if ( m_pWebCore )
1371+
m_pWebCore->ResetFilter ();
13711372
}
13721373

13731374

MTA10/core/CCore.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ class CCore : public CCoreInterface, public CSingleton < CCore >
287287
CXMLFile* m_pConfigFile;
288288
CClientVariables m_ClientVariables;
289289
CCommunity m_Community;
290-
CWebCore* m_pWebCore;
290+
CWebCore* m_pWebCore = nullptr;
291291

292292
// Hook interfaces.
293293
CMessageLoopHook * m_pMessageLoopHook;

MTA10/core/CDirect3DEvents9.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,12 @@ void CDirect3DEvents9::OnPresent ( IDirect3DDevice9 *pDevice )
147147
CGraphics::GetSingleton ().GetRenderItemManager ()->FlushNonAARenderTarget();
148148

149149
bool bTookScreenShot = false;
150+
auto pWebCore = g_pCore->GetWebCore ();
150151
if ( !CGraphics::GetSingleton ().GetScreenGrabber ()->IsQueueEmpty () )
151152
{
152-
g_pCore->GetWebCore ()->OnPreScreenshot ();
153+
if ( pWebCore )
154+
pWebCore->OnPreScreenshot ();
155+
153156
bTookScreenShot = true;
154157
}
155158

@@ -159,8 +162,8 @@ void CDirect3DEvents9::OnPresent ( IDirect3DDevice9 *pDevice )
159162
// Maybe grab screen for upload
160163
CGraphics::GetSingleton ().GetScreenGrabber ()->DoPulse ();
161164

162-
if ( bTookScreenShot )
163-
g_pCore->GetWebCore ()->OnPostScreenshot ();
165+
if ( bTookScreenShot && pWebCore )
166+
pWebCore->OnPostScreenshot ();
164167

165168
// Draw the GUI
166169
CLocalGUI::GetSingleton().Draw ();

MTA10/core/CSettings.cpp

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3011,14 +3011,18 @@ void CSettings::LoadData ( void )
30113011
m_pGridBrowserWhitelist->Clear ();
30123012
m_bBrowserListsChanged = false;
30133013

3014-
std::vector<std::pair<SString, bool>> customBlacklist;
3015-
CCore::GetSingleton ().GetWebCore ()->GetFilterEntriesByType ( customBlacklist, eWebFilterType::WEBFILTER_USER );
3016-
for ( std::vector<std::pair<SString, bool>>::iterator iter = customBlacklist.begin(); iter != customBlacklist.end (); ++iter )
3014+
auto pWebCore = CCore::GetSingleton().GetWebCore();
3015+
if ( pWebCore )
30173016
{
3018-
if ( iter->second == false )
3019-
m_pGridBrowserBlacklist->SetItemText ( m_pGridBrowserBlacklist->AddRow (), 1, iter->first );
3020-
else
3021-
m_pGridBrowserWhitelist->SetItemText ( m_pGridBrowserWhitelist->AddRow (), 1, iter->first );
3017+
std::vector<std::pair<SString, bool>> customBlacklist;
3018+
pWebCore->GetFilterEntriesByType( customBlacklist, eWebFilterType::WEBFILTER_USER );
3019+
for ( std::vector<std::pair<SString, bool>>::iterator iter = customBlacklist.begin(); iter != customBlacklist.end(); ++iter )
3020+
{
3021+
if ( iter->second == false )
3022+
m_pGridBrowserBlacklist->SetItemText( m_pGridBrowserBlacklist->AddRow (), 1, iter->first );
3023+
else
3024+
m_pGridBrowserWhitelist->SetItemText( m_pGridBrowserWhitelist->AddRow (), 1, iter->first );
3025+
}
30223026
}
30233027
}
30243028

@@ -3312,21 +3316,27 @@ void CSettings::SaveData ( void )
33123316
CVARS_SET ("browser_plugins", m_pCheckBoxBrowserPluginsEnabled->GetSelected () );
33133317
}
33143318

3315-
std::vector<SString> customBlacklist;
3316-
for ( int i = 0; i < m_pGridBrowserBlacklist->GetRowCount (); ++i )
3319+
auto pWebCore = CCore::GetSingleton().GetWebCore();
3320+
if ( pWebCore )
33173321
{
3318-
customBlacklist.push_back ( m_pGridBrowserBlacklist->GetItemText ( i, 1 ) );
3322+
std::vector<SString> customBlacklist;
3323+
for ( int i = 0; i < m_pGridBrowserBlacklist->GetRowCount (); ++i )
3324+
{
3325+
customBlacklist.push_back ( m_pGridBrowserBlacklist->GetItemText ( i, 1 ) );
3326+
}
3327+
pWebCore->WriteCustomList( "customblacklist", customBlacklist );
3328+
3329+
std::vector<SString> customWhitelist;
3330+
for ( int i = 0; i < m_pGridBrowserWhitelist->GetRowCount(); ++i )
3331+
{
3332+
customWhitelist.push_back( m_pGridBrowserWhitelist->GetItemText( i, 1 ) );
3333+
}
3334+
pWebCore->WriteCustomList( "customwhitelist", customWhitelist );
3335+
3336+
if ( m_bBrowserListsChanged )
3337+
bBrowserSettingChanged = true;
33193338
}
3320-
CCore::GetSingleton ().GetWebCore ()->WriteCustomList ( "customblacklist", customBlacklist );
33213339

3322-
std::vector<SString> customWhitelist;
3323-
for ( int i = 0; i < m_pGridBrowserWhitelist->GetRowCount (); ++i )
3324-
{
3325-
customWhitelist.push_back ( m_pGridBrowserWhitelist->GetItemText ( i, 1 ) );
3326-
}
3327-
CCore::GetSingleton ().GetWebCore ()->WriteCustomList ( "customwhitelist", customWhitelist );
3328-
if ( m_bBrowserListsChanged )
3329-
bBrowserSettingChanged = true;
33303340

33313341
// Ensure CVARS ranges ok
33323342
CClientVariables::GetSingleton().ValidateValues ();
@@ -4215,4 +4225,4 @@ void CSettings::TabSkip ( bool bBackwards )
42154225
bool CSettings::IsActive ( void )
42164226
{
42174227
return m_pWindow->IsActive ();
4218-
}
4228+
}

MTA10/mods/deathmatch/logic/CClientGame.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2331,7 +2331,8 @@ bool CClientGame::KeyStrokeHandler ( const SString& strKey, bool bState, bool bI
23312331
bool bIgnore = false;
23322332
if ( bState )
23332333
{
2334-
auto pFocusedBrowser = g_pCore->GetWebCore ()->GetFocusedWebView ();
2334+
auto pWebCore = g_pCore->GetWebCore();
2335+
auto pFocusedBrowser = pWebCore ? pWebCore->GetFocusedWebView () : nullptr;
23352336

23362337
if ( g_pCore->IsMenuVisible() || ( g_pCore->GetConsole()->IsInputActive() && bIsConsoleInputKey ) || ( pFocusedBrowser && !pFocusedBrowser->IsLocal () ) )
23372338
bIgnore = true; // Ignore this keydown and the matching keyup
@@ -2390,7 +2391,8 @@ bool CClientGame::CharacterKeyHandler ( WPARAM wChar )
23902391
if ( m_pRootEntity && g_pCore->IsMenuVisible() == false && g_pCore->GetConsole()->IsInputActive() == false )
23912392
{
23922393
// Cancel event if remote browser is focused
2393-
auto pFocusedBrowser = g_pCore->GetWebCore ()->GetFocusedWebView ();
2394+
auto pWebCore = g_pCore->GetWebCore();
2395+
auto pFocusedBrowser = pWebCore ? pWebCore->GetFocusedWebView () : nullptr;
23942396
if ( pFocusedBrowser && !pFocusedBrowser->IsLocal () )
23952397
return false;
23962398

@@ -6328,7 +6330,8 @@ void CClientGame::SetDevelopmentMode ( bool bEnable, bool bEnableWeb )
63286330
else
63296331
g_pGame->GetAudio ()->SetWorldSoundHandler ( NULL );
63306332

6331-
g_pCore->GetWebCore()->SetTestModeEnabled ( bEnableWeb );
6333+
if ( g_pCore->GetWebCore() )
6334+
g_pCore->GetWebCore()->SetTestModeEnabled ( bEnableWeb );
63326335
}
63336336

63346337

MTA10/mods/shared_logic/CClientWebBrowser.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ CClientWebBrowser::CClientWebBrowser ( CClientManager* pManager, ElementID ID, C
1919
SetTypeName ( "webbrowser" );
2020

2121
// Create the web view
22+
assert( g_pCore->GetWebCore() );
2223
m_pWebView = g_pCore->GetWebCore ()->CreateWebView ( pWebBrowserItem->m_uiSizeX, pWebBrowserItem->m_uiSizeY, bLocal, pWebBrowserItem, bTransparent );
2324

2425
// Set events interface

MTA10/mods/shared_logic/luadefs/CLuaBrowserDefs.cpp

Lines changed: 62 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -13,37 +13,61 @@
1313

1414
void CLuaBrowserDefs::LoadFunctions ( void )
1515
{
16-
// Browser functions
17-
CLuaCFunctions::AddFunction ( "createBrowser", CreateBrowser );
18-
CLuaCFunctions::AddFunction ( "requestBrowserDomains", RequestBrowserDomains );
19-
CLuaCFunctions::AddFunction ( "loadBrowserURL", LoadBrowserURL );
20-
CLuaCFunctions::AddFunction ( "isBrowserLoading", IsBrowserLoading );
21-
CLuaCFunctions::AddFunction ( "injectBrowserMouseMove", InjectBrowserMouseMove );
22-
CLuaCFunctions::AddFunction ( "injectBrowserMouseDown", InjectBrowserMouseDown );
23-
CLuaCFunctions::AddFunction ( "injectBrowserMouseUp", InjectBrowserMouseUp );
24-
CLuaCFunctions::AddFunction ( "injectBrowserMouseWheel", InjectBrowserMouseWheel );
25-
CLuaCFunctions::AddFunction ( "getBrowserTitle", GetBrowserTitle );
26-
CLuaCFunctions::AddFunction ( "getBrowserURL", GetBrowserURL );
27-
CLuaCFunctions::AddFunction ( "setBrowserRenderingPaused", SetBrowserRenderingPaused );
28-
CLuaCFunctions::AddFunction ( "executeBrowserJavascript", ExecuteBrowserJavascript );
29-
CLuaCFunctions::AddFunction ( "getBrowserVolume", GetBrowserVolume );
30-
CLuaCFunctions::AddFunction ( "setBrowserVolume", SetBrowserVolume );
31-
CLuaCFunctions::AddFunction ( "isBrowserDomainBlocked", IsBrowserDomainBlocked );
32-
CLuaCFunctions::AddFunction ( "focusBrowser", FocusBrowser );
33-
CLuaCFunctions::AddFunction ( "isBrowserFocused", IsBrowserFocused );
34-
CLuaCFunctions::AddFunction ( "setBrowserProperty", SetBrowserProperty );
35-
CLuaCFunctions::AddFunction ( "getBrowserProperty", GetBrowserProperty );
36-
CLuaCFunctions::AddFunction ( "getBrowserSettings", GetBrowserSettings );
37-
CLuaCFunctions::AddFunction ( "getBrowserSource", GetBrowserSource );
38-
CLuaCFunctions::AddFunction ( "setBrowserAjaxHandler", SetBrowserAjaxHandler );
39-
CLuaCFunctions::AddFunction ( "canBrowserNavigateBack", CanBrowserNavigateBack );
40-
CLuaCFunctions::AddFunction ( "canBrowserNavigateForward", CanBrowserNavigateForward );
41-
CLuaCFunctions::AddFunction ( "navigateBrowserBack", NavigateBrowserBack );
42-
CLuaCFunctions::AddFunction ( "navigateBrowserForward", NavigateBrowserForward );
43-
CLuaCFunctions::AddFunction ( "reloadBrowserPage", ReloadBrowserPage );
44-
CLuaCFunctions::AddFunction ( "toggleBrowserDevTools", ToggleBrowserDevTools );
45-
CLuaCFunctions::AddFunction ( "guiCreateBrowser", GUICreateBrowser );
46-
CLuaCFunctions::AddFunction ( "guiGetBrowser", GUIGetBrowser );
16+
// Define browser functions
17+
std::map<const char*, lua_CFunction> functions
18+
{
19+
{ "createBrowser", CreateBrowser },
20+
{ "requestBrowserDomains", RequestBrowserDomains },
21+
{ "loadBrowserURL", LoadBrowserURL },
22+
{ "isBrowserLoading", IsBrowserLoading },
23+
{ "injectBrowserMouseMove", InjectBrowserMouseMove },
24+
{ "injectBrowserMouseDown", InjectBrowserMouseDown },
25+
{ "injectBrowserMouseUp", InjectBrowserMouseUp },
26+
{ "injectBrowserMouseWheel", InjectBrowserMouseWheel },
27+
{ "getBrowserTitle", GetBrowserTitle },
28+
{ "getBrowserURL", GetBrowserURL },
29+
{ "setBrowserRenderingPaused", SetBrowserRenderingPaused },
30+
{ "executeBrowserJavascript", ExecuteBrowserJavascript },
31+
{ "getBrowserVolume", GetBrowserVolume },
32+
{ "setBrowserVolume", SetBrowserVolume },
33+
{ "isBrowserDomainBlocked", IsBrowserDomainBlocked },
34+
{ "focusBrowser", FocusBrowser },
35+
{ "isBrowserFocused", IsBrowserFocused },
36+
{ "setBrowserProperty", SetBrowserProperty },
37+
{ "getBrowserProperty", GetBrowserProperty },
38+
{ "getBrowserSettings", GetBrowserSettings },
39+
{ "getBrowserSource", GetBrowserSource },
40+
{ "setBrowserAjaxHandler", SetBrowserAjaxHandler },
41+
{ "canBrowserNavigateBack", CanBrowserNavigateBack },
42+
{ "canBrowserNavigateForward", CanBrowserNavigateForward },
43+
{ "navigateBrowserBack", NavigateBrowserBack },
44+
{ "navigateBrowserForward", NavigateBrowserForward },
45+
{ "reloadBrowserPage", ReloadBrowserPage },
46+
{ "toggleBrowserDevTools", ToggleBrowserDevTools },
47+
{ "guiCreateBrowser", GUICreateBrowser },
48+
{ "guiGetBrowser", GUIGetBrowser },
49+
};
50+
51+
// Add browser functions
52+
if ( IsBrowserSupported () )
53+
{
54+
for ( const auto& pair : functions )
55+
{
56+
CLuaCFunctions::AddFunction ( pair.first, pair.second );
57+
}
58+
}
59+
else
60+
{
61+
for ( const auto& pair : functions )
62+
{
63+
CLuaCFunctions::AddFunction( pair.first, [](lua_State* luaVM) -> int {
64+
g_pCore->DebugPrintfColor ( "Called browser function on unsupported, vulnerable operating system. Please upgrade your OS as soon as possible", 255, 0, 0 );
65+
lua_pushboolean ( luaVM, false );
66+
return 1;
67+
} );
68+
}
69+
}
70+
4771
}
4872

4973

@@ -98,6 +122,12 @@ void CLuaBrowserDefs::AddClass ( lua_State* luaVM )
98122
}
99123

100124

125+
bool CLuaBrowserDefs::IsBrowserSupported ()
126+
{
127+
return g_pCore->GetWebCore() != nullptr;
128+
}
129+
130+
101131
int CLuaBrowserDefs::CreateBrowser ( lua_State* luaVM )
102132
{
103133
// texture createBrowser ( int width, int height, bool isLocal [, bool transparent = false] )
@@ -960,4 +990,4 @@ int CLuaBrowserDefs::SetBrowserAjaxHandler ( lua_State* luaVM )
960990

961991
lua_pushboolean ( luaVM, false );
962992
return 1;
963-
}
993+
}

MTA10/mods/shared_logic/luadefs/CLuaBrowserDefs.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ class CLuaBrowserDefs : public CLuaDefs
1818
static void LoadFunctions ( void );
1919
static void AddClass ( lua_State* luaVM );
2020

21+
static bool IsBrowserSupported ();
22+
2123
LUA_DECLARE ( CreateBrowser );
2224
LUA_DECLARE ( RequestBrowserDomains );
2325
LUA_DECLARE ( LoadBrowserURL );
@@ -48,4 +50,4 @@ class CLuaBrowserDefs : public CLuaDefs
4850
LUA_DECLARE ( ToggleBrowserDevTools )
4951
LUA_DECLARE ( GUICreateBrowser );
5052
LUA_DECLARE ( GUIGetBrowser );
51-
};
53+
};

0 commit comments

Comments
 (0)