1
0
mirror of https://github.com/salvadordf/CEF4Delphi.git synced 2025-04-17 06:57:13 +02:00

Added TChromium.SafeSearch and TChromium.YouTubeRestrict

This commit is contained in:
Salvador Díaz Fau 2019-10-06 22:30:36 +02:00
parent 29f5f3475d
commit 00552ef117
5 changed files with 66 additions and 3 deletions

View File

@ -105,6 +105,8 @@ type
FIsOSR : boolean; FIsOSR : boolean;
FInitialized : boolean; FInitialized : boolean;
FClosing : boolean; FClosing : boolean;
FSafeSearch : boolean;
FYouTubeRestrict : integer;
FWindowInfo : TCefWindowInfo; FWindowInfo : TCefWindowInfo;
FBrowserSettings : TCefBrowserSettings; FBrowserSettings : TCefBrowserSettings;
FDevWindowInfo : TCefWindowInfo; FDevWindowInfo : TCefWindowInfo;
@ -302,6 +304,8 @@ type
procedure SetZoomStep(aValue : byte); procedure SetZoomStep(aValue : byte);
procedure SetWindowlessFrameRate(aValue : integer); procedure SetWindowlessFrameRate(aValue : integer);
procedure SetAudioMuted(aValue : boolean); procedure SetAudioMuted(aValue : boolean);
procedure SetSafeSearch(aValue : boolean);
procedure SetYouTubeRestrict(aValue : integer);
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;
@ -662,6 +666,8 @@ type
property FrameCount : NativeUInt read GetFrameCount; property FrameCount : NativeUInt read GetFrameCount;
property DragOperations : TCefDragOperations read FDragOperations write FDragOperations; property DragOperations : TCefDragOperations read FDragOperations write FDragOperations;
property AudioMuted : boolean read GetAudioMuted write SetAudioMuted; property AudioMuted : boolean read GetAudioMuted write SetAudioMuted;
property SafeSearch : boolean read FSafeSearch write SetSafeSearch;
property YouTubeRestrict : integer read FYouTubeRestrict write SetYouTubeRestrict;
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;
@ -844,6 +850,9 @@ begin
FCookiePrefs := CEF_CONTENT_SETTING_ALLOW; FCookiePrefs := CEF_CONTENT_SETTING_ALLOW;
FImagesPrefs := CEF_CONTENT_SETTING_ALLOW; FImagesPrefs := CEF_CONTENT_SETTING_ALLOW;
FZoomStep := ZOOM_STEP_DEF; FZoomStep := ZOOM_STEP_DEF;
FSafeSearch := False;
FYouTubeRestrict := YOUTUBE_RESTRICT_OFF;
{$IFNDEF FPC} {$IFNDEF FPC}
FOldBrowserCompWndPrc := nil; FOldBrowserCompWndPrc := nil;
FOldWidgetCompWndPrc := nil; FOldWidgetCompWndPrc := nil;
@ -2032,6 +2041,24 @@ begin
end; end;
end; end;
procedure TChromium.SetSafeSearch(aValue : boolean);
begin
if (FSafeSearch <> aValue) then
begin
FSafeSearch := aValue;
FUpdatePreferences := True;
end;
end;
procedure TChromium.SetYouTubeRestrict(aValue : integer);
begin
if (FYouTubeRestrict <> aValue) then
begin
FYouTubeRestrict := aValue;
FUpdatePreferences := True;
end;
end;
procedure TChromium.SetWebRTCIPHandlingPolicy(aValue : TCefWebRTCHandlingPolicy); procedure TChromium.SetWebRTCIPHandlingPolicy(aValue : TCefWebRTCHandlingPolicy);
begin begin
if (FWebRTCIPHandlingPolicy <> aValue) then if (FWebRTCIPHandlingPolicy <> aValue) then
@ -2485,6 +2512,8 @@ begin
UpdatePreference(aBrowser, 'plugins.always_authorize', FAlwaysAuthorizePlugins); UpdatePreference(aBrowser, 'plugins.always_authorize', FAlwaysAuthorizePlugins);
UpdatePreference(aBrowser, 'browser.enable_spellchecking', FSpellChecking); UpdatePreference(aBrowser, 'browser.enable_spellchecking', FSpellChecking);
UpdateStringListPref(aBrowser, 'spellcheck.dictionaries', FSpellCheckerDicts); UpdateStringListPref(aBrowser, 'spellcheck.dictionaries', FSpellCheckerDicts);
UpdatePreference(aBrowser, 'settings.force_google_safesearch', FSafeSearch);
UpdatePreference(aBrowser, 'settings.force_youtube_restrict', FYouTubeRestrict);
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);

View File

@ -552,6 +552,12 @@ 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;
// 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
YOUTUBE_RESTRICT_OFF = 0;
YOUTUBE_RESTRICT_MODERATE = 1;
YOUTUBE_RESTRICT_STRICT = 2;
ZOOM_STEP_25 = 0; ZOOM_STEP_25 = 0;
ZOOM_STEP_33 = 1; ZOOM_STEP_33 = 1;
ZOOM_STEP_50 = 2; ZOOM_STEP_50 = 2;

