1
0
mirror of https://github.com/salvadordf/CEF4Delphi.git synced 2025-11-23 21:34:53 +02:00

Added 2 new TChromiumCore properties

Added TChromium.JavascriptEnabled to enable/disable JS at runtime.
Added TChromium.LoadImagesAutomatically to enable/disable image loading at runtime.
This commit is contained in:
Salvador Díaz Fau
2020-08-22 14:56:24 +02:00
parent e36cd5e8c7
commit cfeee87c30
2 changed files with 72 additions and 43 deletions

View File

@@ -141,6 +141,8 @@ type
FDefaultWindowInfoExStyle : cardinal; FDefaultWindowInfoExStyle : cardinal;
FNetworkPredictions : TCefNetworkPredictionOptions; FNetworkPredictions : TCefNetworkPredictionOptions;
FQuicAllowed : boolean; FQuicAllowed : boolean;
FJavascriptEnabled : boolean;
FLoadImagesAutomatically : boolean;
{$IFDEF MSWINDOWS} {$IFDEF MSWINDOWS}
FOldBrowserCompWndPrc : TFNWndProc; FOldBrowserCompWndPrc : TFNWndProc;
@@ -391,6 +393,8 @@ type
procedure SetMultiBrowserMode(aValue : boolean); procedure SetMultiBrowserMode(aValue : boolean);
procedure SetNetworkPredictions(aValue : TCefNetworkPredictionOptions); procedure SetNetworkPredictions(aValue : TCefNetworkPredictionOptions);
procedure SetQuicAllowed(aValue : boolean); procedure SetQuicAllowed(aValue : boolean);
procedure SetJavascriptEnabled(aValue : boolean);
procedure SetLoadImagesAutomatically(aValue : boolean);
function CreateBrowserHost(aWindowInfo : PCefWindowInfo; const aURL : ustring; const aSettings : PCefBrowserSettings; const aExtraInfo : ICefDictionaryValue; const aContext : ICefRequestContext): boolean; function CreateBrowserHost(aWindowInfo : PCefWindowInfo; const aURL : ustring; const aSettings : PCefBrowserSettings; const aExtraInfo : ICefDictionaryValue; const aContext : ICefRequestContext): boolean;
function CreateBrowserHostSync(aWindowInfo : PCefWindowInfo; const aURL : ustring; const aSettings : PCefBrowserSettings; const aExtraInfo : ICefDictionaryValue; const aContext : ICefRequestContext): Boolean; function CreateBrowserHostSync(aWindowInfo : PCefWindowInfo; const aURL : ustring; const aSettings : PCefBrowserSettings; const aExtraInfo : ICefDictionaryValue; const aContext : ICefRequestContext): Boolean;
@@ -880,6 +884,8 @@ type
property Offline : boolean read FOffline write SetOffline; property Offline : boolean read FOffline write SetOffline;
property NetworkPredictions : TCefNetworkPredictionOptions read FNetworkPredictions write SetNetworkPredictions; property NetworkPredictions : TCefNetworkPredictionOptions read FNetworkPredictions write SetNetworkPredictions;
property QuicAllowed : boolean read FQuicAllowed write SetQuicAllowed; property QuicAllowed : boolean read FQuicAllowed write SetQuicAllowed;
property JavascriptEnabled : boolean read FJavascriptEnabled write SetJavascriptEnabled;
property LoadImagesAutomatically : boolean read FLoadImagesAutomatically write SetLoadImagesAutomatically;
property WebRTCIPHandlingPolicy : TCefWebRTCHandlingPolicy read FWebRTCIPHandlingPolicy write SetWebRTCIPHandlingPolicy; property WebRTCIPHandlingPolicy : TCefWebRTCHandlingPolicy read FWebRTCIPHandlingPolicy write SetWebRTCIPHandlingPolicy;
property WebRTCMultipleRoutes : TCefState read FWebRTCMultipleRoutes write SetWebRTCMultipleRoutes; property WebRTCMultipleRoutes : TCefState read FWebRTCMultipleRoutes write SetWebRTCMultipleRoutes;
@@ -1146,50 +1152,52 @@ uses
constructor TChromiumCore.Create(AOwner: TComponent); constructor TChromiumCore.Create(AOwner: TComponent);
begin begin
FBrowsersCS := nil; FBrowsersCS := nil;
FBrowsers := nil; FBrowsers := nil;
FBrowserId := 0; FBrowserId := 0;
FMultiBrowserMode := False; FMultiBrowserMode := False;
{$IFDEF MSWINDOWS} {$IFDEF MSWINDOWS}
FCompHandle := 0; FCompHandle := 0;
{$ENDIF} {$ENDIF}
FIsOSR := False; FIsOSR := False;
FDefaultUrl := 'about:blank'; FDefaultUrl := 'about:blank';
FHandler := nil; FHandler := nil;
FReqContextHandler := nil; FReqContextHandler := nil;
FResourceRequestHandler := nil; FResourceRequestHandler := nil;
FMediaObserver := nil; FMediaObserver := nil;
FMediaObserverReg := nil; FMediaObserverReg := nil;
FDevToolsMsgObserver := nil; FDevToolsMsgObserver := nil;
FDevToolsMsgObserverReg := nil; FDevToolsMsgObserverReg := nil;
FExtensionHandler := nil; FExtensionHandler := nil;
FOptions := nil; FOptions := nil;
FFontOptions := nil; FFontOptions := nil;
FDefaultEncoding := ''; FDefaultEncoding := '';
FPDFPrintOptions := nil; FPDFPrintOptions := nil;
FUpdatePreferences := False; FUpdatePreferences := False;
FCustomHeaderName := ''; FCustomHeaderName := '';
FCustomHeaderValue := ''; FCustomHeaderValue := '';
FPrefsFileName := ''; FPrefsFileName := '';
FAddCustomHeader := False; FAddCustomHeader := False;
FDoNotTrack := True; FDoNotTrack := True;
FSendReferrer := True; FSendReferrer := True;
FRunAllFlashInAllowMode := False; FRunAllFlashInAllowMode := False;
FAllowOutdatedPlugins := False; FAllowOutdatedPlugins := False;
FAlwaysAuthorizePlugins := False; FAlwaysAuthorizePlugins := False;
FSpellChecking := True; FSpellChecking := True;
FSpellCheckerDicts := ''; FSpellCheckerDicts := '';
FZoomStep := ZOOM_STEP_DEF; FZoomStep := ZOOM_STEP_DEF;
FZoomStepCS := nil; FZoomStepCS := nil;
FSafeSearch := False; FSafeSearch := False;
FYouTubeRestrict := YOUTUBE_RESTRICT_OFF; FYouTubeRestrict := YOUTUBE_RESTRICT_OFF;
FPrintingEnabled := True; FPrintingEnabled := True;
FAcceptLanguageList := ''; FAcceptLanguageList := '';
FAcceptCookies := cpAllow; FAcceptCookies := cpAllow;
FBlock3rdPartyCookies := False; FBlock3rdPartyCookies := False;
FOffline := False; FOffline := False;
FNetworkPredictions := CEF_NETWORK_PREDICTION_WIFI_ONLY; FNetworkPredictions := CEF_NETWORK_PREDICTION_WIFI_ONLY;
FQuicAllowed := True; FQuicAllowed := True;
FJavascriptEnabled := True;
FLoadImagesAutomatically := True;
if (GlobalCEFApp <> nil) then if (GlobalCEFApp <> nil) then
FHyperlinkAuditing := GlobalCEFApp.HyperlinkAuditing FHyperlinkAuditing := GlobalCEFApp.HyperlinkAuditing
@@ -2707,6 +2715,24 @@ begin
end; end;
end; end;
procedure TChromiumCore.SetJavascriptEnabled(aValue : boolean);
begin
if (FJavascriptEnabled <> aValue) then
begin
FJavascriptEnabled := aValue;
FUpdatePreferences := True;
end;
end;
procedure TChromiumCore.SetLoadImagesAutomatically(aValue : boolean);
begin
if (FLoadImagesAutomatically <> aValue) then
begin
FLoadImagesAutomatically := aValue;
FUpdatePreferences := True;
end;
end;
procedure TChromiumCore.SetAudioMuted(aValue : boolean); procedure TChromiumCore.SetAudioMuted(aValue : boolean);
begin begin
if Initialized then if Initialized then
@@ -3933,6 +3959,9 @@ begin
UpdatePreference(aBrowser, 'net.network_prediction_options', integer(FNetworkPredictions)); UpdatePreference(aBrowser, 'net.network_prediction_options', integer(FNetworkPredictions));
UpdatePreference(aBrowser, 'net.quic_allowed', FQuicAllowed); UpdatePreference(aBrowser, 'net.quic_allowed', FQuicAllowed);
UpdatePreference(aBrowser, 'webkit.webprefs.javascript_enabled', FJavascriptEnabled);
UpdatePreference(aBrowser, 'webkit.webprefs.loads_images_automatically', FLoadImagesAutomatically);
end; end;
procedure TChromiumCore.doUpdateOwnPreferences; procedure TChromiumCore.doUpdateOwnPreferences;

View File

@@ -2,7 +2,7 @@
"UpdateLazPackages" : [ "UpdateLazPackages" : [
{ {
"ForceNotify" : true, "ForceNotify" : true,
"InternalVersion" : 177, "InternalVersion" : 178,
"Name" : "cef4delphi_lazarus.lpk", "Name" : "cef4delphi_lazarus.lpk",
"Version" : "84.4.1.0" "Version" : "84.4.1.0"
} }