Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Programmieren allgemein (https://www.delphipraxis.net/40-programmieren-allgemein/)
-   -   Delphi Gecko Interface nutzen... (https://www.delphipraxis.net/151964-gecko-interface-nutzen.html)

Z4ppy 7. Jun 2010 23:16

Gecko Interface nutzen...
 
Ich hab absolut keine Ahnung, wie ich mit interfaces arbeiten muss ^^

Also: ich habe mir das Delphi Gecko SDK heruntergeladen, weil es damit einige Probleme bezüglich CSS2 und anderem gab, habe ich dann die neuste Version des originalen Gecko SDK integriert. Das funktioniert soweit auch (inklusive JS, Flash usw.).

Nun zu meinem Problem: Ich möchte gerne Klicks auf Links abfangen. Die TGeckoBrowser Komponente bietet zwar "OnLocationChange", das wird aber erst nach dem Laden ausgelöst. Ich möchte den Klick schon vorher abfangen und dann selber behandeln.

Nach viel Gesuche bin ich auf das Interface nsIContentPolicy gestossen mit der Methode shouldLoad(), was genau dem Punkt entspricht, an dem ich ansetzen muss, um mein Ziel zu erreichen. Meine Versuche, das zu implementieren sind allerdings nicht erfolgreich gewesen.
Ich möchte noch dazu sagen, dass ich bisher noch nie selbst Interfaces implementieren musste, ich hatte immer fertige Vorlagen ;)

Mein Codeversuch:
Delphi-Quellcode:
type
  nsIContentPolicy = interface(nsISupports)
  ['{58cf9dca-40b3-6211-a508-7351f437a53e}']
    function shouldLoad(aContentType: Cardinal; aContentLocation: nsIURI; aRequestOrigin: nsIURI; aContext: nsISupports; aMimeTypeGuess: nsISupports; aExtra: nsISupports): Cardinal; stdcall;
    function shouldProcess(aContentType: Cardinal; aContentLocation: nsIURI; aRequestOrigin: nsIURI; aContext: nsISupports; aMimeType: nsISupports; aExtra: nsISupports): Cardinal; stdcall;
  end;

  TGeckoBrowserEx = class(TGeckoBrowser,nsIContentPolicy)
  private
    function shouldLoad(aContentType: Cardinal; aContentLocation: nsIURI; aRequestOrigin: nsIURI; aContext: nsISupports; aMimeTypeGuess: nsISupports; aExtra: nsISupports): Cardinal; stdcall;
    function shouldProcess(aContentType: Cardinal; aContentLocation: nsIURI; aRequestOrigin: nsIURI; aContext: nsISupports; aMimeType: nsISupports; aExtra: nsISupports): Cardinal; stdcall;
  end;

const
  REJECT_REQUEST = -1;
  REJECT_TYPE = -2;
  REJECT_SERVER = -3;
  REJECT_OTHER = -4;
  ACCEPT = 1;

var
  Form1: TForm1;
  GeckoBrowser1: TGeckoBrowserEx;

implementation

function TGeckoBrowserEx.shouldLoad(aContentType: Cardinal; aContentLocation: nsIURI; aRequestOrigin: nsIURI; aContext: nsISupports; aMimeTypeGuess: nsISupports; aExtra: nsISupports): Cardinal;
begin
  Form1.Memo1.Lines.Add('asdf'); // zum Überprüfen, dass die Methode auch ausgeführt wurde :P In diesem Fall würde jetzt das Laden erlaubt...
  Result:=ACCEPT;
end;

function TGeckoBrowserEx.shouldProcess(aContentType: Cardinal; aContentLocation: nsIURI; aRequestOrigin: nsIURI; aContext: nsISupports; aMimeType: nsISupports; aExtra: nsISupports): Cardinal;
begin
  Result:=ACCEPT;
end;

procedure TForm1.FormShow(Sender: TObject);
begin
  GeckoBrowser1:=TGeckoBrowserEx.Create(self);
  GeckoBrowser1.Parent:=Form1;
  GeckoBrowser1.Show;
  GeckoBrowser1.Top:=8;
  GeckoBrowser1.Left:=8;
  GeckoBrowser1.Width:=1200;
  GeckoBrowser1.Height:=472;
  GeckoBrowser1.LoadURI('http://www.google.com/'); // oder was auch immer, wo halt Links sind, die ich abfangen kann ^^
end;
Nunja, funktioniert genau gar nicht :P

Wie muss ich das machen? :)

