1

I have an application with DCEF (Chromium Embedded).

During a browser session I want to download a specific page into memory, without displaying it in Chromium (the page to download is an xml file which I want to encrypt before writing it to disk).

The current page in Chromium should remain the same during this download.

Using crm.Browser.MainFrame.LoadUrl and crm.onBeforeDownload like so:

procedure TMainForm.crmBeforeDownload(Sender: TObject;
  const browser: ICefBrowser; const downloadItem: ICefDownloadItem;
  const suggestedName: ustring; const callback: ICefBeforeDownloadCallback);
begin
  callback.Cont(ExtractFilePath(ParamStr(0)) + 'myfile.xml', False);
end;

.. the file is written to disk.

Is there a way to get it in memory?

Martijn
  • 35
  • 7
  • 6
    Is there a particular reason you need to use Chromium to download the file? Why not just use a non-visual object, like `TIdHTTP`, from Indy? – Rob Kennedy Nov 06 '12 at 15:45
  • To be able to download the page, I need to be in the same browser session as the Chromium object. Thats why I cannot use another object. – Martijn Nov 06 '12 at 20:36
  • you can probably do it with a bit of JavaScript: add hidden (CSS Styles - `display:none`) `IFRAME` node, load it form the URL u said, then assign the node's `outerHTML` to JS string variable and then pass it outside to Delphi, then delete the node. *Note that even the page is not displayed - it would load secondary fiels such as pictures, menus and such. It was discussed around Opera's behavior of `display:none` which skipped loading the node and webmaster protested* – Arioch 'The Nov 07 '12 at 05:49
  • @Arioch 'The: I'll go with this solution. Thank you. – Martijn Nov 07 '12 at 08:50

1 Answers1

0

Use the CefWebURLRequest class to make the request. Once you receive all of the data (via the CefWebURLRequestClient::OnData callback), you can encrypt it and write it to disk.

Emerick Rogul
  • 6,706
  • 3
  • 32
  • 39