View File

@ -94,6 +94,8 @@ type
FIsOSR : boolean; FIsOSR : boolean;
FInitialized : boolean; FInitialized : boolean;
FClosing : boolean; FClosing : boolean;
FSafeSearch : boolean;
FYouTubeRestrict : integer;
FWindowInfo : TCefWindowInfo; FWindowInfo : TCefWindowInfo;
FBrowserSettings : TCefBrowserSettings; FBrowserSettings : TCefBrowserSettings;
FDevWindowInfo : TCefWindowInfo; FDevWindowInfo : TCefWindowInfo;
@ -285,6 +287,8 @@ type
procedure SetZoomStep(aValue : byte); procedure SetZoomStep(aValue : byte);
procedure SetWindowlessFrameRate(aValue : integer); procedure SetWindowlessFrameRate(aValue : integer);
procedure SetAudioMuted(aValue : boolean); procedure SetAudioMuted(aValue : boolean);
procedure SetSafeSearch(aValue : boolean);
procedure SetYouTubeRestrict(aValue : integer);
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;
@ -622,6 +626,8 @@ type
property FrameCount : NativeUInt read GetFrameCount; property FrameCount : NativeUInt read GetFrameCount;
property DragOperations : TCefDragOperations read FDragOperations write FDragOperations; property DragOperations : TCefDragOperations read FDragOperations write FDragOperations;
property AudioMuted : boolean read GetAudioMuted write SetAudioMuted; property AudioMuted : boolean read GetAudioMuted write SetAudioMuted;
property SafeSearch : boolean read FSafeSearch write SetSafeSearch;
property YouTubeRestrict : integer read FYouTubeRestrict write SetYouTubeRestrict;
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;
@ -792,6 +798,8 @@ begin
FCookiePrefs := CEF_CONTENT_SETTING_ALLOW; FCookiePrefs := CEF_CONTENT_SETTING_ALLOW;
FImagesPrefs := CEF_CONTENT_SETTING_ALLOW; FImagesPrefs := CEF_CONTENT_SETTING_ALLOW;
FZoomStep := ZOOM_STEP_DEF; FZoomStep := ZOOM_STEP_DEF;
FSafeSearch := False;
FYouTubeRestrict := YOUTUBE_RESTRICT_OFF;
{$IFDEF MSWINDOWS} {$IFDEF MSWINDOWS}
FOldBrowserCompWndPrc := nil; FOldBrowserCompWndPrc := nil;
@ -1808,6 +1816,24 @@ begin
end; end;
end; end;
procedure TFMXChromium.SetSafeSearch(aValue : boolean);
begin
if (FSafeSearch <> aValue) then
begin
FSafeSearch := aValue;
FUpdatePreferences := True;
end;
end;
procedure TFMXChromium.SetYouTubeRestrict(aValue : integer);
begin
if (FYouTubeRestrict <> aValue) then
begin
FYouTubeRestrict := aValue;
FUpdatePreferences := True;
end;
end;
procedure TFMXChromium.SetWebRTCIPHandlingPolicy(aValue : TCefWebRTCHandlingPolicy); procedure TFMXChromium.SetWebRTCIPHandlingPolicy(aValue : TCefWebRTCHandlingPolicy);
begin begin
if (FWebRTCIPHandlingPolicy <> aValue) then if (FWebRTCIPHandlingPolicy <> aValue) then
@ -2210,6 +2236,8 @@ begin
UpdatePreference(aBrowser, 'plugins.always_authorize', FAlwaysAuthorizePlugins); UpdatePreference(aBrowser, 'plugins.always_authorize', FAlwaysAuthorizePlugins);
UpdatePreference(aBrowser, 'browser.enable_spellchecking', FSpellChecking); UpdatePreference(aBrowser, 'browser.enable_spellchecking', FSpellChecking);
UpdateStringListPref(aBrowser, 'spellcheck.dictionaries', FSpellCheckerDicts); UpdateStringListPref(aBrowser, 'spellcheck.dictionaries', FSpellCheckerDicts);
UpdatePreference(aBrowser, 'settings.force_google_safesearch', FSafeSearch);
UpdatePreference(aBrowser, 'settings.force_youtube_restrict', FYouTubeRestrict);
if FRunAllFlashInAllowMode then if FRunAllFlashInAllowMode then
UpdatePreference(aBrowser, 'profile.default_content_setting_values.plugins', 1); UpdatePreference(aBrowser, 'profile.default_content_setting_values.plugins', 1);

View File

@ -1,8 +1,8 @@
{ {
"UpdateLazPackages" : [ "UpdateLazPackages" : [
{ {
"ForceNotify" : false, "ForceNotify" : true,
"InternalVersion" : 38, "InternalVersion" : 39,
"Name" : "cef4delphi_lazarus.lpk", "Name" : "cef4delphi_lazarus.lpk",
"Version" : "77.1.11.0" "Version" : "77.1.11.0"
} }