WebClient.cpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #include <ThirdParty/CEF/include/cef_client.h>
  2. #include "WebBrowserHost.h"
  3. #include "WebClient.h"
  4. namespace Atomic
  5. {
  6. class WebClientPrivate : public CefClient
  7. {
  8. friend class WebClient;
  9. public:
  10. WebClientPrivate(WebClient* client)
  11. {
  12. webClient_ = client;
  13. webBrowserHost_ = webClient_->GetSubsystem<WebBrowserHost>();
  14. }
  15. CefRefPtr<CefRenderHandler> GetRenderHandler() OVERRIDE
  16. {
  17. if (webClient_->renderHandler_.Null())
  18. return nullptr;
  19. return webClient_->renderHandler_->GetCEFRenderHandler();
  20. }
  21. virtual CefRefPtr<CefLifeSpanHandler> GetLifeSpanHandler() OVERRIDE
  22. {
  23. return webBrowserHost_->GetCefLifeSpanHandler();
  24. }
  25. bool OnProcessMessageReceived(CefRefPtr<CefBrowser> browser,
  26. CefProcessId source_process,
  27. CefRefPtr<CefProcessMessage> message) OVERRIDE
  28. {
  29. return false;
  30. }
  31. IMPLEMENT_REFCOUNTING(WebClientPrivate);
  32. private:
  33. WeakPtr<WebBrowserHost> webBrowserHost_;
  34. WeakPtr<WebClient> webClient_;
  35. };
  36. WebClient::WebClient(Context* context) : Object(context)
  37. {
  38. d_ = new WebClientPrivate(this);
  39. }
  40. WebClient::~WebClient()
  41. {
  42. renderHandler_ = 0;
  43. //d_->Release();
  44. }
  45. void WebClient::SetWebRenderHandler(WebRenderHandler* handler)
  46. {
  47. renderHandler_ = handler;
  48. }
  49. }