mirror of
https://github.com/salvadordf/CEF4Delphi.git
synced 2025-05-13 21:46:53 +02:00
Fix for issue #265 made by Matthias Kretschmar
Added TChromium.AcceptCookies and TChormium.Block3rdPartyCookies
This commit is contained in:
parent
5649b6e661
commit
f4dd3e69a3
@ -167,6 +167,7 @@ uses
|
|||||||
procedure CreateGlobalCEFApp;
|
procedure CreateGlobalCEFApp;
|
||||||
begin
|
begin
|
||||||
GlobalCEFApp := TCefApplication.Create;
|
GlobalCEFApp := TCefApplication.Create;
|
||||||
|
GlobalCEFApp.cache := 'cache';
|
||||||
//GlobalCEFApp.LogFile := 'cef.log';
|
//GlobalCEFApp.LogFile := 'cef.log';
|
||||||
//GlobalCEFApp.LogSeverity := LOGSEVERITY_VERBOSE;
|
//GlobalCEFApp.LogSeverity := LOGSEVERITY_VERBOSE;
|
||||||
end;
|
end;
|
||||||
@ -181,7 +182,6 @@ procedure TCookieVisitorFrm.BrowserCreatedMsg(var aMessage : TMessage);
|
|||||||
begin
|
begin
|
||||||
CEFWindowParent1.UpdateSize;
|
CEFWindowParent1.UpdateSize;
|
||||||
AddressBarPnl.Enabled := True;
|
AddressBarPnl.Enabled := True;
|
||||||
GoBtn.Click;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCookieVisitorFrm.BrowserDestroyMsg(var aMessage : TMessage);
|
procedure TCookieVisitorFrm.BrowserDestroyMsg(var aMessage : TMessage);
|
||||||
@ -319,10 +319,10 @@ begin
|
|||||||
'/',
|
'/',
|
||||||
True,
|
True,
|
||||||
True,
|
True,
|
||||||
False,
|
True,
|
||||||
now,
|
|
||||||
now,
|
now,
|
||||||
now,
|
now,
|
||||||
|
now + 1,
|
||||||
False);
|
False);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -384,6 +384,8 @@ procedure TCookieVisitorFrm.FormCreate(Sender: TObject);
|
|||||||
begin
|
begin
|
||||||
FCanClose := False;
|
FCanClose := False;
|
||||||
FClosing := False;
|
FClosing := False;
|
||||||
|
|
||||||
|
Chromium1.DefaultURL := Edit1.Text;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCookieVisitorFrm.FormShow(Sender: TObject);
|
procedure TCookieVisitorFrm.FormShow(Sender: TObject);
|
||||||
|
@ -126,6 +126,8 @@ type
|
|||||||
FWebRTCMultipleRoutes : TCefState;
|
FWebRTCMultipleRoutes : TCefState;
|
||||||
FWebRTCNonProxiedUDP : TCefState;
|
FWebRTCNonProxiedUDP : TCefState;
|
||||||
FAcceptLanguageList : ustring;
|
FAcceptLanguageList : ustring;
|
||||||
|
FAcceptCookies : TCefCookiePref;
|
||||||
|
FBlock3rdPartyCookies : boolean;
|
||||||
|
|
||||||
{$IFDEF MSWINDOWS}
|
{$IFDEF MSWINDOWS}
|
||||||
FOldBrowserCompWndPrc : TFNWndProc;
|
FOldBrowserCompWndPrc : TFNWndProc;
|
||||||
@ -328,6 +330,8 @@ type
|
|||||||
procedure SetYouTubeRestrict(aValue : integer);
|
procedure SetYouTubeRestrict(aValue : integer);
|
||||||
procedure SetPrintingEnabled(aValue : boolean);
|
procedure SetPrintingEnabled(aValue : boolean);
|
||||||
procedure SetAcceptLanguageList(const aValue : ustring);
|
procedure SetAcceptLanguageList(const aValue : ustring);
|
||||||
|
procedure SetAcceptCookies(const aValue : TCefCookiePref);
|
||||||
|
procedure SetBlock3rdPartyCookies(const aValue : boolean);
|
||||||
procedure SetOnRequestContextInitialized(const aValue : TOnRequestContextInitialized);
|
procedure SetOnRequestContextInitialized(const aValue : TOnRequestContextInitialized);
|
||||||
procedure SetOnBeforePluginLoad(const aValue : TOnBeforePluginLoad);
|
procedure SetOnBeforePluginLoad(const aValue : TOnBeforePluginLoad);
|
||||||
|
|
||||||
@ -738,6 +742,8 @@ type
|
|||||||
property YouTubeRestrict : integer read FYouTubeRestrict write SetYouTubeRestrict;
|
property YouTubeRestrict : integer read FYouTubeRestrict write SetYouTubeRestrict;
|
||||||
property PrintingEnabled : boolean read FPrintingEnabled write SetPrintingEnabled;
|
property PrintingEnabled : boolean read FPrintingEnabled write SetPrintingEnabled;
|
||||||
property AcceptLanguageList : ustring read FAcceptLanguageList write SetAcceptLanguageList;
|
property AcceptLanguageList : ustring read FAcceptLanguageList write SetAcceptLanguageList;
|
||||||
|
property AcceptCookies : TCefCookiePref read FAcceptCookies write SetAcceptCookies;
|
||||||
|
property Block3rdPartyCookies : boolean read FBlock3rdPartyCookies write SetBlock3rdPartyCookies;
|
||||||
|
|
||||||
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;
|
||||||
@ -965,6 +971,8 @@ begin
|
|||||||
FYouTubeRestrict := YOUTUBE_RESTRICT_OFF;
|
FYouTubeRestrict := YOUTUBE_RESTRICT_OFF;
|
||||||
FPrintingEnabled := True;
|
FPrintingEnabled := True;
|
||||||
FAcceptLanguageList := '';
|
FAcceptLanguageList := '';
|
||||||
|
FAcceptCookies := cpAllow;
|
||||||
|
FBlock3rdPartyCookies := False;
|
||||||
|
|
||||||
{$IFDEF MSWINDOWS}
|
{$IFDEF MSWINDOWS}
|
||||||
FOldBrowserCompWndPrc := nil;
|
FOldBrowserCompWndPrc := nil;
|
||||||
@ -2552,6 +2560,24 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TChromiumCore.SetAcceptCookies(const aValue : TCefCookiePref);
|
||||||
|
begin
|
||||||
|
if (FAcceptCookies <> aValue) then
|
||||||
|
begin
|
||||||
|
FAcceptCookies := aValue;
|
||||||
|
FUpdatePreferences := True;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TChromiumCore.SetBlock3rdPartyCookies(const aValue : boolean);
|
||||||
|
begin
|
||||||
|
if (FBlock3rdPartyCookies <> aValue) then
|
||||||
|
begin
|
||||||
|
FBlock3rdPartyCookies := aValue;
|
||||||
|
FUpdatePreferences := True;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TChromiumCore.SetOnRequestContextInitialized(const aValue : TOnRequestContextInitialized);
|
procedure TChromiumCore.SetOnRequestContextInitialized(const aValue : TOnRequestContextInitialized);
|
||||||
begin
|
begin
|
||||||
FOnRequestContextInitialized := aValue;
|
FOnRequestContextInitialized := aValue;
|
||||||
@ -3188,6 +3214,15 @@ begin
|
|||||||
UpdatePreference(aBrowser, 'printing.enabled', FPrintingEnabled);
|
UpdatePreference(aBrowser, 'printing.enabled', FPrintingEnabled);
|
||||||
UpdatePreference(aBrowser, 'intl.accept_languages', FAcceptLanguageList);
|
UpdatePreference(aBrowser, 'intl.accept_languages', FAcceptLanguageList);
|
||||||
|
|
||||||
|
case FAcceptCookies of
|
||||||
|
cpAllow : UpdatePreference(aBrowser, 'profile.default_content_setting_values.cookies', CEF_COOKIE_PREF_ALLOW);
|
||||||
|
cpBlock : UpdatePreference(aBrowser, 'profile.default_content_setting_values.cookies', CEF_COOKIE_PREF_BLOCK);
|
||||||
|
else UpdatePreference(aBrowser, 'profile.default_content_setting_values.cookies', CEF_COOKIE_PREF_DEFAULT);
|
||||||
|
end;
|
||||||
|
|
||||||
|
UpdatePreference(aBrowser, 'profile.managed_default_content_settings.cookies', CEF_COOKIE_PREF_DEFAULT);
|
||||||
|
UpdatePreference(aBrowser, 'profile.block_third_party_cookies', FBlock3rdPartyCookies);
|
||||||
|
|
||||||
if (FMaxConnectionsPerProxy <> CEF_MAX_CONNECTIONS_PER_PROXY_DEFAULT_VALUE) then
|
if (FMaxConnectionsPerProxy <> CEF_MAX_CONNECTIONS_PER_PROXY_DEFAULT_VALUE) then
|
||||||
UpdatePreference(aBrowser, 'net.max_connections_per_proxy', FMaxConnectionsPerProxy);
|
UpdatePreference(aBrowser, 'net.max_connections_per_proxy', FMaxConnectionsPerProxy);
|
||||||
|
|
||||||
@ -4648,13 +4683,10 @@ function TChromiumCore.doOnGetAuthCredentials(const browser : ICefBrowser;
|
|||||||
begin
|
begin
|
||||||
Result := False;
|
Result := False;
|
||||||
|
|
||||||
if isProxy then
|
if isProxy and (FProxyType = CEF_PROXYTYPE_FIXED_SERVERS) and (callback <> nil) then
|
||||||
begin
|
|
||||||
if (FProxyType = CEF_PROXYTYPE_FIXED_SERVERS) and (callback <> nil) then
|
|
||||||
begin
|
begin
|
||||||
Result := True;
|
Result := True;
|
||||||
callback.cont(FProxyUsername, FProxyPassword);
|
callback.cont(FProxyUsername, FProxyPassword);
|
||||||
end;
|
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if Assigned(FOnGetAuthCredentials) then
|
if Assigned(FOnGetAuthCredentials) then
|
||||||
|
@ -548,6 +548,10 @@ const
|
|||||||
CEF_MAX_CONNECTIONS_PER_PROXY_MIN_VALUE = 7;
|
CEF_MAX_CONNECTIONS_PER_PROXY_MIN_VALUE = 7;
|
||||||
CEF_MAX_CONNECTIONS_PER_PROXY_MAX_VALUE = 99;
|
CEF_MAX_CONNECTIONS_PER_PROXY_MAX_VALUE = 99;
|
||||||
|
|
||||||
|
CEF_COOKIE_PREF_DEFAULT = 0;
|
||||||
|
CEF_COOKIE_PREF_ALLOW = 1;
|
||||||
|
CEF_COOKIE_PREF_BLOCK = 2;
|
||||||
|
|
||||||
// https://chromium.googlesource.com/chromium/src/+/refs/tags/77.0.3865.90/chrome/common/net/safe_search_util.h (YouTubeRestrictMode)
|
// https://chromium.googlesource.com/chromium/src/+/refs/tags/77.0.3865.90/chrome/common/net/safe_search_util.h (YouTubeRestrictMode)
|
||||||
// https://www.chromium.org/administrators/policy-list-3#ForceYouTubeRestrict
|
// https://www.chromium.org/administrators/policy-list-3#ForceYouTubeRestrict
|
||||||
YOUTUBE_RESTRICT_OFF = 0;
|
YOUTUBE_RESTRICT_OFF = 0;
|
||||||
|
@ -385,6 +385,9 @@ type
|
|||||||
|
|
||||||
TCefProcessType = (ptBrowser, ptRenderer, ptZygote, ptGPU, ptUtility, ptOther);
|
TCefProcessType = (ptBrowser, ptRenderer, ptZygote, ptGPU, ptUtility, ptOther);
|
||||||
|
|
||||||
|
// Used in TChromium preferences to allow or block cookies.
|
||||||
|
TCefCookiePref = (cpDefault, cpAllow, cpBlock);
|
||||||
|
|
||||||
TCefAplicationStatus = (asLoading,
|
TCefAplicationStatus = (asLoading,
|
||||||
asLoaded,
|
asLoaded,
|
||||||
asInitialized,
|
asInitialized,
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
"UpdateLazPackages" : [
|
"UpdateLazPackages" : [
|
||||||
{
|
{
|
||||||
"ForceNotify" : true,
|
"ForceNotify" : true,
|
||||||
"InternalVersion" : 104,
|
"InternalVersion" : 105,
|
||||||
"Name" : "cef4delphi_lazarus.lpk",
|
"Name" : "cef4delphi_lazarus.lpk",
|
||||||
"Version" : "80.0.4.0"
|
"Version" : "80.0.4.0"
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user