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

Update to CEF 83.4.0

This commit is contained in:
Salvador Díaz Fau
2020-06-21 21:27:55 +02:00
parent ef2277fe6c
commit 7e3e8bad24
25 changed files with 1106 additions and 298 deletions

View File

@@ -183,7 +183,7 @@ uses
// This method for sending text messages is limited to around 10000 characters
// but it's much easier to implement than using a JavaScript extension.
// It cosist of using the JavaScript command "console.log" with a known text
// preamble. The browser process rceives the console message in the
// preamble. The browser process receives the console message in the
// TChromium.OnConsoleMessage event and we identify the right message thanks to
// the preamble in the message.
@@ -399,6 +399,18 @@ begin
// Remove it if you don't want to use the DOM visitor
GlobalCEFApp.LogFile := 'debug.log';
GlobalCEFApp.LogSeverity := LOGSEVERITY_INFO;
// Delphi can only debug one process and it debugs the browser process by
// default. If you need to debug code executed in the render process you will
// need to use any of the methods described here :
// https://www.briskbard.com/index.php?lang=en&pageid=cef#debugging
// Using the "Single process" mode is one of the ways to debug all the code
// because everything is executed in the browser process and Delphi won't have
// any problems. However, The "Single process" mode is unsupported by CEF and
// it causes unexpected issues. You should *ONLY* use it for debugging
// purposses.
//GlobalCEFApp.SingleProcess := True;
end;
procedure TDOMVisitorFrm.Chromium1AfterCreated(Sender: TObject; const browser: ICefBrowser);

View File

@@ -58,6 +58,7 @@ const
MINIBROWSER_CONTEXTMENU_SETJSEVENT = MENU_ID_USER_FIRST + 1;
MINIBROWSER_CONTEXTMENU_JSVISITDOM = MENU_ID_USER_FIRST + 2;
MINIBROWSER_CONTEXTMENU_SHOWDEVTOOLS = MENU_ID_USER_FIRST + 3;
MINIBROWSER_CONTEXTMENU_OFFLINE = MENU_ID_USER_FIRST + 4;
MOUSEOVER_MESSAGE_NAME = 'mouseover';
CUSTOMNAME_MESSAGE_NAME = 'customname';
@@ -93,6 +94,8 @@ type
FCanClose : boolean; // Set to True in TChromium.OnBeforeClose
FClosing : boolean; // Set to True in the CloseQuery event.
FOffline : boolean;
procedure BrowserCreatedMsg(var aMessage : TMessage); message CEF_AFTERCREATED;
procedure BrowserDestroyMsg(var aMessage : TMessage); message CEF_DESTROY;
procedure ShowTextViewerMsg(var aMessage : TMessage); message MINIBROWSER_SHOWTEXTVIEWER;
@@ -100,6 +103,8 @@ type
procedure WMMoving(var aMessage : TMessage); message WM_MOVING;
procedure WMEnterMenuLoop(var aMessage: TMessage); message WM_ENTERMENULOOP;
procedure WMExitMenuLoop(var aMessage: TMessage); message WM_EXITMENULOOP;
function SwitchOfflineMode : integer;
end;
var
@@ -112,7 +117,7 @@ implementation
{$R *.dfm}
uses
uSimpleTextViewer, uCEFMiscFunctions, uTestExtensionHandler;
uSimpleTextViewer, uCEFMiscFunctions, uTestExtensionHandler, uCEFDictionaryValue;
// BASIC CONCEPTS
// ==============
@@ -332,6 +337,8 @@ begin
model.AddItem(MINIBROWSER_CONTEXTMENU_SETJSEVENT, 'Set mouseover event');
model.AddItem(MINIBROWSER_CONTEXTMENU_JSVISITDOM, 'Visit DOM in JavaScript');
model.AddItem(MINIBROWSER_CONTEXTMENU_SHOWDEVTOOLS, 'Show DevTools');
model.AddCheckItem(MINIBROWSER_CONTEXTMENU_OFFLINE, 'Offline');
model.SetChecked(MINIBROWSER_CONTEXTMENU_OFFLINE, FOffline);
end;
procedure TJSExtensionFrm.Chromium1BeforePopup(Sender: TObject;
@@ -396,6 +403,29 @@ begin
TempPoint.y := params.YCoord;
Chromium1.ShowDevTools(TempPoint, nil);
end;
MINIBROWSER_CONTEXTMENU_OFFLINE :
SwitchOfflineMode;
end;
end;
// This is a simple example to set the "offline" mode in the DevTools using the TChromium methods directly.
function TJSExtensionFrm.SwitchOfflineMode : integer;
var
TempParams : ICefDictionaryValue;
begin
try
FOffline := not(FOffline);
TempParams := TCefDictionaryValueRef.New;
TempParams.SetBool('offline', FOffline);
TempParams.SetDouble('latency', 0);
TempParams.SetDouble('downloadThroughput', 0);
TempParams.SetDouble('uploadThroughput', 0);
Result := Chromium1.ExecuteDevToolsMethod(0, 'Network.emulateNetworkConditions', TempParams);
finally
TempParams := nil;
end;
end;