I'm using DCEF3 on Delphi XE3.
Task is : Create different cookie storages for different TChromium instances.
Problem : I'm creating different ICefCookieManager instances for each TChromium instances and its returning in GetCookieManager event.
Example code:
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Chromium1: TChromium;
Chromium2: TChromium;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Chromium1GetCookieManager(Sender: TObject;
const browser: ICefBrowser; const mainUrl: ustring;
out Result: ICefCookieManager);
procedure Chromium2GetCookieManager(Sender: TObject;
const browser: ICefBrowser; const mainUrl: ustring;
out Result: ICefCookieManager);
private
{ Private declarations }
CookieManager: ICefCookieManager;
CookieManager2: ICefCookieManager;
public
{ Public declarations }
end;
var
Form1: TForm1;
procedure TForm1.FormCreate(Sender: TObject);
begin
CookieManager:=TCefCookieManagerRef.New('C:\Cookies\1');
CookieManager2:=TCefCookieManagerRef.New('C:\Cookies\2');
end;
procedure TForm1.Chromium1GetCookieManager(Sender: TObject;
const browser: ICefBrowser; const mainUrl: ustring;
out Result: ICefCookieManager);
begin
Result:=CookieManager;
end;
procedure TForm1.Chromium2GetCookieManager(Sender: TObject;
const browser: ICefBrowser; const mainUrl: ustring;
out Result: ICefCookieManager);
begin
Result:=CookieManager2;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Chromium1.Load('http://somesite.com');
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Chromium2.Load('http://somesite.com');
end;
If I add ShowMessage('First')
to Chromium1GetCookieManager
event, and ShowMessage('Second')
to Chromium2GetCookieManager
, always the message "First" will be shown, no matter whether I press button1 or button2.
In other words Chromium1GetCookieManager is called for both instances.
Problem is solved, thanks to all.
How to solve the problem?
Just turn off cefsingleprocess variable in your project1.dpr.
Example: