+ /* Webview */
+ if (rv) {
+ v = WEBKIT_WEB_VIEW(
+ webkit_web_view_new_with_related_view(rv));
+ } else {
+ settings = webkit_settings_new_with_settings(
+ "allow-file-access-from-file-urls", curconfig[FileURLsCrossAccess].val.i,
+ "allow-universal-access-from-file-urls", curconfig[FileURLsCrossAccess].val.i,
+ "auto-load-images", curconfig[LoadImages].val.i,
+ "default-charset", curconfig[DefaultCharset].val.v,
+ "default-font-size", curconfig[FontSize].val.i,
+ "enable-caret-browsing", curconfig[CaretBrowsing].val.i,
+ "enable-developer-extras", curconfig[Inspector].val.i,
+ "enable-dns-prefetching", curconfig[DNSPrefetch].val.i,
+ "enable-frame-flattening", curconfig[FrameFlattening].val.i,
+ "enable-html5-database", curconfig[DiskCache].val.i,
+ "enable-html5-local-storage", curconfig[DiskCache].val.i,
+ "enable-java", curconfig[Java].val.i,
+ "enable-javascript", curconfig[JavaScript].val.i,
+ "enable-plugins", curconfig[Plugins].val.i,
+ "enable-accelerated-2d-canvas", curconfig[AcceleratedCanvas].val.i,
+ "enable-site-specific-quirks", curconfig[SiteQuirks].val.i,
+ "enable-smooth-scrolling", curconfig[SmoothScrolling].val.i,
+ "enable-webgl", curconfig[WebGL].val.i,
+ "media-playback-requires-user-gesture", curconfig[MediaManualPlay].val.i,
+ NULL);
+/* For more interesting settings, have a look at
+ * http://webkitgtk.org/reference/webkit2gtk/stable/WebKitSettings.html */
+
+ if (strcmp(fulluseragent, "")) {
+ webkit_settings_set_user_agent(settings, fulluseragent);
+ } else if (surfuseragent) {
+ webkit_settings_set_user_agent_with_application_details(
+ settings, "Surf", VERSION);
+ }
+ useragent = webkit_settings_get_user_agent(settings);
+
+ contentmanager = webkit_user_content_manager_new();
+
+ context = webkit_web_context_new_with_website_data_manager(
+ webkit_website_data_manager_new(
+ "base-cache-directory", cachedir,
+ "base-data-directory", cachedir,
+ NULL));
+
+ /* rendering process model, can be a shared unique one
+ * or one for each view */
+ webkit_web_context_set_process_model(context,
+ WEBKIT_PROCESS_MODEL_MULTIPLE_SECONDARY_PROCESSES);
+ /* TLS */
+ webkit_web_context_set_tls_errors_policy(context,
+ curconfig[StrictTLS].val.i ? WEBKIT_TLS_ERRORS_POLICY_FAIL :
+ WEBKIT_TLS_ERRORS_POLICY_IGNORE);
+ /* disk cache */
+ webkit_web_context_set_cache_model(context,
+ curconfig[DiskCache].val.i ? WEBKIT_CACHE_MODEL_WEB_BROWSER :
+ WEBKIT_CACHE_MODEL_DOCUMENT_VIEWER);
+
+ /* Currently only works with text file to be compatible with curl */
+ webkit_cookie_manager_set_persistent_storage(
+ webkit_web_context_get_cookie_manager(context), cookiefile,
+ WEBKIT_COOKIE_PERSISTENT_STORAGE_TEXT);
+ /* cookie policy */
+ webkit_cookie_manager_set_accept_policy(
+ webkit_web_context_get_cookie_manager(context),
+ cookiepolicy_get());
+ /* languages */
+ webkit_web_context_set_preferred_languages(context,
+ curconfig[PreferredLanguages].val.v);
+ webkit_web_context_set_spell_checking_languages(context,
+ curconfig[SpellLanguages].val.v);
+ webkit_web_context_set_spell_checking_enabled(context,
+ curconfig[SpellChecking].val.i);
+
+ g_signal_connect(G_OBJECT(context), "download-started",
+ G_CALLBACK(downloadstarted), c);
+ g_signal_connect(G_OBJECT(context), "initialize-web-extensions",
+ G_CALLBACK(initwebextensions), c);
+
+ v = g_object_new(WEBKIT_TYPE_WEB_VIEW,
+ "settings", settings,
+ "user-content-manager", contentmanager,
+ "web-context", context,
+ NULL);
+ }
+
+ g_signal_connect(G_OBJECT(v), "notify::estimated-load-progress",
+ G_CALLBACK(progresschanged), c);
+ g_signal_connect(G_OBJECT(v), "notify::title",
+ G_CALLBACK(titlechanged), c);
+ g_signal_connect(G_OBJECT(v), "button-release-event",
+ G_CALLBACK(buttonreleased), c);
+ g_signal_connect(G_OBJECT(v), "close",
+ G_CALLBACK(closeview), c);
+ g_signal_connect(G_OBJECT(v), "create",
+ G_CALLBACK(createview), c);
+ g_signal_connect(G_OBJECT(v), "decide-policy",
+ G_CALLBACK(decidepolicy), c);
+ g_signal_connect(G_OBJECT(v), "insecure-content-detected",
+ G_CALLBACK(insecurecontent), c);
+ g_signal_connect(G_OBJECT(v), "load-failed-with-tls-errors",
+ G_CALLBACK(loadfailedtls), c);
+ g_signal_connect(G_OBJECT(v), "load-changed",
+ G_CALLBACK(loadchanged), c);
+ g_signal_connect(G_OBJECT(v), "mouse-target-changed",
+ G_CALLBACK(mousetargetchanged), c);
+ g_signal_connect(G_OBJECT(v), "permission-request",
+ G_CALLBACK(permissionrequested), c);
+ g_signal_connect(G_OBJECT(v), "ready-to-show",
+ G_CALLBACK(showview), c);
+
+ return v;