The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

814 lines
25KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE 6 technical preview.
  4. Copyright (c) 2017 - ROLI Ltd.
  5. You may use this code under the terms of the GPL v3
  6. (see www.gnu.org/licenses).
  7. For this technical preview, this file is not subject to commercial licensing.
  8. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  9. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  10. DISCLAIMED.
  11. ==============================================================================
  12. */
  13. namespace juce
  14. {
  15. extern int juce_gtkWebkitMain (int argc, const char* argv[]);
  16. class CommandReceiver
  17. {
  18. public:
  19. struct Responder
  20. {
  21. virtual ~Responder() {}
  22. virtual void handleCommand (const String& cmd, const var& param) = 0;
  23. virtual void receiverHadError() = 0;
  24. };
  25. CommandReceiver (Responder* responderToUse, int inputChannelToUse)
  26. : responder (responderToUse), inChannel (inputChannelToUse)
  27. {
  28. setBlocking (inChannel, false);
  29. }
  30. static void setBlocking (int fd, bool shouldBlock)
  31. {
  32. int flags = fcntl (fd, F_GETFL);
  33. fcntl (fd, F_SETFL, (shouldBlock ? (flags & ~O_NONBLOCK)
  34. : (flags | O_NONBLOCK)));
  35. }
  36. int getFd() const { return inChannel; }
  37. void tryNextRead()
  38. {
  39. for (;;)
  40. {
  41. size_t len = (receivingLength ? sizeof (size_t) : bufferLength.len);
  42. if (! receivingLength)
  43. buffer.realloc (len);
  44. char* dst = (receivingLength ? bufferLength.data : buffer.getData());
  45. ssize_t actual = read (inChannel, &dst[pos], static_cast<size_t> (len - pos));
  46. if (actual < 0)
  47. {
  48. if (errno == EINTR)
  49. continue;
  50. break;
  51. }
  52. pos += static_cast<size_t> (actual);
  53. if (pos == len)
  54. {
  55. pos = 0;
  56. if (! receivingLength)
  57. parseJSON (String (buffer.getData(), bufferLength.len));
  58. receivingLength = (! receivingLength);
  59. }
  60. }
  61. if (errno != EAGAIN && errno != EWOULDBLOCK && responder != nullptr)
  62. responder->receiverHadError();
  63. }
  64. static void sendCommand (int outChannel, const String& cmd, const var& params)
  65. {
  66. DynamicObject::Ptr obj = new DynamicObject;
  67. obj->setProperty (getCmdIdentifier(), cmd);
  68. if (! params.isVoid())
  69. obj->setProperty (getParamIdentifier(), params);
  70. String json (JSON::toString (var (obj.get())));
  71. size_t jsonLength = static_cast<size_t> (json.length());
  72. size_t len = sizeof (size_t) + jsonLength;
  73. HeapBlock<char> buffer (len);
  74. char* dst = buffer.getData();
  75. memcpy (dst, &jsonLength, sizeof (size_t));
  76. dst += sizeof (size_t);
  77. memcpy (dst, json.toRawUTF8(), jsonLength);
  78. ssize_t ret;
  79. do
  80. {
  81. ret = write (outChannel, buffer.getData(), len);
  82. } while (ret == -1 && errno == EINTR);
  83. }
  84. private:
  85. void parseJSON (const String& json)
  86. {
  87. var object (JSON::fromString (json));
  88. if (! object.isVoid())
  89. {
  90. String cmd (object.getProperty (getCmdIdentifier(), var()).toString());
  91. var params (object.getProperty (getParamIdentifier(), var()));
  92. if (responder != nullptr)
  93. responder->handleCommand (cmd, params);
  94. }
  95. }
  96. static Identifier getCmdIdentifier() { static Identifier Id ("cmd"); return Id; }
  97. static Identifier getParamIdentifier() { static Identifier Id ("params"); return Id; }
  98. Responder* responder;
  99. int inChannel;
  100. size_t pos = 0;
  101. bool receivingLength = true;
  102. union { char data [sizeof (size_t)]; size_t len; } bufferLength;
  103. HeapBlock<char> buffer;
  104. };
  105. //==============================================================================
  106. class GtkChildProcess : private CommandReceiver::Responder
  107. {
  108. public:
  109. //==============================================================================
  110. GtkChildProcess (int inChannel, int outChannelToUse)
  111. : outChannel (outChannelToUse), receiver (this, inChannel)
  112. {}
  113. typedef void (*SetHardwareAcclPolicyFunctionPtr) (WebKitSettings*, int);
  114. int entry()
  115. {
  116. CommandReceiver::setBlocking (outChannel, true);
  117. gtk_init (nullptr, nullptr);
  118. WebKitSettings* settings = webkit_settings_new();
  119. // webkit_settings_set_hardware_acceleration_policy was only added recently to webkit2
  120. // but is needed when running a WebBrowserComponent in a Parallels VM with 3D acceleration enabled
  121. auto setHardwarePolicy
  122. = reinterpret_cast<SetHardwareAcclPolicyFunctionPtr> (dlsym (RTLD_DEFAULT, "webkit_settings_set_hardware_acceleration_policy"));
  123. if (setHardwarePolicy != nullptr)
  124. setHardwarePolicy (settings, 2 /*WEBKIT_HARDWARE_ACCELERATION_POLICY_NEVER*/);
  125. GtkWidget *plug;
  126. plug = gtk_plug_new(0);
  127. GtkWidget* container;
  128. container = gtk_scrolled_window_new (nullptr, nullptr);
  129. GtkWidget* webviewWidget = webkit_web_view_new_with_settings (settings);
  130. webview = WEBKIT_WEB_VIEW (webviewWidget);
  131. gtk_container_add (GTK_CONTAINER (container), webviewWidget);
  132. gtk_container_add (GTK_CONTAINER (plug), container);
  133. webkit_web_view_load_uri (webview, "about:blank");
  134. g_signal_connect (webview, "decide-policy",
  135. G_CALLBACK (decidePolicyCallback), this);
  136. g_signal_connect (webview, "load-changed",
  137. G_CALLBACK (loadChangedCallback), this);
  138. g_signal_connect (webview, "load-failed",
  139. G_CALLBACK (loadFailedCallback), this);
  140. gtk_widget_show_all (plug);
  141. unsigned long wID = (unsigned long) gtk_plug_get_id (GTK_PLUG (plug));
  142. ssize_t ret;
  143. do {
  144. ret = write (outChannel, &wID, sizeof (wID));
  145. } while (ret == -1 && errno == EINTR);
  146. g_unix_fd_add (receiver.getFd(), G_IO_IN, pipeReadyStatic, this);
  147. receiver.tryNextRead();
  148. gtk_main();
  149. return 0;
  150. }
  151. void goToURL (const var& params)
  152. {
  153. static Identifier urlIdentifier ("url");
  154. String url (params.getProperty (urlIdentifier, var()).toString());
  155. webkit_web_view_load_uri (webview, url.toRawUTF8());
  156. }
  157. void handleDecisionResponse (const var& params)
  158. {
  159. WebKitPolicyDecision* decision
  160. = (WebKitPolicyDecision*) ((int64) params.getProperty ("decision_id", var (0)));
  161. bool allow = params.getProperty ("allow", var (false));
  162. if (decision != nullptr && decisions.contains (decision))
  163. {
  164. if (allow)
  165. webkit_policy_decision_use (decision);
  166. else
  167. webkit_policy_decision_ignore (decision);
  168. decisions.removeAllInstancesOf (decision);
  169. g_object_unref (decision);
  170. }
  171. }
  172. //==============================================================================
  173. void handleCommand (const String& cmd, const var& params) override
  174. {
  175. if (cmd == "quit") quit();
  176. else if (cmd == "goToURL") goToURL (params);
  177. else if (cmd == "goBack") webkit_web_view_go_back (webview);
  178. else if (cmd == "goForward") webkit_web_view_go_forward (webview);
  179. else if (cmd == "refresh") webkit_web_view_reload (webview);
  180. else if (cmd == "stop") webkit_web_view_stop_loading (webview);
  181. else if (cmd == "decision") handleDecisionResponse (params);
  182. }
  183. void receiverHadError() override
  184. {
  185. exit (-1);
  186. }
  187. //==============================================================================
  188. bool pipeReady (gint fd, GIOCondition)
  189. {
  190. if (fd == receiver.getFd())
  191. {
  192. receiver.tryNextRead();
  193. return true;
  194. }
  195. return false;
  196. }
  197. void quit()
  198. {
  199. gtk_main_quit();
  200. }
  201. bool onNavigation (String frameName,
  202. WebKitNavigationAction* action,
  203. WebKitPolicyDecision* decision)
  204. {
  205. if (decision != nullptr && frameName.isEmpty())
  206. {
  207. g_object_ref (decision);
  208. decisions.add (decision);
  209. DynamicObject::Ptr params = new DynamicObject;
  210. params->setProperty ("url", String (webkit_uri_request_get_uri (webkit_navigation_action_get_request (action))));
  211. params->setProperty ("decision_id", (int64) decision);
  212. CommandReceiver::sendCommand (outChannel, "pageAboutToLoad", var (params.get()));
  213. return true;
  214. }
  215. return false;
  216. }
  217. bool onNewWindow (String /*frameName*/,
  218. WebKitNavigationAction* action,
  219. WebKitPolicyDecision* decision)
  220. {
  221. if (decision != nullptr)
  222. {
  223. DynamicObject::Ptr params = new DynamicObject;
  224. params->setProperty ("url", String (webkit_uri_request_get_uri (webkit_navigation_action_get_request (action))));
  225. CommandReceiver::sendCommand (outChannel, "newWindowAttemptingToLoad", var (params.get()));
  226. // never allow new windows
  227. webkit_policy_decision_ignore (decision);
  228. return true;
  229. }
  230. return false;
  231. }
  232. void onLoadChanged (WebKitLoadEvent loadEvent)
  233. {
  234. if (loadEvent == WEBKIT_LOAD_FINISHED)
  235. {
  236. DynamicObject::Ptr params = new DynamicObject;
  237. params->setProperty ("url", String (webkit_web_view_get_uri (webview)));
  238. CommandReceiver::sendCommand (outChannel, "pageFinishedLoading", var (params.get()));
  239. }
  240. }
  241. bool onDecidePolicy (WebKitPolicyDecision* decision,
  242. WebKitPolicyDecisionType decisionType)
  243. {
  244. switch (decisionType)
  245. {
  246. case WEBKIT_POLICY_DECISION_TYPE_NAVIGATION_ACTION:
  247. {
  248. WebKitNavigationPolicyDecision* navigationDecision = WEBKIT_NAVIGATION_POLICY_DECISION (decision);
  249. const char* frameName = webkit_navigation_policy_decision_get_frame_name (navigationDecision);
  250. return onNavigation (String (frameName != nullptr ? frameName : ""),
  251. webkit_navigation_policy_decision_get_navigation_action (navigationDecision),
  252. decision);
  253. }
  254. break;
  255. case WEBKIT_POLICY_DECISION_TYPE_NEW_WINDOW_ACTION:
  256. {
  257. WebKitNavigationPolicyDecision* navigationDecision = WEBKIT_NAVIGATION_POLICY_DECISION (decision);
  258. const char* frameName = webkit_navigation_policy_decision_get_frame_name (navigationDecision);
  259. return onNewWindow (String (frameName != nullptr ? frameName : ""),
  260. webkit_navigation_policy_decision_get_navigation_action (navigationDecision),
  261. decision);
  262. }
  263. break;
  264. case WEBKIT_POLICY_DECISION_TYPE_RESPONSE:
  265. {
  266. WebKitResponsePolicyDecision *response = WEBKIT_RESPONSE_POLICY_DECISION (decision);
  267. // for now just always allow response requests
  268. ignoreUnused (response);
  269. webkit_policy_decision_use (decision);
  270. return true;
  271. }
  272. break;
  273. default:
  274. break;
  275. }
  276. return false;
  277. }
  278. void onLoadFailed (GError* error)
  279. {
  280. DynamicObject::Ptr params = new DynamicObject;
  281. params->setProperty ("error", String (error != nullptr ? error->message : "unknown error"));
  282. CommandReceiver::sendCommand (outChannel, "pageLoadHadNetworkError", var (params.get()));
  283. }
  284. private:
  285. static gboolean pipeReadyStatic (gint fd, GIOCondition condition, gpointer user)
  286. {
  287. return (reinterpret_cast<GtkChildProcess*> (user)->pipeReady (fd, condition) ? TRUE : FALSE);
  288. }
  289. static gboolean decidePolicyCallback (WebKitWebView*,
  290. WebKitPolicyDecision* decision,
  291. WebKitPolicyDecisionType decisionType,
  292. gpointer user)
  293. {
  294. GtkChildProcess& owner = *reinterpret_cast<GtkChildProcess*> (user);
  295. return (owner.onDecidePolicy (decision, decisionType) ? TRUE : FALSE);
  296. }
  297. static void loadChangedCallback (WebKitWebView*,
  298. WebKitLoadEvent loadEvent,
  299. gpointer user)
  300. {
  301. GtkChildProcess& owner = *reinterpret_cast<GtkChildProcess*> (user);
  302. owner.onLoadChanged (loadEvent);
  303. }
  304. static void loadFailedCallback (WebKitWebView*,
  305. WebKitLoadEvent /*loadEvent*/,
  306. gchar* /*failing_uri*/,
  307. GError* error,
  308. gpointer user)
  309. {
  310. GtkChildProcess& owner = *reinterpret_cast<GtkChildProcess*> (user);
  311. owner.onLoadFailed (error);
  312. }
  313. int outChannel;
  314. CommandReceiver receiver;
  315. WebKitWebView* webview = nullptr;
  316. Array<WebKitPolicyDecision*> decisions;
  317. };
  318. //==============================================================================
  319. class WebBrowserComponent::Pimpl : private Thread,
  320. private CommandReceiver::Responder
  321. {
  322. public:
  323. Pimpl (WebBrowserComponent& parent)
  324. : Thread ("Webview"), owner (parent)
  325. {}
  326. ~Pimpl() override
  327. {
  328. quit();
  329. }
  330. //==============================================================================
  331. void init()
  332. {
  333. launchChild();
  334. int ret = pipe (threadControl);
  335. ignoreUnused (ret);
  336. jassert (ret == 0);
  337. CommandReceiver::setBlocking (inChannel, true);
  338. CommandReceiver::setBlocking (outChannel, true);
  339. CommandReceiver::setBlocking (threadControl[0], false);
  340. CommandReceiver::setBlocking (threadControl[1], true);
  341. unsigned long windowHandle;
  342. ssize_t actual = read (inChannel, &windowHandle, sizeof (windowHandle));
  343. if (actual != (ssize_t) sizeof (windowHandle))
  344. {
  345. killChild();
  346. return;
  347. }
  348. receiver.reset (new CommandReceiver (this, inChannel));
  349. pfds.push_back ({ threadControl[0], POLLIN, 0 });
  350. pfds.push_back ({ receiver->getFd(), POLLIN, 0 });
  351. startThread();
  352. xembed.reset (new XEmbedComponent (windowHandle));
  353. owner.addAndMakeVisible (xembed.get());
  354. }
  355. void quit()
  356. {
  357. if (isThreadRunning())
  358. {
  359. signalThreadShouldExit();
  360. char ignore = 0;
  361. ssize_t ret;
  362. do
  363. {
  364. ret = write (threadControl[1], &ignore, 1);
  365. } while (ret == -1 && errno == EINTR);
  366. waitForThreadToExit (-1);
  367. receiver = nullptr;
  368. }
  369. if (childProcess != 0)
  370. {
  371. CommandReceiver::sendCommand (outChannel, "quit", var());
  372. killChild();
  373. }
  374. }
  375. //==============================================================================
  376. void goToURL (const String& url, const StringArray* headers, const MemoryBlock* postData)
  377. {
  378. DynamicObject::Ptr params = new DynamicObject;
  379. params->setProperty ("url", url);
  380. if (headers != nullptr)
  381. params->setProperty ("headers", var (*headers));
  382. if (postData != nullptr)
  383. params->setProperty ("postData", var (*postData));
  384. CommandReceiver::sendCommand (outChannel, "goToURL", var (params.get()));
  385. }
  386. void goBack() { CommandReceiver::sendCommand (outChannel, "goBack", var()); }
  387. void goForward() { CommandReceiver::sendCommand (outChannel, "goForward", var()); }
  388. void refresh() { CommandReceiver::sendCommand (outChannel, "refresh", var()); }
  389. void stop() { CommandReceiver::sendCommand (outChannel, "stop", var()); }
  390. void resized()
  391. {
  392. if (xembed != nullptr)
  393. xembed->setBounds (owner.getLocalBounds());
  394. }
  395. private:
  396. //==============================================================================
  397. void killChild()
  398. {
  399. if (childProcess != 0)
  400. {
  401. xembed = nullptr;
  402. int status = 0, result;
  403. result = waitpid (childProcess, &status, WNOHANG);
  404. for (int i = 0; i < 15 && (! WIFEXITED(status) || result != childProcess); ++i)
  405. {
  406. Thread::sleep (100);
  407. result = waitpid (childProcess, &status, WNOHANG);
  408. }
  409. // clean-up any zombies
  410. status = 0;
  411. if (! WIFEXITED(status) || result != childProcess)
  412. {
  413. do
  414. {
  415. kill (childProcess, SIGTERM);
  416. waitpid (childProcess, &status, 0);
  417. } while (! WIFEXITED(status));
  418. }
  419. childProcess = 0;
  420. }
  421. }
  422. void launchChild()
  423. {
  424. int ret;
  425. int inPipe[2], outPipe[2];
  426. ret = pipe (inPipe);
  427. ignoreUnused (ret); jassert (ret == 0);
  428. ret = pipe (outPipe);
  429. ignoreUnused (ret); jassert (ret == 0);
  430. int pid = fork();
  431. if (pid == 0)
  432. {
  433. close (inPipe[0]);
  434. close (outPipe[1]);
  435. HeapBlock<const char*> argv (5);
  436. StringArray arguments;
  437. arguments.add (File::getSpecialLocation (File::currentExecutableFile).getFullPathName());
  438. arguments.add ("--juce-gtkwebkitfork-child");
  439. arguments.add (String (outPipe[0]));
  440. arguments.add (String (inPipe [1]));
  441. for (int i = 0; i < arguments.size(); ++i)
  442. argv[i] = arguments[i].toRawUTF8();
  443. argv[4] = nullptr;
  444. #if JUCE_STANDALONE_APPLICATION
  445. execv (arguments[0].toRawUTF8(), (char**) argv.getData());
  446. #else
  447. juce_gtkWebkitMain (4, (const char**) argv.getData());
  448. #endif
  449. exit (0);
  450. }
  451. close (inPipe[1]);
  452. close (outPipe[0]);
  453. inChannel = inPipe[0];
  454. outChannel = outPipe[1];
  455. childProcess = pid;
  456. }
  457. void run() override
  458. {
  459. while (! threadShouldExit())
  460. {
  461. if (shouldExit())
  462. return;
  463. receiver->tryNextRead();
  464. int result = 0;
  465. while (result == 0 || (result < 0 && errno == EINTR))
  466. result = poll (&pfds.front(), static_cast<nfds_t> (pfds.size()), 0);
  467. if (result < 0)
  468. break;
  469. }
  470. }
  471. bool shouldExit()
  472. {
  473. char ignore;
  474. ssize_t result = read (threadControl[0], &ignore, 1);
  475. return (result != -1 || (errno != EAGAIN && errno != EWOULDBLOCK));
  476. }
  477. //==============================================================================
  478. void handleCommandOnMessageThread (const String& cmd, const var& params)
  479. {
  480. String url (params.getProperty ("url", var()).toString());
  481. if (cmd == "pageAboutToLoad") handlePageAboutToLoad (url, params);
  482. else if (cmd == "pageFinishedLoading") owner.pageFinishedLoading (url);
  483. else if (cmd == "windowCloseRequest") owner.windowCloseRequest();
  484. else if (cmd == "newWindowAttemptingToLoad") owner.newWindowAttemptingToLoad (url);
  485. else if (cmd == "pageLoadHadNetworkError") handlePageLoadHadNetworkError (params);
  486. threadBlocker.signal();
  487. }
  488. void handlePageAboutToLoad (const String& url, const var& inputParams)
  489. {
  490. int64 decision_id = inputParams.getProperty ("decision_id", var (0));
  491. if (decision_id != 0)
  492. {
  493. DynamicObject::Ptr params = new DynamicObject;
  494. params->setProperty ("decision_id", decision_id);
  495. params->setProperty ("allow", owner.pageAboutToLoad (url));
  496. CommandReceiver::sendCommand (outChannel, "decision", var (params.get()));
  497. }
  498. }
  499. void handlePageLoadHadNetworkError (const var& params)
  500. {
  501. String error = params.getProperty ("error", "Unknown error");
  502. if (owner.pageLoadHadNetworkError (error))
  503. goToURL (String ("data:text/plain,") + error, nullptr, nullptr);
  504. }
  505. void handleCommand (const String& cmd, const var& params) override
  506. {
  507. threadBlocker.reset();
  508. (new HandleOnMessageThread (this, cmd, params))->post();
  509. // wait until the command has executed on the message thread
  510. // this ensures that Pimpl can never be deleted while the
  511. // message has not been executed yet
  512. threadBlocker.wait (-1);
  513. }
  514. void receiverHadError() override {}
  515. //==============================================================================
  516. struct HandleOnMessageThread : public CallbackMessage
  517. {
  518. HandleOnMessageThread (Pimpl* pimpl, const String& cmdToUse, const var& params)
  519. : owner (pimpl), cmdToSend (cmdToUse), paramsToSend (params)
  520. {}
  521. void messageCallback() override
  522. {
  523. owner->handleCommandOnMessageThread (cmdToSend, paramsToSend);
  524. }
  525. Pimpl* owner;
  526. String cmdToSend;
  527. var paramsToSend;
  528. };
  529. private:
  530. WebBrowserComponent& owner;
  531. std::unique_ptr<CommandReceiver> receiver;
  532. int childProcess = 0, inChannel = 0, outChannel = 0;
  533. int threadControl[2];
  534. std::unique_ptr<XEmbedComponent> xembed;
  535. WaitableEvent threadBlocker;
  536. std::vector<pollfd> pfds;
  537. };
  538. //==============================================================================
  539. WebBrowserComponent::WebBrowserComponent (const bool unloadPageWhenBrowserIsHidden_)
  540. : browser (new Pimpl (*this)),
  541. unloadPageWhenBrowserIsHidden (unloadPageWhenBrowserIsHidden_)
  542. {
  543. ignoreUnused (blankPageShown);
  544. ignoreUnused (unloadPageWhenBrowserIsHidden);
  545. setOpaque (true);
  546. browser->init();
  547. }
  548. WebBrowserComponent::~WebBrowserComponent()
  549. {
  550. }
  551. //==============================================================================
  552. void WebBrowserComponent::goToURL (const String& url,
  553. const StringArray* headers,
  554. const MemoryBlock* postData)
  555. {
  556. lastURL = url;
  557. if (headers != nullptr)
  558. lastHeaders = *headers;
  559. else
  560. lastHeaders.clear();
  561. if (postData != nullptr)
  562. lastPostData = *postData;
  563. else
  564. lastPostData.reset();
  565. browser->goToURL (url, headers, postData);
  566. }
  567. void WebBrowserComponent::stop()
  568. {
  569. browser->stop();
  570. }
  571. void WebBrowserComponent::goBack()
  572. {
  573. lastURL.clear();
  574. browser->goBack();
  575. }
  576. void WebBrowserComponent::goForward()
  577. {
  578. lastURL.clear();
  579. browser->goForward();
  580. }
  581. void WebBrowserComponent::refresh()
  582. {
  583. browser->refresh();
  584. }
  585. //==============================================================================
  586. void WebBrowserComponent::paint (Graphics& g)
  587. {
  588. g.fillAll (Colours::white);
  589. }
  590. void WebBrowserComponent::checkWindowAssociation()
  591. {
  592. }
  593. void WebBrowserComponent::reloadLastURL()
  594. {
  595. if (lastURL.isNotEmpty())
  596. {
  597. goToURL (lastURL, &lastHeaders, &lastPostData);
  598. lastURL.clear();
  599. }
  600. }
  601. void WebBrowserComponent::parentHierarchyChanged()
  602. {
  603. checkWindowAssociation();
  604. }
  605. void WebBrowserComponent::resized()
  606. {
  607. if (browser != nullptr)
  608. browser->resized();
  609. }
  610. void WebBrowserComponent::visibilityChanged()
  611. {
  612. checkWindowAssociation();
  613. }
  614. void WebBrowserComponent::focusGained (FocusChangeType)
  615. {
  616. }
  617. void WebBrowserComponent::clearCookies()
  618. {
  619. // Currently not implemented on linux as WebBrowserComponent currently does not
  620. // store cookies on linux
  621. jassertfalse;
  622. }
  623. int juce_gtkWebkitMain (int argc, const char* argv[])
  624. {
  625. if (argc != 4) return -1;
  626. GtkChildProcess child (String (argv[2]).getIntValue(),
  627. String (argv[3]).getIntValue());
  628. return child.entry();
  629. }
  630. } // namespace juce