1
0
mirror of https://github.com/salvadordf/CEF4Delphi.git synced 2025-02-02 10:25:26 +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;
FInitialized : boolean;
FClosing : boolean;
FSafeSearch : boolean;
FYouTubeRestrict : integer;
FWindowInfo : TCefWindowInfo;
FBrowserSettings : TCefBrowserSettings;
FDevWindowInfo : TCefWindowInfo;
@ -302,6 +304,8 @@ type
procedure SetZoomStep(aValue : byte);
procedure SetWindowlessFrameRate(aValue : integer);
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;
@ -662,6 +666,8 @@ type
property FrameCount : NativeUInt read GetFrameCount;
property DragOperations : TCefDragOperations read FDragOperations write FDragOperations;
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 WebRTCMultipleRoutes : TCefState read FWebRTCMultipleRoutes write SetWebRTCMultipleRoutes;
@ -844,6 +850,9 @@ begin
FCookiePrefs := CEF_CONTENT_SETTING_ALLOW;
FImagesPrefs := CEF_CONTENT_SETTING_ALLOW;
FZoomStep := ZOOM_STEP_DEF;
FSafeSearch := False;
FYouTubeRestrict := YOUTUBE_RESTRICT_OFF;
{$IFNDEF FPC}
FOldBrowserCompWndPrc := nil;
FOldWidgetCompWndPrc := nil;
@ -2032,6 +2041,24 @@ begin
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);
begin
if (FWebRTCIPHandlingPolicy <> aValue) then
@ -2485,6 +2512,8 @@ begin
UpdatePreference(aBrowser, 'plugins.always_authorize', FAlwaysAuthorizePlugins);
UpdatePreference(aBrowser, 'browser.enable_spellchecking', FSpellChecking);
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
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_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_33 = 1;
ZOOM_STEP_50 = 2;

View File

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

View File

@ -494,7 +494,7 @@ function TCustomRequestHandler.GetAuthCredentials(const browser : ICefBrowser;
isProxy : Boolean;
const host : ustring;
port : Integer;
const realm : ustring;
const realm : ustring;
const scheme : ustring;
const callback : ICefAuthCallback): Boolean;
begin

View File

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