delphi - Different cookie handlers for two chromium instances on one form -
i'm using dcef3 on delphi xe3.
task is : create different cookie storages different tchromium instances.
problem : i'm creating different icefcookiemanager instances each tchromium instances , 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 add showmessage('first')
chromium1getcookiemanager
event, , showmessage('second')
chromium2getcookiemanager
, message "first" shown, no matter whether press button1 or button2.
in other words chromium1getcookiemanager called both instances.
problem solved, all.
how solve problem?
turn off cefsingleprocess variable in project1.dpr.
example:
program project1; uses forms, cefvcl, ceflib, unit1 in 'unit1.pas' {form1}; {$r *.res} begin cefsingleprocess := false;//this i'm talking application.initialize; application.createform(tform1, form1); application.run; end.
Comments
Post a Comment