WebProcessMainGtk.cpp 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /*
  2. * Copyright (C) 2010 Apple Inc. All rights reserved.
  3. * Portions Copyright (c) 2010 Motorola Mobility, Inc. All rights reserved.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions
  7. * are met:
  8. * 1. Redistributions of source code must retain the above copyright
  9. * notice, this list of conditions and the following disclaimer.
  10. * 2. Redistributions in binary form must reproduce the above copyright
  11. * notice, this list of conditions and the following disclaimer in the
  12. * documentation and/or other materials provided with the distribution.
  13. *
  14. * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
  15. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
  16. * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  17. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
  18. * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  19. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  20. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  21. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  22. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  23. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  24. * THE POSSIBILITY OF SUCH DAMAGE.
  25. */
  26. #include "config.h"
  27. #include "WebProcessMainGtk.h"
  28. #include "WKBase.h"
  29. #include "WebKit2Initialize.h"
  30. #include <WebCore/AuthenticationChallenge.h>
  31. #include <WebCore/NetworkingContext.h>
  32. #include <WebCore/ResourceHandle.h>
  33. #include <WebCore/RunLoop.h>
  34. #include <WebKit2/WebProcess.h>
  35. #include <gtk/gtk.h>
  36. #include <libintl.h>
  37. #include <libsoup/soup.h>
  38. #include <unistd.h>
  39. #include <wtf/gobject/GOwnPtr.h>
  40. #include <wtf/gobject/GRefPtr.h>
  41. using namespace WebCore;
  42. namespace WebKit {
  43. WK_EXPORT int WebProcessMainGtk(int argc, char* argv[])
  44. {
  45. ASSERT(argc == 2);
  46. #ifndef NDEBUG
  47. if (g_getenv("WEBKIT2_PAUSE_WEB_PROCESS_ON_LAUNCH"))
  48. sleep(30);
  49. #endif
  50. gtk_init(&argc, &argv);
  51. bindtextdomain(GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
  52. bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
  53. InitializeWebKit2();
  54. int socket = atoi(argv[1]);
  55. ChildProcessInitializationParameters parameters;
  56. parameters.connectionIdentifier = socket;
  57. WebProcess::shared().initialize(parameters);
  58. // Despite using system CAs to validate certificates we're
  59. // accepting invalid certificates by default. New API will be
  60. // added later to let client accept/discard invalid certificates.
  61. SoupSession* session = WebCore::ResourceHandle::defaultSession();
  62. g_object_set(session, SOUP_SESSION_SSL_USE_SYSTEM_CA_FILE, TRUE,
  63. SOUP_SESSION_SSL_STRICT, FALSE, NULL);
  64. RunLoop::run();
  65. if (SoupSessionFeature* soupCache = soup_session_get_feature(session, SOUP_TYPE_CACHE)) {
  66. soup_cache_flush(SOUP_CACHE(soupCache));
  67. soup_cache_dump(SOUP_CACHE(soupCache));
  68. }
  69. return 0;
  70. }
  71. } // namespace WebKit