Стартовый пул
This commit is contained in:
291
gecko/Components/BrowserSupports.pas
Normal file
291
gecko/Components/BrowserSupports.pas
Normal file
@@ -0,0 +1,291 @@
|
||||
(* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is GeckoComponents for Delphi.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Takanori Ito.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2003
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** *)
|
||||
unit BrowserSupports;
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
nsGeckoStrings, nsTypes, nsXPCOM;
|
||||
|
||||
const
|
||||
GFXIFORMATS_IID: TGUID = '{96d086e6-1dd1-11b2-b6b2-b77b59390247}';
|
||||
GFXIFORMATS_RGB = 0;
|
||||
GFXIFORMATS_BGR = 1;
|
||||
GFXIFORMATS_RGB_A1 = 2;
|
||||
GFXIFORMATS_BGR_A1 = 3;
|
||||
GFXIFORMATS_RGB_A8 = 4;
|
||||
GFXIFORMATS_BGR_A8 = 5;
|
||||
GFXIFORMATS_RGBA = 6;
|
||||
GFXIFORMATS_BGRA = 7;
|
||||
|
||||
GFXIIMAGEFRAME_IID: TGUID = '{51cc27a8-1dd2-11b2-a1aa-dad33ab193b4}';
|
||||
|
||||
IMGICONTAINER_IID: TGUID = '{5e8405a4-1dd2-11b2-8385-bc8e3446cad3}';
|
||||
IMGICONTAINER_kNormalAnimMode = 0;
|
||||
IMGICONTAINER_kDontAnimMode = 1;
|
||||
IMGICONTAINER_kLoopOnceAnimMode = 2;
|
||||
|
||||
IMGICONTAINEROBSERVER_IID: TGUID = '{153f1518-1dd2-11b2-b9cd-b16eb63e0471}';
|
||||
|
||||
NS_IBASEWINDOW_IID: TGUID = '{046bc8a0-8015-11d3-af70-00a024ffc08c}';
|
||||
|
||||
NS_ICONTEXTMENULISTENER2_IID: TGUID = '{7fb719b3-d804-4964-9596-77cf924ee314}';
|
||||
NS_ICONTEXTMENULISTENER2_CONTEXT_NONE = 0;
|
||||
NS_ICONTEXTMENULISTENER2_CONTEXT_LINK = 1;
|
||||
NS_ICONTEXTMENULISTENER2_CONTEXT_IMAGE = 2;
|
||||
NS_ICONTEXTMENULISTENER2_CONTEXT_DOCUMENT = 4;
|
||||
NS_ICONTEXTMENULISTENER2_CONTEXT_TEXT = 8;
|
||||
NS_ICONTEXTMENULISTENER2_CONTEXT_INPUT = 16;
|
||||
NS_ICONTEXTMENULISTENER2_CONTEXT_BACKGROUND_IMAGE = 32;
|
||||
|
||||
NS_ICONTEXTMENUINFO_IID: TGUID = '{2f977d56-5485-11d4-87e2-0010a4e75ef2}';
|
||||
|
||||
NS_IWEBNAVIGATION_IID: TGUID = '{f5d9e7b0-d930-11d3-b057-00a024ffc08c}';
|
||||
NS_IWEBNAVIGATION_LOAD_FLAGS_MASK = 65535;
|
||||
NS_IWEBNAVIGATION_LOAD_FLAGS_NONE = 0;
|
||||
NS_IWEBNAVIGATION_LOAD_FLAGS_IS_REFRESH = 16;
|
||||
NS_IWEBNAVIGATION_LOAD_FLAGS_IS_LINK = 32;
|
||||
NS_IWEBNAVIGATION_LOAD_FLAGS_BYPASS_HISTORY = 64;
|
||||
NS_IWEBNAVIGATION_LOAD_FLAGS_REPLACE_HISTORY = 128;
|
||||
NS_IWEBNAVIGATION_LOAD_FLAGS_BYPASS_CACHE = 256;
|
||||
NS_IWEBNAVIGATION_LOAD_FLAGS_BYPASS_PROXY = 512;
|
||||
NS_IWEBNAVIGATION_LOAD_FLAGS_CHARSET_CHANGE = 1024;
|
||||
NS_IWEBNAVIGATION_STOP_NETWORK = 1;
|
||||
NS_IWEBNAVIGATION_STOP_CONTENT = 2;
|
||||
NS_IWEBNAVIGATION_STOP_ALL = 3;
|
||||
|
||||
type
|
||||
gfxIFormats = interface;
|
||||
gfxIImageFrame = interface;
|
||||
imgIContainer = interface;
|
||||
imgIContainerObserver = interface;
|
||||
nsIBaseWindow = interface;
|
||||
nsIContextMenuListener2 = interface;
|
||||
nsIContextMenuInfo = interface;
|
||||
nsIWebNavigation = interface;
|
||||
(***
|
||||
* A color is a 32 bit unsigned integer with
|
||||
* four components: R, G, B and A.
|
||||
*
|
||||
* @var typedef PRUint32 gfx_color
|
||||
*)
|
||||
gfx_color = PRUint32;
|
||||
(***
|
||||
* typedef that should be used for bit depths
|
||||
* @var typedef unsigned short gfx_depth
|
||||
*)
|
||||
gfx_depth = PRUint16;
|
||||
(***
|
||||
* typedef that should be used for image formats
|
||||
* @var typedef long gfx_format
|
||||
* @see gfxIFormats
|
||||
*)
|
||||
gfx_format = PRInt32;
|
||||
nscoord = PRInt32;
|
||||
//In all currently supported platforms the native window handle is a pointer
|
||||
//size handle. In Linux64 THANDLE can not be used because by default it is 32
|
||||
//bits due file descriptors which are 32 bits even in 64 bit platform.
|
||||
//Win32 WindowHandle 32 bits THANDLE 32 bits
|
||||
//Win64 WindowHandle 64 bits THANDLE 64 bits
|
||||
//Linux32 WindowHandle 32 bits THANDLE 32 bits
|
||||
//Linux64 WindowHandle 64 bits THANDLE 32 bits
|
||||
nativeWindow = PtrUInt;
|
||||
gfxIFormats = interface
|
||||
['{96d086e6-1dd1-11b2-b6b2-b77b59390247}']
|
||||
end;
|
||||
|
||||
gfxIImageFrame = interface(nsISupports)
|
||||
['{51cc27a8-1dd2-11b2-a1aa-dad33ab193b4}']
|
||||
procedure Init(aX: nscoord; aY: nscoord; aWidth: nscoord; aHeight: nscoord; aFormat: gfx_format; aDepth: gfx_depth); safecall;
|
||||
function GetMutable(): PRBool; safecall;
|
||||
procedure SetMutable(aMutable: PRBool); safecall;
|
||||
property Mutable: PRBool read GetMutable write SetMutable;
|
||||
function GetX(): nscoord; safecall;
|
||||
property X: nscoord read GetX;
|
||||
function GetY(): nscoord; safecall;
|
||||
property Y: nscoord read GetY;
|
||||
function GetWidth(): nscoord; safecall;
|
||||
property Width: nscoord read GetWidth;
|
||||
function GetHeight(): nscoord; safecall;
|
||||
property Height: nscoord read GetHeight;
|
||||
procedure GetRect(rect: nsRect); safecall;
|
||||
function GetFormat(): gfx_format; safecall;
|
||||
property Format: gfx_format read GetFormat;
|
||||
function GetImageBytesPerRow(): PRUint32; safecall;
|
||||
property ImageBytesPerRow: PRUint32 read GetImageBytesPerRow;
|
||||
function GetImageDataLength(): PRUint32; safecall;
|
||||
property ImageDataLength: PRUint32 read GetImageDataLength;
|
||||
procedure GetImageData(out bits: PRUint8Array; out length: PRUint32); safecall;
|
||||
procedure SetImageData(data: PRUint8Array; length: PRUint32; offset: PRInt32); safecall;
|
||||
procedure LockImageData(); safecall;
|
||||
procedure UnlockImageData(); safecall;
|
||||
function GetAlphaBytesPerRow(): PRUint32; safecall;
|
||||
property AlphaBytesPerRow: PRUint32 read GetAlphaBytesPerRow;
|
||||
function GetAlphaDataLength(): PRUint32; safecall;
|
||||
property AlphaDataLength: PRUint32 read GetAlphaDataLength;
|
||||
procedure GetAlphaData(out bits: PRUint8Array; out length: PRUint32); safecall;
|
||||
procedure SetAlphaData(data: PRUint8Array; length: PRUint32; offset: PRInt32); safecall;
|
||||
procedure LockAlphaData(); safecall;
|
||||
procedure UnlockAlphaData(); safecall;
|
||||
procedure DrawTo(aDst: gfxIImageFrame; aDX: nscoord; aDY: nscoord; aDWidth: nscoord; aDHeight: nscoord); safecall;
|
||||
function GetTimeout(): PRInt32; safecall;
|
||||
procedure SetTimeout(aTimeout: PRInt32); safecall;
|
||||
property Timeout: PRInt32 read GetTimeout write SetTimeout;
|
||||
function GetFrameDisposalMethod(): PRInt32; safecall;
|
||||
procedure SetFrameDisposalMethod(aFrameDisposalMethod: PRInt32); safecall;
|
||||
property FrameDisposalMethod: PRInt32 read GetFrameDisposalMethod write SetFrameDisposalMethod;
|
||||
function GetBackgroundColor(): gfx_color; safecall;
|
||||
procedure SetBackgroundColor(aBackgroundColor: gfx_color); safecall;
|
||||
property BackgroundColor: gfx_color read GetBackgroundColor write SetBackgroundColor;
|
||||
end;
|
||||
|
||||
imgIContainer = interface(nsISupports)
|
||||
['{5e8405a4-1dd2-11b2-8385-bc8e3446cad3}']
|
||||
procedure Init(aWidth: nscoord; aHeight: nscoord; aObserver: imgIContainerObserver); safecall;
|
||||
function GetPreferredAlphaChannelFormat(): gfx_format; safecall;
|
||||
property PreferredAlphaChannelFormat: gfx_format read GetPreferredAlphaChannelFormat;
|
||||
function GetWidth(): nscoord; safecall;
|
||||
property Width: nscoord read GetWidth;
|
||||
function GetHeight(): nscoord; safecall;
|
||||
property Height: nscoord read GetHeight;
|
||||
function GetCurrentFrame(): gfxIImageFrame; safecall;
|
||||
property CurrentFrame: gfxIImageFrame read GetCurrentFrame;
|
||||
function GetNumFrames(): PRUint32; safecall;
|
||||
property NumFrames: PRUint32 read GetNumFrames;
|
||||
function GetAnimationMode(): PRUint16; safecall;
|
||||
procedure SetAnimationMode(aAnimationMode: PRUint16); safecall;
|
||||
property AnimationMode: PRUint16 read GetAnimationMode write SetAnimationMode;
|
||||
function GetFrameAt(index: PRUint32): gfxIImageFrame; safecall;
|
||||
procedure AppendFrame(item: gfxIImageFrame); safecall;
|
||||
procedure RemoveFrame(item: gfxIImageFrame); safecall;
|
||||
procedure EndFrameDecode(framenumber: PRUint32; timeout: PRUint32); safecall;
|
||||
procedure DecodingComplete(); safecall;
|
||||
procedure Clear(); safecall;
|
||||
procedure StartAnimation(); safecall;
|
||||
procedure StopAnimation(); safecall;
|
||||
procedure ResetAnimation(); safecall;
|
||||
function GetLoopCount(): PRInt32; safecall;
|
||||
procedure SetLoopCount(aLoopCount: PRInt32); safecall;
|
||||
property LoopCount: PRInt32 read GetLoopCount write SetLoopCount;
|
||||
end;
|
||||
|
||||
imgIContainerObserver = interface(nsISupports)
|
||||
['{153f1518-1dd2-11b2-b9cd-b16eb63e0471}']
|
||||
procedure FrameChanged(aContainer: imgIContainer; aFrame: gfxIImageFrame; const aDirtyRect: nsRect); safecall;
|
||||
end;
|
||||
|
||||
nsIBaseWindow = interface(nsISupports)
|
||||
['{046bc8a0-8015-11d3-af70-00a024ffc08c}']
|
||||
procedure InitWindow(parentNativeWindow: nativeWindow; parentWidget: nsIWidget; x: PRInt32; y: PRInt32; cx: PRInt32; cy: PRInt32); safecall;
|
||||
procedure Create(); safecall;
|
||||
procedure Destroy(); safecall;
|
||||
procedure SetPosition(x: PRInt32; y: PRInt32); safecall;
|
||||
procedure GetPosition(out x: PRInt32; out y: PRInt32); safecall;
|
||||
procedure SetSize(cx: PRInt32; cy: PRInt32; fRepaint: PRBool); safecall;
|
||||
procedure GetSize(out cx: PRInt32; out cy: PRInt32); safecall;
|
||||
procedure SetPositionAndSize(x: PRInt32; y: PRInt32; cx: PRInt32; cy: PRInt32; fRepaint: PRBool); safecall;
|
||||
procedure GetPositionAndSize(out x: PRInt32; out y: PRInt32; out cx: PRInt32; out cy: PRInt32); safecall;
|
||||
procedure Repaint(force: PRBool); safecall;
|
||||
function GetParentWidget(): nsIWidget; safecall;
|
||||
procedure SetParentWidget(aParentWidget: nsIWidget); safecall;
|
||||
property ParentWidget: nsIWidget read GetParentWidget write SetParentWidget;
|
||||
function GetParentNativeWindow(): nativeWindow; safecall;
|
||||
procedure SetParentNativeWindow(aParentNativeWindow: nativeWindow); safecall;
|
||||
property ParentNativeWindow: nativeWindow read GetParentNativeWindow write SetParentNativeWindow;
|
||||
function GetVisibility(): PRBool; safecall;
|
||||
procedure SetVisibility(aVisibility: PRBool); safecall;
|
||||
property Visibility: PRBool read GetVisibility write SetVisibility;
|
||||
function GetEnabled(): PRBool; safecall;
|
||||
procedure SetEnabled(aEnabled: PRBool); safecall;
|
||||
property Enabled: PRBool read GetEnabled write SetEnabled;
|
||||
function GetBlurSuppression(): PRBool; safecall;
|
||||
procedure SetBlurSuppression(aBlurSuppression: PRBool); safecall;
|
||||
property BlurSuppression: PRBool read GetBlurSuppression write SetBlurSuppression;
|
||||
function GetMainWidget(): nsIWidget; safecall;
|
||||
property MainWidget: nsIWidget read GetMainWidget;
|
||||
procedure SetFocus(); safecall;
|
||||
function GetTitle(): PWideChar; safecall;
|
||||
procedure SetTitle(const aTitle: PWideChar); safecall;
|
||||
property Title: PWideChar read GetTitle write SetTitle;
|
||||
end;
|
||||
|
||||
nsIContextMenuListener2 = interface(nsISupports)
|
||||
['{7fb719b3-d804-4964-9596-77cf924ee314}']
|
||||
procedure OnShowContextMenu(aContextFlags: PRUint32; aUtils: nsIContextMenuInfo); safecall;
|
||||
end;
|
||||
|
||||
nsIContextMenuInfo = interface(nsISupports)
|
||||
['{2f977d56-5485-11d4-87e2-0010a4e75ef2}']
|
||||
function GetMouseEvent(): nsIDOMEvent; safecall;
|
||||
property MouseEvent: nsIDOMEvent read GetMouseEvent;
|
||||
function GetTargetNode(): nsIDOMNode; safecall;
|
||||
property TargetNode: nsIDOMNode read GetTargetNode;
|
||||
procedure GetAssociatedLink(aAssociatedLink: nsAString); safecall;
|
||||
function GetImageContainer(): imgIContainer; safecall;
|
||||
property ImageContainer: imgIContainer read GetImageContainer;
|
||||
function GetImageSrc(): nsIURI; safecall;
|
||||
property ImageSrc: nsIURI read GetImageSrc;
|
||||
function GetBackgroundImageContainer(): imgIContainer; safecall;
|
||||
property BackgroundImageContainer: imgIContainer read GetBackgroundImageContainer;
|
||||
function GetBackgroundImageSrc(): nsIURI; safecall;
|
||||
property BackgroundImageSrc: nsIURI read GetBackgroundImageSrc;
|
||||
end;
|
||||
|
||||
nsIWebNavigation = interface(nsISupports)
|
||||
['{f5d9e7b0-d930-11d3-b057-00a024ffc08c}']
|
||||
function GetCanGoBack(): PRBool; safecall;
|
||||
property CanGoBack: PRBool read GetCanGoBack;
|
||||
function GetCanGoForward(): PRBool; safecall;
|
||||
property CanGoForward: PRBool read GetCanGoForward;
|
||||
procedure GoBack(); safecall;
|
||||
procedure GoForward(); safecall;
|
||||
procedure GotoIndex(index: PRInt32); safecall;
|
||||
procedure LoadURI(const uri: PWideChar; loadFlags: PRUint32; referrer: nsIURI; postData: nsIInputStream; headers: nsIInputStream); safecall;
|
||||
procedure Reload(reloadFlags: PRUint32); safecall;
|
||||
procedure Stop(stopFlags: PRUint32); safecall;
|
||||
function GetDocument(): nsIDOMDocument; safecall;
|
||||
property Document: nsIDOMDocument read GetDocument;
|
||||
function GetCurrentURI(): nsIURI; safecall;
|
||||
property CurrentURI: nsIURI read GetCurrentURI;
|
||||
function GetReferringURI(): nsIURI; safecall;
|
||||
property ReferringURI: nsIURI read GetReferringURI;
|
||||
function GetSessionHistory(): nsISHistory; safecall;
|
||||
procedure SetSessionHistory(aSessionHistory: nsISHistory); safecall;
|
||||
property SessionHistory: nsISHistory read GetSessionHistory write SetSessionHistory;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
end.
|
164
gecko/Components/CallbackInterfaces.pas
Normal file
164
gecko/Components/CallbackInterfaces.pas
Normal file
@@ -0,0 +1,164 @@
|
||||
(* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is GeckoComponents for Delphi.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Takanori Ito.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2003
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** *)
|
||||
unit CallbackInterfaces;
|
||||
|
||||
{$MACRO on}
|
||||
|
||||
{$IFDEF Windows}
|
||||
{$DEFINE extdecl:=stdcall}
|
||||
{$ELSE Windows}
|
||||
{$DEFINE extdecl:=cdecl}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFNDEF FPC_HAS_CONSTREF}
|
||||
{$DEFINE constref:=const}
|
||||
{$ENDIF}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
nsXPCOM, nsTypes;
|
||||
|
||||
type
|
||||
IGeckoCreateWindowTarget = interface
|
||||
['{934D4785-B78A-43D0-ABAD-1CC71AC06E24}']
|
||||
function GetWebBrowserChrome: nsIWebBrowserChrome;
|
||||
function DoCreateChromeWindow(chromeFlags: Longword): nsIWebBrowserChrome;
|
||||
end;
|
||||
|
||||
IGeckoBrowserChrome = interface
|
||||
['{8852637D-BB99-4ADA-82C8-8B94AFEC23C6}']
|
||||
function GetCreateWindowTarget: IGeckoCreateWindowTarget;
|
||||
end;
|
||||
|
||||
function InitWindowCreator: Boolean;
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
Classes, SysUtils, nsError, nsXPCOMGlue, GeckoChromeWindow;
|
||||
|
||||
type
|
||||
TWindowCreator = class(TInterfacedObject,
|
||||
nsIWindowCreator)
|
||||
function CreateChromeWindow(parent: nsIWebBrowserChrome;
|
||||
chromeFlags: PRUint32):
|
||||
nsIWebBrowserChrome; safecall;
|
||||
function SafeCallException(Obj: TObject; Addr: Pointer): HResult; override;
|
||||
end;
|
||||
|
||||
{$PUSH}
|
||||
{$HINTS OFF}
|
||||
procedure UseParameter(var X);
|
||||
begin
|
||||
end;
|
||||
{$POP}
|
||||
|
||||
function FindTarget(chrome: nsIWebBrowserChrome): IGeckoCreateWindowTarget;
|
||||
var
|
||||
chrome2: IGeckoBrowserChrome;
|
||||
begin
|
||||
if Supports(chrome, IGeckoBrowserChrome, chrome2) then
|
||||
begin
|
||||
Result := chrome2.GetCreateWindowTarget;
|
||||
end;
|
||||
end;
|
||||
|
||||
var
|
||||
sWindowCreatorInitialized: Boolean = False;
|
||||
sWindowCreator: TWindowCreator = nil;
|
||||
|
||||
function InitWindowCreator: Boolean;
|
||||
const
|
||||
NS_WINDOWWATCHER_CONTRACTID = '@mozilla.org/embedcomp/window-watcher;1';
|
||||
var
|
||||
creator: TWindowCreator;
|
||||
wwatch: nsIWindowWatcher;
|
||||
begin
|
||||
try
|
||||
Result := False;
|
||||
if not sWindowCreatorInitialized then
|
||||
begin
|
||||
sWindowCreatorInitialized := True;
|
||||
creator := TWindowCreator.Create;
|
||||
sWindowCreator := creator;
|
||||
end;
|
||||
if not Assigned(sWindowCreator) then Exit;
|
||||
|
||||
NS_GetService(NS_WINDOWWATCHER_CONTRACTID, nsIWindowWatcher, wwatch);
|
||||
|
||||
wwatch.SetWindowCreator(sWindowCreator);
|
||||
|
||||
Result := True;
|
||||
except
|
||||
Result := False;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TWindowCreator.CreateChromeWindow(parent: nsIWebBrowserChrome;
|
||||
chromeFlags: PRUint32):
|
||||
nsIWebBrowserChrome;
|
||||
var
|
||||
target: IGeckoCreateWindowTarget;
|
||||
chrome: TGeckoChromeForm;
|
||||
begin
|
||||
if (chromeFlags and CHROME_OPENAS_CHROME)<>0 then
|
||||
begin
|
||||
chrome := TGeckoChromeForm.CreateWithChromeFlags(nil, chromeFlags);
|
||||
try
|
||||
target := IGeckoCreateWindowTarget(chrome);
|
||||
Result := target.GetWebBrowserChrome;
|
||||
except
|
||||
chrome.Close;
|
||||
raise;
|
||||
end;
|
||||
end else
|
||||
begin
|
||||
target := FindTarget(parent);
|
||||
if Assigned(target) then
|
||||
Result := target.DoCreateChromeWindow(chromeFlags);
|
||||
if not Assigned(Result) then
|
||||
raise EGeckoHint.CreateFmt('Attempt to create a new Chrome window but handler does not create a new one. Chrome flags: %8X',[chromeFlags]);
|
||||
end;
|
||||
end;
|
||||
|
||||
function TWindowCreator.SafeCallException(Obj: TObject; Addr: Pointer): HResult;
|
||||
begin
|
||||
UseParameter(Obj);
|
||||
UseParameter(Addr);
|
||||
Result := HRESULT(NS_ERROR_FAILURE);
|
||||
end;
|
||||
|
||||
end.
|
BIN
gecko/Components/GeckoBrowser.dcr
Normal file
BIN
gecko/Components/GeckoBrowser.dcr
Normal file
Binary file not shown.
2349
gecko/Components/GeckoBrowser.pas
Normal file
2349
gecko/Components/GeckoBrowser.pas
Normal file
File diff suppressed because it is too large
Load Diff
18
gecko/Components/GeckoChromeWindow.dfm
Normal file
18
gecko/Components/GeckoChromeWindow.dfm
Normal file
@@ -0,0 +1,18 @@
|
||||
object GeckoChromeForm: TGeckoChromeForm
|
||||
Left = 192
|
||||
Top = 107
|
||||
Width = 800
|
||||
Height = 600
|
||||
Color = clBtnFace
|
||||
Font.Charset = DEFAULT_CHARSET
|
||||
Font.Color = clWindowText
|
||||
Font.Height = -12
|
||||
Font.Name = 'Tahoma'
|
||||
Font.Style = []
|
||||
OldCreateOrder = False
|
||||
OnClose = FormClose
|
||||
OnCreate = FormCreate
|
||||
OnResize = FormResize
|
||||
PixelsPerInch = 96
|
||||
TextHeight = 12
|
||||
end
|
12
gecko/Components/GeckoChromeWindow.lfm
Normal file
12
gecko/Components/GeckoChromeWindow.lfm
Normal file
@@ -0,0 +1,12 @@
|
||||
object GeckoChromeForm: TGeckoChromeForm
|
||||
Left = 192
|
||||
Height = 600
|
||||
Top = 107
|
||||
Width = 800
|
||||
Font.Height = -12
|
||||
Font.Name = 'Tahoma'
|
||||
OnClose = FormClose
|
||||
OnCreate = FormCreate
|
||||
OnResize = FormResize
|
||||
LCLVersion = '0.9.29'
|
||||
end
|
558
gecko/Components/GeckoChromeWindow.pas
Normal file
558
gecko/Components/GeckoChromeWindow.pas
Normal file
@@ -0,0 +1,558 @@
|
||||
(* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is GeckoComponents for Delphi.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Takanori Ito.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2003
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** *)
|
||||
unit GeckoChromeWindow;
|
||||
|
||||
{$MACRO on}
|
||||
|
||||
{$IFDEF Windows}
|
||||
{$DEFINE extdecl:=stdcall}
|
||||
{$ELSE Windows}
|
||||
{$DEFINE extdecl:=cdecl}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFNDEF FPC_HAS_CONSTREF}
|
||||
{$DEFINE constref:=const}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF LCLCocoa}
|
||||
{$MODESWITCH ObjectiveC1}
|
||||
{$ENDIF}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
{$IFNDEF LCL} Windows, Messages, {$ELSE} LclIntf, LResources, {$ENDIF}
|
||||
SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
||||
Dialogs, CallbackInterfaces, nsXPCOM, nsTypes, nsXPCOM_std19
|
||||
{$IFDEF LCLCarbon}, CarbonPrivate {$ENDIF}
|
||||
{$IFDEF LCLGtk2}, gtk2 {$ENDIF}
|
||||
{$IFDEF LCLCocoa}, CocoaAll, CocoaUtils, CocoaPrivate {$ENDIF};
|
||||
|
||||
type
|
||||
//In all currently supported platforms the native window handle is a pointer
|
||||
//size handle. In Linux64 THANDLE can not be used because by default it is 32
|
||||
//bits due file descriptors which are 32 bits even in 64 bit platform.
|
||||
//Win32 WindowHandle 32 bits THANDLE 32 bits
|
||||
//Win64 WindowHandle 64 bits THANDLE 64 bits
|
||||
//Linux32 WindowHandle 32 bits THANDLE 32 bits
|
||||
//Linux64 WindowHandle 64 bits THANDLE 32 bits
|
||||
nativeWindow = PtrUInt;
|
||||
|
||||
TGeckoChromeForm = class(TForm,
|
||||
IGeckoCreateWindowTarget,
|
||||
nsIWebBrowserChrome,
|
||||
nsIEmbeddingSiteWindow,
|
||||
nsIWebProgressListener,
|
||||
nsIInterfaceRequestor_std19,
|
||||
nsIWeakReference,
|
||||
nsISupportsWeakReference)
|
||||
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure FormResize(Sender: TObject);
|
||||
private
|
||||
{ Private 錾 }
|
||||
FWebBrowser: nsIWebBrowser;
|
||||
FChromeFlags: Longword;
|
||||
|
||||
// nsIWebBrowserChrome
|
||||
procedure SetStatus(statusType: PRUint32; const status: PWideChar); safecall;
|
||||
function GetWebBrowser(): nsIWebBrowser; safecall;
|
||||
procedure SetWebBrowser(aWebBrowser: nsIWebBrowser); safecall;
|
||||
function GetChromeFlags: PRUint32; safecall;
|
||||
procedure SetChromeFlags(aChromeFlags: PRUint32); safecall;
|
||||
procedure DestroyBrowserWindow(); safecall;
|
||||
procedure SizeBrowserTo(aCX: PRInt32; aCY: PRInt32); safecall;
|
||||
procedure ShowAsModal(); safecall;
|
||||
function IsWindowModal(): PRBool; safecall;
|
||||
procedure ExitModalEventLoop(aStatus: nsresult); safecall;
|
||||
// nsIEmbeddingSiteWindow
|
||||
procedure SetDimensions(flags: PRUint32; x, y, cx, cy: PRInt32); safecall;
|
||||
procedure GetDimensions(flags: Longword; out x, y, cx, cy: PRInt32); safecall;
|
||||
procedure SetFocus; reintroduce; safecall;
|
||||
function GetVisibility(): PRBool; safecall;
|
||||
procedure SetVisibility(Value: PRBool); safecall;
|
||||
function GetTitle(): PWideChar; safecall;
|
||||
procedure SetTitle(const Value: PWideChar); safecall;
|
||||
function GetSiteWindow: Pointer; safecall;
|
||||
// nsIWebProgressListener
|
||||
procedure OnStateChange(aWebProgress: nsIWebProgress; aRequest: nsIRequest; aStateFlags: PRUint32; aStatus: nsresult); safecall;
|
||||
procedure OnProgressChange(aWebProgress: nsIWebProgress; aRequest: nsIRequest; aCurSelfProgress: PRInt32; aMaxSelfProgress: PRInt32; aCurTotalProgress: PRInt32; aMaxTotalProgress: PRInt32); safecall;
|
||||
procedure OnLocationChange(aWebProgress: nsIWebProgress; aRequest: nsIRequest; location: nsIURI); safecall;
|
||||
procedure OnStatusChange(aWebProgress: nsIWebProgress; aRequest: nsIRequest; aStatus: nsresult; const aMessage: PWideChar); safecall;
|
||||
procedure OnSecurityChange(aWebProgress: nsIWebProgress; aRequest: nsIRequest; state: PRUint32); safecall;
|
||||
// nsIInterfaceRequestor
|
||||
function NS_GetInterface(constref uuid: TGUID; out Intf): nsresult; extdecl;
|
||||
function nsIInterfaceRequestor_std19.GetInterface = NS_GetInterface;
|
||||
// for nsIWeakReference
|
||||
procedure QueryReferent(constref IID: TGUID; out Obj); safecall;
|
||||
// for nsISupportsWeakReference
|
||||
function GetWeakReference(): nsIWeakReference; safecall;
|
||||
|
||||
function GetNativeWindow : nativeWindow; //FPC port: added this.
|
||||
procedure InitWebBrowser;
|
||||
procedure UpdateChrome;
|
||||
procedure ContentFinishedLoading;
|
||||
public
|
||||
{ Public 錾 }
|
||||
function SafeCallException(Obj: TObject; Addr: Pointer): HResult; override;
|
||||
|
||||
constructor CreateWithChromeFlags(AOwner: TComponent; aChromeFlags: Longword);
|
||||
|
||||
// IGeckoCreateWindowTarget
|
||||
function DoCreateChromeWindow(chromeFlags: Longword): nsIWebBrowserChrome;
|
||||
function GetWebBrowserChrome: nsIWebBrowserChrome;
|
||||
property WebBrowser : nsIWebBrowser read FWebBrowser; //FPC port: added this.
|
||||
end;
|
||||
|
||||
var
|
||||
GeckoChromeForm: TGeckoChromeForm;
|
||||
|
||||
implementation
|
||||
|
||||
{$IFNDEF LCL}
|
||||
{$R *.dfm}
|
||||
{$ENDIF}
|
||||
|
||||
uses
|
||||
nsXPCOMGlue, nsError, BrowserSupports;
|
||||
|
||||
{$PUSH}
|
||||
{$HINTS OFF}
|
||||
procedure UseParameter(var X);
|
||||
begin
|
||||
end;
|
||||
{$POP}
|
||||
|
||||
constructor TGeckoChromeForm.CreateWithChromeFlags(AOwner: TComponent; AChromeFlags: Longword);
|
||||
begin
|
||||
inherited Create(AOwner);
|
||||
FChromeFlags := aChromeFlags;
|
||||
UpdateChrome;
|
||||
end;
|
||||
|
||||
procedure TGeckoChromeForm.FormClose(Sender: TObject;
|
||||
var Action: TCloseAction);
|
||||
begin
|
||||
Action := caFree;
|
||||
end;
|
||||
|
||||
function TGeckoChromeForm.GetNativeWindow : nativeWindow;
|
||||
{$IFDEF LCLCocoa}
|
||||
var
|
||||
ARect : NSRect;
|
||||
AView : NSView;
|
||||
{$ENDIF}
|
||||
begin
|
||||
{$IFDEF MSWINDOWS}Result := Handle;{$ENDIF}
|
||||
|
||||
{$IFDEF LCLCarbon}Result := THANDLE(TCarbonWindow(Handle).Window);{$ENDIF}
|
||||
//Carbon doesn't work but leave in so package compiles in Carbon IDE.
|
||||
|
||||
// {$IFDEF LCLCocoa}Result := Pointer(TCocoaForm(Handle).MainWindowView.superview);{$ENDIF}
|
||||
//Old PasCocoa-based widgetset.
|
||||
|
||||
//NSLog(NSStringUtf8(FloatToStr(NSView(TCocoaWindow(Handle).contentView).frame.size.width)));
|
||||
{$IFDEF LCLCocoa}Result := THANDLE(TCocoaWindow(Handle).contentView);{$ENDIF}
|
||||
//New ObjC-based Cocoa widgetset.
|
||||
|
||||
(*
|
||||
//Does adding a view work better than using window's view (below)? No, it doesn't.
|
||||
{$IFDEF LCLCocoa}
|
||||
ARect := NSView(TCocoaWindow(Handle).contentView).visibleRect;
|
||||
ARect.size.width := ARect.size.width - 30;
|
||||
ARect.size.height := ARect.size. height - 30;
|
||||
ARect.origin.x := 15;
|
||||
ARect.origin.y := 15;
|
||||
AView := NSView.alloc.initWithFrame(ARect);
|
||||
NSView(TCocoaWindow(Handle).contentView).addSubView(AView);
|
||||
Result := THANDLE(AView);
|
||||
{$ENDIF}
|
||||
*)
|
||||
|
||||
{$IFDEF LCLGtk}Result := Handle;{$ENDIF} //Is Handle same as GTK Window?
|
||||
|
||||
{$IFDEF LCLGtk2}
|
||||
Result := nativeWindow(PGtkWindow(GeckoChromeForm.Handle)^.bin.child);
|
||||
{$ENDIF} //Is Handle same as GTK Window?
|
||||
end;
|
||||
|
||||
procedure TGeckoChromeForm.InitWebBrowser;
|
||||
var
|
||||
base: nsIBaseWindow;
|
||||
begin
|
||||
NS_CreateInstance(NS_WEBBROWSER_CID, nsIWebBrowser, FWebBrowser);
|
||||
|
||||
FWebBrowser.ContainerWindow := Self;
|
||||
|
||||
base := FWebBrowser as nsIBaseWindow;
|
||||
base.InitWindow(GetNativeWindow, nil, 0, 0, ClientWidth, ClientHeight);
|
||||
base.Create;
|
||||
FWebBrowser.AddWebBrowserListener(Self, nsIWebProgressListener);
|
||||
base.SetVisibility(True);
|
||||
end;
|
||||
|
||||
procedure TGeckoChromeForm.UpdateChrome;
|
||||
begin
|
||||
{if (FChromeFlags and CHROME_WINDOW_BORDERS)<>0 then
|
||||
if (FChromeFlags and CHROME_WINDOW_RESIZE)<>0 then
|
||||
BorderStyle := bsSizeable
|
||||
else
|
||||
if (FChromeFlags and CHROME_OPENAS_DIALOG)<>0 then
|
||||
BorderStyle := bsDialog
|
||||
else
|
||||
BorderStyle := bsSingle
|
||||
else
|
||||
BorderStyle := bsNone;}
|
||||
BorderStyle := bsSizeable;
|
||||
|
||||
{
|
||||
if (FChromeFlags and CHROME_WINDOW_CLOSE)<>0 then
|
||||
BorderIcons := BorderIcons + [biClose]
|
||||
else
|
||||
BorderIcons := BorderIcons - [biClose];
|
||||
}
|
||||
|
||||
if (FChromeFlags and CHROME_SCROLLBARS)<>0 then
|
||||
AutoScroll := True
|
||||
else
|
||||
AutoScroll := False;
|
||||
|
||||
{
|
||||
if (FChromeFlags and CHROME_TITLEBAR)<>0 then
|
||||
BorderIcons := BorderIcons + [biSystemMenu]
|
||||
else
|
||||
BorderIcons := BorderIcons - [biSystemMenu];
|
||||
}
|
||||
|
||||
end;
|
||||
|
||||
function TGeckoChromeForm.DoCreateChromeWindow(chromeFlags: Longword): nsIWebBrowserChrome;
|
||||
begin
|
||||
UseParameter(chromeFlags);
|
||||
Result := nil;
|
||||
end;
|
||||
|
||||
function TGeckoChromeForm.GetWebBrowserChrome: nsIWebBrowserChrome;
|
||||
begin
|
||||
Result := Self;
|
||||
end;
|
||||
|
||||
procedure TGeckoChromeForm.SetStatus(statusType: Longword; const status: PWideChar);
|
||||
begin
|
||||
UseParameter(statusType);
|
||||
end;
|
||||
|
||||
function TGeckoChromeForm.GetWebBrowser: nsIWebBrowser;
|
||||
begin
|
||||
Result := FWebBrowser as nsIWebBrowser;
|
||||
end;
|
||||
|
||||
procedure TGeckoChromeForm.SetWebBrowser(aWebBrowser: nsIWebBrowser);
|
||||
begin
|
||||
UseParameter(aWebBrowser);
|
||||
end;
|
||||
|
||||
function TGeckoChromeForm.GetChromeFlags: PRUint32;
|
||||
begin
|
||||
Result := FChromeFlags;
|
||||
end;
|
||||
|
||||
procedure TGeckoChromeForm.SetChromeFlags(aChromeFlags: Longword);
|
||||
begin
|
||||
FChromeFlags := aChromeFlags;
|
||||
UpdateChrome;
|
||||
end;
|
||||
|
||||
procedure TGeckoChromeForm.DestroyBrowserWindow;
|
||||
begin
|
||||
Close;
|
||||
end;
|
||||
|
||||
procedure TGeckoChromeForm.SizeBrowserTo(aCX, aCY: Integer);
|
||||
var
|
||||
dx, dy: Integer;
|
||||
begin
|
||||
dx := Width - ClientWidth;
|
||||
dy := Height - ClientHeight;
|
||||
SetBounds(Left, Top, aCX+dx, aCY+dy);
|
||||
end;
|
||||
|
||||
procedure TGeckoChromeForm.ShowAsModal;
|
||||
begin
|
||||
Visible := False;
|
||||
ShowModal;
|
||||
end;
|
||||
|
||||
function TGeckoChromeForm.IsWindowModal: PRBool;
|
||||
begin
|
||||
Result := False;
|
||||
end;
|
||||
|
||||
procedure TGeckoChromeForm.ExitModalEventLoop(aStatus: nsresult); safecall;
|
||||
begin
|
||||
UseParameter(aStatus);
|
||||
ModalResult := 1;
|
||||
end;
|
||||
|
||||
procedure TGeckoChromeForm.SetDimensions(flags: Longword; x, y, cx, cy: Longint);
|
||||
const
|
||||
FLAGS_POSITION = NS_IEMBEDDINGSITEWINDOW_DIM_FLAGS_POSITION;
|
||||
FLAGS_SIZE_INNER = ns_IEmbeddingSiteWindow_DIM_FLAGS_SIZE_INNER;
|
||||
FLAGS_SIZE_OUTER = ns_IEmbeddingSiteWindow_DIM_FLAGS_SIZE_OUTER;
|
||||
var
|
||||
dx, dy: Integer;
|
||||
begin
|
||||
dx := Width - ClientWidth;
|
||||
dy := Height - ClientHeight;
|
||||
|
||||
if (flags and FLAGS_POSITION)<>0 then
|
||||
begin
|
||||
if (flags and FLAGS_SIZE_INNER)<>0 then
|
||||
begin
|
||||
Bounds(x, y, cx+dx, cy+dy);
|
||||
end else
|
||||
if (flags and FLAGS_SIZE_OUTER)<>0 then
|
||||
begin
|
||||
Bounds(x, y, cx, cy);
|
||||
end else
|
||||
begin
|
||||
Bounds(x, y, Width, Height);
|
||||
end;
|
||||
end else
|
||||
if (flags and FLAGS_SIZE_INNER)<>0 then
|
||||
begin
|
||||
Bounds(Left, Top, cx+dx, cy+dy);
|
||||
end else
|
||||
if (flags and FLAGS_SIZE_OUTER)<>0 then
|
||||
begin
|
||||
Bounds(Left, Top, cx, cy);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TGeckoChromeForm.GetDimensions(flags: Longword; out x, y, cx, cy: Longint);
|
||||
const
|
||||
FLAGS_POSITION = ns_IEmbeddingSiteWindow_DIM_FLAGS_POSITION;
|
||||
FLAGS_SIZE_INNER = ns_IEmbeddingSiteWindow_DIM_FLAGS_SIZE_INNER;
|
||||
FLAGS_SIZE_OUTER = ns_IEmbeddingSiteWindow_DIM_FLAGS_SIZE_OUTER;
|
||||
begin
|
||||
if (flags and FLAGS_POSITION)<>0 then
|
||||
begin
|
||||
x := Left;
|
||||
y := Top;
|
||||
end;
|
||||
|
||||
if (flags and FLAGS_SIZE_INNER)<>0 then
|
||||
begin
|
||||
cx := ClientWidth;
|
||||
cy := ClientHeight;
|
||||
end else
|
||||
if (flags and FLAGS_SIZE_OUTER)<>0 then
|
||||
begin
|
||||
cx := Width;
|
||||
cy := Height;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TGeckoChromeForm.SetFocus();
|
||||
begin
|
||||
end;
|
||||
|
||||
function TGeckoChromeForm.GetVisibility: PRBool;
|
||||
begin
|
||||
Result := True;
|
||||
end;
|
||||
|
||||
procedure TGeckoChromeForm.SetVisibility(Value: LongBool);
|
||||
begin
|
||||
UseParameter(Value);
|
||||
Visible := Value;
|
||||
end;
|
||||
|
||||
function TGeckoChromeForm.GetTitle: PWideChar;
|
||||
begin
|
||||
Result := nil;
|
||||
end;
|
||||
|
||||
procedure TGeckoChromeForm.SetTitle(const Value: PWideChar);
|
||||
begin
|
||||
Caption := WideString(Value);
|
||||
end;
|
||||
|
||||
function TGeckoChromeForm.GetSiteWindow: Pointer;
|
||||
begin
|
||||
//Known "not safe" conversion.
|
||||
{$PUSH}
|
||||
{$HINTS OFF}
|
||||
Result := Pointer(GetNativeWindow);
|
||||
{$POP}
|
||||
end;
|
||||
|
||||
procedure TGeckoChromeForm.OnStateChange(aWebProgress: nsIWebProgress; aRequest: nsIRequest; aStateFlags: PRUint32; aStatus: nsresult);
|
||||
begin
|
||||
UseParameter(aWebProgress);
|
||||
UseParameter(aRequest);
|
||||
UseParameter(aStatus);
|
||||
if ((aStateFlags and NS_IWEBPROGRESSLISTENER_STATE_STOP)<>0) and
|
||||
((aStateFlags and NS_IWEBPROGRESSLISTENER_STATE_IS_DOCUMENT)<>0) then
|
||||
begin
|
||||
ContentFinishedLoading();
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TGeckoChromeForm.OnProgressChange(aWebProgress: nsIWebProgress; aRequest: nsIRequest; aCurSelfProgress: PRInt32; aMaxSelfProgress: PRInt32; aCurTotalProgress: PRInt32; aMaxTotalProgress: PRInt32);
|
||||
begin
|
||||
UseParameter(aWebProgress);
|
||||
UseParameter(aRequest);
|
||||
UseParameter(aCurSelfProgress);
|
||||
UseParameter(aMaxSelfProgress);
|
||||
UseParameter(aCurTotalProgress);
|
||||
UseParameter(aMaxTotalProgress);
|
||||
end;
|
||||
|
||||
procedure TGeckoChromeForm.OnLocationChange(aWebProgress: nsIWebProgress; aRequest: nsIRequest; location: nsIURI);
|
||||
begin
|
||||
UseParameter(aWebProgress);
|
||||
UseParameter(aRequest);
|
||||
UseParameter(location);
|
||||
end;
|
||||
|
||||
procedure TGeckoChromeForm.OnStatusChange(aWebProgress: nsIWebProgress; aRequest: nsIRequest; aStatus: nsresult; const aMessage: PWideChar);
|
||||
begin
|
||||
UseParameter(aWebProgress);
|
||||
UseParameter(aRequest);
|
||||
UseParameter(aStatus);
|
||||
end;
|
||||
|
||||
procedure TGeckoChromeForm.OnSecurityChange(aWebProgress: nsIWebProgress; aRequest: nsIRequest; state: PRUint32);
|
||||
begin
|
||||
UseParameter(aWebProgress);
|
||||
UseParameter(aRequest);
|
||||
UseParameter(state);
|
||||
end;
|
||||
|
||||
function TGeckoChromeForm.NS_GetInterface(constref uuid: TGUID; out Intf): nsresult;
|
||||
var
|
||||
domwin: nsIDOMWindow;
|
||||
begin
|
||||
if IsEqualGUID(uuid, nsIDOMWindow) then
|
||||
begin
|
||||
if Assigned(FWebBrowser) then
|
||||
begin
|
||||
domwin := FWebBrowser.ContentDOMWindow;
|
||||
Result := domwin.QueryInterface(uuid, Intf);
|
||||
end else
|
||||
Result := NS_ERROR_NOT_INITIALIZED;
|
||||
end else
|
||||
begin
|
||||
// FPC port: Result is PRUInt32, but QueryInterface returns Longint,
|
||||
// so cast to nsresult to prevent range check error.
|
||||
try
|
||||
Result := nsresult(QueryInterface(uuid, Intf));
|
||||
except
|
||||
Result:=0;
|
||||
Integer(Intf):=0;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TGeckoChromeForm.QueryReferent(constref IID: TGUID; out Obj);
|
||||
var
|
||||
rv: nsresult;
|
||||
begin
|
||||
rv := QueryInterface(IID, Obj);
|
||||
if NS_FAILED(rv) then
|
||||
raise EIntfCastError.Create('QueryReferent');
|
||||
end;
|
||||
|
||||
function TGeckoChromeForm.GetWeakReference: nsIWeakReference;
|
||||
begin
|
||||
Result := Self as nsIWeakReference;
|
||||
end;
|
||||
|
||||
procedure TGeckoChromeForm.FormCreate(Sender: TObject);
|
||||
begin
|
||||
InitWebBrowser;
|
||||
end;
|
||||
|
||||
procedure TGeckoChromeForm.FormResize(Sender: TObject);
|
||||
var
|
||||
baseWin: nsIBaseWindow;
|
||||
begin
|
||||
baseWin:=FWebBrowser as nsIBaseWindow;
|
||||
baseWin.SetPositionAndSize(0, 0, ClientWidth, ClientHeight, True);
|
||||
baseWin.SetVisibility(True);
|
||||
end;
|
||||
|
||||
procedure TGeckoChromeForm.ContentFinishedLoading;
|
||||
var
|
||||
contentWin: nsIDOMWindow;
|
||||
baseWin: nsIBaseWindow;
|
||||
begin
|
||||
contentWin := FWebBrowser.ContentDOMWindow;
|
||||
try
|
||||
//Will try to resize the form to the size of the HTML page, but if the HTML
|
||||
//does not have a width specified (UNRESTRICTED) it will raise an exception
|
||||
//and badly resize the HTML content.
|
||||
contentWin.SizeToContent;
|
||||
except
|
||||
//Workaround
|
||||
baseWin:=FWebBrowser as nsIBaseWindow;
|
||||
//Forces reflow...
|
||||
baseWin.SetPositionAndSize(0,0,ClientWidth, ClientHeight+1, false);
|
||||
baseWin.SetPositionAndSize(0,0,ClientWidth, ClientHeight, true);
|
||||
end;
|
||||
Visible:=true;
|
||||
end;
|
||||
|
||||
{$IFDEF LCL}
|
||||
const
|
||||
E_FAIL = HRESULT($80004005);
|
||||
{$ENDIF}
|
||||
|
||||
function TGeckoChromeForm.SafeCallException(Obj: TObject; Addr: Pointer): HResult;
|
||||
begin
|
||||
UseParameter(Addr);
|
||||
if Obj is EIntfCastError then
|
||||
Result := E_NOINTERFACE
|
||||
else
|
||||
Result := E_FAIL;
|
||||
end;
|
||||
|
||||
initialization
|
||||
{$IFDEF LCL}
|
||||
{$I GeckoChromeWindow.lrs}
|
||||
{$ENDIF}
|
||||
|
||||
end.
|
175
gecko/Components/GeckoComponents.bdsproj
Normal file
175
gecko/Components/GeckoComponents.bdsproj
Normal file
@@ -0,0 +1,175 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<BorlandProject>
|
||||
<PersonalityInfo>
|
||||
<Option>
|
||||
<Option Name="Personality">Delphi.Personality</Option>
|
||||
<Option Name="ProjectType">VCLApplication</Option>
|
||||
<Option Name="Version">1.0</Option>
|
||||
<Option Name="GUID">{8F5E9F94-0EAD-4709-89B8-171CF26AA59B}</Option>
|
||||
</Option>
|
||||
</PersonalityInfo>
|
||||
<Delphi.Personality>
|
||||
<Source>
|
||||
<Source Name="MainSource">GeckoComponents.dpk</Source>
|
||||
</Source>
|
||||
<FileVersion>
|
||||
<FileVersion Name="Version">7.0</FileVersion>
|
||||
</FileVersion>
|
||||
<Compiler>
|
||||
<Compiler Name="A">8</Compiler>
|
||||
<Compiler Name="B">0</Compiler>
|
||||
<Compiler Name="C">1</Compiler>
|
||||
<Compiler Name="D">1</Compiler>
|
||||
<Compiler Name="E">0</Compiler>
|
||||
<Compiler Name="F">0</Compiler>
|
||||
<Compiler Name="G">1</Compiler>
|
||||
<Compiler Name="H">1</Compiler>
|
||||
<Compiler Name="I">1</Compiler>
|
||||
<Compiler Name="J">0</Compiler>
|
||||
<Compiler Name="K">0</Compiler>
|
||||
<Compiler Name="L">1</Compiler>
|
||||
<Compiler Name="M">0</Compiler>
|
||||
<Compiler Name="N">1</Compiler>
|
||||
<Compiler Name="O">1</Compiler>
|
||||
<Compiler Name="P">1</Compiler>
|
||||
<Compiler Name="Q">0</Compiler>
|
||||
<Compiler Name="R">0</Compiler>
|
||||
<Compiler Name="S">0</Compiler>
|
||||
<Compiler Name="T">1</Compiler>
|
||||
<Compiler Name="U">0</Compiler>
|
||||
<Compiler Name="V">1</Compiler>
|
||||
<Compiler Name="W">0</Compiler>
|
||||
<Compiler Name="X">1</Compiler>
|
||||
<Compiler Name="Y">1</Compiler>
|
||||
<Compiler Name="Z">1</Compiler>
|
||||
<Compiler Name="ShowHints">True</Compiler>
|
||||
<Compiler Name="ShowWarnings">True</Compiler>
|
||||
<Compiler Name="UnitAliases">WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;</Compiler>
|
||||
<Compiler Name="NamespacePrefix"></Compiler>
|
||||
<Compiler Name="GenerateDocumentation">False</Compiler>
|
||||
<Compiler Name="DefaultNamespace"></Compiler>
|
||||
<Compiler Name="SymbolDeprecated">True</Compiler>
|
||||
<Compiler Name="SymbolLibrary">True</Compiler>
|
||||
<Compiler Name="SymbolPlatform">True</Compiler>
|
||||
<Compiler Name="SymbolExperimental">True</Compiler>
|
||||
<Compiler Name="UnitLibrary">True</Compiler>
|
||||
<Compiler Name="UnitPlatform">True</Compiler>
|
||||
<Compiler Name="UnitDeprecated">True</Compiler>
|
||||
<Compiler Name="UnitExperimental">True</Compiler>
|
||||
<Compiler Name="HResultCompat">True</Compiler>
|
||||
<Compiler Name="HidingMember">True</Compiler>
|
||||
<Compiler Name="HiddenVirtual">True</Compiler>
|
||||
<Compiler Name="Garbage">True</Compiler>
|
||||
<Compiler Name="BoundsError">True</Compiler>
|
||||
<Compiler Name="ZeroNilCompat">True</Compiler>
|
||||
<Compiler Name="StringConstTruncated">True</Compiler>
|
||||
<Compiler Name="ForLoopVarVarPar">True</Compiler>
|
||||
<Compiler Name="TypedConstVarPar">True</Compiler>
|
||||
<Compiler Name="AsgToTypedConst">True</Compiler>
|
||||
<Compiler Name="CaseLabelRange">True</Compiler>
|
||||
<Compiler Name="ForVariable">True</Compiler>
|
||||
<Compiler Name="ConstructingAbstract">True</Compiler>
|
||||
<Compiler Name="ComparisonFalse">True</Compiler>
|
||||
<Compiler Name="ComparisonTrue">True</Compiler>
|
||||
<Compiler Name="ComparingSignedUnsigned">True</Compiler>
|
||||
<Compiler Name="CombiningSignedUnsigned">True</Compiler>
|
||||
<Compiler Name="UnsupportedConstruct">True</Compiler>
|
||||
<Compiler Name="FileOpen">True</Compiler>
|
||||
<Compiler Name="FileOpenUnitSrc">True</Compiler>
|
||||
<Compiler Name="BadGlobalSymbol">True</Compiler>
|
||||
<Compiler Name="DuplicateConstructorDestructor">True</Compiler>
|
||||
<Compiler Name="InvalidDirective">True</Compiler>
|
||||
<Compiler Name="PackageNoLink">True</Compiler>
|
||||
<Compiler Name="PackageThreadVar">True</Compiler>
|
||||
<Compiler Name="ImplicitImport">True</Compiler>
|
||||
<Compiler Name="HPPEMITIgnored">True</Compiler>
|
||||
<Compiler Name="NoRetVal">True</Compiler>
|
||||
<Compiler Name="UseBeforeDef">True</Compiler>
|
||||
<Compiler Name="ForLoopVarUndef">True</Compiler>
|
||||
<Compiler Name="UnitNameMismatch">True</Compiler>
|
||||
<Compiler Name="NoCFGFileFound">True</Compiler>
|
||||
<Compiler Name="ImplicitVariants">True</Compiler>
|
||||
<Compiler Name="UnicodeToLocale">True</Compiler>
|
||||
<Compiler Name="LocaleToUnicode">True</Compiler>
|
||||
<Compiler Name="ImagebaseMultiple">True</Compiler>
|
||||
<Compiler Name="SuspiciousTypecast">True</Compiler>
|
||||
<Compiler Name="PrivatePropAccessor">True</Compiler>
|
||||
<Compiler Name="UnsafeType">False</Compiler>
|
||||
<Compiler Name="UnsafeCode">False</Compiler>
|
||||
<Compiler Name="UnsafeCast">False</Compiler>
|
||||
<Compiler Name="OptionTruncated">True</Compiler>
|
||||
<Compiler Name="WideCharReduced">True</Compiler>
|
||||
<Compiler Name="DuplicatesIgnored">True</Compiler>
|
||||
<Compiler Name="UnitInitSeq">True</Compiler>
|
||||
<Compiler Name="LocalPInvoke">True</Compiler>
|
||||
<Compiler Name="MessageDirective">True</Compiler>
|
||||
<Compiler Name="CodePage"></Compiler>
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Linker Name="MapFile">0</Linker>
|
||||
<Linker Name="OutputObjs">0</Linker>
|
||||
<Linker Name="GenerateHpps">False</Linker>
|
||||
<Linker Name="ConsoleApp">1</Linker>
|
||||
<Linker Name="DebugInfo">False</Linker>
|
||||
<Linker Name="RemoteSymbols">False</Linker>
|
||||
<Linker Name="GenerateDRC">False</Linker>
|
||||
<Linker Name="MinStackSize">16384</Linker>
|
||||
<Linker Name="MaxStackSize">1048576</Linker>
|
||||
<Linker Name="ImageBase">4194304</Linker>
|
||||
<Linker Name="ExeDescription">Gecko Components</Linker>
|
||||
</Linker>
|
||||
<Directories>
|
||||
<Directories Name="OutputDir"></Directories>
|
||||
<Directories Name="UnitOutputDir"></Directories>
|
||||
<Directories Name="PackageDLLOutputDir"></Directories>
|
||||
<Directories Name="PackageDCPOutputDir"></Directories>
|
||||
<Directories Name="SearchPath"></Directories>
|
||||
<Directories Name="Packages"></Directories>
|
||||
<Directories Name="Conditionals"></Directories>
|
||||
<Directories Name="DebugSourceDirs"></Directories>
|
||||
<Directories Name="UsePackages">False</Directories>
|
||||
</Directories>
|
||||
<Parameters>
|
||||
<Parameters Name="RunParams"></Parameters>
|
||||
<Parameters Name="HostApplication"></Parameters>
|
||||
<Parameters Name="Launcher"></Parameters>
|
||||
<Parameters Name="UseLauncher">False</Parameters>
|
||||
<Parameters Name="DebugCWD"></Parameters>
|
||||
<Parameters Name="Debug Symbols Search Path"></Parameters>
|
||||
<Parameters Name="LoadAllSymbols">True</Parameters>
|
||||
<Parameters Name="LoadUnspecifiedSymbols">False</Parameters>
|
||||
</Parameters>
|
||||
<Language>
|
||||
<Language Name="ActiveLang"></Language>
|
||||
<Language Name="ProjectLang">$00000000</Language>
|
||||
<Language Name="RootDir"></Language>
|
||||
</Language>
|
||||
<VersionInfo>
|
||||
<VersionInfo Name="IncludeVerInfo">False</VersionInfo>
|
||||
<VersionInfo Name="AutoIncBuild">False</VersionInfo>
|
||||
<VersionInfo Name="MajorVer">1</VersionInfo>
|
||||
<VersionInfo Name="MinorVer">0</VersionInfo>
|
||||
<VersionInfo Name="Release">0</VersionInfo>
|
||||
<VersionInfo Name="Build">0</VersionInfo>
|
||||
<VersionInfo Name="Debug">False</VersionInfo>
|
||||
<VersionInfo Name="PreRelease">False</VersionInfo>
|
||||
<VersionInfo Name="Special">False</VersionInfo>
|
||||
<VersionInfo Name="Private">False</VersionInfo>
|
||||
<VersionInfo Name="DLL">False</VersionInfo>
|
||||
<VersionInfo Name="Locale">1041</VersionInfo>
|
||||
<VersionInfo Name="CodePage">932</VersionInfo>
|
||||
</VersionInfo>
|
||||
<VersionInfoKeys>
|
||||
<VersionInfoKeys Name="CompanyName"></VersionInfoKeys>
|
||||
<VersionInfoKeys Name="FileDescription"></VersionInfoKeys>
|
||||
<VersionInfoKeys Name="FileVersion">1.0.0.0</VersionInfoKeys>
|
||||
<VersionInfoKeys Name="InternalName"></VersionInfoKeys>
|
||||
<VersionInfoKeys Name="LegalCopyright"></VersionInfoKeys>
|
||||
<VersionInfoKeys Name="LegalTrademarks"></VersionInfoKeys>
|
||||
<VersionInfoKeys Name="OriginalFilename"></VersionInfoKeys>
|
||||
<VersionInfoKeys Name="ProductName"></VersionInfoKeys>
|
||||
<VersionInfoKeys Name="ProductVersion">1.0.0.0</VersionInfoKeys>
|
||||
<VersionInfoKeys Name="Comments"></VersionInfoKeys>
|
||||
</VersionInfoKeys>
|
||||
</Delphi.Personality>
|
||||
</BorlandProject>
|
76
gecko/Components/GeckoComponents.dpk
Normal file
76
gecko/Components/GeckoComponents.dpk
Normal file
@@ -0,0 +1,76 @@
|
||||
(* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is GeckoComponents for Delphi.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Takanori Ito.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2003
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** *)
|
||||
package GeckoComponents;
|
||||
|
||||
{$R *.res}
|
||||
{$ALIGN 8}
|
||||
{$ASSERTIONS ON}
|
||||
{$BOOLEVAL OFF}
|
||||
{$DEBUGINFO ON}
|
||||
{$EXTENDEDSYNTAX ON}
|
||||
{$IMPORTEDDATA ON}
|
||||
{$IOCHECKS ON}
|
||||
{$LOCALSYMBOLS ON}
|
||||
{$LONGSTRINGS ON}
|
||||
{$OPENSTRINGS ON}
|
||||
{$OPTIMIZATION ON}
|
||||
{$OVERFLOWCHECKS OFF}
|
||||
{$RANGECHECKS OFF}
|
||||
{$REFERENCEINFO ON}
|
||||
{$SAFEDIVIDE OFF}
|
||||
{$STACKFRAMES OFF}
|
||||
{$TYPEDADDRESS ON}
|
||||
{$VARSTRINGCHECKS ON}
|
||||
{$WRITEABLECONST OFF}
|
||||
{$MINENUMSIZE 1}
|
||||
{$IMAGEBASE $400000}
|
||||
{$DESCRIPTION 'Gecko Components'}
|
||||
{$IMPLICITBUILD OFF}
|
||||
|
||||
requires
|
||||
rtl,
|
||||
vcl,
|
||||
GeckoSDK;
|
||||
|
||||
contains
|
||||
GeckoBrowser in 'GeckoBrowser.pas',
|
||||
BrowserSupports in 'BrowserSupports.pas',
|
||||
CallbackInterfaces in 'CallbackInterfaces.pas',
|
||||
GeckoChromeWindow in 'GeckoChromeWindow.pas' {GeckoChromeForm},
|
||||
GeckoSimpleProfile in 'GeckoSimpleProfile.pas',
|
||||
GeckoInit in 'GeckoInit.pas',
|
||||
GeckoDirectoryService in 'GeckoDirectoryService.pas';
|
||||
|
||||
end.
|
120
gecko/Components/GeckoComponents.dproj
Normal file
120
gecko/Components/GeckoComponents.dproj
Normal file
@@ -0,0 +1,120 @@
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<ProjectGuid>{4978B162-26BE-441E-B790-751148DC88CC}</ProjectGuid>
|
||||
<MainSource>GeckoComponents.dpk</MainSource>
|
||||
<Config Condition="'$(Config)'==''">デバッグ</Config>
|
||||
<DCC_DCCCompiler>DCC32</DCC_DCCCompiler>
|
||||
<ProjectVersion>12.0</ProjectVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Config)'=='Base' or '$(Base)'!=''">
|
||||
<Base>true</Base>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Config)'=='リリース' or '$(Cfg_1)'!=''">
|
||||
<Cfg_1>true</Cfg_1>
|
||||
<CfgParent>Base</CfgParent>
|
||||
<Base>true</Base>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Config)'=='デバッグ' or '$(Cfg_2)'!=''">
|
||||
<Cfg_2>true</Cfg_2>
|
||||
<CfgParent>Base</CfgParent>
|
||||
<Base>true</Base>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Base)'!=''">
|
||||
<DCC_ImageBase>00400000</DCC_ImageBase>
|
||||
<DCC_SymbolReferenceInfo>1</DCC_SymbolReferenceInfo>
|
||||
<GenPackage>true</GenPackage>
|
||||
<DCC_DependencyCheckOutputName>GeckoComponents.bpl</DCC_DependencyCheckOutputName>
|
||||
<DCC_TypedAtParameter>true</DCC_TypedAtParameter>
|
||||
<DCC_Platform>x86</DCC_Platform>
|
||||
<DCC_Description>Gecko Components</DCC_Description>
|
||||
<DCC_S>false</DCC_S>
|
||||
<DCC_OutputNeverBuildDcps>true</DCC_OutputNeverBuildDcps>
|
||||
<GenDll>true</GenDll>
|
||||
<DCC_N>false</DCC_N>
|
||||
<DCC_E>false</DCC_E>
|
||||
<DCC_F>false</DCC_F>
|
||||
<DCC_K>false</DCC_K>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Cfg_1)'!=''">
|
||||
<DCC_LocalDebugSymbols>false</DCC_LocalDebugSymbols>
|
||||
<DCC_Define>RELEASE;$(DCC_Define)</DCC_Define>
|
||||
<DCC_SymbolReferenceInfo>0</DCC_SymbolReferenceInfo>
|
||||
<DCC_DebugInformation>false</DCC_DebugInformation>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Cfg_2)'!=''">
|
||||
<DCC_Define>DEBUG;$(DCC_Define)</DCC_Define>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<DelphiCompile Include="GeckoComponents.dpk">
|
||||
<MainSource>MainSource</MainSource>
|
||||
</DelphiCompile>
|
||||
<DCCReference Include="rtl.dcp"/>
|
||||
<DCCReference Include="vcl.dcp"/>
|
||||
<DCCReference Include="GeckoSDK.dcp"/>
|
||||
<DCCReference Include="GeckoBrowser.pas"/>
|
||||
<DCCReference Include="BrowserSupports.pas"/>
|
||||
<DCCReference Include="CallbackInterfaces.pas"/>
|
||||
<DCCReference Include="GeckoChromeWindow.pas">
|
||||
<Form>GeckoChromeForm</Form>
|
||||
</DCCReference>
|
||||
<DCCReference Include="GeckoSimpleProfile.pas"/>
|
||||
<DCCReference Include="GeckoInit.pas"/>
|
||||
<DCCReference Include="GeckoDirectoryService.pas"/>
|
||||
<BuildConfiguration Include="Base">
|
||||
<Key>Base</Key>
|
||||
</BuildConfiguration>
|
||||
<BuildConfiguration Include="デバッグ">
|
||||
<Key>Cfg_2</Key>
|
||||
<CfgParent>Base</CfgParent>
|
||||
</BuildConfiguration>
|
||||
<BuildConfiguration Include="リリース">
|
||||
<Key>Cfg_1</Key>
|
||||
<CfgParent>Base</CfgParent>
|
||||
</BuildConfiguration>
|
||||
</ItemGroup>
|
||||
<Import Project="$(BDS)\Bin\CodeGear.Delphi.Targets" Condition="Exists('$(BDS)\Bin\CodeGear.Delphi.Targets')"/>
|
||||
<ProjectExtensions>
|
||||
<Borland.Personality>Delphi.Personality.12</Borland.Personality>
|
||||
<Borland.ProjectType>Package</Borland.ProjectType>
|
||||
<BorlandProject>
|
||||
<Delphi.Personality>
|
||||
<Source>
|
||||
<Source Name="MainSource">GeckoComponents.dpk</Source>
|
||||
</Source>
|
||||
<Parameters>
|
||||
<Parameters Name="UseLauncher">False</Parameters>
|
||||
<Parameters Name="LoadAllSymbols">True</Parameters>
|
||||
<Parameters Name="LoadUnspecifiedSymbols">False</Parameters>
|
||||
</Parameters>
|
||||
<VersionInfo>
|
||||
<VersionInfo Name="IncludeVerInfo">False</VersionInfo>
|
||||
<VersionInfo Name="AutoIncBuild">False</VersionInfo>
|
||||
<VersionInfo Name="MajorVer">1</VersionInfo>
|
||||
<VersionInfo Name="MinorVer">0</VersionInfo>
|
||||
<VersionInfo Name="Release">0</VersionInfo>
|
||||
<VersionInfo Name="Build">0</VersionInfo>
|
||||
<VersionInfo Name="Debug">False</VersionInfo>
|
||||
<VersionInfo Name="PreRelease">False</VersionInfo>
|
||||
<VersionInfo Name="Special">False</VersionInfo>
|
||||
<VersionInfo Name="Private">False</VersionInfo>
|
||||
<VersionInfo Name="DLL">False</VersionInfo>
|
||||
<VersionInfo Name="Locale">1041</VersionInfo>
|
||||
<VersionInfo Name="CodePage">932</VersionInfo>
|
||||
</VersionInfo>
|
||||
<VersionInfoKeys>
|
||||
<VersionInfoKeys Name="CompanyName"/>
|
||||
<VersionInfoKeys Name="FileDescription"/>
|
||||
<VersionInfoKeys Name="FileVersion">1.0.0.0</VersionInfoKeys>
|
||||
<VersionInfoKeys Name="InternalName"/>
|
||||
<VersionInfoKeys Name="LegalCopyright"/>
|
||||
<VersionInfoKeys Name="LegalTrademarks"/>
|
||||
<VersionInfoKeys Name="OriginalFilename"/>
|
||||
<VersionInfoKeys Name="ProductName"/>
|
||||
<VersionInfoKeys Name="ProductVersion">1.0.0.0</VersionInfoKeys>
|
||||
<VersionInfoKeys Name="Comments"/>
|
||||
</VersionInfoKeys>
|
||||
</Delphi.Personality>
|
||||
</BorlandProject>
|
||||
<ProjectFileVersion>12</ProjectFileVersion>
|
||||
</ProjectExtensions>
|
||||
</Project>
|
150
gecko/Components/GeckoComponents.lpk
Normal file
150
gecko/Components/GeckoComponents.lpk
Normal file
@@ -0,0 +1,150 @@
|
||||
<?xml version="1.0"?>
|
||||
<CONFIG>
|
||||
<Package Version="3">
|
||||
<Name Value="GeckoComponents"/>
|
||||
<AddToProjectUsesSection Value="False"/>
|
||||
<Author Value="Gecko Components for Delphi; ported to Lazarus by Phil Hess"/>
|
||||
<CompilerOptions>
|
||||
<Version Value="9"/>
|
||||
<SearchPaths>
|
||||
<OtherUnitFiles Value="..;../each-version"/>
|
||||
<UnitOutputDirectory Value="units/$(TargetCPU)-$(TargetOS)"/>
|
||||
</SearchPaths>
|
||||
<Parsing>
|
||||
<SyntaxOptions>
|
||||
<SyntaxMode Value="Delphi"/>
|
||||
<CStyleOperator Value="False"/>
|
||||
<IncludeAssertionCode Value="True"/>
|
||||
<AllowLabel Value="False"/>
|
||||
<CPPInline Value="False"/>
|
||||
</SyntaxOptions>
|
||||
</Parsing>
|
||||
<CodeGeneration>
|
||||
<Checks>
|
||||
<IOChecks Value="True"/>
|
||||
<RangeChecks Value="True"/>
|
||||
<OverflowChecks Value="True"/>
|
||||
<StackChecks Value="True"/>
|
||||
</Checks>
|
||||
<VerifyObjMethodCallValidity Value="True"/>
|
||||
</CodeGeneration>
|
||||
<Linking>
|
||||
<Debugging>
|
||||
<GenerateDebugInfo Value="True"/>
|
||||
<UseHeaptrc Value="True"/>
|
||||
</Debugging>
|
||||
</Linking>
|
||||
<Other>
|
||||
<WriteFPCLogo Value="False"/>
|
||||
<CompilerPath Value="$(CompPath)"/>
|
||||
</Other>
|
||||
</CompilerOptions>
|
||||
<Description Value="Gecko Components for Lazarus"/>
|
||||
<License Value="MPL 1.1"/>
|
||||
<Version Release="3"/>
|
||||
<Files Count="21">
|
||||
<Item1>
|
||||
<Filename Value="GeckoBrowser.pas"/>
|
||||
<HasRegisterProc Value="True"/>
|
||||
<UnitName Value="GeckoBrowser"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<Filename Value="GeckoChromeWindow.lfm"/>
|
||||
<Type Value="LFM"/>
|
||||
</Item2>
|
||||
<Item3>
|
||||
<Filename Value="GeckoChromeWindow.lrs"/>
|
||||
<Type Value="LRS"/>
|
||||
</Item3>
|
||||
<Item4>
|
||||
<Filename Value="GeckoChromeWindow.pas"/>
|
||||
<UnitName Value="GeckoChromeWindow"/>
|
||||
</Item4>
|
||||
<Item5>
|
||||
<Filename Value="GeckoInit.pas"/>
|
||||
<UnitName Value="GeckoInit"/>
|
||||
</Item5>
|
||||
<Item6>
|
||||
<Filename Value="../nsCID.pas"/>
|
||||
<UnitName Value="nsCID"/>
|
||||
</Item6>
|
||||
<Item7>
|
||||
<Filename Value="../nsConsts.pas"/>
|
||||
<UnitName Value="nsConsts"/>
|
||||
</Item7>
|
||||
<Item8>
|
||||
<Filename Value="../nsEnumerators.pas"/>
|
||||
<UnitName Value="nsEnumerators"/>
|
||||
</Item8>
|
||||
<Item9>
|
||||
<Filename Value="../nsError.pas"/>
|
||||
<UnitName Value="nsError"/>
|
||||
</Item9>
|
||||
<Item10>
|
||||
<Filename Value="../nsErrorUtils.pas"/>
|
||||
<UnitName Value="nsErrorUtils"/>
|
||||
</Item10>
|
||||
<Item11>
|
||||
<Filename Value="../nsGeckoStrings.pas"/>
|
||||
<UnitName Value="nsGeckoStrings"/>
|
||||
</Item11>
|
||||
<Item12>
|
||||
<Filename Value="../nsInit.pas"/>
|
||||
<UnitName Value="nsInit"/>
|
||||
</Item12>
|
||||
<Item13>
|
||||
<Filename Value="../nsMemory.pas"/>
|
||||
<UnitName Value="nsMemory"/>
|
||||
</Item13>
|
||||
<Item14>
|
||||
<Filename Value="../nsNetUtil.pas"/>
|
||||
<UnitName Value="nsNetUtil"/>
|
||||
</Item14>
|
||||
<Item15>
|
||||
<Filename Value="../nsStream.pas"/>
|
||||
<UnitName Value="nsStream"/>
|
||||
</Item15>
|
||||
<Item16>
|
||||
<Filename Value="../nsTypes.pas"/>
|
||||
<UnitName Value="nsTypes"/>
|
||||
</Item16>
|
||||
<Item17>
|
||||
<Filename Value="../nsXPCOM.pas"/>
|
||||
<UnitName Value="nsXPCOM"/>
|
||||
</Item17>
|
||||
<Item18>
|
||||
<Filename Value="../nsXPCOMGlue.pas"/>
|
||||
<UnitName Value="nsXPCOMGlue"/>
|
||||
</Item18>
|
||||
<Item19>
|
||||
<Filename Value="../nsXRE.pas"/>
|
||||
<UnitName Value="nsXRE"/>
|
||||
</Item19>
|
||||
<Item20>
|
||||
<Filename Value="../each-version/nsXPCOM_std19.pas"/>
|
||||
<UnitName Value="nsXPCOM_std19"/>
|
||||
</Item20>
|
||||
<Item21>
|
||||
<Filename Value="GeckoPromptService.pas"/>
|
||||
<HasRegisterProc Value="True"/>
|
||||
<UnitName Value="GeckoPromptService"/>
|
||||
</Item21>
|
||||
</Files>
|
||||
<Type Value="RunAndDesignTime"/>
|
||||
<RequiredPkgs Count="2">
|
||||
<Item1>
|
||||
<PackageName Value="LCL"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<PackageName Value="IDEIntf"/>
|
||||
</Item2>
|
||||
</RequiredPkgs>
|
||||
<UsageOptions>
|
||||
<UnitPath Value="$(PkgOutDir)/"/>
|
||||
</UsageOptions>
|
||||
<PublishOptions>
|
||||
<Version Value="2"/>
|
||||
<IgnoreBinaries Value="False"/>
|
||||
</PublishOptions>
|
||||
</Package>
|
||||
</CONFIG>
|
25
gecko/Components/GeckoComponents.pas
Normal file
25
gecko/Components/GeckoComponents.pas
Normal file
@@ -0,0 +1,25 @@
|
||||
{ This file was automatically created by Lazarus. Do not edit!
|
||||
This source is only used to compile and install the package.
|
||||
}
|
||||
|
||||
unit GeckoComponents;
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
GeckoBrowser, GeckoChromeWindow, GeckoInit, nsCID, nsConsts,
|
||||
nsEnumerators, nsError, nsErrorUtils, nsGeckoStrings, nsInit, nsMemory,
|
||||
nsNetUtil, nsStream, nsTypes, nsXPCOM, nsXPCOMGlue, nsXRE, nsXPCOM_std19,
|
||||
GeckoPromptService, LazarusPackageIntf;
|
||||
|
||||
implementation
|
||||
|
||||
procedure Register;
|
||||
begin
|
||||
RegisterUnit('GeckoBrowser', @GeckoBrowser.Register);
|
||||
RegisterUnit('GeckoPromptService', @GeckoPromptService.Register);
|
||||
end;
|
||||
|
||||
initialization
|
||||
RegisterPackage('GeckoComponents', @Register);
|
||||
end.
|
85
gecko/Components/GeckoComponents.template
Normal file
85
gecko/Components/GeckoComponents.template
Normal file
@@ -0,0 +1,85 @@
|
||||
<?xml version="1.0"?>
|
||||
<CONFIG>
|
||||
<Package Version="3">
|
||||
<Name Value="GeckoComponents"/>
|
||||
<AddToProjectUsesSection Value="False"/>
|
||||
<Author Value="Gecko Components for Delphi; ported to Lazarus by Phil Hess"/>
|
||||
<CompilerOptions>
|
||||
<Version Value="9"/>
|
||||
<SearchPaths>
|
||||
<UnitOutputDirectory Value="units/$(TargetCPU)-$(TargetOS)"/>
|
||||
</SearchPaths>
|
||||
<Parsing>
|
||||
<SyntaxOptions>
|
||||
<SyntaxMode Value="Delphi"/>
|
||||
<CStyleOperator Value="False"/>
|
||||
<IncludeAssertionCode Value="True"/>
|
||||
<AllowLabel Value="False"/>
|
||||
<CPPInline Value="False"/>
|
||||
<UseAnsiStrings Value="False"/>
|
||||
</SyntaxOptions>
|
||||
</Parsing>
|
||||
<CodeGeneration>
|
||||
<Checks>
|
||||
<IOChecks Value="True"/>
|
||||
<RangeChecks Value="True"/>
|
||||
<OverflowChecks Value="True"/>
|
||||
<StackChecks Value="True"/>
|
||||
</Checks>
|
||||
<VerifyObjMethodCallValidity Value="True"/>
|
||||
</CodeGeneration>
|
||||
<Linking>
|
||||
<Debugging>
|
||||
<GenerateDebugInfo Value="True"/>
|
||||
<UseHeaptrc Value="True"/>
|
||||
</Debugging>
|
||||
</Linking>
|
||||
<Other>
|
||||
<WriteFPCLogo Value="False"/>
|
||||
<CompilerPath Value="$(CompPath)"/>
|
||||
</Other>
|
||||
</CompilerOptions>
|
||||
<Description Value="Gecko Components for Lazarus"/>
|
||||
<License Value="MPL 1.1"/>
|
||||
<Version Release="3"/>
|
||||
<Files Count="5">
|
||||
<Item1>
|
||||
<Filename Value="GeckoBrowser.pas"/>
|
||||
<HasRegisterProc Value="True"/>
|
||||
<UnitName Value="GeckoBrowser"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<Filename Value="GeckoChromeWindow.lfm"/>
|
||||
<Type Value="LFM"/>
|
||||
</Item2>
|
||||
<Item3>
|
||||
<Filename Value="GeckoChromeWindow.lrs"/>
|
||||
<Type Value="LRS"/>
|
||||
</Item3>
|
||||
<Item4>
|
||||
<Filename Value="GeckoChromeWindow.pas"/>
|
||||
<UnitName Value="GeckoChromeWindow"/>
|
||||
</Item4>
|
||||
<Item5>
|
||||
<Filename Value="GeckoInit.pas"/>
|
||||
<UnitName Value="GeckoInit"/>
|
||||
</Item5>
|
||||
</Files>
|
||||
<Type Value="RunAndDesignTime"/>
|
||||
<RequiredPkgs Count="2">
|
||||
<Item1>
|
||||
<PackageName Value="LCL"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<PackageName Value="IDEIntf"/>
|
||||
</Item2>
|
||||
</RequiredPkgs>
|
||||
<UsageOptions>
|
||||
<UnitPath Value="$(PkgOutDir)"/>
|
||||
</UsageOptions>
|
||||
<PublishOptions>
|
||||
<Version Value="2"/>
|
||||
<IgnoreBinaries Value="False"/>
|
||||
</PublishOptions>
|
||||
</Package>
|
||||
</CONFIG>
|
302
gecko/Components/GeckoDirectoryService.pas
Normal file
302
gecko/Components/GeckoDirectoryService.pas
Normal file
@@ -0,0 +1,302 @@
|
||||
unit GeckoDirectoryService;
|
||||
|
||||
{$MACRO on}
|
||||
|
||||
{$IFDEF Windows}
|
||||
{$DEFINE extdecl:=stdcall}
|
||||
{$ELSE Windows}
|
||||
{$DEFINE extdecl:=cdecl}
|
||||
{$ENDIF}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
SysUtils, Classes, nsXPCOM;
|
||||
|
||||
type
|
||||
TGeckoDirectoryServiceOnGetFile = function (
|
||||
const AProp: AnsiString): String of object;
|
||||
TGeckoDirectoryServiceOnGetFileList = function (
|
||||
const AProp: AnsiString; AList: TStrings): Boolean of Object;
|
||||
|
||||
TCustomDirectoryServiceProvider = class(TComponent)
|
||||
private
|
||||
{ Private declarations }
|
||||
FOnGetFile: TGeckoDirectoryServiceOnGetFile;
|
||||
FOnGetFileList: TGeckoDirectoryServiceOnGetFileList;
|
||||
FProxy: nsIDirectoryServiceProvider;
|
||||
|
||||
function ProcessGetFile(const AProp: AnsiString; var APersistent: Boolean)
|
||||
: String;
|
||||
function ProcessGetFileList(const AProp: AnsiString;
|
||||
AFileList: TStrings): Boolean;
|
||||
property OnGetFile: TGeckoDirectoryServiceOnGetFile read FOnGetFile
|
||||
write FOnGetFile;
|
||||
property OnGetFileList: TGeckoDirectoryServiceOnGetFileList
|
||||
read FOnGetFileList write FOnGetFileList;
|
||||
protected
|
||||
{ Protected declarations }
|
||||
public
|
||||
{ Public declarations }
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
destructor Destroy; override;
|
||||
published
|
||||
{ Published declarations }
|
||||
end;
|
||||
|
||||
TGeckoDirectoryServiceProvider = class(TCustomDirectoryServiceProvider)
|
||||
private
|
||||
{ Private declarations }
|
||||
FRegDir: AnsiString;
|
||||
FRegFile: AnsiString;
|
||||
FDefaultsDir: AnsiString;
|
||||
FPrefDefaultsDir: AnsiString;
|
||||
FProfileDefaultsDir: AnsiString;
|
||||
FProfileDefaultsNlocDir: AnsiString;
|
||||
|
||||
protected
|
||||
{ Protected declarations }
|
||||
public
|
||||
{ Public declarations }
|
||||
published
|
||||
{ Published declarations }
|
||||
property OnGetFile;
|
||||
end;
|
||||
|
||||
procedure Register;
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
nsTypes, nsInit, nsError, nsGeckoStrings, nsXPCOMGlue, nsCID, GeckoInit,
|
||||
nsXPCOM_std19, nsEnumerators, Windows;
|
||||
|
||||
type
|
||||
TDirectoryServiceProviderProxy = class(TInterfacedObject,
|
||||
nsIDirectoryServiceProvider_std19,
|
||||
nsIDirectoryServiceProvider2_std19)
|
||||
FOwner: TCustomDirectoryServiceProvider;
|
||||
constructor Create(AOwner: TCustomDirectoryServiceProvider);
|
||||
function GetFile(const prop: PAnsiChar; out persistent: PRBool;
|
||||
out _retval: nsIFile_std19): nsresult; extdecl;
|
||||
function GetFiles(const prop: PAnsiChar;
|
||||
out _retval: nsISimpleEnumerator_std19): nsresult; extdecl;
|
||||
end;
|
||||
|
||||
procedure Register;
|
||||
begin
|
||||
RegisterComponents('Gecko', [TGeckoDirectoryServiceProvider]);
|
||||
end;
|
||||
|
||||
constructor TDirectoryServiceProviderProxy.Create(
|
||||
AOwner: TCustomDirectoryServiceProvider);
|
||||
begin
|
||||
inherited Create;
|
||||
FOwner := AOwner;
|
||||
end;
|
||||
|
||||
var
|
||||
sModulePath: array[0..MAX_PATH] of Char;
|
||||
sModulePathInitialized: Boolean = False;
|
||||
|
||||
function GetModulePath: String;
|
||||
begin
|
||||
if not sModulePathInitialized then
|
||||
begin
|
||||
GetModuleFileName(0, sModulePath, MAX_PATH);
|
||||
sModulePathInitialized := True;
|
||||
end;
|
||||
Result := PChar(@sModulePath);
|
||||
end;
|
||||
|
||||
function MakeILocalFile(const AFilename: String;
|
||||
out ALocalFile: nsILocalFile): nsresult;
|
||||
var
|
||||
localFile: nsILocalFile;
|
||||
{$ifndef UNICODE}
|
||||
localFileStr: IInterfacedCString;
|
||||
{$else}
|
||||
localFileStr: IInterfacedString;
|
||||
{$endif}
|
||||
modulePath: String;
|
||||
targetPath, relativePath: String;
|
||||
begin
|
||||
modulePath := GetModulePath;
|
||||
|
||||
if (Length(AFilename)>0) and
|
||||
(AFilename[1] = '\') then
|
||||
begin
|
||||
// case of Path from root or network path
|
||||
if (Length(afilename)>=2) and
|
||||
(afilename[2] <> '\') then
|
||||
begin
|
||||
// case of Path from root
|
||||
targetPath := ExtractFileDrive(modulePath) + afilename;
|
||||
end else
|
||||
begin
|
||||
// case of network path
|
||||
targetPath := afilename;
|
||||
end;
|
||||
end else
|
||||
if (Length(afilename)<3) or
|
||||
(afilename[2] <> ':') then
|
||||
begin
|
||||
// case of relative path
|
||||
targetPath := ExtractFileDir(modulePath);
|
||||
if Length(afilename)>0 then
|
||||
relativePath := afilename;
|
||||
end else
|
||||
begin
|
||||
// case of full path
|
||||
targetPath := afilename;
|
||||
end;
|
||||
|
||||
try
|
||||
{$ifndef UNICODE}
|
||||
localFileStr := NewCString(targetPath);
|
||||
{$else}
|
||||
localFileStr := NewString(targetPath);
|
||||
{$endif}
|
||||
except
|
||||
Result := NS_ERROR_FAILURE;
|
||||
Exit;
|
||||
end;
|
||||
{$ifndef UNICODE}
|
||||
Result := NS_NewNativeLocalFile(localFileStr.ACString, True, localFile);
|
||||
{$else}
|
||||
Result := NS_NewLocalFile(localFileStr.AString, True, localFile);
|
||||
{$endif}
|
||||
if NS_FAILED(Result) then Exit;
|
||||
|
||||
if Length(relativePath)>0 then
|
||||
begin
|
||||
localFileStr.Assign(relativePath);
|
||||
{$ifndef UNICODE}
|
||||
localFile.AppendRelativeNativePath(localFileStr.ACString);
|
||||
{$else}
|
||||
localFile.AppendRelativePath(localFileStr.AString);
|
||||
{$endif}
|
||||
end;
|
||||
|
||||
Result := localFile.QueryInterface(nsILocalFile, ALocalFile);
|
||||
end;
|
||||
|
||||
function TDirectoryServiceProviderProxy.GetFile(const prop: PAnsiChar;
|
||||
out persistent: PRBool; out _retval: nsIFile_std19): nsresult;
|
||||
var
|
||||
path: String;
|
||||
localFile: nsILocalFile;
|
||||
persist: Boolean;
|
||||
begin
|
||||
if Assigned(FOwner) then
|
||||
begin
|
||||
path := FOwner.ProcessGetFile(prop, persist);
|
||||
if (Length(path)=0) and Assigned(FOwner.FOnGetFile) then
|
||||
begin
|
||||
path := FOwner.FOnGetFile(prop);
|
||||
end;
|
||||
end;
|
||||
|
||||
if Length(path)=0 then
|
||||
begin
|
||||
Result := NS_ERROR_FAILURE;
|
||||
end else
|
||||
begin
|
||||
Result := MakeILocalFile(path, localFile);
|
||||
if NS_SUCCEEDED(Result) then
|
||||
begin
|
||||
Result := localFile.QueryInterface(nsIFile_std19, _retval);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TDirectoryServiceProviderProxy.GetFiles(const prop: PAnsiChar;
|
||||
out _retval: nsISimpleEnumerator_std19): nsresult;
|
||||
var
|
||||
enum: nsISimpleEnumerator;
|
||||
lfile: nsILocalFile;
|
||||
done: Boolean;
|
||||
list: TStringList;
|
||||
intfList: TInterfaceList;
|
||||
i: Integer;
|
||||
begin
|
||||
list := TStringList.Create;
|
||||
try
|
||||
intfList := TInterfaceList.Create;
|
||||
try
|
||||
enum := NewSimpleEnumeratorFromTInterfaceList(intfList, True);
|
||||
except
|
||||
Result := NS_ERROR_FAILURE;
|
||||
intfList.Free;
|
||||
Exit;
|
||||
end;
|
||||
|
||||
if Assigned(FOwner) then
|
||||
begin
|
||||
Done := FOwner.ProcessGetFileList(prop, list);
|
||||
if not Done then
|
||||
begin
|
||||
Result := NS_ERROR_FAILURE;
|
||||
Exit;
|
||||
end;
|
||||
for i:=0 to list.Count -1 do
|
||||
begin
|
||||
Result := MakeILocalFile(list[i], lfile);
|
||||
if NS_FAILED(Result) then
|
||||
Exit;
|
||||
intfList.Add(lfile);
|
||||
end;
|
||||
Result := enum.QueryInterface(nsISimpleEnumerator, _retval);
|
||||
end else
|
||||
begin
|
||||
Result := NS_ERROR_FAILURE;
|
||||
end;
|
||||
finally
|
||||
list.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
constructor TCustomDirectoryServiceProvider.Create(AOwner: TComponent);
|
||||
var
|
||||
dirSrv: nsIDirectoryService;
|
||||
begin
|
||||
inherited;
|
||||
|
||||
if not (csDesigning in ComponentState) then
|
||||
begin
|
||||
GeckoComponentsStartup;
|
||||
|
||||
FProxy := TDirectoryServiceProviderProxy.Create(Self)
|
||||
as nsIDirectoryServiceProvider;
|
||||
NS_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, nsIDirectoryService, dirSrv);
|
||||
dirSrv.RegisterProvider(FProxy);
|
||||
end;
|
||||
end;
|
||||
|
||||
destructor TCustomDirectoryServiceProvider.Destroy;
|
||||
var
|
||||
dirSrv: nsIDirectoryService;
|
||||
begin
|
||||
if not (csDesigning in ComponentState) then
|
||||
begin
|
||||
NS_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, nsIDirectoryService, dirSrv);
|
||||
dirSrv.UnregisterProvider(FProxy);
|
||||
|
||||
GeckoComponentsShutdown;
|
||||
end;
|
||||
|
||||
inherited;
|
||||
end;
|
||||
|
||||
function TCustomDirectoryServiceProvider.ProcessGetFile(const AProp: AnsiString;
|
||||
var APersistent: Boolean): String;
|
||||
begin
|
||||
end;
|
||||
|
||||
function TCustomDirectoryServiceProvider.ProcessGetFileList(
|
||||
const AProp: AnsiString; AFileList: TStrings): Boolean;
|
||||
begin
|
||||
Result := False;
|
||||
end;
|
||||
|
||||
end.
|
72
gecko/Components/GeckoInit.pas
Normal file
72
gecko/Components/GeckoInit.pas
Normal file
@@ -0,0 +1,72 @@
|
||||
unit GeckoInit;
|
||||
|
||||
interface
|
||||
|
||||
procedure GeckoComponentsStartup(XPComPath: string = '');
|
||||
procedure GeckoComponentsShutdown;
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
nsXPCOM, nsInit, nsTypes, nsErrorUtils, nsError,
|
||||
nsXPCOMGlue, nsXRE {$IFDEF MSWINDOWS}, Windows {$ENDIF};
|
||||
|
||||
var
|
||||
sInitCount: Integer = 0;
|
||||
|
||||
procedure GeckoComponentsStartup(XPComPath: string = '');
|
||||
const
|
||||
NS_DIRECTORY_SERVICE_CID: TGUID = '{f00152d0-b40b-11d3-8c9c-000064657374}';
|
||||
var
|
||||
rv: nsresult;
|
||||
errorStr: AnsiString;
|
||||
ServiceManager: nsIServiceManager;
|
||||
DirectoryService: nsIDirectoryService;
|
||||
begin
|
||||
if sInitCount>0 then
|
||||
begin
|
||||
Inc(sInitCount);
|
||||
Exit;
|
||||
end;
|
||||
|
||||
rv := XRE_Startup('1.9', True, '2.0', False, XPComPath);
|
||||
|
||||
if NS_FAILED(rv) then
|
||||
begin
|
||||
errorStr := NS_GetErrorStringBundleKey(rv);
|
||||
XPCOMGlueShutdown;
|
||||
raise EGeckoError.Create(string(errorStr));
|
||||
end;
|
||||
|
||||
//Register the service via Service Manager.
|
||||
if not Assigned(GeckoEngineDirectoryService) then
|
||||
GeckoEngineDirectoryService:=IDirectoryServiceProvider.Create;
|
||||
NS_GetServiceManager(ServiceManager);
|
||||
ServiceManager.GetService(NS_DIRECTORY_SERVICE_CID, DirectoryService,DirectoryService);
|
||||
{$IFDEF LCLGTK2 AND defined(cpux86_64)}
|
||||
//No register meanwhile the DirectoryService bug in Linux64 is not solved.
|
||||
{$ELSE}
|
||||
DirectoryService.RegisterProvider(GeckoEngineDirectoryService);
|
||||
{$ENDIF}
|
||||
|
||||
Inc(sInitCount);
|
||||
end;
|
||||
|
||||
procedure GeckoComponentsShutdown();
|
||||
begin
|
||||
if sInitCount = 0 then
|
||||
begin
|
||||
raise EGeckoError.Create(
|
||||
'ERROR: Too many calls for GeckoComponentsShutdown then GeckoComponentsStartup');
|
||||
end;
|
||||
|
||||
Dec(sInitCount);
|
||||
|
||||
if sInitCount = 0 then
|
||||
begin
|
||||
XRE_Shutdown();
|
||||
end;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
359
gecko/Components/GeckoPromptService.pas
Normal file
359
gecko/Components/GeckoPromptService.pas
Normal file
@@ -0,0 +1,359 @@
|
||||
unit GeckoPromptService;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, nsXPCOM, nsTypes;
|
||||
|
||||
const
|
||||
NS_PROMPT_SERVICE_CID: TGUID = '{a2112d6a-0e28-421f-b46a-25c0b308cbd0}';
|
||||
|
||||
type
|
||||
TGeckoPromptAlert=procedure(Sender: TObject; const aDialogTitle: UTF8String; const aText: UTF8String) of object;
|
||||
TGeckoPromptAlertCheck=procedure (Sender: TObject; const aDialogTitle: UTF8String; const aText: UTF8String; const aCheckMsg: UTF8String; out aCheckState: Boolean) of object;
|
||||
TGeckoPromptConfirm=procedure(Sender: TObject; const aDialogTitle: UTF8String; const aText: UTF8String; var aCancel: Boolean) of object;
|
||||
TGeckoPromptConfirmCheck=procedure(Sender: TObject; const aDialogTitle: UTF8String; const aText: UTF8String; const aCheckMsg: UTF8String; out aCheckState: Boolean; var aCancel: Boolean) of object;
|
||||
TGeckoPromptConfirmEx=procedure(Sender: TObject; const aDialogTitle: UTF8String; const aText: UTF8String; aButtonFlags: Cardinal; const aButton0Title: UTF8String; const aButton1Title: UTF8String; const aButton2Title: UTF8String; const aCheckMsg: UTF8String; out aCheckState: Boolean; out aSelectedButton) of object;
|
||||
TGeckoPromptPrompt=procedure(Sender: TObject; const aDialogTitle: UTF8String; const aText: UTF8String; var aValue: UTF8String; const aCheckMsg: UTF8String; var aCheckState: Boolean; var aCancel: Boolean) of object;
|
||||
TGeckoPromptPromptUsernameAndPassword=procedure(Sender: TObject; const aDialogTitle: UTF8String; const aText: UTF8String; out aUsername: UTF8String; out aPassword: UTF8String; const aCheckMsg: UTF8String; out aCheckState: Boolean; var aCancel: Boolean) of object;
|
||||
TGeckoPromptPromptPassword=procedure(Sender: TObject; const aDialogTitle: UTF8String; const aText: UTF8String; out aPassword: UTF8String; const aCheckMsg: UTF8String; out aCheckState: Boolean; var aCancel: Boolean) of object;
|
||||
TGeckoPromptSelect=procedure(Sender: TObject; const aDialogTitle: UTF8String; const aText: UTF8String; aCount: Cardinal; const aSelectList_array; out aOutSelection: integer; var aCancel: Boolean) of object;
|
||||
TGeckoPromptPromptAuth=procedure(Sender: TObject;const aChannel: nsIChannel;const level: integer;const authInfo: nsIAuthInformation;const checkboxLabel: UTF8String;var checkValue: Boolean; var aRetryOnFail: Boolean) of object;
|
||||
TGeckoPromptAsyncPromptAuth=procedure(Sender: TObject;aChannel: nsIChannel;aCallback: nsIAuthPromptCallback;aContext: nsISupports;level: Cardinal;authInfo: nsIAuthInformation;checkboxLabel: UTF8String;var checkValue: Boolean; var nsICancelable) of object;
|
||||
TGeckoPromptPromptAuthSimple=procedure(Sender: TObject;var aUserName,aPassword: UTF8String;const aCheckBoxText,aRealm: UTF8String;var aCheckValue: Boolean; var aRetryOnFail: Boolean) of object;
|
||||
|
||||
{ IPromptService }
|
||||
|
||||
IPromptService = class (TInterfacedObject,
|
||||
nsIPromptService,
|
||||
nsIPromptService2)
|
||||
private
|
||||
public
|
||||
//nsIPromptService
|
||||
procedure Alert(aParent: nsIDOMWindow; const aDialogTitle: PWideChar; const aText: PWideChar); safecall;
|
||||
procedure AlertCheck(aParent: nsIDOMWindow; const aDialogTitle: PWideChar; const aText: PWideChar; const aCheckMsg: PWideChar; out aCheckState: PRBool); safecall;
|
||||
function Confirm(aParent: nsIDOMWindow; const aDialogTitle: PWideChar; const aText: PWideChar): PRBool; safecall;
|
||||
function ConfirmCheck(aParent: nsIDOMWindow; const aDialogTitle: PWideChar; const aText: PWideChar; const aCheckMsg: PWideChar; out aCheckState: PRBool): PRBool; safecall;
|
||||
function ConfirmEx(aParent: nsIDOMWindow; const aDialogTitle: PWideChar; const aText: PWideChar; aButtonFlags: PRUint32; const aButton0Title: PWideChar; const aButton1Title: PWideChar; const aButton2Title: PWideChar; const aCheckMsg: PWideChar; out aCheckState: PRBool): PRInt32; safecall;
|
||||
function Prompt(aParent: nsIDOMWindow; const aDialogTitle: PWideChar; const aText: PWideChar; var aValue: PWideChar; const aCheckMsg: PWideChar; var aCheckState: PRBool): PRBool; safecall;
|
||||
function PromptUsernameAndPassword(aParent: nsIDOMWindow; const aDialogTitle: PWideChar; const aText: PWideChar; out aUsername: PWideChar; out aPassword: PWideChar; const aCheckMsg: PWideChar; out aCheckState: PRBool): PRBool; safecall;
|
||||
function PromptPassword(aParent: nsIDOMWindow; const aDialogTitle: PWideChar; const aText: PWideChar; out aPassword: PWideChar; const aCheckMsg: PWideChar; out aCheckState: PRBool): PRBool; safecall;
|
||||
function Select(aParent: nsIDOMWindow; const aDialogTitle: PWideChar; const aText: PWideChar; aCount: PRUint32; const aSelectList_array; out aOutSelection: PRInt32): PRBool; safecall;
|
||||
//nsIPromptService2
|
||||
function PromptAuth(aParent: nsIDOMWindow; aChannel: nsIChannel; level: PRUint32; authInfo: nsIAuthInformation; const checkboxLabel: PWideChar; var checkValue: LongBool): LongBool; safecall;
|
||||
function AsyncPromptAuth(aParent: nsIDOMWindow; aChannel: nsIChannel; aCallback: nsIAuthPromptCallback; aContext: nsISupports; level: PRUint32; authInfo: nsIAuthInformation; const checkboxLabel: PWideChar; var checkValue: LongBool): nsICancelable; safecall;
|
||||
end;
|
||||
|
||||
{ IPromptServiceFactory }
|
||||
|
||||
IPromptServiceFactory = class(TInterfacedObject,nsIFactory)
|
||||
procedure CreateInstance(aOuter: nsISupports; constref iid: TGUID; out _result); safecall;
|
||||
procedure LockFactory(lock: PRBool); safecall;
|
||||
end;
|
||||
|
||||
TCustomGeckoPrompt=class(TComponent)
|
||||
private
|
||||
protected
|
||||
FOnAlert: TGeckoPromptAlert;
|
||||
FOnAlertCheck: TGeckoPromptAlertCheck;
|
||||
FOnConfirm: TGeckoPromptConfirm;
|
||||
FOnConfirmCheck: TGeckoPromptConfirmCheck;
|
||||
FOnConfirmEx: TGeckoPromptConfirmEx;
|
||||
FOnPrompt: TGeckoPromptPrompt;
|
||||
FOnPromptUsernameAndPassword: TGeckoPromptPromptUsernameAndPassword;
|
||||
FOnPromptPassword: TGeckoPromptPromptPassword;
|
||||
FOnSelect: TGeckoPromptSelect;
|
||||
FOnPromptAuth: TGeckoPromptPromptAuth;
|
||||
FOnAsyncPromptAuth: TGeckoPromptAsyncPromptAuth;
|
||||
FOnPromptAuthSimple: TGeckoPromptPromptAuthSimple;
|
||||
public
|
||||
property Alert: TGeckoPromptAlert
|
||||
read FOnAlert write FOnAlert;
|
||||
property AlertCheck: TGeckoPromptAlertCheck
|
||||
read FOnAlertCheck write FOnAlertCheck;
|
||||
property Confirm: TGeckoPromptConfirm
|
||||
read FOnConfirm write FOnConfirm;
|
||||
property ConfirmCheck: TGeckoPromptConfirmCheck
|
||||
read FOnConfirmCheck write FOnConfirmCheck;
|
||||
property ConfirmEx: TGeckoPromptConfirmEx
|
||||
read FOnConfirmEx write FOnConfirmEx;
|
||||
property Prompt: TGeckoPromptPrompt
|
||||
read FOnPrompt write FOnPrompt;
|
||||
property PromptUsernameAndPassword: TGeckoPromptPromptUsernameAndPassword
|
||||
read FOnPromptUsernameAndPassword write FOnPromptUsernameAndPassword;
|
||||
property PromptPassword: TGeckoPromptPromptPassword
|
||||
read FOnPromptPassword write FOnPromptPassword;
|
||||
property Select: TGeckoPromptSelect
|
||||
read FOnSelect write FOnSelect;
|
||||
property PromptAuth: TGeckoPromptPromptAuth
|
||||
read FOnPromptAuth write FOnPromptAuth;
|
||||
property AsyncPromptAuth: TGeckoPromptAsyncPromptAuth
|
||||
read FOnAsyncPromptAuth write FOnAsyncPromptAuth;
|
||||
property PromptAuthSimple: TGeckoPromptPromptAuthSimple
|
||||
read FOnPromptAuthSimple write FOnPromptAuthSimple;
|
||||
end;
|
||||
|
||||
TGeckoPrompt=class(TCustomGeckoPrompt)
|
||||
private
|
||||
protected
|
||||
public
|
||||
published
|
||||
property Alert;
|
||||
property AlertCheck;
|
||||
property Confirm;
|
||||
property ConfirmCheck;
|
||||
property ConfirmEx;
|
||||
property Prompt;
|
||||
property PromptUsernameAndPassword;
|
||||
property PromptPassword;
|
||||
property Select;
|
||||
property PromptAuth;
|
||||
property AsyncPromptAuth;
|
||||
property PromptAuthSimple;
|
||||
end;
|
||||
|
||||
procedure RegisterPromptService;
|
||||
|
||||
procedure Register;
|
||||
|
||||
implementation
|
||||
|
||||
uses nsInit,nsGeckoStrings,GeckoBrowser,nsMemory;
|
||||
|
||||
var
|
||||
GeckoPromptServiceFactory: IPromptServiceFactory;
|
||||
ThisGeckoPromptService: IPromptService;
|
||||
|
||||
procedure Register;
|
||||
begin
|
||||
RegisterComponents('Gecko', [TGeckoPrompt]);
|
||||
end;
|
||||
|
||||
function UnImplemented: Boolean;
|
||||
begin
|
||||
(*
|
||||
This warning only appears when used in the Lazarus IDE.
|
||||
Otherwise the exception is eaten by the try...except and
|
||||
default behavior is executed.
|
||||
*)
|
||||
try
|
||||
Raise exception.Create('GeckoPort unimplemented feature in TGeckoPrompt. Please report at http://sourceforge.net/projects/lazarus-ccr/ or at http://forum.lazarus.freepascal.org/');
|
||||
except
|
||||
end;
|
||||
Result:=false;
|
||||
end;
|
||||
|
||||
procedure nsParamStringUpdate(var pwParamString: PWideChar; const aNewString: UTF8String);
|
||||
var
|
||||
wNewString: WideString;
|
||||
BufferSize: SizeInt;
|
||||
begin
|
||||
if Assigned(pwParamString) then begin
|
||||
nsMemory.Free(pwParamString);
|
||||
pwParamString:=nil;
|
||||
end;
|
||||
if Length(aNewString)>0 then begin
|
||||
wNewString:=UTF8Decode(aNewString);
|
||||
BufferSize:=(Length(wNewString)+1)*sizeof(wNewString[1]); //chars + 1 NULL
|
||||
pwParamString:=nsMemory.Alloc(BufferSize);
|
||||
move(wNewString[1],pwParamString^,BufferSize);
|
||||
end;
|
||||
end;
|
||||
|
||||
function FindAssociatedPromptService(const aParent: nsIDOMWindow; out AGecko: TGeckoBrowser): TGeckoPrompt;
|
||||
var
|
||||
Gecko: TGeckoBrowser;
|
||||
begin
|
||||
Gecko:=TGeckoBrowser.GetGeckoBrowserWithDOMWindow(aParent);
|
||||
if Assigned(Gecko) then begin
|
||||
Result:=Gecko.Prompt;
|
||||
AGecko:=Gecko;
|
||||
end else begin
|
||||
Result:=nil;
|
||||
AGecko:=nil;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure RegisterPromptService;
|
||||
var
|
||||
PromptService: nsIPromptService;
|
||||
ComponentRegistrar: nsIComponentRegistrar;
|
||||
begin
|
||||
if not Assigned(GeckoPromptServiceFactory) then begin
|
||||
NS_GetComponentRegistrar(ComponentRegistrar);
|
||||
GeckoPromptServiceFactory:=IPromptServiceFactory.Create;
|
||||
ComponentRegistrar.RegisterFactory(NS_PROMPT_SERVICE_CID,'Prompt Service',nil,GeckoPromptServiceFactory);
|
||||
end;
|
||||
end;
|
||||
|
||||
{ IPromptService }
|
||||
|
||||
procedure IPromptService.Alert(aParent: nsIDOMWindow;
|
||||
const aDialogTitle: PWideChar; const aText: PWideChar); safecall;
|
||||
begin
|
||||
Unimplemented;
|
||||
end;
|
||||
|
||||
procedure IPromptService.AlertCheck(aParent: nsIDOMWindow;
|
||||
const aDialogTitle: PWideChar; const aText: PWideChar;
|
||||
const aCheckMsg: PWideChar; out aCheckState: PRBool); safecall;
|
||||
begin
|
||||
Unimplemented;
|
||||
end;
|
||||
|
||||
function IPromptService.Confirm(aParent: nsIDOMWindow;
|
||||
const aDialogTitle: PWideChar; const aText: PWideChar): PRBool; safecall;
|
||||
begin
|
||||
Result:=Unimplemented;
|
||||
end;
|
||||
|
||||
function IPromptService.ConfirmCheck(aParent: nsIDOMWindow;
|
||||
const aDialogTitle: PWideChar; const aText: PWideChar;
|
||||
const aCheckMsg: PWideChar; out aCheckState: PRBool): PRBool; safecall;
|
||||
begin
|
||||
Result:=Unimplemented;
|
||||
end;
|
||||
|
||||
function IPromptService.ConfirmEx(aParent: nsIDOMWindow;
|
||||
const aDialogTitle: PWideChar; const aText: PWideChar;
|
||||
aButtonFlags: PRUint32; const aButton0Title: PWideChar;
|
||||
const aButton1Title: PWideChar; const aButton2Title: PWideChar;
|
||||
const aCheckMsg: PWideChar; out aCheckState: PRBool): PRInt32; safecall;
|
||||
begin
|
||||
UnImplemented;
|
||||
Result:=0;
|
||||
end;
|
||||
|
||||
function IPromptService.Prompt(aParent: nsIDOMWindow;
|
||||
const aDialogTitle: PWideChar; const aText: PWideChar; var aValue: PWideChar;
|
||||
const aCheckMsg: PWideChar; var aCheckState: PRBool): PRBool; safecall;
|
||||
var
|
||||
ThePrompt: TGeckoPrompt;
|
||||
Gecko: TGeckoBrowser;
|
||||
TheValue: UTF8String;
|
||||
Cancel: Boolean;
|
||||
CheckState: Boolean;
|
||||
begin
|
||||
Result:=false;
|
||||
ThePrompt:=FindAssociatedPromptService(aParent,Gecko);
|
||||
if Assigned(ThePrompt) then begin
|
||||
if Assigned(ThePrompt.FOnPrompt) then begin
|
||||
TheValue:=UTF8Encode(WideString(aValue));
|
||||
CheckState:=aCheckState;
|
||||
Cancel:=false;
|
||||
ThePrompt.FOnPrompt(Gecko,
|
||||
UTF8Encode(WideString(aDialogTitle)),
|
||||
UTF8Encode(WideString(aText)),
|
||||
TheValue,
|
||||
UTF8Encode(WideString(aCheckMsg)),
|
||||
CheckState,
|
||||
Cancel);
|
||||
Result:=not Cancel;
|
||||
if Result then begin
|
||||
nsParamStringUpdate(aValue,TheValue);
|
||||
aCheckState:=CheckState;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
function IPromptService.PromptUsernameAndPassword(aParent: nsIDOMWindow;
|
||||
const aDialogTitle: PWideChar; const aText: PWideChar; out
|
||||
aUsername: PWideChar; out aPassword: PWideChar; const aCheckMsg: PWideChar;
|
||||
out aCheckState: PRBool): PRBool; safecall;
|
||||
begin
|
||||
Result:=Unimplemented;
|
||||
end;
|
||||
|
||||
function IPromptService.PromptPassword(aParent: nsIDOMWindow;
|
||||
const aDialogTitle: PWideChar; const aText: PWideChar; out
|
||||
aPassword: PWideChar; const aCheckMsg: PWideChar; out aCheckState: PRBool
|
||||
): PRBool; safecall;
|
||||
begin
|
||||
Result:=Unimplemented;
|
||||
end;
|
||||
|
||||
function IPromptService.Select(aParent: nsIDOMWindow;
|
||||
const aDialogTitle: PWideChar; const aText: PWideChar; aCount: PRUint32;
|
||||
const aSelectList_array; out aOutSelection: PRInt32): PRBool; safecall;
|
||||
begin
|
||||
Result:=Unimplemented;
|
||||
end;
|
||||
|
||||
function IPromptService.PromptAuth(aParent: nsIDOMWindow; aChannel: nsIChannel;
|
||||
level: PRUint32; authInfo: nsIAuthInformation;
|
||||
const checkboxLabel: PWideChar; var checkValue: LongBool): LongBool; safecall;
|
||||
var
|
||||
ThePrompt: TGeckoPrompt;
|
||||
Gecko: TGeckoBrowser;
|
||||
RetryOnFail: Boolean;
|
||||
UserName, Password,
|
||||
Realm: IInterfacedString;
|
||||
CheckBoxValue: Boolean;
|
||||
pUserName,pPassword: UTF8String;
|
||||
Flags: PRUint32;
|
||||
begin
|
||||
Result:=false;
|
||||
ThePrompt:=FindAssociatedPromptService(aParent,Gecko);
|
||||
if Assigned(ThePrompt) then begin
|
||||
if Assigned(ThePrompt.FOnPromptAuth) then begin
|
||||
//Full Auth mode
|
||||
RetryOnFail:=false;
|
||||
CheckBoxValue:=checkValue;
|
||||
ThePrompt.FOnPromptAuth(Gecko,aChannel,Level,authInfo,UTF8Encode(WideString(checkboxLabel)),CheckBoxValue,RetryOnFail);
|
||||
checkValue:=CheckBoxValue;
|
||||
Result:=RetryOnFail;
|
||||
end else if Assigned(ThePrompt.FOnPromptAuthSimple) then begin
|
||||
//Simple Auth mode only for host, proxy and others must be handled by OnPromptAuth
|
||||
authInfo.GetFlags(Flags);
|
||||
if (Flags and not(NS_IAUTHINFORMATION_AUTH_HOST))=0 then begin
|
||||
UserName:=NewString;
|
||||
Password:=NewString;
|
||||
Realm:=NewString;
|
||||
authInfo.GetUsername(UserName.AString);
|
||||
authInfo.GetPassword(Password.AString);
|
||||
authInfo.GetRealm(Realm.AString);
|
||||
pUserName:=UTF8Encode(UserName.ToString);
|
||||
pPassword:=UTF8Encode(Password.ToString);
|
||||
CheckBoxValue:=checkValue;
|
||||
RetryOnFail:=false;
|
||||
ThePrompt.FOnPromptAuthSimple(Gecko,pUserName,pPassword,UTF8Encode(WideString(checkboxLabel)),UTF8Encode(Realm.ToString),CheckBoxValue,RetryOnFail);
|
||||
Result:=RetryOnFail;
|
||||
UserName.Assign(UTF8Decode(pUserName));
|
||||
Password.Assign(UTF8Decode(pPassword));
|
||||
checkValue:=CheckBoxValue;
|
||||
authInfo.SetUsername(UserName.AString);
|
||||
authInfo.SetPassword(Password.AString);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
function IPromptService.AsyncPromptAuth(aParent: nsIDOMWindow;
|
||||
aChannel: nsIChannel; aCallback: nsIAuthPromptCallback;
|
||||
aContext: nsISupports; level: PRUint32; authInfo: nsIAuthInformation;
|
||||
const checkboxLabel: PWideChar; var checkValue: LongBool): nsICancelable; safecall;
|
||||
begin
|
||||
Result:=nil;
|
||||
end;
|
||||
|
||||
{ IPromptServiceFactory }
|
||||
|
||||
procedure IPromptServiceFactory.CreateInstance(aOuter: nsISupports; constref
|
||||
iid: TGUID; out _result); safecall;
|
||||
begin
|
||||
if not Assigned(ThisGeckoPromptService) then
|
||||
ThisGeckoPromptService:=IPromptService.Create;
|
||||
ThisGeckoPromptService.QueryInterface(IID,_result);
|
||||
end;
|
||||
|
||||
procedure IPromptServiceFactory.LockFactory(lock: PRBool); safecall;
|
||||
begin
|
||||
//Unused by Gecko but keep to be ABI compatible in Win32.
|
||||
end;
|
||||
|
||||
|
||||
end.
|
||||
|
241
gecko/Components/GeckoSimpleProfile.pas
Normal file
241
gecko/Components/GeckoSimpleProfile.pas
Normal file
@@ -0,0 +1,241 @@
|
||||
(* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is GeckoComponents for Delphi.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Takanori Ito.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2003
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** *)
|
||||
unit GeckoSimpleProfile;
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Windows, Messages, SysUtils, Classes;
|
||||
|
||||
type
|
||||
TGeckoSimpleProfile = class(TComponent)
|
||||
private
|
||||
{ Private <20>錾 }
|
||||
procedure SetProfileBaseDirectory(Value: String);
|
||||
function GetProfileBaseDirectory: String;
|
||||
protected
|
||||
{ Protected <20>錾 }
|
||||
public
|
||||
{ Public <20>錾 }
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
destructor Destroy; override;
|
||||
published
|
||||
{ Published <20>錾 }
|
||||
property ProfileBaseDirectory: String
|
||||
read GetProfileBaseDirectory
|
||||
write SetProfileBaseDirectory;
|
||||
end;
|
||||
|
||||
procedure Register;
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
nsXPCOM, nsXPCOMGlue, nsError, nsGeckoStrings, nsProfile, nsTypes, nsInit,
|
||||
GeckoInit;
|
||||
|
||||
procedure Register;
|
||||
begin
|
||||
RegisterComponents('Gecko', [TGeckoSimpleProfile]);
|
||||
end;
|
||||
|
||||
var
|
||||
sProfileDirServiceProvider: nsProfileDirServiceProvider;
|
||||
sProfileBaseDirectory: String;
|
||||
sRefCnt: Integer = 0;
|
||||
|
||||
procedure ChangeProfileBaseDirectory; forward;
|
||||
procedure SavePreferences; forward;
|
||||
procedure LoadPreferences; forward;
|
||||
|
||||
constructor TGeckoSimpleProfile.Create(AOwner: TComponent);
|
||||
var
|
||||
provider: nsProfileDirServiceProvider;
|
||||
begin
|
||||
inherited Create(AOwner);
|
||||
|
||||
if not (csDesigning in ComponentState) then
|
||||
begin
|
||||
GeckoComponentsStartup;
|
||||
|
||||
if not Assigned(sProfileDirServiceProvider) then
|
||||
begin
|
||||
provider := NS_NewProfileDirServiceProvider(True);
|
||||
|
||||
sProfileDirServiceProvider := provider;
|
||||
|
||||
//if Length(sProfileBaseDirectory)>0 then
|
||||
ChangeProfileBaseDirectory;
|
||||
sProfileDirServiceProvider.Register;
|
||||
end;
|
||||
Inc(sRefCnt);
|
||||
end;
|
||||
end;
|
||||
|
||||
destructor TGeckoSimpleProfile.Destroy;
|
||||
begin
|
||||
if not (csDesigning in ComponentState) then
|
||||
begin
|
||||
SavePreferences;
|
||||
|
||||
Dec(sRefCnt);
|
||||
if sRefCnt=0 then
|
||||
sProfileDirServiceProvider := nil;
|
||||
|
||||
GeckoComponentsShutdown;
|
||||
end;
|
||||
|
||||
inherited;
|
||||
end;
|
||||
|
||||
procedure TGeckoSimpleProfile.SetProfileBaseDirectory(Value: String);
|
||||
begin
|
||||
if Value = sProfileBaseDirectory then Exit;
|
||||
|
||||
sProfileBaseDirectory := Value;
|
||||
|
||||
if not (csDesigning in ComponentState) then
|
||||
begin
|
||||
ChangeProfileBaseDirectory;
|
||||
LoadPreferences;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TGeckoSimpleProfile.GetProfileBaseDirectory: String;
|
||||
begin
|
||||
Result := sProfileBaseDirectory;
|
||||
end;
|
||||
|
||||
procedure ChangeProfileBaseDirectory;
|
||||
var
|
||||
rv: nsresult;
|
||||
localFile: nsILocalFile;
|
||||
{$ifndef UNICODE}
|
||||
localFileStr: IInterfacedCString;
|
||||
{$else}
|
||||
localFileStr: IInterfacedString;
|
||||
{$endif}
|
||||
modulePath: array[0..MAX_PATH] of Char;
|
||||
targetPath, relativePath: String;
|
||||
begin
|
||||
GetModuleFileName(0, modulePath, MAX_PATH);
|
||||
|
||||
if (Length(sProfileBaseDirectory)>0) and
|
||||
(sProfileBaseDirectory[1] = '\') then
|
||||
begin
|
||||
// case of Path from root or network path
|
||||
if (Length(sProfileBaseDirectory)>=2) and
|
||||
(sProfileBaseDirectory[2] <> '\') then
|
||||
begin
|
||||
// case of Path from root
|
||||
targetPath := ExtractFileDrive(modulePath) + sProfileBaseDirectory;
|
||||
end else
|
||||
begin
|
||||
// case of network path
|
||||
targetPath := sProfileBaseDirectory;
|
||||
end;
|
||||
end else
|
||||
if (Length(sProfileBaseDirectory)<3) or
|
||||
(sProfileBaseDirectory[2] <> ':') then
|
||||
begin
|
||||
// case of relative path
|
||||
targetPath := ExtractFileDir(modulePath);
|
||||
if Length(sProfileBaseDirectory)>0 then
|
||||
relativePath := sProfileBaseDirectory;
|
||||
end else
|
||||
begin
|
||||
// case of full path
|
||||
targetPath := sProfileBaseDirectory;
|
||||
end;
|
||||
|
||||
try
|
||||
{$ifndef UNICODE}
|
||||
localFileStr := NewCString(targetPath);
|
||||
{$else}
|
||||
localFileStr := NewString(targetPath);
|
||||
{$endif}
|
||||
except
|
||||
Exit;
|
||||
end;
|
||||
{$ifndef UNICODE}
|
||||
rv := NS_NewNativeLocalFile(localFileStr.ACString, True, localFile);
|
||||
{$else}
|
||||
rv := NS_NewLocalFile(localFileStr.AString, True, localFile);
|
||||
{$endif}
|
||||
if NS_FAILED(rv) then Exit;
|
||||
|
||||
if Length(relativePath)>0 then
|
||||
begin
|
||||
localFileStr.Assign(relativePath);
|
||||
{$ifndef UNICODE}
|
||||
localFile.AppendRelativeNativePath(localFileStr.ACString);
|
||||
{$else}
|
||||
localFile.AppendRelativePath(localFileStr.AString);
|
||||
{$endif}
|
||||
end;
|
||||
|
||||
sProfileDirServiceProvider.SetProfileDir(localFile);
|
||||
end;
|
||||
|
||||
procedure SavePreferences;
|
||||
var
|
||||
prefSrv: nsIPrefService;
|
||||
prefFile: nsIFile;
|
||||
begin
|
||||
NS_GetService(NS_PREFSERVICE_CID, nsIPrefService, prefSrv);
|
||||
prefFile := NS_GetSpecialDirectory(NS_APP_PREFS_50_FILE);
|
||||
prefSrv.SavePrefFile(prefFile);
|
||||
end;
|
||||
|
||||
procedure LoadPreferences;
|
||||
var
|
||||
prefSrv: nsIPrefService;
|
||||
prefFile, prefDir: nsIFile;
|
||||
begin
|
||||
NS_GetService(NS_PREFSERVICE_CID, nsIPrefService, prefSrv);
|
||||
prefDir := NS_GetSpecialDirectory(NS_APP_PREFS_50_DIR);
|
||||
if not prefDir.Exists then
|
||||
begin
|
||||
prefDir.Create(NS_IFILE_DIRECTORY_TYPE, 7*64+5*8+5);
|
||||
end;
|
||||
prefFile := NS_GetSpecialDirectory(NS_APP_PREFS_50_FILE);
|
||||
prefSrv.ResetPrefs;
|
||||
if prefFile.Exists then
|
||||
begin
|
||||
prefSrv.ReadUserPrefs(prefFile);
|
||||
end;
|
||||
end;
|
||||
|
||||
end.
|
BIN
gecko/Components/TGeckoBrowser.bmp
Normal file
BIN
gecko/Components/TGeckoBrowser.bmp
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.7 KiB |
BIN
gecko/Components/TGeckoPrompt.bmp
Normal file
BIN
gecko/Components/TGeckoPrompt.bmp
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.6 KiB |
BIN
gecko/Components/gecko-logo.png
Normal file
BIN
gecko/Components/gecko-logo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 26 KiB |
BIN
gecko/Components/geckologo.png
Normal file
BIN
gecko/Components/geckologo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 26 KiB |
1
gecko/Components/geckoresources.rc
Normal file
1
gecko/Components/geckoresources.rc
Normal file
@@ -0,0 +1 @@
|
||||
ID_GECKO_LOGO RCDATA geckologo.png
|
Reference in New Issue
Block a user