Author Topic: idea for embedding a chromium browser  (Read 43517 times)

laggyluk

  • Jr. Member
  • **
  • Posts: 69
idea for embedding a chromium browser
« on: March 01, 2013, 11:59:52 pm »
i've done some searching and it looks like lazarus doesn't have an easy way to integrate a standalone web browser into a project.
on other hand chromium embedded browser works fine with delphi.
so I was wondering, maybe it's possible to build chromium into a dll in delphi and then use in lazarus project. I don't know much about dll's so does it make any sense before I start digging into the subject?

Cyrax

  • Hero Member
  • *****
  • Posts: 836
Re: idea for embedding a chromium browser
« Reply #1 on: March 02, 2013, 03:15:19 am »
I assume that you have seen this link : https://code.google.com/p/delphichromiumembedded/

I have few patches for both DCEF and DCEF3 (to get them compile and work with FPC trunk and Lazarus trunk) and simple component for Lazarus. If you want them, I can attach/give a download link to files. I need clean up their code first, however.

laggyluk

  • Jr. Member
  • **
  • Posts: 69
Re: idea for embedding a chromium browser
« Reply #2 on: March 02, 2013, 10:04:44 am »
Yeah, i'm referring to it. I've read on the project discussion board that it doesn't work with lazarus so if you have a working code and willing to share that would be great.

Dibo

  • Hero Member
  • *****
  • Posts: 1061
Re: idea for embedding a chromium browser
« Reply #3 on: March 02, 2013, 11:58:22 am »

laggyluk

  • Jr. Member
  • **
  • Posts: 69
Re: idea for embedding a chromium browser
« Reply #4 on: March 02, 2013, 02:06:12 pm »
seen the link before but I'm on windows

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12984
  • FPC developer.
Re: idea for embedding a chromium browser
« Reply #5 on: March 02, 2013, 02:19:40 pm »
On Windows COM instrumenting IE should also work I guess. It is just that the easy wrapper in Delphi (TWebBrowser) doesn't exist yet

theo

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1947

Cyrax

  • Hero Member
  • *****
  • Posts: 836
Re: idea for embedding a chromium browser
« Reply #7 on: April 12, 2013, 05:35:29 pm »
Here they are.

dcef3_lazarus_patch.zip contains SVN patch file for DCEF3 r26. Patch includes Lazarus package for it.

laz_chromium_component.zip is the component for Lazarus.
« Last Edit: April 12, 2013, 05:37:01 pm by Cyrax »

vfclists

  • Hero Member
  • *****
  • Posts: 1165
    • HowTos Considered Harmful?
Re: idea for embedding a chromium browser
« Reply #8 on: April 19, 2013, 08:52:51 pm »
I have been lurking and waiting for this :). I will give it a try as soon as I can.

Here they are.

dcef3_lazarus_patch.zip contains SVN patch file for DCEF3 r26. Patch includes Lazarus package for it.

laz_chromium_component.zip is the component for Lazarus.
Lazarus 3.0/FPC 3.2.2

a.atalla

  • Jr. Member
  • **
  • Posts: 82
Re: idea for embedding a chromium browser
« Reply #9 on: April 19, 2013, 09:28:38 pm »
i could embed IE in a form using activex  very easy
http://wiki.freepascal.org/LazActiveX
Lazarus 1.0.8 | FPC 2.6.2 x64  | Arch Linux x64 | Windows 7-x86

zbyna

  • Jr. Member
  • **
  • Posts: 63
Re: idea for embedding a chromium browser
« Reply #10 on: May 20, 2014, 01:09:32 am »
Anyone tried this:

https://github.com/dliw/fpCEF3
?

zbyna

  • Jr. Member
  • **
  • Posts: 63
Re: idea for embedding a chromium browser
« Reply #11 on: May 28, 2014, 09:39:35 pm »
Anyone tried this:

https://github.com/dliw/fpCEF3
?

Does not work with actual CEF3 cef_binary_3.1650.1562_windows32,
 it is needed to use cef_binary_3.1547.1412_windows32_client  :)

zbyna

  • Jr. Member
  • **
  • Posts: 63
Re: idea for embedding a chromium browser
« Reply #12 on: May 30, 2014, 02:22:33 pm »
fpCEF3 seemed promissing to me but I am stuck with retreiving  dom information in this project.
Seems that I am not able to use visitdomproc()   :'(   Since I am not very versed programmer the issue is
probably between chair and keyboard :) 

I encounter no error messages, I am able run project without problem but these lines do not work:

Code: [Select]
procedure pokus(const document:ICefDomDocument); //does not work
              begin
                Mainform.Memo1.text:=document.GetFocusedNode.GetValue;
                ShowMessage('Funguje :-)');
              end;

procedure TMainform.ChromiumKeyEvent(Sender: TObject;
  const Browser: ICefBrowser; const event: PCefKeyEvent;
  osEvent: TCefEventHandle; out Result: Boolean);
var
    mujFrame : ICefFrame;
    dok:ICefDomDocument;
    mojeJmenaFramu: TStrings;
begin
   pokus1:= @pokus;
   Memo1.text:='Identifikátor framu :'+ inttostr( Chromium.Browser.GetMainFrame.GetIdentifier)+ LineEnding
                + 'Počet frames : '+ inttostr (Chromium.Browser.GetFrameCount);
   Chromium.Browser.GetMainFrame.VisitDomProc(pokus1); //does not work
end;                                                                                                                       

I enclose all project
Thanks for potential help

Code: [Select]
Unit Main;

