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.

825 lines
25KB

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