Skip to content

Commit fc1f285

Browse files
committed
Revert "Disable CEF on XP and Vista"
This reverts commit 9637463.
1 parent 280bcaf commit fc1f285

File tree

8 files changed

+64
-114
lines changed

8 files changed

+64
-114
lines changed

MTA10/core/CCore.cpp

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

133134
// Create the mod manager
134135
m_pModManager = new CModManager;
@@ -225,7 +226,7 @@ CCore::~CCore ( void )
225226
delete m_pGraphics;
226227

227228
// Delete the web
228-
SAFE_DELETE ( m_pWebCore );
229+
delete m_pWebCore;
229230

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

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

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

13741373

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 = nullptr;
290+
CWebCore* m_pWebCore;
291291

292292
// Hook interfaces.
293293
CMessageLoopHook * m_pMessageLoopHook;

MTA10/core/CDirect3DEvents9.cpp

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

149149
bool bTookScreenShot = false;
150-
auto pWebCore = g_pCore->GetWebCore ();
151150
if ( !CGraphics::GetSingleton ().GetScreenGrabber ()->IsQueueEmpty () )
152151
{
153-
if ( pWebCore )
154-
pWebCore->OnPreScreenshot ();
155-
152+
g_pCore->GetWebCore ()->OnPreScreenshot ();
156153
bTookScreenShot = true;
157154
}
158155

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

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

168165
// Draw the GUI
169166
CLocalGUI::GetSingleton().Draw ();

MTA10/core/CSettings.cpp

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

3014-
auto pWebCore = CCore::GetSingleton().GetWebCore();
3015-
if ( pWebCore )
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 )
30163017
{
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-
}
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 );
30263022
}
30273023
}
30283024

@@ -3316,27 +3312,21 @@ void CSettings::SaveData ( void )
33163312
CVARS_SET ("browser_plugins", m_pCheckBoxBrowserPluginsEnabled->GetSelected () );
33173313
}
33183314

3319-
auto pWebCore = CCore::GetSingleton().GetWebCore();
3320-
if ( pWebCore )
3315+
std::vector<SString> customBlacklist;
3316+
for ( int i = 0; i < m_pGridBrowserBlacklist->GetRowCount (); ++i )
33213317
{
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;
3318+
customBlacklist.push_back ( m_pGridBrowserBlacklist->GetItemText ( i, 1 ) );
33383319
}
3320+
CCore::GetSingleton ().GetWebCore ()->WriteCustomList ( "customblacklist", customBlacklist );
33393321

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;
33403330

33413331
// Ensure CVARS ranges ok
33423332
CClientVariables::GetSingleton().ValidateValues ();
@@ -4225,4 +4215,4 @@ void CSettings::TabSkip ( bool bBackwards )
42254215
bool CSettings::IsActive ( void )
42264216
{
42274217
return m_pWindow->IsActive ();
4228-
}
4218+
}

MTA10/mods/deathmatch/logic/CClientGame.cpp

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

23372336
if ( g_pCore->IsMenuVisible() || ( g_pCore->GetConsole()->IsInputActive() && bIsConsoleInputKey ) || ( pFocusedBrowser && !pFocusedBrowser->IsLocal () ) )
23382337
bIgnore = true; // Ignore this keydown and the matching keyup
@@ -2391,8 +2390,7 @@ bool CClientGame::CharacterKeyHandler ( WPARAM wChar )
23912390
if ( m_pRootEntity && g_pCore->IsMenuVisible() == false && g_pCore->GetConsole()->IsInputActive() == false )
23922391
{
23932392
// Cancel event if remote browser is focused
2394-
auto pWebCore = g_pCore->GetWebCore();
2395-
auto pFocusedBrowser = pWebCore ? pWebCore->GetFocusedWebView () : nullptr;
2393+
auto pFocusedBrowser = g_pCore->GetWebCore ()->GetFocusedWebView ();
23962394
if ( pFocusedBrowser && !pFocusedBrowser->IsLocal () )
23972395
return false;
23982396

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

6333-
if ( g_pCore->GetWebCore() )
6334-
g_pCore->GetWebCore()->SetTestModeEnabled ( bEnableWeb );
6331+
g_pCore->GetWebCore()->SetTestModeEnabled ( bEnableWeb );
63356332
}
63366333

63376334

MTA10/mods/shared_logic/CClientWebBrowser.cpp

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

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

2524
// Set events interface

MTA10/mods/shared_logic/luadefs/CLuaBrowserDefs.cpp

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

1414
void CLuaBrowserDefs::LoadFunctions ( void )
1515
{
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-
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 );
7147
}
7248

7349

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

124100

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

991961
lua_pushboolean ( luaVM, false );
992962
return 1;
993-
}
963+
}

MTA10/mods/shared_logic/luadefs/CLuaBrowserDefs.h

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

21-
static bool IsBrowserSupported ();
22-
2321
LUA_DECLARE ( CreateBrowser );
2422
LUA_DECLARE ( RequestBrowserDomains );
2523
LUA_DECLARE ( LoadBrowserURL );
@@ -50,4 +48,4 @@ class CLuaBrowserDefs : public CLuaDefs
5048
LUA_DECLARE ( ToggleBrowserDevTools )
5149
LUA_DECLARE ( GUICreateBrowser );
5250
LUA_DECLARE ( GUIGetBrowser );
53-
};
51+
};

0 commit comments

Comments
 (0)