CefDownloadImageCallback.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132
  1. namespace Xilium.CefGlue
  2. {
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Diagnostics;
  6. using System.Runtime.InteropServices;
  7. using Xilium.CefGlue.Interop;
  8. /// <summary>
  9. /// Callback interface for CefBrowserHost::DownloadImage. The methods of this
  10. /// class will be called on the browser process UI thread.
  11. /// </summary>
  12. public abstract unsafe partial class CefDownloadImageCallback
  13. {
  14. private void on_download_image_finished(cef_download_image_callback_t* self, cef_string_t* image_url, int http_status_code, cef_image_t* image)
  15. {
  16. CheckSelf(self);
  17. var m_imageUrl = cef_string_t.ToString(image_url);
  18. var m_image = CefImage.FromNativeOrNull(image); // TODO dispose?
  19. OnDownloadImageFinished(m_imageUrl, http_status_code, m_image);
  20. }
  21. /// <summary>
  22. /// Method that will be executed when the image download has completed.
  23. /// |image_url| is the URL that was downloaded and |http_status_code| is the
  24. /// resulting HTTP status code. |image| is the resulting image, possibly at
  25. /// multiple scale factors, or empty if the download failed.
  26. /// </summary>
  27. protected abstract void OnDownloadImageFinished(string imageUrl, int httpStatusCode, CefImage image);
  28. }
  29. }