MfG Z4ppy

Z4ppy 8. Jun 2010 13:07

AW: Gecko Interface nutzen...
 
Hier habe ich nun mal mein Testprojekt hochgeladen, inklusive der ganzen Gecko Engine Dateien.
Das Delphi Gecko SDK wird benötigt (GeckoComponents und GeckoSDK aus dem Archiv) ;) Der Link dorthin findet sich oben...

Vielleicht kann mir so besser geholfen werden, wenn mir noch zu helfen ist ^^

MfG Z4ppy

Z4ppy 12. Jun 2010 16:43

AW: Gecko Interface nutzen...
 
Ich habe im MDC (Mozilla Development Center ^^) nun die offizielle Beschreibung des nsIContentPolicy Interface gefunden. Scheint doch etwas komplizierter zu sein, das zu implementieren. Wie muss ich das in Delphi umsetzen? C++ (oder welche Sprache das auch immer ist xD) beherrsche ich nicht wirklich...

MfG Z4ppy

Z4ppy 15. Jun 2010 00:39

AW: Gecko Interface nutzen...
 
Kann mir wirklich keiner helfen? :cry:
Das kann doch nicht soo schwer sein... für euch Profis ^^

MfG Z4ppy

generic 15. Jun 2010 01:28

AW: Gecko Interface nutzen...
 
Ich wollte mich mit dem Thema Gecko immer mal befassen. Hab nur gerade das Webkit am Wickel. Wenn ich das mit Cairo unter Windows kompiliert bekomme, dann schauen wir mal weiter.
Also keine Hektik ;-)

Z4ppy 15. Jun 2010 22:44

AW: Gecko Interface nutzen...
 
Alles klar :)

MfG Z4ppy

Z4ppy 12. Aug 2010 03:50

AW: Gecko Interface nutzen...
 
Ich erlaube mir mal, hier zu bumpen nach knapp 2 Monaten ^^

MfG Z4ppy

generic 12. Aug 2010 08:54

AW: Gecko Interface nutzen...
 
Ich bin an der Front auch noch nicht weiter, aber du kannst ja mal bei
http://sourceforge.net/projects/d-gecko/ schauen ob er weiter ist.

Dort wird das SDK für Delphi weiter entwickelt.
Der letzte commit war allerdings vor 516 Tagen.

Z4ppy 12. Aug 2010 12:58

AW: Gecko Interface nutzen...
 
Das ist das, was ich schon verwende, und dort wird leider auf dieses Interface gar nicht eingegangen :( Scheint für den Normalbenutzer nicht wichtig genug zu sein...

MfG Z4ppy

r2d2-aeg 20. Aug 2010 23:39

AW: Gecko Interface nutzen...
 
Hallo
hätte mal ne Frage:
wie kann ich denn die originale Gecko SDK in die Delphi Gecko SDK integrieren?

LG R2D2-AEG

Z4ppy 22. Aug 2010 22:49

AW: Gecko Interface nutzen...
 
Du lädst dir von hier die passende Version herunter und entpackst den Inhalt des ordners xulrunner-sdk\bin in den Ordner deines Projektes. Die Delphi Gecko SDK Units funktionieren auch für die neuste Version ;)

Die Frage des Threads ist leider nach wie vor unbeantwortet :cry:

MfG Z4ppy

Z4ppy 2. Okt 2010 17:07

AW: Gecko Interface nutzen...
 
Kann mir niemand den Code (siehe hier) in Delphi übersetzen? :cry:

MfG Z4ppy


Alle Zeitangaben in WEZ +1. Es ist jetzt 22:01 Uhr.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz