WebClient.cpp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772
  1. #include <include/cef_app.h>
  2. #include <include/cef_client.h>
  3. #include <include/cef_browser.h>
  4. #include <include/wrapper/cef_helpers.h>
  5. #include <include/base/cef_bind.h>
  6. #include <include/wrapper/cef_closure_task.h>
  7. #include "include/wrapper/cef_message_router.h"
  8. #include <Atomic/Core/ProcessUtils.h>
  9. #include <Atomic/Core/CoreEvents.h>
  10. #include <Atomic/IO/Log.h>
  11. #include <Atomic/Input/Input.h>
  12. #include <Atomic/Graphics/Graphics.h>
  13. #include "WebBrowserHost.h"
  14. #include "WebMessageHandler.h"
  15. #include "WebClient.h"
  16. #include "WebKeyboard.h"
  17. #include "WebViewEvents.h"
  18. #include "WebString.h"
  19. #include <SDL/include/SDL.h>
  20. #include <ThirdParty/SDL/include/SDL_syswm.h>
  21. namespace Atomic
  22. {
  23. #ifdef ATOMIC_PLATFORM_OSX
  24. void* GetNSWindowContentView(void* window);
  25. #endif
  26. class WebClientPrivate : public CefClient,
  27. public CefLifeSpanHandler,
  28. public CefLoadHandler,
  29. public CefDisplayHandler,
  30. public CefRequestHandler,
  31. public CefKeyboardHandler
  32. {
  33. friend class WebClient;
  34. public:
  35. WebClientPrivate(WebClient* client)
  36. {
  37. webClient_ = client;
  38. webBrowserHost_ = webClient_->GetSubsystem<WebBrowserHost>();
  39. CefMessageRouterConfig config;
  40. config.js_query_function = "atomicQuery";
  41. config.js_cancel_function = "atomicQueryCancel";
  42. browserSideRouter_ = CefMessageRouterBrowserSide::Create(config);
  43. }
  44. virtual ~WebClientPrivate()
  45. {
  46. }
  47. CefRefPtr<CefRenderHandler> GetRenderHandler() OVERRIDE
  48. {
  49. if (webClient_->renderHandler_.Null())
  50. return nullptr;
  51. return webClient_->renderHandler_->GetCEFRenderHandler();
  52. }
  53. CefRefPtr<CefLifeSpanHandler> GetLifeSpanHandler() OVERRIDE
  54. {
  55. return this;
  56. }
  57. CefRefPtr<CefLoadHandler> GetLoadHandler() OVERRIDE
  58. {
  59. return this;
  60. }
  61. CefRefPtr<CefDisplayHandler> GetDisplayHandler() OVERRIDE
  62. {
  63. return this;
  64. }
  65. CefRefPtr<CefRequestHandler> GetRequestHandler() OVERRIDE
  66. {
  67. return this;
  68. }
  69. CefRefPtr<CefKeyboardHandler> GetKeyboardHandler() OVERRIDE
  70. {
  71. return this;
  72. }
  73. // CefKeyboardHandler
  74. virtual bool OnPreKeyEvent(CefRefPtr<CefBrowser> browser,
  75. const CefKeyEvent& event,
  76. CefEventHandle os_event,
  77. bool* is_keyboard_shortcut) OVERRIDE
  78. {
  79. return false;
  80. }
  81. // CefRequestHandler methods
  82. bool OnBeforeBrowse(CefRefPtr<CefBrowser> browser,
  83. CefRefPtr<CefFrame> frame,
  84. CefRefPtr<CefRequest> request,
  85. bool is_redirect) OVERRIDE
  86. {
  87. CEF_REQUIRE_UI_THREAD();
  88. browserSideRouter_->OnBeforeBrowse(browser, frame);
  89. return false;
  90. }
  91. bool OnProcessMessageReceived(
  92. CefRefPtr<CefBrowser> browser,
  93. CefProcessId source_process,
  94. CefRefPtr<CefProcessMessage> message) OVERRIDE
  95. {
  96. CEF_REQUIRE_UI_THREAD();
  97. if (browserSideRouter_->OnProcessMessageReceived(browser, source_process, message))
  98. {
  99. return true;
  100. }
  101. return false;
  102. }
  103. void OnRenderProcessTerminated(CefRefPtr<CefBrowser> browser,
  104. TerminationStatus status) OVERRIDE
  105. {
  106. CEF_REQUIRE_UI_THREAD();
  107. browserSideRouter_->OnRenderProcessTerminated(browser);
  108. }
  109. // CefLoadHandler
  110. void OnLoadStart(CefRefPtr<CefBrowser> browser,
  111. CefRefPtr<CefFrame> frame) OVERRIDE
  112. {
  113. if (webClient_.Null() || !frame->IsMain())
  114. return;
  115. VariantMap eventData;
  116. eventData[WebViewLoadStart::P_CLIENT] = webClient_;
  117. CefString cefURL = frame->GetURL();
  118. String url;
  119. ConvertCEFString(cefURL, url);
  120. eventData[WebViewLoadStart::P_URL] = url;
  121. webClient_->SendEvent(E_WEBVIEWLOADSTART, eventData);
  122. }
  123. void OnLoadEnd(CefRefPtr<CefBrowser> browser,
  124. CefRefPtr<CefFrame> frame,
  125. int httpStatusCode) OVERRIDE
  126. {
  127. if (webClient_.Null() || !frame->IsMain())
  128. return;
  129. VariantMap eventData;
  130. eventData[WebViewLoadEnd::P_CLIENT] = webClient_;
  131. CefString cefURL = frame->GetURL();
  132. String url;
  133. ConvertCEFString(cefURL, url);
  134. eventData[WebViewLoadEnd::P_URL] = url;
  135. webClient_->SendEvent(E_WEBVIEWLOADEND, eventData);
  136. }
  137. void OnLoadError(CefRefPtr<CefBrowser> browser,
  138. CefRefPtr<CefFrame> frame,
  139. ErrorCode errorCode,
  140. const CefString& errorText,
  141. const CefString& failedUrl) OVERRIDE
  142. {
  143. if (webClient_.Null())
  144. return;
  145. }
  146. void OnLoadingStateChange(CefRefPtr<CefBrowser> browser,
  147. bool isLoading,
  148. bool canGoBack,
  149. bool canGoForward) OVERRIDE
  150. {
  151. if (webClient_.Null())
  152. return;
  153. VariantMap eventData;
  154. eventData[WebViewLoadStateChange::P_CLIENT] = webClient_;
  155. eventData[WebViewLoadStateChange::P_LOADING] = isLoading;
  156. eventData[WebViewLoadStateChange::P_CANGOBACK] = canGoBack;
  157. eventData[WebViewLoadStateChange::P_CANGOFORWARD] = canGoForward;
  158. webClient_->SendEvent(E_WEBVIEWLOADSTATECHANGE, eventData);
  159. }
  160. // CefDisplayHandler
  161. void OnAddressChange(CefRefPtr<CefBrowser> browser,
  162. CefRefPtr<CefFrame> frame,
  163. const CefString& url) OVERRIDE
  164. {
  165. if (webClient_.Null() || !frame->IsMain())
  166. return;
  167. VariantMap eventData;
  168. eventData[WebViewAddressChange::P_CLIENT] = webClient_;
  169. String _url;
  170. ConvertCEFString(url, _url);
  171. eventData[WebViewAddressChange::P_URL] = _url;
  172. webClient_->SendEvent(E_WEBVIEWADDRESSCHANGE, eventData);
  173. }
  174. void OnTitleChange(CefRefPtr<CefBrowser> browser,
  175. const CefString& title) OVERRIDE
  176. {
  177. if (webClient_.Null())
  178. return;
  179. VariantMap eventData;
  180. eventData[WebViewTitleChange::P_CLIENT] = webClient_;
  181. String _title;
  182. ConvertCEFString(title, _title);
  183. eventData[WebViewTitleChange::P_TITLE] = _title;
  184. webClient_->SendEvent(E_WEBVIEWTITLECHANGE, eventData);
  185. }
  186. ///
  187. // Called to display a console message. Return true to stop the message from
  188. // being output to the console.
  189. ///
  190. /*--cef(optional_param=message,optional_param=source)--*/
  191. virtual bool OnConsoleMessage(CefRefPtr<CefBrowser> browser,
  192. const CefString& message,
  193. const CefString& source,
  194. int line) OVERRIDE
  195. {
  196. if (webClient_.Null())
  197. return false;
  198. String _message;
  199. ConvertCEFString(message, _message);
  200. String _source;
  201. ConvertCEFString(source, _source);
  202. LOGINFOF("WebViewJS: %s (%s:%i)", _message.CString(), _source.CString(), line);
  203. return false;
  204. }
  205. bool CreateBrowser(const String& initialURL, int width, int height)
  206. {
  207. if (webClient_->renderHandler_.Null())
  208. {
  209. LOGERROR("WebClient::CreateBrowser - No render handler specified");
  210. return false;
  211. }
  212. CefWindowInfo windowInfo;
  213. CefBrowserSettings browserSettings;
  214. browserSettings.webgl = STATE_ENABLED;
  215. browserSettings.file_access_from_file_urls = STATE_ENABLED;
  216. browserSettings.universal_access_from_file_urls = STATE_ENABLED;
  217. windowInfo.width = width;
  218. windowInfo.height = height;
  219. Graphics* graphics = webClient_->GetSubsystem<Graphics>();
  220. SDL_Window* sdlWindow = static_cast<SDL_Window*>(graphics->GetSDLWindow());
  221. SDL_SysWMinfo info;
  222. SDL_VERSION(&info.version);
  223. if(SDL_GetWindowWMInfo(sdlWindow, &info))
  224. {
  225. #ifdef ATOMIC_PLATFORM_OSX
  226. NSView* view = (NSView*) GetNSWindowContentView(info.info.cocoa.window);
  227. windowInfo.SetAsWindowless(view, false);
  228. #endif
  229. #ifdef ATOMIC_PLATFORM_WINDOWS
  230. windowInfo.SetAsWindowless(info.info.win.window, false);
  231. #endif
  232. webClient_->renderHandler_->SetSize(width, height);
  233. CefRefPtr<CefBrowser> browser = CefBrowserHost::CreateBrowserSync(windowInfo, this,
  234. initialURL.CString(), browserSettings, nullptr);
  235. if (!browser.get())
  236. return false;
  237. browser_ = browser;
  238. return true;
  239. }
  240. return false;
  241. }
  242. // CefLifeSpanHandler methods:
  243. virtual void OnAfterCreated(CefRefPtr<CefBrowser> browser) OVERRIDE
  244. {
  245. CEF_REQUIRE_UI_THREAD();
  246. }
  247. virtual bool DoClose(CefRefPtr<CefBrowser> browser) OVERRIDE
  248. {
  249. return false;
  250. }
  251. virtual void OnBeforeClose(CefRefPtr<CefBrowser> browser) OVERRIDE
  252. {
  253. CEF_REQUIRE_UI_THREAD();
  254. browser_ = nullptr;
  255. }
  256. void CloseBrowser(bool force_close)
  257. {
  258. if (!CefCurrentlyOn(TID_UI))
  259. {
  260. // Execute on the UI thread.
  261. CefPostTask(TID_UI,
  262. base::Bind(&WebClientPrivate::CloseBrowser, this, force_close));
  263. return;
  264. }
  265. if (!browser_.get())
  266. return;
  267. browser_->GetHost()->CloseBrowser(force_close);
  268. }
  269. IMPLEMENT_REFCOUNTING(WebClientPrivate);
  270. private:
  271. CefRefPtr<CefBrowser> browser_;
  272. WeakPtr<WebBrowserHost> webBrowserHost_;
  273. WeakPtr<WebClient> webClient_;
  274. CefRefPtr<CefMessageRouterBrowserSide> browserSideRouter_;
  275. };
  276. WebClient::WebClient(Context* context) : Object(context)
  277. {
  278. d_ = new WebClientPrivate(this);
  279. }
  280. WebClient::~WebClient()
  281. {
  282. if (d_)
  283. {
  284. List<SharedPtr<WebMessageHandler>>::Iterator itr = messageHandlers_.Begin();
  285. while (itr != messageHandlers_.End())
  286. {
  287. CefMessageRouterBrowserSide::Handler* handler = static_cast<CefMessageRouterBrowserSide::Handler*>((*itr)->GetCefHandler());
  288. d_->browserSideRouter_->RemoveHandler(handler);
  289. itr++;
  290. }
  291. d_->CloseBrowser(true);
  292. }
  293. renderHandler_ = 0;
  294. //d_->Release();
  295. }
  296. void WebClient::SendMouseClickEvent(int x, int y, unsigned button, bool mouseUp, unsigned modifier, int clickCount) const
  297. {
  298. if (!d_->browser_.get())
  299. return;
  300. CefRefPtr<CefBrowserHost> host = d_->browser_->GetHost();
  301. CefMouseEvent mevent;
  302. mevent.x = x;
  303. mevent.y = y;
  304. mevent.modifiers = 0;
  305. //MBT_LEFT = 0,
  306. //MBT_MIDDLE,
  307. //MBT_RIGHT,
  308. host->SendMouseClickEvent(mevent, (CefBrowserHost::MouseButtonType) button, mouseUp, clickCount);
  309. }
  310. void WebClient::SendMousePressEvent(int x, int y, unsigned button, unsigned modifier, int clickCount) const
  311. {
  312. SendMouseClickEvent(x, y, button, false, modifier, clickCount);
  313. SendMouseClickEvent(x, y, button, true, modifier, clickCount);
  314. }
  315. void WebClient::SendMouseMoveEvent(int x, int y, unsigned modifier, bool mouseLeave) const
  316. {
  317. if (!d_->browser_.get())
  318. return;
  319. CefRefPtr<CefBrowserHost> host = d_->browser_->GetHost();
  320. CefMouseEvent mevent;
  321. mevent.x = x;
  322. mevent.y = y;
  323. mevent.modifiers = 0;
  324. Input* input = GetSubsystem<Input>();
  325. if (input->GetMouseButtonDown(MOUSEB_LEFT))
  326. mevent.modifiers |= EVENTFLAG_LEFT_MOUSE_BUTTON;
  327. if (input->GetMouseButtonDown(MOUSEB_MIDDLE))
  328. mevent.modifiers |= EVENTFLAG_MIDDLE_MOUSE_BUTTON;
  329. if (input->GetMouseButtonDown(MOUSEB_RIGHT))
  330. mevent.modifiers |= EVENTFLAG_RIGHT_MOUSE_BUTTON;
  331. host->SendMouseMoveEvent(mevent, mouseLeave);
  332. }
  333. void WebClient::SendMouseWheelEvent(int x, int y, unsigned modifier,int deltaX, int deltaY) const
  334. {
  335. if (!d_->browser_.get())
  336. return;
  337. CefRefPtr<CefBrowserHost> host = d_->browser_->GetHost();
  338. CefMouseEvent mevent;
  339. mevent.x = x;
  340. mevent.y = y;
  341. mevent.modifiers = 0;
  342. deltaY = -deltaY * 5;
  343. #ifndef ATOMIC_PLATFORM_OSX
  344. deltaY *= 5;
  345. #endif
  346. host->SendMouseWheelEvent(mevent, deltaX, deltaY);
  347. }
  348. /*
  349. EVENTFLAG_CAPS_LOCK_ON = 1 << 0,
  350. EVENTFLAG_SHIFT_DOWN = 1 << 1,
  351. EVENTFLAG_CONTROL_DOWN = 1 << 2,
  352. EVENTFLAG_ALT_DOWN = 1 << 3,
  353. EVENTFLAG_LEFT_MOUSE_BUTTON = 1 << 4,
  354. EVENTFLAG_MIDDLE_MOUSE_BUTTON = 1 << 5,
  355. EVENTFLAG_RIGHT_MOUSE_BUTTON = 1 << 6,
  356. // Mac OS-X command key.
  357. EVENTFLAG_COMMAND_DOWN = 1 << 7,
  358. EVENTFLAG_NUM_LOCK_ON = 1 << 8,
  359. EVENTFLAG_IS_KEY_PAD = 1 << 9,
  360. EVENTFLAG_IS_LEFT = 1 << 10,
  361. EVENTFLAG_IS_RIGHT = 1 << 11,
  362. } cef_event_flags_t;
  363. */
  364. void WebClient::SendKeyEvent(const StringHash eventType, VariantMap& eventData)
  365. {
  366. if (!d_->browser_.get())
  367. return;
  368. CefRefPtr<CefBrowserHost> host = d_->browser_->GetHost();
  369. CefKeyEvent keyEvent;
  370. if (!ConvertKeyEvent(GetSubsystem<Input>(), eventType, eventData, keyEvent))
  371. return;
  372. host->SendKeyEvent(keyEvent);
  373. #ifdef ATOMIC_PLATFORM_WINDOWS
  374. // RETURN KEY: We need to send both keydown and char for return key
  375. // this allows it to be used both to confirm entry on popups,
  376. // while also being used for text input
  377. if (keyEvent.windows_key_code == 13)
  378. {
  379. keyEvent.type = KEYEVENT_CHAR;
  380. host->SendKeyEvent(keyEvent);
  381. }
  382. #endif
  383. #ifdef ATOMIC_PLATFORM_OSX
  384. // RETURN KEY: We need to send both keydown and char for return key
  385. // this allows it to be used both to confirm entry on popups,
  386. // while also being used for text input
  387. if (keyEvent.native_key_code == 36)
  388. {
  389. keyEvent.type = KEYEVENT_CHAR;
  390. host->SendKeyEvent(keyEvent);
  391. }
  392. // Send an empty key event on OSX, which seems to fix
  393. // keyboard problems on OSX with cefclient
  394. // ./cefclient --off-screen-rendering-enabled
  395. // return does not work at all on cef client with offscreen
  396. // bad interaction with arrow keys (for example here, after
  397. // hitting arrow keys, return/text takes a couple presses to register
  398. memset((void*)&keyEvent, 0, sizeof(keyEvent));
  399. keyEvent.type = KEYEVENT_KEYDOWN;
  400. keyEvent.modifiers = 0;
  401. keyEvent.native_key_code = 0;
  402. host->SendKeyEvent(keyEvent);
  403. #endif
  404. }
  405. void WebClient::SendTextInputEvent(const StringHash eventType, VariantMap& eventData)
  406. {
  407. if (!d_->browser_.get())
  408. return;
  409. CefRefPtr<CefBrowserHost> host = d_->browser_->GetHost();
  410. CefKeyEvent keyEvent;
  411. if (!ConvertTextInputEvent(eventType, eventData, keyEvent))
  412. return;
  413. host->SendKeyEvent(keyEvent);
  414. }
  415. void WebClient::SendFocusEvent(bool focus)
  416. {
  417. if (!d_->browser_.get())
  418. return;
  419. CefRefPtr<CefBrowserHost> host = d_->browser_->GetHost();
  420. host->SendFocusEvent(focus);
  421. }
  422. // Javascript
  423. void WebClient::ExecuteJavaScript(const String& script)
  424. {
  425. if (!d_->browser_.get())
  426. return;
  427. d_->browser_->GetMainFrame()->ExecuteJavaScript(CefString(script.CString()), "", 0);
  428. }
  429. void WebClient::AddMessageHandler(WebMessageHandler* handler, bool first)
  430. {
  431. SharedPtr<WebMessageHandler> _handler(handler);
  432. if (handler->GetWebClient())
  433. {
  434. LOGWARNING("WebClient::AddMessageHandler - message handler already added to another client");
  435. return;
  436. }
  437. if (messageHandlers_.Contains(_handler))
  438. {
  439. LOGWARNING("WebClient::AddMessageHandler - message handler already added to this client");
  440. return;
  441. }
  442. _handler->SetWebClient(this);
  443. messageHandlers_.Push(_handler);
  444. d_->browserSideRouter_->AddHandler(static_cast<CefMessageRouterBrowserSide::Handler*>(handler->GetCefHandler()), first);
  445. }
  446. void WebClient::RemoveMessageHandler(WebMessageHandler* handler)
  447. {
  448. SharedPtr<WebMessageHandler> _handler(handler);
  449. List<SharedPtr<WebMessageHandler>>::Iterator itr = messageHandlers_.Find(_handler);
  450. if (itr == messageHandlers_.End())
  451. {
  452. LOGWARNING("WebClient::RemoveMessageHandler - message handler not found");
  453. return;
  454. }
  455. d_->browserSideRouter_->RemoveHandler(static_cast<CefMessageRouterBrowserSide::Handler*>(handler->GetCefHandler()));
  456. messageHandlers_.Erase(itr);
  457. }
  458. // Navigation
  459. void WebClient::LoadURL(const String& url)
  460. {
  461. if (!d_->browser_.get())
  462. {
  463. return;
  464. }
  465. CefString _url(url.CString());
  466. d_->browser_->GetMainFrame()->LoadURL(_url);
  467. }
  468. void WebClient::GoBack()
  469. {
  470. if (!d_->browser_.get())
  471. return;
  472. d_->browser_->GoBack();
  473. }
  474. void WebClient::GoForward()
  475. {
  476. if (!d_->browser_.get())
  477. return;
  478. d_->browser_->GoForward();
  479. }
  480. bool WebClient::IsLoading()
  481. {
  482. if (!d_->browser_.get())
  483. return false;
  484. return d_->browser_->IsLoading();
  485. }
  486. void WebClient::Reload()
  487. {
  488. if (!d_->browser_.get())
  489. return;
  490. d_->browser_->Reload();
  491. }
  492. void WebClient::ShortcutCut()
  493. {
  494. if (!d_->browser_.get())
  495. return;
  496. d_->browser_->GetFocusedFrame()->Cut();
  497. }
  498. void WebClient::ShortcutCopy()
  499. {
  500. if (!d_->browser_.get())
  501. return;
  502. d_->browser_->GetFocusedFrame()->Copy();
  503. }
  504. void WebClient::ShortcutPaste()
  505. {
  506. if (!d_->browser_.get())
  507. return;
  508. d_->browser_->GetFocusedFrame()->Paste();
  509. }
  510. void WebClient::ShortcutSelectAll()
  511. {
  512. if (!d_->browser_.get())
  513. return;
  514. d_->browser_->GetFocusedFrame()->SelectAll();
  515. }
  516. void WebClient::ShortcutUndo()
  517. {
  518. if (!d_->browser_.get())
  519. return;
  520. d_->browser_->GetFocusedFrame()->Undo();
  521. }
  522. void WebClient::ShortcutRedo()
  523. {
  524. if (!d_->browser_.get())
  525. return;
  526. d_->browser_->GetFocusedFrame()->Redo();
  527. }
  528. void WebClient::ShortcutDelete()
  529. {
  530. if (!d_->browser_.get())
  531. return;
  532. d_->browser_->GetFocusedFrame()->Delete();
  533. }
  534. void WebClient::WasResized()
  535. {
  536. if (!d_->browser_.get())
  537. return;
  538. CefRefPtr<CefBrowserHost> host = d_->browser_->GetHost();
  539. host->WasResized();;
  540. }
  541. bool WebClient::CreateBrowser(const String& initialURL, int width, int height)
  542. {
  543. bool result = d_->CreateBrowser(initialURL, width, height);
  544. return result;
  545. }
  546. void WebClient::SetSize(int width, int height)
  547. {
  548. if (renderHandler_.Null())
  549. return;
  550. if (renderHandler_->GetWidth() == width && renderHandler_->GetHeight() == height)
  551. return;
  552. renderHandler_->SetSize(width, height);
  553. WasResized();
  554. }
  555. void WebClient::SetWebRenderHandler(WebRenderHandler* handler)
  556. {
  557. handler->SetWebClient(this);
  558. renderHandler_ = handler;
  559. }
  560. CefClient* WebClient::GetCefClient()
  561. {
  562. return d_;
  563. }
  564. }