Page 2 of 3

Re: Unable to set referer

Posted: Sat Aug 22, 2020 12:10 pm
by Student
2623

Re: Unable to set referer

Posted: Sat Aug 22, 2020 2:58 pm
by andreykrasnodar
Student wrote: Sat Aug 22, 2020 12:10 pm2623
Буду очень благодарен, если поделитесь ссылкой. Не могу найти и всё...

Re: Unable to set referer

Posted: Sat Aug 22, 2020 3:05 pm
by salvadordf
OldCEF4Delphi with the 2623 branch of CEF is here :
https://github.com/salvadordf/OldCEF4Delphi

Re: Unable to set referer

Posted: Sun Aug 23, 2020 8:59 am
by andreykrasnodar
salvadordf wrote: Sat Aug 22, 2020 3:05 pm OldCEF4Delphi with the 2623 branch of CEF is here :
https://github.com/salvadordf/OldCEF4Delphi
I have installed this component and now there are too many errors and no documentation.
For example, I have varables

Code: Select all

map: ICefStringMultimap
Request: ICefRequest;
Header: ICefStringMultimap;
, in cef3 I wrote

Code: Select all

  map := ICefStringMultimapOwn.Create;
  Request := TCefRequestRef.New;
  Header := TCefStringMultimapOwn.Create;
What is now?

Re: Unable to set referer

Posted: Sun Aug 23, 2020 9:18 am
by andreykrasnodar
Also

Code: Select all

CefSingleProcess
CefUserAgent
CefLocale
CefUserDataPath
CefCache
CefAcceptLanguageList:='ru';
TCefCookieManagerRef.Global(CefBack);
.SetStoragePath(CookiesPath, True, CefBack);

Re: Unable to set referer

Posted: Sun Aug 23, 2020 9:30 am
by salvadordf
andreykrasnodar wrote: Sun Aug 23, 2020 8:59 am
salvadordf wrote: Sat Aug 22, 2020 3:05 pm OldCEF4Delphi with the 2623 branch of CEF is here :
https://github.com/salvadordf/OldCEF4Delphi
I have installed this component and now there are too many errors and no documentation.
For example, I have varables

Code: Select all

map: ICefStringMultimap
Request: ICefRequest;
Header: ICefStringMultimap;
, in cef3 I wrote

Code: Select all

  map := ICefStringMultimapOwn.Create;
  Request := TCefRequestRef.New;
  Header := TCefStringMultimapOwn.Create;
What is now?
Now you can use the TChromium.CustomHeaderName and TChromium.CustomHeaderValue properties to set HTTP headers easily.

Here you have an example in case you still want to do it manually :
https://github.com/salvadordf/OldCEF4De ... .pas#L3179
andreykrasnodar wrote: Sun Aug 23, 2020 9:18 am Also

Code: Select all

CefSingleProcess
CefUserAgent
CefLocale
CefUserDataPath
CefCache
CefAcceptLanguageList:='ru';
TCefCookieManagerRef.Global(CefBack);
.SetStoragePath(CookiesPath, True, CefBack);
Many of those variables are now properties of GlobalCEFApp.

Use GlobalCEFApp.SingleProcess, GlobalCEFApp.UserAgent, GlobalCEFApp.Locale, GlobalCEFApp.UserDataPath, GlobalCEFApp.Cache, GlobalCEFApp.AcceptLanguageList, GlobalCEFApp.Cookies, etc.

Read this page :
https://www.briskbard.com/index.php?lang=en&pageid=cef

Most of that information is still relevant to the OldCEF4Delphi component. Also, open the SimpleBrowser and SimpleBrowser2 demos and read the code comments.

I would suggest that you take a look at the demos and pick one that is similar to what you need. Then use it as a template for your application.
If your application uses the OSR mode then perhaps you should use the SimpleOSRBrowser demo.

Be careful with the GlobalCEFApp.SingleProcess property. That mode is NOT supported by CEF and it's a known cause of issues. You should only use it for debugging purposes.

Re: Unable to set referer

Posted: Sun Aug 23, 2020 9:42 am
by salvadordf
One more thing.

OldCEF4Delphi and CEF4Delphi use the recomended settings to initialize CEF.

That means that by default you use the "multithread message loop" (known as CEF_MULTI_THREADED_MESSAGE_LOOP in dcef3) and most of the TChromium and GlobalCEFApp events are executed in a CEF thread.

As you know, VCL is not thread safe and you should not create, destroy or modify VCL controls inside those events. The demos are oversimplified and they still modify controls inside those events but you should move that code to the main application thread.

Re: Unable to set referer

Posted: Sun Aug 23, 2020 12:06 pm
by andreykrasnodar
salvadordf wrote: Sun Aug 23, 2020 9:30 am Many of those variables are now properties of GlobalCEFApp.

Use GlobalCEFApp.SingleProcess, GlobalCEFApp.UserAgent, GlobalCEFApp.Locale, GlobalCEFApp.UserDataPath, GlobalCEFApp.Cache, GlobalCEFApp.AcceptLanguageList, GlobalCEFApp.Cookies, etc.
Great! It works. Thanks.
I have compiled my project with no errors, but... it crashes after creating... Damn.

Re: Unable to set referer

Posted: Sun Aug 23, 2020 7:50 pm
by andreykrasnodar
I did it! Now it works with CEF4Delphi.
But I still can not send request.

Code: Select all

  Request.Url:='https://google.com';
  request.Method:='GET';
  request.SetReferrer('https://yahoo.com',REFERRER_POLICY_DEFAULT);
  chromium2.Browser.MainFrame.LoadRequest(Request);
cases an error
Access violation at address 006AF59D in module 'browser.exe'. Read of address 00000000.
I think because request is not created.
In earlier version I used

Code: Select all

Request := TCefRequestRef.New;
New version does not contain TCefRequestRef

Re: Unable to set referer

Posted: Mon Aug 24, 2020 12:12 pm
by Student
Ищи в отдельных модулях, uCEFRequest