{$MODE objfpc}{$H+}

Interface

Uses
  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, LCLType, ExtCtrls,
  cef3types, cef3lib, cef3intf, cef3lcl, cef3gui;

Type

  { TMainform }

  TMainform = class(TForm)
    BGo : TButton;
    Button1: TButton;
    Chromium : TChromium;
    EUrl : TEdit;
    LUrl : TStaticText;
    Memo1: TMemo;
    procedure BGoClick(Sender : TObject);
    procedure ChromiumKeyEvent(Sender: TObject; const Browser: ICefBrowser;
      const event: PCefKeyEvent; osEvent: TCefEventHandle; out Result: Boolean);
    procedure ChromiumLoadEnd(Sender : TObject; const Browser : ICefBrowser;
      const Frame : ICefFrame; httpStatusCode : Integer);
    procedure ChromiumTitleChange(Sender : TObject;
      const Browser : ICefBrowser; const title : ustring);
    procedure EUrlKeyDown(Sender : TObject; var Key : Word;
      Shift : TShiftState);
    procedure FormCreate(Sender : TObject);

  private
    { private declarations }
  public
    { public declarations }
  end;
  procedure pokus(const document:ICefDomDocument);
Var
  Mainform : TMainform;
  pokus1:TCefDomVisitorProc;

Implementation

{$R *.lfm}

{ TMainform }

procedure TMainform.BGoClick(Sender : TObject);
var
    mujFrame : ICefFrame;
begin
  Chromium.Load(EUrl.Text);
  //mujFrame:=Chromium.Browser.GetMainFrame;
  //mujFrame.ExecuteJavaScript('alert("ExecuteJavaScript works!")',mujFrame.GetURL(), 0);;
end;

procedure pokus(const document:ICefDomDocument); //does not work
              begin
                Mainform.Memo1.text:=document.GetFocusedNode.GetValue;
                ShowMessage('Funguje :-)');
              end;

procedure TMainform.ChromiumKeyEvent(Sender: TObject;
  const Browser: ICefBrowser; const event: PCefKeyEvent;
  osEvent: TCefEventHandle; out Result: Boolean);
var
    mujFrame : ICefFrame;
    dok:ICefDomDocument;
    mojeJmenaFramu: TStrings;
begin
   pokus1:= @pokus;
   Memo1.text:='Identifikátor framu :'+ inttostr( Chromium.Browser.GetMainFrame.GetIdentifier)+ LineEnding
                + 'Počet frames : '+ inttostr (Chromium.Browser.GetFrameCount);
   Chromium.Browser.GetMainFrame.VisitDomProc(pokus1); //does not work
end;

procedure TMainform.ChromiumLoadEnd(Sender : TObject; const Browser : ICefBrowser; const Frame : ICefFrame;
  httpStatusCode : Integer);
begin
  EUrl.Text := UTF8Encode(Browser.MainFrame.Url);
end;

procedure TMainform.ChromiumTitleChange(Sender : TObject; const Browser : ICefBrowser; const title : ustring);
begin
  Caption := 'Browser - ' + UTF8Encode(title);
end;

procedure TMainform.EUrlKeyDown(Sender : TObject; var Key : Word; Shift : TShiftState);
begin
  If Key = VK_RETURN then BGoClick(Sender);
end;

procedure TMainform.FormCreate(Sender : TObject);
begin
  {$INFO Uncomment to use a subprocess, potřebuje subprocess.exe zkompilovaný pro aktuální
  platformu v adresáři aplikace viz. příklady v ..\fpCEF3-master\Examples\SubProcess\}
  CefBrowserSubprocessPath := '.' + PathDelim + 'subprocess'{$IFDEF WINDOWS}+'.exe'{$ENDIF};
end;

end.           

zbyna

  • Jr. Member
  • **
  • Posts: 63
Re: idea for embedding a chromium browser
« Reply #13 on: June 03, 2014, 07:24:01 pm »
I managed to force procedure pokus to work until document.GetFocusedNode.GetValue.
There were some errors in cef3ref.pas which I caught but behaving of all VisitDomProc s methods and ICefDomDocument seems too difficult for me to fixed it.
I am moving to Internet Explorer it suits my needs.
Good experience sofar for me: do not use project without documentation unless you have a lot of time ...  OK it is provided free of charge as all freepascal and lazarus too I know  ;) 

             

dliw

  • New Member
  • *
  • Posts: 21
Re: idea for embedding a chromium browser
« Reply #14 on: June 03, 2014, 10:04:23 pm »
Hi,
first of all: I'm the maintainer of fpCEF.
Unfortunately I was really busy in the past months (and still have a lot work to do), so I wasn't able to update to the newer version 3.1650 in time.
But now I am almost done with it, so I hope to publish a rather big update soon.

Quote
There were some errors in cef3ref.pas
Can you tell me what was wrong? I would really like to know...

If you want to give Chromium another chance - and stay on Windows only - you could also try https://bitbucket.org/WaspAce/wacef.
It claims to be fpc compatible and it is very similar to fpCEF (both are based on DCEF).

Missing docs is a problem, but if you look into cef3api.pas you will see:
Code: [Select]
    // Visit the DOM document. This function can only be called from the render
    // process.
    visit_dom: procedure(self: PCefFrame; visitor: PCefDomVisitor); cconv;
Probably that's the problem, see here for reference: https://stackoverflow.com/questions/14470176/enumerating-dom-nodes-in-tchromium
« Last Edit: June 04, 2014, 12:13:56 am by dliw »

 

TinyPortal © 2005-2018