You've already forked CEF4Delphi
mirror of
https://github.com/salvadordf/CEF4Delphi.git
synced 2025-11-23 21:34:53 +02:00
Update to CEF 134.3.1
This commit is contained in:
@@ -4351,9 +4351,13 @@ end;
|
||||
|
||||
function TCefApplicationCore.Load_cef_preference_capi_h : boolean;
|
||||
begin
|
||||
{$IFDEF FPC}Pointer({$ENDIF}cef_preference_manager_get_global{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_preference_manager_get_global');
|
||||
{$IFDEF FPC}Pointer({$ENDIF}cef_preference_manager_get_global{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_preference_manager_get_global');
|
||||
{$IFDEF FPC}Pointer({$ENDIF}cef_preference_manager_get_chrome_variations_as_switches{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_preference_manager_get_chrome_variations_as_switches');
|
||||
{$IFDEF FPC}Pointer({$ENDIF}cef_preference_manager_get_chrome_variations_as_strings{$IFDEF FPC}){$ENDIF} := GetProcAddress(FLibHandle, 'cef_preference_manager_get_chrome_variations_as_strings');
|
||||
|
||||
Result := assigned(cef_preference_manager_get_global);
|
||||
Result := assigned(cef_preference_manager_get_global) and
|
||||
assigned(cef_preference_manager_get_chrome_variations_as_switches) and
|
||||
assigned(cef_preference_manager_get_chrome_variations_as_strings);
|
||||
end;
|
||||
|
||||
function TCefApplicationCore.Load_cef_print_settings_capi_h : boolean;
|
||||
|
||||
@@ -30,7 +30,8 @@ uses
|
||||
{$IFDEF MSWINDOWS}uCEFDragAndDropMgr,{$ENDIF}
|
||||
{$IFDEF LINUX}uCEFLinuxTypes, uCEFLinuxFunctions,{$ENDIF}
|
||||
uCEFChromiumOptions, uCEFChromiumFontOptions, uCEFPDFPrintOptions,
|
||||
uCEFBrowserViewComponent, uCEFWindowInfoWrapper;
|
||||
uCEFBrowserViewComponent, uCEFWindowInfoWrapper, uCEFPreferenceObserver,
|
||||
uCEFSettingObserver;
|
||||
|
||||
type
|
||||
TBrowserInfoList = class;
|
||||
@@ -55,6 +56,10 @@ type
|
||||
FMediaObserverReg : ICefRegistration;
|
||||
FDevToolsMsgObserver : ICefDevToolsMessageObserver;
|
||||
FDevToolsMsgObserverReg : ICefRegistration;
|
||||
FSettingObserver : ICefSettingObserver;
|
||||
FSettingObserverReg : ICefRegistration;
|
||||
FPreferenceInfoList : TPreferenceInfoList;
|
||||
FPreferenceInfoCS : TCriticalSection;
|
||||
FDefaultUrl : ustring;
|
||||
FOptions : TChromiumOptions;
|
||||
FFontOptions : TChromiumFontOptions;
|
||||
@@ -302,6 +307,12 @@ type
|
||||
FOnShowPermissionPrompt : TOnShowPermissionPromptEvent;
|
||||
FOnDismissPermissionPrompt : TOnDismissPermissionPromptEvent;
|
||||
|
||||
// ICefPreferenceObserver
|
||||
FOnPreferenceChanged : TOnPreferenceChangedEvent;
|
||||
|
||||
// ICefSettingObserver
|
||||
FOnSettingChanged : TOnSettingChangedEvent;
|
||||
|
||||
// Custom
|
||||
FOnTextResultAvailable : TOnTextResultAvailableEvent;
|
||||
FOnPdfPrintFinished : TOnPdfPrintFinishedEvent;
|
||||
@@ -436,11 +447,15 @@ type
|
||||
procedure DestroyResourceRequestHandler;
|
||||
procedure DestroyMediaObserver;
|
||||
procedure DestroyDevToolsMsgObserver;
|
||||
procedure DestroySettingObserver;
|
||||
procedure DestroyPreferenceObserver;
|
||||
procedure DestroyAllHandlersAndObservers;
|
||||
|
||||
procedure CreateResourceRequestHandler; virtual;
|
||||
procedure CreateMediaObserver; virtual;
|
||||
procedure CreateDevToolsMsgObserver; virtual;
|
||||
procedure CreateSettingObserver; virtual;
|
||||
procedure CreatePreferenceObserver; virtual;
|
||||
procedure CreateRequestContextHandler; virtual;
|
||||
procedure CreateOptionsClasses; virtual;
|
||||
procedure CreateSyncObjects; virtual;
|
||||
@@ -665,6 +680,12 @@ type
|
||||
function doOnShowPermissionPrompt(const browser: ICefBrowser; prompt_id: uint64; const requesting_origin: ustring; requested_permissions: cardinal; const callback: ICefPermissionPromptCallback): boolean;
|
||||
procedure doOnDismissPermissionPrompt(const browser: ICefBrowser; prompt_id: uint64; result: TCefPermissionRequestResult);
|
||||
|
||||
// ICefPreferenceObserver
|
||||
procedure doOnPreferenceChanged(const name_: ustring);
|
||||
|
||||
// ICefSettingObserver
|
||||
procedure doOnSettingChanged(const requesting_url, top_level_url : ustring; content_type: TCefContentSettingTypes);
|
||||
|
||||
// Custom
|
||||
procedure GetSettings(var aSettings : TCefBrowserSettings);
|
||||
procedure doCookiesDeleted(numDeleted : integer); virtual;
|
||||
@@ -697,10 +718,12 @@ type
|
||||
procedure doToggleAudioMuted; virtual;
|
||||
procedure doEnableFocus; virtual;
|
||||
function doTryCloseBrowser : boolean; virtual;
|
||||
procedure doAddPreferenceObserver(const name_ : ustring); virtual;
|
||||
|
||||
function MustCreateAudioHandler : boolean; virtual;
|
||||
function MustCreateCommandHandler : boolean; virtual;
|
||||
function MustCreateDevToolsMessageObserver : boolean; virtual;
|
||||
function MustCreateSettingObserver : boolean; virtual;
|
||||
function MustCreateLoadHandler : boolean; virtual;
|
||||
function MustCreateFocusHandler : boolean; virtual;
|
||||
function MustCreateContextMenuHandler : boolean; virtual;
|
||||
@@ -1116,6 +1139,25 @@ type
|
||||
/// </summary>
|
||||
procedure ToggleAudioMuted;
|
||||
/// <summary>
|
||||
/// Add an observer for preference changes. |name| is the name of the
|
||||
/// preference to observe. If |name| is NULL then all preferences will be
|
||||
/// observed. Observing all preferences has performance consequences and is
|
||||
/// not recommended outside of testing scenarios. The observer will remain
|
||||
/// registered until the returned Registration object is destroyed. This
|
||||
/// function must be called on the browser process UI thread.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para><see href="https://bitbucket.org/chromiumembedded/cef/src/master/include/capi/cef_preference_capi.h">CEF source file: /include/capi/cef_preference_capi.h (cef_preference_manager_t)</see></para>
|
||||
/// </remarks>
|
||||
procedure AddPreferenceObserver(const name_: ustring);
|
||||
/// <summary>
|
||||
/// Remove an observer for preference changes.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para><see href="https://bitbucket.org/chromiumembedded/cef/src/master/include/capi/cef_preference_capi.h">CEF source file: /include/capi/cef_preference_capi.h (cef_preference_manager_t)</see></para>
|
||||
/// </remarks>
|
||||
procedure RemovePreferenceObserver(const name_ : ustring);
|
||||
/// <summary>
|
||||
/// Used to delete cookies immediately or asynchronously. If aDeleteImmediately is false TChromiumCore.DeleteCookies triggers
|
||||
/// the TChromiumCore.OnCookiesDeleted event when the cookies are deleted.
|
||||
/// </summary>
|
||||
@@ -1217,6 +1259,15 @@ type
|
||||
/// </summary>
|
||||
function AddDevToolsMessageObserver(const observer: ICefDevToolsMessageObserver): ICefRegistration;
|
||||
/// <summary>
|
||||
/// Add an observer for content and website setting changes. The observer will
|
||||
/// remain registered until the returned Registration object is destroyed.
|
||||
/// This function must be called on the browser process UI thread.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para><see href="https://bitbucket.org/chromiumembedded/cef/src/master/include/capi/cef_request_context_capi.h">CEF source file: /include/capi/cef_request_context_capi.h (cef_request_context_t)</see></para>
|
||||
/// </remarks>
|
||||
function AddSettingObserver(const observer: ICefSettingObserver): ICefRegistration;
|
||||
/// <summary>
|
||||
/// <para>Search for |searchText|. |forward| indicates whether to search forward or
|
||||
/// backward within the page. |matchCase| indicates whether the search should
|
||||
/// be case-sensitive. |findNext| indicates whether this is the first request
|
||||
@@ -3960,6 +4011,25 @@ type
|
||||
/// <para><see href="https://bitbucket.org/chromiumembedded/cef/src/master/include/capi/cef_permission_handler_capi.h">CEF source file: /include/capi/cef_permission_handler_capi.h (cef_permission_handler_t)</see></para>
|
||||
/// </remarks>
|
||||
property OnDismissPermissionPrompt : TOnDismissPermissionPromptEvent read FOnDismissPermissionPrompt write FOnDismissPermissionPrompt;
|
||||
/// <summary>
|
||||
/// Called when a preference has changed. The new value can be retrieved using
|
||||
/// ICefRequestContext.GetPreference.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>This event will be called on the browser process CEF UI thread.</para>
|
||||
/// <para><see href="https://bitbucket.org/chromiumembedded/cef/src/master/include/capi/cef_preference_capi.h">CEF source file: /include/capi/cef_preference_capi.h (cef_preference_observer_t)</see></para>
|
||||
/// </remarks>
|
||||
property OnPreferenceChanged : TOnPreferenceChangedEvent read FOnPreferenceChanged write FOnPreferenceChanged;
|
||||
/// <summary>
|
||||
/// Called when a content or website setting has changed. The new value can be
|
||||
/// retrieved using ICefRequestContext.GetContentSetting or
|
||||
/// ICefRequestContext.GetWebsiteSetting.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>This event will be called on the browser process CEF UI thread.</para>
|
||||
/// <para><see href="https://bitbucket.org/chromiumembedded/cef/src/master/include/capi/cef_preference_capi.h">CEF source file: /include/capi/cef_preference_capi.h (cef_setting_observer_t)</see></para>
|
||||
/// </remarks>
|
||||
property OnSettingChanged : TOnSettingChangedEvent read FOnSettingChanged write FOnSettingChanged;
|
||||
end;
|
||||
|
||||
TBrowserInfo = class
|
||||
@@ -4074,6 +4144,10 @@ begin
|
||||
FMediaObserverReg := nil;
|
||||
FDevToolsMsgObserver := nil;
|
||||
FDevToolsMsgObserverReg := nil;
|
||||
FSettingObserver := nil;
|
||||
FSettingObserverReg := nil;
|
||||
FPreferenceInfoList := nil;
|
||||
FPreferenceInfoCS := nil;
|
||||
FOptions := nil;
|
||||
FFontOptions := nil;
|
||||
FDefaultEncoding := '';
|
||||
@@ -4187,13 +4261,14 @@ begin
|
||||
|
||||
DestroyAllBrowsers;
|
||||
|
||||
if (FWindowInfo <> nil) then FreeAndNil(FWindowInfo);
|
||||
if (FDevWindowInfo <> nil) then FreeAndNil(FDevWindowInfo);
|
||||
if (FFontOptions <> nil) then FreeAndNil(FFontOptions);
|
||||
if (FOptions <> nil) then FreeAndNil(FOptions);
|
||||
if (FPDFPrintOptions <> nil) then FreeAndNil(FPDFPrintOptions);
|
||||
if (FZoomStepCS <> nil) then FreeAndNil(FZoomStepCS);
|
||||
if (FBrowsersCS <> nil) then FreeAndNil(FBrowsersCS);
|
||||
if (FWindowInfo <> nil) then FreeAndNil(FWindowInfo);
|
||||
if (FDevWindowInfo <> nil) then FreeAndNil(FDevWindowInfo);
|
||||
if (FFontOptions <> nil) then FreeAndNil(FFontOptions);
|
||||
if (FOptions <> nil) then FreeAndNil(FOptions);
|
||||
if (FPDFPrintOptions <> nil) then FreeAndNil(FPDFPrintOptions);
|
||||
if (FZoomStepCS <> nil) then FreeAndNil(FZoomStepCS);
|
||||
if (FBrowsersCS <> nil) then FreeAndNil(FBrowsersCS);
|
||||
if (FPreferenceInfoCS <> nil) then FreeAndNil(FPreferenceInfoCS);
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TChromiumCore.Destroy', e) then raise;
|
||||
@@ -4390,8 +4465,22 @@ begin
|
||||
FDevToolsMsgObserver := nil;
|
||||
end;
|
||||
|
||||
procedure TChromiumCore.DestroySettingObserver;
|
||||
begin
|
||||
FSettingObserverReg := nil;
|
||||
FSettingObserver := nil;
|
||||
end;
|
||||
|
||||
procedure TChromiumCore.DestroyPreferenceObserver;
|
||||
begin
|
||||
if (FPreferenceInfoList <> nil) then
|
||||
FreeAndNil(FPreferenceInfoList);
|
||||
end;
|
||||
|
||||
procedure TChromiumCore.DestroyAllHandlersAndObservers;
|
||||
begin
|
||||
DestroySettingObserver;
|
||||
DestroyPreferenceObserver;
|
||||
DestroyDevToolsMsgObserver;
|
||||
DestroyMediaObserver;
|
||||
DestroyResourceRequestHandler;
|
||||
@@ -4413,6 +4502,19 @@ begin
|
||||
FDevToolsMsgObserver := TCustomDevToolsMessageObserver.Create(self);
|
||||
end;
|
||||
|
||||
procedure TChromiumCore.CreateSettingObserver;
|
||||
begin
|
||||
if MustCreateSettingObserver and
|
||||
(FSettingObserver = nil) then
|
||||
FSettingObserver := TCustomSettingObserver.Create(self);
|
||||
end;
|
||||
|
||||
procedure TChromiumCore.CreatePreferenceObserver;
|
||||
begin
|
||||
if (FPreferenceInfoList = nil) then
|
||||
FPreferenceInfoList := TPreferenceInfoList.Create;
|
||||
end;
|
||||
|
||||
procedure TChromiumCore.CreateResourceRequestHandler;
|
||||
begin
|
||||
if MustCreateResourceRequestHandler and
|
||||
@@ -4434,8 +4536,9 @@ procedure TChromiumCore.CreateSyncObjects;
|
||||
begin
|
||||
if (Owner = nil) or not(csDesigning in ComponentState) then
|
||||
begin
|
||||
FZoomStepCS := TCriticalSection.Create;
|
||||
FBrowsersCS := TCriticalSection.Create;
|
||||
FZoomStepCS := TCriticalSection.Create;
|
||||
FBrowsersCS := TCriticalSection.Create;
|
||||
FPreferenceInfoCS := TCriticalSection.Create;
|
||||
end;
|
||||
end;
|
||||
|
||||
@@ -4510,6 +4613,8 @@ begin
|
||||
CreateResourceRequestHandler;
|
||||
CreateMediaObserver;
|
||||
CreateDevToolsMsgObserver;
|
||||
CreatePreferenceObserver;
|
||||
CreateSettingObserver;
|
||||
|
||||
aClient := FHandler;
|
||||
Result := True;
|
||||
@@ -4688,6 +4793,12 @@ begin
|
||||
FOnShowPermissionPrompt := nil;
|
||||
FOnDismissPermissionPrompt := nil;
|
||||
|
||||
// ICefPreferenceObserver
|
||||
FOnPreferenceChanged := nil;
|
||||
|
||||
// ICefSettingObserver
|
||||
FOnSettingChanged := nil;
|
||||
|
||||
// Custom
|
||||
FOnTextResultAvailable := nil;
|
||||
FOnPdfPrintFinished := nil;
|
||||
@@ -4758,6 +4869,8 @@ begin
|
||||
CreateResourceRequestHandler;
|
||||
CreateMediaObserver;
|
||||
CreateDevToolsMsgObserver;
|
||||
CreatePreferenceObserver;
|
||||
CreateSettingObserver;
|
||||
|
||||
if (aContext = nil) then
|
||||
TempOldContext := TCefRequestContextRef.Global()
|
||||
@@ -4811,6 +4924,8 @@ begin
|
||||
CreateResourceRequestHandler;
|
||||
CreateMediaObserver;
|
||||
CreateDevToolsMsgObserver;
|
||||
CreatePreferenceObserver;
|
||||
CreateSettingObserver;
|
||||
|
||||
if (aContext = nil) then
|
||||
TempOldContext := TCefRequestContextRef.Global()
|
||||
@@ -6926,6 +7041,33 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TChromiumCore.AddPreferenceObserver(const name_: ustring);
|
||||
var
|
||||
TempTask : ICefTask;
|
||||
begin
|
||||
if CefCurrentlyOn(TID_UI) then
|
||||
doAddPreferenceObserver(name_)
|
||||
else
|
||||
if Initialized then
|
||||
try
|
||||
TempTask := TCefAddPreferenceObserverTask.Create(self, name_);
|
||||
CefPostTask(TID_UI, TempTask);
|
||||
finally
|
||||
TempTask := nil;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TChromiumCore.RemovePreferenceObserver(const name_ : ustring);
|
||||
begin
|
||||
if assigned(FPreferenceInfoCS) then
|
||||
try
|
||||
FPreferenceInfoCS.Acquire;
|
||||
FPreferenceInfoList.RemovePreference(name_);
|
||||
finally
|
||||
FPreferenceInfoCS.Release;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TChromiumCore.GetRequestContext : ICefRequestContext;
|
||||
begin
|
||||
if Initialized then
|
||||
@@ -7898,6 +8040,26 @@ begin
|
||||
FTryingToCloseBrowser := False;
|
||||
end;
|
||||
|
||||
procedure TChromiumCore.doAddPreferenceObserver(const name_ : ustring);
|
||||
var
|
||||
TempContext : ICefRequestContext;
|
||||
i : integer;
|
||||
begin
|
||||
if assigned(FPreferenceInfoCS) and Initialized then
|
||||
try
|
||||
FPreferenceInfoCS.Acquire;
|
||||
TempContext := Browser.Host.RequestContext;
|
||||
|
||||
if (TempContext <> nil) and not(FPreferenceInfoList.HasPreference(name_)) then
|
||||
begin
|
||||
i := FPreferenceInfoList.AddPreference(name_, self);
|
||||
TempContext.AddPreferenceObserver(name, TPreferenceInfo(FPreferenceInfoList[i]).Observer);
|
||||
end;
|
||||
finally
|
||||
FPreferenceInfoCS.Release;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TChromiumCore.doEnableFocus;
|
||||
begin
|
||||
FCanFocus := True;
|
||||
@@ -8108,6 +8270,11 @@ begin
|
||||
assigned(FOnDevToolsAgentDetached);
|
||||
end;
|
||||
|
||||
function TChromiumCore.MustCreateSettingObserver : boolean;
|
||||
begin
|
||||
Result := assigned(FOnSettingChanged);
|
||||
end;
|
||||
|
||||
function TChromiumCore.MustCreatePrintHandler : boolean;
|
||||
begin
|
||||
Result := assigned(FOnPrintStart) or
|
||||
@@ -8295,6 +8462,21 @@ begin
|
||||
Result := nil;
|
||||
end;
|
||||
|
||||
function TChromiumCore.AddSettingObserver(const observer: ICefSettingObserver): ICefRegistration;
|
||||
var
|
||||
TempContext : ICefRequestContext;
|
||||
begin
|
||||
Result := nil;
|
||||
|
||||
if Initialized then
|
||||
begin
|
||||
TempContext := Browser.Host.RequestContext;
|
||||
|
||||
if (TempContext <> nil) then
|
||||
Result := TempContext.AddSettingObserver(observer);
|
||||
end;
|
||||
end;
|
||||
|
||||
{$IFDEF MSWINDOWS}
|
||||
procedure TChromiumCore.WndProc(var aMessage: TMessage);
|
||||
begin
|
||||
@@ -8508,6 +8690,9 @@ begin
|
||||
if (FDevToolsMsgObserver <> nil) and (FDevToolsMsgObserverReg = nil) then
|
||||
FDevToolsMsgObserverReg := AddDevToolsMessageObserver(FDevToolsMsgObserver);
|
||||
|
||||
if (FSettingObserver <> nil) and (FSettingObserverReg = nil) then
|
||||
FSettingObserverReg := AddSettingObserver(FSettingObserver);
|
||||
|
||||
if assigned(FOnAfterCreated) then
|
||||
FOnAfterCreated(Self, browser);
|
||||
|
||||
@@ -9142,6 +9327,18 @@ begin
|
||||
FOnDismissPermissionPrompt(self, browser, prompt_id, result);
|
||||
end;
|
||||
|
||||
procedure TChromiumCore.doOnPreferenceChanged(const name_: ustring);
|
||||
begin
|
||||
if assigned(FOnPreferenceChanged) then
|
||||
FOnPreferenceChanged(self, name_);
|
||||
end;
|
||||
|
||||
procedure TChromiumCore.doOnSettingChanged(const requesting_url, top_level_url : ustring; content_type: TCefContentSettingTypes);
|
||||
begin
|
||||
if assigned(FOnSettingChanged) then
|
||||
FOnSettingChanged(self, requesting_url, top_level_url, content_type);
|
||||
end;
|
||||
|
||||
procedure TChromiumCore.doOnFullScreenModeChange(const browser : ICefBrowser;
|
||||
fullscreen : Boolean);
|
||||
begin
|
||||
|
||||
@@ -188,6 +188,12 @@ type
|
||||
TOnShowPermissionPromptEvent = procedure(Sender: TObject; const browser: ICefBrowser; prompt_id: uint64; const requesting_origin: ustring; requested_permissions: cardinal; const callback: ICefPermissionPromptCallback; var aResult: boolean) of object;
|
||||
TOnDismissPermissionPromptEvent = procedure(Sender: TObject; const browser: ICefBrowser; prompt_id: uint64; result: TCefPermissionRequestResult) of object;
|
||||
|
||||
// ICefPreferenceObserver
|
||||
TOnPreferenceChangedEvent = procedure(Sender: TObject; const name: ustring) of object;
|
||||
|
||||
// ICefSettingObserver
|
||||
TOnSettingChangedEvent = procedure(Sender: TObject; const requesting_url, top_level_url : ustring; content_type: TCefContentSettingTypes) of object;
|
||||
|
||||
// Custom
|
||||
TOnTextResultAvailableEvent = procedure(Sender: TObject; const aText : ustring) of object;
|
||||
TOnPdfPrintFinishedEvent = procedure(Sender: TObject; aResultOK : boolean) of object;
|
||||
|
||||
@@ -290,6 +290,14 @@ const
|
||||
/// </remarks>
|
||||
ERR_NETWORK_ACCESS_REVOKED = -33;
|
||||
/// <summary>
|
||||
/// The request was blocked by fingerprinting protections.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>TCefErrorCode value.</para>
|
||||
/// <para><see href="https://bitbucket.org/chromiumembedded/cef/src/master/include/internal/cef_types.h">CEF source file: /include/internal/cef_types.h (cef_errorcode_t)</see></para>
|
||||
/// </remarks>
|
||||
ERR_BLOCKED_BY_FINGERPRINTING_PROTECTION = -34;
|
||||
/// <summary>
|
||||
/// A connection was closed (corresponding to a TCP FIN).
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
@@ -2319,6 +2327,8 @@ const
|
||||
IDC_TASK_MANAGER_MAIN_MENU = 40288;
|
||||
IDC_COMPARE_MENU = 40289;
|
||||
IDC_SHOW_ALL_COMPARISON_TABLES = 40290;
|
||||
IDC_ADD_TO_COMPARISON_TABLE_MENU = 40291;
|
||||
IDC_CREATE_NEW_COMPARISON_TABLE_WITH_TAB = 40292;
|
||||
IDC_SPELLCHECK_SUGGESTION_0 = 41000;
|
||||
IDC_SPELLCHECK_SUGGESTION_1 = 41001;
|
||||
IDC_SPELLCHECK_SUGGESTION_2 = 41002;
|
||||
@@ -2435,6 +2445,8 @@ const
|
||||
IDC_CONTENT_CONTEXT_OPEN_WITH14 = 50213;
|
||||
IDC_CONTENT_CONTEXT_EMOJI = 50220;
|
||||
IDC_CONTEXT_COMPOSE = 50230;
|
||||
IDC_CONTENT_CONTEXT_CLOSE_GLIC = 50231;
|
||||
IDC_CONTENT_CONTEXT_RELOAD_GLIC = 50232;
|
||||
IDC_BOOKMARK_BAR_OPEN_ALL = 51000;
|
||||
IDC_BOOKMARK_BAR_OPEN_ALL_NEW_WINDOW = 51001;
|
||||
IDC_BOOKMARK_BAR_OPEN_ALL_INCOGNITO = 51002;
|
||||
@@ -2510,10 +2522,11 @@ const
|
||||
IDC_DEVICE_SYSTEM_TRAY_ICON_FIRST = 53260;
|
||||
IDC_DEVICE_SYSTEM_TRAY_ICON_LAST = 53299;
|
||||
IDC_SET_BROWSER_AS_DEFAULT = 53300;
|
||||
IDC_COMPACT_MODE = 53301;
|
||||
IDC_GLIC_STATUS_ICON_MENU_SHOW = 53310;
|
||||
IDC_GLIC_STATUS_ICON_MENU_CUSTOMIZE_KEYBOARD_SHORTCUT = 53311;
|
||||
IDC_GLIC_STATUS_ICON_MENU_SETTINGS = 53312;
|
||||
IDC_GLIC_STATUS_ICON_MENU_REMOVE_ICON = 53312;
|
||||
IDC_GLIC_STATUS_ICON_MENU_SETTINGS = 53313;
|
||||
IDC_GLIC_STATUS_ICON_MENU_EXIT = 53314;
|
||||
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -479,6 +479,12 @@ type
|
||||
function doOnShowPermissionPrompt(const browser: ICefBrowser; prompt_id: uint64; const requesting_origin: ustring; requested_permissions: cardinal; const callback: ICefPermissionPromptCallback): boolean;
|
||||
procedure doOnDismissPermissionPrompt(const browser: ICefBrowser; prompt_id: uint64; result: TCefPermissionRequestResult);
|
||||
|
||||
// ICefPreferenceObserver
|
||||
procedure doOnPreferenceChanged(const name: ustring);
|
||||
|
||||
// ICefSettingObserver
|
||||
procedure doOnSettingChanged(const requesting_url, top_level_url : ustring; content_type: TCefContentSettingTypes);
|
||||
|
||||
// Custom
|
||||
procedure doCookiesDeleted(numDeleted : integer);
|
||||
procedure doPdfPrintFinished(aResultOK : boolean);
|
||||
@@ -510,6 +516,7 @@ type
|
||||
procedure doToggleAudioMuted;
|
||||
procedure doEnableFocus;
|
||||
function doTryCloseBrowser : boolean;
|
||||
procedure doAddPreferenceObserver(const name : ustring);
|
||||
function MustCreateAudioHandler : boolean;
|
||||
function MustCreateCommandHandler : boolean;
|
||||
function MustCreateLoadHandler : boolean;
|
||||
@@ -8024,6 +8031,24 @@ type
|
||||
procedure OnResolveCompleted(result: TCefErrorCode; const resolvedIps: TStrings);
|
||||
end;
|
||||
|
||||
/// <summary>
|
||||
/// Implemented by the client to observe preference changes and registered via
|
||||
/// ICefPreferenceManager.AddPreferenceObserver. The functions of this
|
||||
/// structure will be called on the browser process UI thread.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para><see cref="uCEFTypes|TCefPreferenceObserver">Implements TCefPreferenceObserver</see></para>
|
||||
/// <para><see href="https://bitbucket.org/chromiumembedded/cef/src/master/include/capi/cef_preference_capi.h">CEF source file: /include/capi/cef_preference_capi.h (cef_preference_observer_t)</see></para>
|
||||
/// </remarks>
|
||||
ICefPreferenceObserver = interface(ICefBaseRefCounted)
|
||||
['{874985B5-2DA9-47E6-9E5F-4151BAF5A444}']
|
||||
/// <summary>
|
||||
/// Called when a preference has changed. The new value can be retrieved using
|
||||
/// ICefPreferenceManager.GetPreference.
|
||||
/// </summary>
|
||||
procedure OnPreferenceChanged(const name : ustring);
|
||||
end;
|
||||
|
||||
/// <summary>
|
||||
/// Manage access to preferences. Many built-in preferences are registered by
|
||||
/// Chromium. Custom preferences can be registered in
|
||||
@@ -8073,6 +8098,34 @@ type
|
||||
/// process UI thread.
|
||||
/// </summary>
|
||||
function SetPreference(const name: ustring; const value: ICefValue; out error: ustring): Boolean;
|
||||
/// <summary>
|
||||
/// Add an observer for preference changes. |name| is the name of the
|
||||
/// preference to observe. If |name| is NULL then all preferences will be
|
||||
/// observed. Observing all preferences has performance consequences and is
|
||||
/// not recommended outside of testing scenarios. The observer will remain
|
||||
/// registered until the returned Registration object is destroyed. This
|
||||
/// function must be called on the browser process UI thread.
|
||||
/// </summary>
|
||||
function AddPreferenceObserver(const name: ustring; const observer: ICefPreferenceObserver): ICefRegistration;
|
||||
end;
|
||||
|
||||
/// <summary>
|
||||
/// Implemented by the client to observe content and website setting changes and
|
||||
/// registered via ICefRequestContext.AddSettingObserver. The functions of
|
||||
/// this structure will be called on the browser process UI thread.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para><see cref="uCEFTypes|TCefSettingObserver">Implements TCefSettingObserver</see></para>
|
||||
/// <para><see href="https://bitbucket.org/chromiumembedded/cef/src/master/include/capi/cef_preference_capi.h">CEF source file: /include/capi/cef_preference_capi.h (cef_setting_observer_t)</see></para>
|
||||
/// </remarks>
|
||||
ICefSettingObserver = interface(ICefBaseRefCounted)
|
||||
['{84E0FD25-F337-451F-9661-3D2E5844882C}']
|
||||
/// <summary>
|
||||
/// Called when a content or website setting has changed. The new value can be
|
||||
/// retrieved using ICefRequestContext.GetContentSetting or
|
||||
/// ICefRequestContext.GetWebsiteSetting.
|
||||
/// </summary>
|
||||
procedure OnSettingChanged(const requesting_url, top_level_url : ustring; content_type: TCefContentSettingTypes);
|
||||
end;
|
||||
|
||||
/// <summary>
|
||||
@@ -8254,6 +8307,12 @@ type
|
||||
/// </summary>
|
||||
function GetChromeColorSchemeVariant: TCefColorVariant;
|
||||
/// <summary>
|
||||
/// Add an observer for content and website setting changes. The observer will
|
||||
/// remain registered until the returned Registration object is destroyed.
|
||||
/// This function must be called on the browser process UI thread.
|
||||
/// </summary>
|
||||
function AddSettingObserver(const observer: ICefSettingObserver): ICefRegistration;
|
||||
/// <summary>
|
||||
/// Returns the cache path for this object. If NULL an "incognito mode" in-
|
||||
/// memory cache is being used.
|
||||
/// </summary>
|
||||
|
||||
@@ -120,7 +120,9 @@ var
|
||||
cef_get_path : function(key: TCefPathKey; path: PCefString): Integer; cdecl;
|
||||
|
||||
// /include/capi/cef_preference_capi.h
|
||||
cef_preference_manager_get_global : function : PCefPreferenceManager; cdecl;
|
||||
cef_preference_manager_get_global : function : PCefPreferenceManager; cdecl;
|
||||
cef_preference_manager_get_chrome_variations_as_switches : procedure(switches: TCefStringList); cdecl; {* CEF_API_ADDED(13401) *}
|
||||
cef_preference_manager_get_chrome_variations_as_strings : procedure(strings: TCefStringList); cdecl; {* CEF_API_ADDED(13401) *}
|
||||
|
||||
// /include/capi/cef_print_settings_capi.h
|
||||
cef_print_settings_create : function : PCefPrintSettings; cdecl;
|
||||
|
||||
@@ -20,22 +20,94 @@ uses
|
||||
uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes;
|
||||
|
||||
type
|
||||
/// <summary>
|
||||
/// Manage access to preferences. Many built-in preferences are registered by
|
||||
/// Chromium. Custom preferences can be registered in
|
||||
/// ICefBrowserProcessHandler.OnRegisterCustomPreferences.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para><see href="https://bitbucket.org/chromiumembedded/cef/src/master/include/capi/cef_preference_capi.h">CEF source file: /include/capi/cef_preference_capi.h (cef_preference_manager_t)</see></para>
|
||||
/// </remarks>
|
||||
TCefPreferenceManagerRef = class(TCefBaseRefCountedRef, ICefPreferenceManager)
|
||||
protected
|
||||
/// <summary>
|
||||
/// Returns true (1) if a preference with the specified |name| exists. This
|
||||
/// function must be called on the browser process UI thread.
|
||||
/// </summary>
|
||||
function HasPreference(const name: ustring): Boolean;
|
||||
/// <summary>
|
||||
/// Returns the value for the preference with the specified |name|. Returns
|
||||
/// NULL if the preference does not exist. The returned object contains a copy
|
||||
/// of the underlying preference value and modifications to the returned
|
||||
/// object will not modify the underlying preference value. This function must
|
||||
/// be called on the browser process UI thread.
|
||||
/// </summary>
|
||||
function GetPreference(const name: ustring): ICefValue;
|
||||
/// <summary>
|
||||
/// Returns the value for the preference with the specified |name|. Returns
|
||||
/// NULL if the preference does not exist. The returned object contains a copy
|
||||
/// of the underlying preference value and modifications to the returned
|
||||
/// object will not modify the underlying preference value. This function must
|
||||
/// be called on the browser process UI thread.
|
||||
/// </summary>
|
||||
function GetAllPreferences(includeDefaults: Boolean): ICefDictionaryValue;
|
||||
/// <summary>
|
||||
/// Returns true (1) if the preference with the specified |name| can be
|
||||
/// modified using SetPreference. As one example preferences set via the
|
||||
/// command-line usually cannot be modified. This function must be called on
|
||||
/// the browser process UI thread.
|
||||
/// </summary>
|
||||
function CanSetPreference(const name: ustring): Boolean;
|
||||
/// <summary>
|
||||
/// Returns true (1) if the preference with the specified |name| can be
|
||||
/// modified using SetPreference. As one example preferences set via the
|
||||
/// command-line usually cannot be modified. This function must be called on
|
||||
/// the browser process UI thread.
|
||||
/// </summary>
|
||||
function SetPreference(const name: ustring; const value: ICefValue; out error: ustring): Boolean;
|
||||
/// <summary>
|
||||
/// Add an observer for preference changes. |name| is the name of the
|
||||
/// preference to observe. If |name| is NULL then all preferences will be
|
||||
/// observed. Observing all preferences has performance consequences and is
|
||||
/// not recommended outside of testing scenarios. The observer will remain
|
||||
/// registered until the returned Registration object is destroyed. This
|
||||
/// function must be called on the browser process UI thread.
|
||||
/// </summary>
|
||||
function AddPreferenceObserver(const name: ustring; const observer: ICefPreferenceObserver): ICefRegistration;
|
||||
public
|
||||
class function UnWrap(data: Pointer): ICefPreferenceManager;
|
||||
class function Global: ICefPreferenceManager;
|
||||
class function UnWrap(data: Pointer): ICefPreferenceManager;
|
||||
/// <summary>
|
||||
/// Returns the global preference manager object.
|
||||
/// </summary>
|
||||
class function Global: ICefPreferenceManager;
|
||||
/// <summary>
|
||||
/// Returns the current Chrome Variations configuration (combination of field
|
||||
/// trials and chrome://flags) as equivalent command-line switches
|
||||
/// (`--[enable|disable]-features=XXXX`, etc). These switches can be used to
|
||||
/// apply the same configuration when launching a CEF-based application. See
|
||||
/// https://developer.chrome.com/docs/web-platform/chrome-variations for
|
||||
/// background and details. Note that field trial tests are disabled by default
|
||||
/// in Official CEF builds (via the `disable_fieldtrial_testing_config=true (1)`
|
||||
/// GN flag). This function must be called on the browser process UI thread.
|
||||
/// </summary>
|
||||
class procedure GetChromeVariationsAsSwitches(const switches: TStrings);
|
||||
/// <summary>
|
||||
/// Returns the current Chrome Variations configuration (combination of field
|
||||
/// trials and chrome://flags) as human-readable strings. This is the human-
|
||||
/// readable equivalent of the "Active Variations" section of chrome://version.
|
||||
/// See https://developer.chrome.com/docs/web-platform/chrome-variations for
|
||||
/// background and details. Note that field trial tests are disabled by default
|
||||
/// in Official CEF builds (via the `disable_fieldtrial_testing_config=true (1)`
|
||||
/// GN flag). This function must be called on the browser process UI thread.
|
||||
/// </summary>
|
||||
class procedure GetChromeVariationsAsStrings(const strings: TStrings);
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
uCEFLibFunctions, uCEFMiscFunctions, uCEFValue, uCEFDictionaryValue;
|
||||
uCEFLibFunctions, uCEFMiscFunctions, uCEFValue, uCEFDictionaryValue,
|
||||
uCEFRegistration, uCEFStringList;
|
||||
|
||||
class function TCefPreferenceManagerRef.UnWrap(data: Pointer): ICefPreferenceManager;
|
||||
begin
|
||||
@@ -50,6 +122,30 @@ begin
|
||||
Result := UnWrap(cef_preference_manager_get_global());
|
||||
end;
|
||||
|
||||
class procedure TCefPreferenceManagerRef.GetChromeVariationsAsSwitches(const switches: TStrings);
|
||||
var
|
||||
TempSL : ICefStringList;
|
||||
begin
|
||||
if (switches <> nil) then
|
||||
begin
|
||||
TempSL := TCefStringListOwn.Create;
|
||||
cef_preference_manager_get_chrome_variations_as_switches(TempSL.Handle);
|
||||
TempSL.CopyToStrings(switches);
|
||||
end;
|
||||
end;
|
||||
|
||||
class procedure TCefPreferenceManagerRef.GetChromeVariationsAsStrings(const strings: TStrings);
|
||||
var
|
||||
TempSL : ICefStringList;
|
||||
begin
|
||||
if (strings <> nil) then
|
||||
begin
|
||||
TempSL := TCefStringListOwn.Create;
|
||||
cef_preference_manager_get_chrome_variations_as_strings(TempSL.Handle);
|
||||
TempSL.CopyToStrings(strings);
|
||||
end;
|
||||
end;
|
||||
|
||||
function TCefPreferenceManagerRef.HasPreference(const name: ustring): Boolean;
|
||||
var
|
||||
TempName : TCefString;
|
||||
@@ -92,4 +188,20 @@ begin
|
||||
error := CefStringClearAndGet(@TempError);
|
||||
end;
|
||||
|
||||
function TCefPreferenceManagerRef.AddPreferenceObserver(const name: ustring; const observer: ICefPreferenceObserver): ICefRegistration;
|
||||
var
|
||||
TempName : TCefString;
|
||||
TempNamePtr : Pointer;
|
||||
begin
|
||||
if (length(name) > 0) then
|
||||
begin
|
||||
TempName := CefString(name);
|
||||
TempNamePtr := @TempName;
|
||||
end
|
||||
else
|
||||
TempNamePtr := nil;
|
||||
|
||||
Result := TCefRegistrationRef.UnWrap(PCefPreferenceManager(FData)^.add_preference_observer(PCefPreferenceManager(FData), TempNamePtr, CefGetData(observer)));
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
219
source/uCEFPreferenceObserver.pas
Normal file
219
source/uCEFPreferenceObserver.pas
Normal file
@@ -0,0 +1,219 @@
|
||||
unit uCEFPreferenceObserver;
|
||||
|
||||
{$IFDEF FPC}
|
||||
{$MODE OBJFPC}{$H+}
|
||||
{$ENDIF}
|
||||
|
||||
{$I cef.inc}
|
||||
|
||||
{$IFNDEF TARGET_64BITS}{$ALIGN ON}{$ENDIF}
|
||||
{$MINENUMSIZE 4}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
{$IFDEF DELPHI16_UP}
|
||||
System.Classes,
|
||||
{$ELSE}
|
||||
Classes,
|
||||
{$ENDIF}
|
||||
uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes;
|
||||
|
||||
type
|
||||
TCefPreferenceObserverOwn = class(TCefBaseRefCountedOwn, ICefPreferenceObserver)
|
||||
protected
|
||||
procedure OnPreferenceChanged(const name : ustring); virtual;
|
||||
|
||||
procedure RemoveReferences; virtual;
|
||||
|
||||
public
|
||||
constructor Create; virtual;
|
||||
end;
|
||||
|
||||
TCustomPreferenceObserver = class(TCefPreferenceObserverOwn)
|
||||
protected
|
||||
FEvents : Pointer;
|
||||
|
||||
procedure OnPreferenceChanged(const name : ustring); override;
|
||||
|
||||
procedure RemoveReferences; override;
|
||||
|
||||
public
|
||||
constructor Create(const events : IChromiumEvents); reintroduce; virtual;
|
||||
destructor Destroy; override;
|
||||
end;
|
||||
|
||||
TPreferenceInfo = class
|
||||
protected
|
||||
FObserver : ICefPreferenceObserver;
|
||||
FRegistration : ICefRegistration;
|
||||
FName : ustring;
|
||||
|
||||
public
|
||||
constructor Create(const aName : ustring; const events : IChromiumEvents);
|
||||
destructor Destroy; override;
|
||||
|
||||
property PrefName : ustring read FName;
|
||||
property Observer : ICefPreferenceObserver read FObserver;
|
||||
property Registration : ICefRegistration read FRegistration write FRegistration;
|
||||
end;
|
||||
|
||||
TPreferenceInfoList = class(TList)
|
||||
protected
|
||||
function SearchPreference(const aName : ustring): integer;
|
||||
|
||||
public
|
||||
destructor Destroy; override;
|
||||
|
||||
function HasPreference(const aName : ustring): boolean;
|
||||
function AddPreference(const aName : ustring; const events : IChromiumEvents): integer;
|
||||
procedure RemovePreference(const aName : ustring);
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
{$IFDEF DELPHI16_UP}
|
||||
System.SysUtils,
|
||||
{$ELSE}
|
||||
SysUtils,
|
||||
{$ENDIF}
|
||||
uCEFMiscFunctions, uCEFLibFunctions, uCEFBrowser;
|
||||
|
||||
|
||||
// TCefPreferenceObserverOwn
|
||||
|
||||
procedure cef_preference_observer_on_preference_changed(self: PCefPreferenceObserver; const name: PCefString); stdcall;
|
||||
var
|
||||
TempObject : TObject;
|
||||
begin
|
||||
TempObject := CefGetObject(self);
|
||||
|
||||
if (TempObject <> nil) and (TempObject is TCefPreferenceObserverOwn) then
|
||||
TCefPreferenceObserverOwn(TempObject).OnPreferenceChanged(CefString(name));
|
||||
end;
|
||||
|
||||
constructor TCefPreferenceObserverOwn.Create;
|
||||
begin
|
||||
inherited CreateData(SizeOf(TCefPreferenceObserver));
|
||||
|
||||
PCefPreferenceObserver(FData)^.on_preference_changed := {$IFDEF FPC}@{$ENDIF}cef_preference_observer_on_preference_changed;
|
||||
end;
|
||||
|
||||
procedure TCefPreferenceObserverOwn.OnPreferenceChanged(const name : ustring);
|
||||
begin
|
||||
//
|
||||
end;
|
||||
|
||||
procedure TCefPreferenceObserverOwn.RemoveReferences;
|
||||
begin
|
||||
//
|
||||
end;
|
||||
|
||||
|
||||
// TCustomPreferenceObserver
|
||||
|
||||
constructor TCustomPreferenceObserver.Create(const events : IChromiumEvents);
|
||||
begin
|
||||
inherited Create;
|
||||
|
||||
FEvents := Pointer(events);
|
||||
end;
|
||||
|
||||
destructor TCustomPreferenceObserver.Destroy;
|
||||
begin
|
||||
RemoveReferences;
|
||||
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TCustomPreferenceObserver.RemoveReferences;
|
||||
begin
|
||||
FEvents := nil;
|
||||
end;
|
||||
|
||||
procedure TCustomPreferenceObserver.OnPreferenceChanged(const name : ustring);
|
||||
begin
|
||||
if (FEvents <> nil) then
|
||||
IChromiumEvents(FEvents).doOnPreferenceChanged(name);
|
||||
end;
|
||||
|
||||
|
||||
// TPreferenceInfo
|
||||
|
||||
constructor TPreferenceInfo.Create(const aName : ustring; const events : IChromiumEvents);
|
||||
begin
|
||||
inherited Create;
|
||||
|
||||
FName := aName;
|
||||
FObserver := TCustomPreferenceObserver.Create(events);
|
||||
FRegistration := nil;
|
||||
end;
|
||||
|
||||
destructor TPreferenceInfo.Destroy;
|
||||
begin
|
||||
FRegistration := nil;
|
||||
FObserver := nil;
|
||||
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
|
||||
// TPreferenceInfoList
|
||||
|
||||
|
||||
|
||||
destructor TPreferenceInfoList.Destroy;
|
||||
var
|
||||
i : integer;
|
||||
begin
|
||||
i := pred(Count);
|
||||
while (i >= 0) do
|
||||
begin
|
||||
TPreferenceInfo(Items[i]).Free;
|
||||
dec(i);
|
||||
end;
|
||||
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
function TPreferenceInfoList.SearchPreference(const aName : ustring): integer;
|
||||
var
|
||||
i : integer;
|
||||
begin
|
||||
Result := -1;
|
||||
|
||||
i := pred(Count);
|
||||
while (i >= 0) do
|
||||
if (TPreferenceInfo(Items[i]).PrefName = aName) then
|
||||
begin
|
||||
Result := i;
|
||||
exit;
|
||||
end
|
||||
else
|
||||
dec(i);
|
||||
end;
|
||||
|
||||
function TPreferenceInfoList.HasPreference(const aName : ustring): boolean;
|
||||
begin
|
||||
Result := SearchPreference(aName) >= 0;
|
||||
end;
|
||||
|
||||
function TPreferenceInfoList.AddPreference(const aName : ustring; const events : IChromiumEvents): integer;
|
||||
begin
|
||||
Result := Add(TPreferenceInfo.Create(aName, events));
|
||||
end;
|
||||
|
||||
procedure TPreferenceInfoList.RemovePreference(const aName : ustring);
|
||||
var
|
||||
i : integer;
|
||||
begin
|
||||
i := SearchPreference(aName);
|
||||
if (i >= 0) then
|
||||
begin
|
||||
TPreferenceInfo(Items[i]).Free;
|
||||
Delete(i);
|
||||
end;
|
||||
end;
|
||||
|
||||
end.
|
||||
@@ -210,6 +210,13 @@ type
|
||||
/// </summary>
|
||||
function GetChromeColorSchemeVariant: TCefColorVariant;
|
||||
|
||||
/// <summary>
|
||||
/// Add an observer for content and website setting changes. The observer will
|
||||
/// remain registered until the returned Registration object is destroyed.
|
||||
/// This function must be called on the browser process UI thread.
|
||||
/// </summary>
|
||||
function AddSettingObserver(const observer: ICefSettingObserver): ICefRegistration;
|
||||
|
||||
public
|
||||
class function UnWrap(data: Pointer): ICefRequestContext; reintroduce;
|
||||
/// <summary>
|
||||
@@ -262,7 +269,7 @@ implementation
|
||||
|
||||
uses
|
||||
uCEFMiscFunctions, uCEFLibFunctions, uCEFCookieManager, uCEFRequestContextHandler,
|
||||
uCEFStringList, uCEFMediaRouter, uCEFValue;
|
||||
uCEFStringList, uCEFMediaRouter, uCEFValue, uCEFRegistration;
|
||||
|
||||
function TCefRequestContextRef.ClearSchemeHandlerFactories: Boolean;
|
||||
begin
|
||||
@@ -426,6 +433,11 @@ begin
|
||||
Result := PCefRequestContext(FData)^.get_chrome_color_scheme_variant(PCefRequestContext(FData));
|
||||
end;
|
||||
|
||||
function TCefRequestContextRef.AddSettingObserver(const observer: ICefSettingObserver): ICefRegistration;
|
||||
begin
|
||||
Result := TCefRegistrationRef.UnWrap(PCefRequestContext(FData)^.add_setting_observer(PCefRequestContext(FData), CefGetData(observer)));
|
||||
end;
|
||||
|
||||
function TCefRequestContextRef.RegisterSchemeHandlerFactory(const schemeName : ustring;
|
||||
const domainName : ustring;
|
||||
const factory : ICefSchemeHandlerFactory): Boolean;
|
||||
|
||||
106
source/uCEFSettingObserver.pas
Normal file
106
source/uCEFSettingObserver.pas
Normal file
@@ -0,0 +1,106 @@
|
||||
unit uCEFSettingObserver;
|
||||
|
||||
{$IFDEF FPC}
|
||||
{$MODE OBJFPC}{$H+}
|
||||
{$ENDIF}
|
||||
|
||||
{$I cef.inc}
|
||||
|
||||
{$IFNDEF TARGET_64BITS}{$ALIGN ON}{$ENDIF}
|
||||
{$MINENUMSIZE 4}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes;
|
||||
|
||||
type
|
||||
TCefSettingObserverOwn = class(TCefBaseRefCountedOwn, ICefSettingObserver)
|
||||
protected
|
||||
procedure OnSettingChanged(const requesting_url, top_level_url : ustring; content_type: TCefContentSettingTypes); virtual;
|
||||
|
||||
procedure RemoveReferences; virtual;
|
||||
|
||||
public
|
||||
constructor Create; virtual;
|
||||
end;
|
||||
|
||||
TCustomSettingObserver = class(TCefSettingObserverOwn)
|
||||
protected
|
||||
FEvents : Pointer;
|
||||
|
||||
procedure OnSettingChanged(const requesting_url, top_level_url : ustring; content_type: TCefContentSettingTypes); override;
|
||||
|
||||
procedure RemoveReferences; override;
|
||||
|
||||
public
|
||||
constructor Create(const events : IChromiumEvents); reintroduce; virtual;
|
||||
destructor Destroy; override;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
uCEFMiscFunctions, uCEFLibFunctions, uCEFBrowser;
|
||||
|
||||
|
||||
// TCefSettingObserverOwn
|
||||
|
||||
procedure cef_setting_observer_on_setting_changed(self: PCefSettingObserver; const requesting_url, top_level_url: PCefString; content_type: TCefContentSettingTypes); stdcall;
|
||||
var
|
||||
TempObject : TObject;
|
||||
begin
|
||||
TempObject := CefGetObject(self);
|
||||
|
||||
if (TempObject <> nil) and (TempObject is TCefSettingObserverOwn) then
|
||||
TCefSettingObserverOwn(TempObject).OnSettingChanged(CefString(requesting_url),
|
||||
CefString(top_level_url),
|
||||
content_type);
|
||||
end;
|
||||
|
||||
constructor TCefSettingObserverOwn.Create;
|
||||
begin
|
||||
inherited CreateData(SizeOf(TCefSettingObserver));
|
||||
|
||||
PCefSettingObserver(FData)^.on_setting_changed := {$IFDEF FPC}@{$ENDIF}cef_setting_observer_on_setting_changed;
|
||||
end;
|
||||
|
||||
procedure TCefSettingObserverOwn.OnSettingChanged(const requesting_url, top_level_url : ustring; content_type: TCefContentSettingTypes);
|
||||
begin
|
||||
//
|
||||
end;
|
||||
|
||||
procedure TCefSettingObserverOwn.RemoveReferences;
|
||||
begin
|
||||
//
|
||||
end;
|
||||
|
||||
|
||||
// TCustomSettingObserver
|
||||
|
||||
constructor TCustomSettingObserver.Create(const events : IChromiumEvents);
|
||||
begin
|
||||
inherited Create;
|
||||
|
||||
FEvents := Pointer(events);
|
||||
end;
|
||||
|
||||
destructor TCustomSettingObserver.Destroy;
|
||||
begin
|
||||
RemoveReferences;
|
||||
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TCustomSettingObserver.RemoveReferences;
|
||||
begin
|
||||
FEvents := nil;
|
||||
end;
|
||||
|
||||
procedure TCustomSettingObserver.OnSettingChanged(const requesting_url, top_level_url : ustring; content_type: TCefContentSettingTypes);
|
||||
begin
|
||||
if (FEvents <> nil) then
|
||||
IChromiumEvents(FEvents).doOnSettingChanged(requesting_url, top_level_url, content_type);
|
||||
end;
|
||||
|
||||
end.
|
||||
@@ -202,6 +202,15 @@ type
|
||||
procedure Execute; override;
|
||||
end;
|
||||
|
||||
TCefAddPreferenceObserverTask = class(TCefChromiumTask)
|
||||
protected
|
||||
FName : ustring;
|
||||
procedure Execute; override;
|
||||
|
||||
public
|
||||
constructor Create(const aEvents : IChromiumEvents; const aName : ustring); reintroduce;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
@@ -700,4 +709,29 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
// TCefAddPreferenceObserverTask
|
||||
|
||||
constructor TCefAddPreferenceObserverTask.Create(const aEvents : IChromiumEvents; const aName : ustring);
|
||||
begin
|
||||
inherited Create(aEvents);
|
||||
|
||||
FName := aName;
|
||||
end;
|
||||
|
||||
procedure TCefAddPreferenceObserverTask.Execute;
|
||||
begin
|
||||
try
|
||||
try
|
||||
if CanExecute then
|
||||
IChromiumEvents(FEvents).doAddPreferenceObserver(FName);
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TCefAddPreferenceObserverTask.Execute', e) then raise;
|
||||
end;
|
||||
finally
|
||||
FEvents := nil;
|
||||
end;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
@@ -34,6 +34,7 @@ type
|
||||
PCefBinaryValue = ^TCefBinaryValue;
|
||||
PCefSchemeRegistrar = ^TCefSchemeRegistrar;
|
||||
PCefPreferenceRegistrar = ^TCefPreferenceRegistrar;
|
||||
PCefPreferenceObserver = ^TCefPreferenceObserver;
|
||||
PCefPreferenceManager = ^TCefPreferenceManager;
|
||||
PCefCommandLine = ^TCefCommandLine;
|
||||
PCefCommandHandler = ^TCefCommandHandler;
|
||||
@@ -140,6 +141,7 @@ type
|
||||
PCefSSLStatus = ^TCefSSLStatus;
|
||||
PCefSelectClientCertificateCallback = ^TCefSelectClientCertificateCallback;
|
||||
PCefCallback = ^TCefCallback;
|
||||
PCefSettingObserver = ^TCefSettingObserver;
|
||||
PCefCookie = ^TCefCookie;
|
||||
PCefRequestContext = ^TCefRequestContext;
|
||||
PCefRequestContextHandler = ^TCefRequestContextHandler;
|
||||
@@ -3340,6 +3342,7 @@ type
|
||||
CEF_CPAIT_DISCOUNTS,
|
||||
CEF_CPAIT_OPTIMIZATION_GUIDE,
|
||||
CEF_CPAIT_COLLABORATION_MESSAGING, {* CEF_API_ADDED(13304) *}
|
||||
CEF_CPAIT_CHANGE_PASSWORD, {* CEF_API_ADDED(13400) *}
|
||||
CEF_CPAIT_NUM_VALUES
|
||||
);
|
||||
|
||||
@@ -5430,7 +5433,15 @@ type
|
||||
/// or legacy behavior.
|
||||
/// </summary>
|
||||
CEF_CONTENT_SETTING_TYPE_LEGACY_COOKIE_SCOPE,
|
||||
|
||||
/// <summary>
|
||||
/// Website setting to indicate whether the user has allowlisted suspicious
|
||||
/// notifications for the origin.
|
||||
/// </summary>
|
||||
CEF_CONTENT_SETTING_TYPE_ARE_SUSPICIOUS_NOTIFICATIONS_ALLOWLISTED_BY_USER, {* CEF_API_ADDED(13400) *}
|
||||
/// <summary>
|
||||
/// Content settings for access to the Controlled Frame API.
|
||||
/// </summary>
|
||||
CEF_CONTENT_SETTING_TYPE_CONTROLLED_FRAME, {* CEF_API_ADDED(13400) *}
|
||||
CEF_CONTENT_SETTING_TYPE_NUM_VALUES
|
||||
);
|
||||
|
||||
@@ -6053,6 +6064,23 @@ type
|
||||
add_preference : function(self: PCefPreferenceRegistrar; const name: PCefString; default_value: PCefValue): Integer; stdcall;
|
||||
end;
|
||||
|
||||
/// <summary>
|
||||
/// Implemented by the client to observe preference changes and registered via
|
||||
/// cef_preference_manager_t::AddPreferenceObserver. The functions of this
|
||||
/// structure will be called on the browser process UI thread.
|
||||
///
|
||||
/// NOTE: This struct is allocated client-side.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>Implemented by ICefPreferenceObserver.</para>
|
||||
/// <para><see href="https://bitbucket.org/chromiumembedded/cef/src/master/include/capi/cef_preference_capi.h">CEF source file: /include/capi/cef_preference_capi.h (cef_preference_observer_t)</see></para>
|
||||
/// </remarks>
|
||||
{* CEF_API_ADDED(13401) *}
|
||||
TCefPreferenceObserver = record
|
||||
base : TCefBaseRefCounted;
|
||||
on_preference_changed : procedure(self: PCefPreferenceObserver; const name: PCefString); stdcall;
|
||||
end;
|
||||
|
||||
/// <summary>
|
||||
/// Manage access to preferences. Many built-in preferences are registered by
|
||||
/// Chromium. Custom preferences can be registered in
|
||||
@@ -6071,6 +6099,7 @@ type
|
||||
get_all_preferences : function(self: PCefPreferenceManager; include_defaults: Integer): PCefDictionaryValue; stdcall;
|
||||
can_set_preference : function(self: PCefPreferenceManager; const name: PCefString): Integer; stdcall;
|
||||
set_preference : function(self: PCefPreferenceManager; const name: PCefString; value: PCefValue; error: PCefString): Integer; stdcall;
|
||||
add_preference_observer : function(self: PCefPreferenceManager; const name: PCefString; observer: PCefPreferenceObserver): PCefRegistration; stdcall; {* CEF_API_ADDED(13401) *}
|
||||
end;
|
||||
|
||||
/// <summary>
|
||||
@@ -6742,6 +6771,23 @@ type
|
||||
cancel : procedure(self: PCefCallback); stdcall;
|
||||
end;
|
||||
|
||||
/// <summary>
|
||||
/// Implemented by the client to observe content and website setting changes and
|
||||
/// registered via cef_request_context_t::AddSettingObserver. The functions of
|
||||
/// this structure will be called on the browser process UI thread.
|
||||
///
|
||||
/// NOTE: This struct is allocated client-side.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>Implemented by ICefSettingObserver.</para>
|
||||
/// <para><see href="https://bitbucket.org/chromiumembedded/cef/src/master/include/capi/cef_request_context_capi.h">CEF source file: /include/capi/cef_request_context_capi.h (cef_setting_observer_t)</see></para>
|
||||
/// </remarks>
|
||||
{* CEF_API_ADDED(13401) *}
|
||||
TCefSettingObserver = record
|
||||
base : TCefBaseRefCounted;
|
||||
on_setting_changed : procedure(self: PCefSettingObserver; const requesting_url, top_level_url: PCefString; content_type: TCefContentSettingTypes); stdcall;
|
||||
end;
|
||||
|
||||
/// <summary>
|
||||
/// A request context provides request handling for a set of related browser or
|
||||
/// URL request objects. A request context can be specified when creating a new
|
||||
@@ -6787,6 +6833,7 @@ type
|
||||
get_chrome_color_scheme_mode : function(self: PCefRequestContext): TCefColorVariant; stdcall;
|
||||
get_chrome_color_scheme_color : function(self: PCefRequestContext): TCefColor; stdcall;
|
||||
get_chrome_color_scheme_variant : function(self: PCefRequestContext): TCefColorVariant; stdcall;
|
||||
add_setting_observer : function(self: PCefRequestContext; observer: PCefSettingObserver): PCefRegistration; stdcall; {* CEF_API_ADDED(13401) *}
|
||||
end;
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
CEF_SUPPORTED_VERSION_MAJOR = 133;
|
||||
CEF_SUPPORTED_VERSION_MINOR = 4;
|
||||
CEF_SUPPORTED_VERSION_RELEASE = 8;
|
||||
CEF_SUPPORTED_VERSION_MAJOR = 134;
|
||||
CEF_SUPPORTED_VERSION_MINOR = 3;
|
||||
CEF_SUPPORTED_VERSION_RELEASE = 1;
|
||||
CEF_SUPPORTED_VERSION_BUILD = 0;
|
||||
|
||||
CEF_CHROMEELF_VERSION_MAJOR = CEF_SUPPORTED_VERSION_MAJOR;
|
||||
CEF_CHROMEELF_VERSION_MINOR = 0;
|
||||
CEF_CHROMEELF_VERSION_RELEASE = 6943;
|
||||
CEF_CHROMEELF_VERSION_BUILD = 142;
|
||||
CEF_CHROMEELF_VERSION_RELEASE = 6998;
|
||||
CEF_CHROMEELF_VERSION_BUILD = 89;
|
||||
|
||||
// values defined in cef_api_versions.json
|
||||
CEF_API_VERSION_MIN = 13300;
|
||||
CEF_API_VERSION_LAST = 13304;
|
||||
CEF_API_VERSION_LAST = 13401;
|
||||
CEF_API_VERSION = CEF_API_VERSION_LAST;
|
||||
|
||||
// value defined in /include/cef_api_hash.h
|
||||
CEF_API_VERSION_EXPERIMENTAL = 999999;
|
||||
|
||||
// values defined in cef_api_versions.json
|
||||
CEF_API_HASH_PLATFORM_LINUX = 'f1ababb4ff51ecbf77c481cee3721ef0eca9c8ca';
|
||||
CEF_API_HASH_PLATFORM_MAC = '98964c37b8917d83da4b173e22905503d38ad08f';
|
||||
CEF_API_HASH_PLATFORM_WINDOWS = '19c014af0082aa901398e006381b6980e4f806e9';
|
||||
CEF_API_HASH_PLATFORM_LINUX = 'b14bee2c0fd250da67faea421f620b58e5dea9a2';
|
||||
CEF_API_HASH_PLATFORM_MAC = 'b54732b528bc2669481ec0cf17c7b97b033720b9';
|
||||
CEF_API_HASH_PLATFORM_WINDOWS = '751255204f006b8b883a8baf552a2da792f8aa44';
|
||||
|
||||
Reference in New Issue
Block a user