Beispiel #1
0
 MultiprocessTest()
     : m_mainLoop(g_main_loop_new(nullptr, TRUE))
     , m_initializeWebExtensionsSignalCount(0)
     , m_webViewBusNames(numViews)
     , m_webViews(numViews)
 {
     webkit_web_context_set_process_model(m_webContext.get(), WEBKIT_PROCESS_MODEL_MULTIPLE_SECONDARY_PROCESSES);
 }
Beispiel #2
0
int main(int argc, char *argv[])
{
    gtk_init(&argc, &argv);
#if ENABLE_DEVELOPER_MODE
    g_setenv("WEBKIT_INJECTED_BUNDLE_PATH", WEBKIT_INJECTED_BUNDLE_PATH, FALSE);
#endif

    const gchar *singleprocess = g_getenv("MINIBROWSER_SINGLEPROCESS");
    webkit_web_context_set_process_model(webkit_web_context_get_default(), (singleprocess && *singleprocess) ?
        WEBKIT_PROCESS_MODEL_SHARED_SECONDARY_PROCESS : WEBKIT_PROCESS_MODEL_MULTIPLE_SECONDARY_PROCESSES);

    GOptionContext *context = g_option_context_new(NULL);
    g_option_context_add_main_entries(context, commandLineOptions, 0);
    g_option_context_add_group(context, gtk_get_option_group(TRUE));

    WebKitSettings *webkitSettings = webkit_settings_new();
    webkit_settings_set_enable_developer_extras(webkitSettings, TRUE);
    webkit_settings_set_enable_webgl(webkitSettings, TRUE);
    if (!addSettingsGroupToContext(context, webkitSettings))
        g_clear_object(&webkitSettings);

    GError *error = 0;
    if (!g_option_context_parse(context, &argc, &argv, &error)) {
        g_printerr("Cannot parse arguments: %s\n", error->message);
        g_error_free(error);
        g_option_context_free(context);

        return 1;
    }
    g_option_context_free (context);

    // Enable the favicon database, by specifying the default directory.
    webkit_web_context_set_favicon_database_directory(webkit_web_context_get_default(), NULL);

    webkit_web_context_register_uri_scheme(webkit_web_context_get_default(), miniBrowserAboutScheme, aboutURISchemeRequestCallback, NULL, NULL);

    if (uriArguments) {
        int i;

        for (i = 0; uriArguments[i]; i++)
            createBrowserWindow(uriArguments[i], webkitSettings, FALSE);
    } else
        createBrowserWindow(BROWSER_DEFAULT_URL, webkitSettings, TRUE);

    g_clear_object(&webkitSettings);

    gtk_main();

    return 0;
}
Beispiel #3
0
static void
ephy_embed_shell_setup_process_model (EphyEmbedShell *shell)
{
  EphyEmbedShellPrivate *priv = ephy_embed_shell_get_instance_private (shell);
  EphyPrefsProcessModel process_model;
  guint max_processes;

  if (ephy_embed_shell_get_mode (shell) == EPHY_EMBED_SHELL_MODE_APPLICATION)
    process_model = EPHY_PREFS_PROCESS_MODEL_SHARED_SECONDARY_PROCESS;
  else
    process_model = g_settings_get_enum (EPHY_SETTINGS_MAIN, EPHY_PREFS_PROCESS_MODEL);

  switch (process_model) {
  case EPHY_PREFS_PROCESS_MODEL_SHARED_SECONDARY_PROCESS:
    max_processes = 1;
    break;
  case EPHY_PREFS_PROCESS_MODEL_ONE_SECONDARY_PROCESS_PER_WEB_VIEW:
    max_processes = g_settings_get_uint (EPHY_SETTINGS_MAIN, EPHY_PREFS_MAX_PROCESSES);
    break;
  }

  webkit_web_context_set_process_model (priv->web_context, WEBKIT_PROCESS_MODEL_MULTIPLE_SECONDARY_PROCESSES);
  webkit_web_context_set_web_process_count_limit (priv->web_context, max_processes);
}
Beispiel #4
0
int main(int argn, char **argv)
{
    config = config_init(argn, argv);

	gtk_init(0, NULL);
    //GtkWidget * window = gtk_offscreen_window_new();
    GtkWidget * window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_window_set_default_size(GTK_WINDOW(window), 900, 600);
    GdkScreen* screen = gtk_window_get_screen(GTK_WINDOW(window));
    GdkVisual* rgba_visual = gdk_screen_get_rgba_visual(screen);
    WebKitSettings * setting;
    WebKitWebView *webView;
    if (rgba_visual) {
        gtk_widget_set_visual(window, rgba_visual);
    }
    gtk_widget_set_app_paintable(window, TRUE);

	WebKitWebContext* context = webkit_web_context_get_default();
	//webkit_web_context_set_process_model(context, WEBKIT_PROCESS_MODEL_MULTIPLE_SECONDARY_PROCESSES);
	//webkit_web_context_set_process_model(context, WEBKIT_PROCESS_MODEL_SHARED_SECONDARY_PROCESS);
	//webkit_web_context_set_cache_model(context, WEBKIT_CACHE_MODEL_WEB_BROWSER);
    webkit_web_context_set_disk_cache_directory(context, "/tmp/cache");
    webkit_web_context_set_process_model(context, WEBKIT_PROCESS_MODEL_MULTIPLE_SECONDARY_PROCESSES);
	webkit_web_context_set_cache_model(context, WEBKIT_CACHE_MODEL_DOCUMENT_VIEWER);
	webkit_web_context_set_tls_errors_policy(context, WEBKIT_TLS_ERRORS_POLICY_IGNORE);

    webkit_web_context_clear_cache(context);

	webView = WEBKIT_WEB_VIEW(
            webkit_web_view_new_with_user_content_manager(webkit_user_content_manager_new()));
    //webView =WEBKIT_WEB_VIEW(webkit_web_view_new_with_context(context));
    setting = webkit_web_view_get_settings(webView);
    webkit_settings_set_enable_page_cache(setting, false);
    webkit_settings_set_enable_javascript(setting, true);
    webkit_settings_set_enable_offline_web_application_cache(setting, false);
	//webView = WEBKIT_WEB_VIEW(webkit_web_view_new_with_settings(setting));
    g_object_set(setting,
	//	"enable-private-browsing", NanBooleanOptionValue(opts, H("private"), false),
		"enable-plugins", FALSE,
		"print-backgrounds", TRUE,
		"enable-javascript", TRUE,
		"enable-html5-database", FALSE,
		"enable-html5-local-storage", FALSE,
		"enable-java", FALSE,
		"enable-page-cache", FALSE,
		"enable-write-console-messages-to-stdout", TRUE,
		"enable-offline-web-application-cache", FALSE,
	//	"auto-load-images", NanBooleanOptionValue(opts, H("images"), true),
		"zoom-text-only", FALSE,
		"media-playback-requires-user-gesture", FALSE, // effectively disables media playback ?
	//	"user-agent", ua,
        NULL
	);

	gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(webView));
	g_signal_connect(webView, "ready-to-show", G_CALLBACK(ready_to_show), NULL);
	g_signal_connect(webView, "load-changed", G_CALLBACK(web_view_load_changed), NULL);
	g_signal_connect(webView, "web-view-ready", G_CALLBACK(ready_to_show), NULL);

    g_signal_connect(webView, "resource-load-started", G_CALLBACK(resource_started), window);

    g_signal_connect(window, "destroy", G_CALLBACK(destroyWindowCb), NULL);
    g_signal_connect(webView, "close-web-view", G_CALLBACK(closeWebViewCb), window);

    webkit_web_view_load_uri(webView, config->url);
	//gtk_widget_show_all(window);

    gtk_main();

    return 0;
}
Beispiel #5
0
int main(int argc, char *argv[])
{
    gtk_init(&argc, &argv);
    g_setenv("WEBKIT_INJECTED_BUNDLE_PATH", WEBKIT_INJECTED_BUNDLE_PATH, FALSE);

    const gchar *multiprocess = g_getenv("MINIBROWSER_MULTIPROCESS");
    if(true){//wangc force multiprocess : (multiprocess && *multiprocess) {
        webkit_web_context_set_process_model(webkit_web_context_get_default(),
            WEBKIT_PROCESS_MODEL_MULTIPLE_SECONDARY_PROCESSES);
    }

    GOptionContext *context = g_option_context_new(NULL);
    g_option_context_add_main_entries(context, commandLineOptions, 0);
    g_option_context_add_group(context, gtk_get_option_group(TRUE));

    WebKitSettings *webkitSettings = webkit_settings_new();
    InitSettingsWithFile(webkitSettings);  //Init WebKitSettings With Config File.
    webkit_settings_set_enable_developer_extras(webkitSettings, TRUE);
    webkit_settings_set_enable_webgl(webkitSettings, TRUE);
    if (!addSettingsGroupToContext(context, webkitSettings))
        g_clear_object(&webkitSettings);

    GError *error = 0;
    if (!g_option_context_parse(context, &argc, &argv, &error)) {
        g_printerr("Cannot parse arguments: %s\n", error->message);
        g_error_free(error);
        g_option_context_free(context);

        return 1;
    }
    g_option_context_free (context);

    g_assert(initCookieManager(webkitSettings));

    // Enable the favicon database, by specifying the default directory.
    webkit_web_context_set_favicon_database_directory(webkit_web_context_get_default(), NULL);

    webkit_web_context_register_uri_scheme(webkit_web_context_get_default(), miniBrowserAboutScheme, aboutURISchemeRequestCallback, NULL, NULL);

    webkit_web_context_set_tls_errors_policy(webkit_web_context_get_default(), WEBKIT_TLS_ERRORS_POLICY_IGNORE);

    if (uriArguments) {
        int i;

        for (i = 0; uriArguments[i]; i++)
            createBrowserWindow(uriArguments[i], webkitSettings);
    } else { 
        //createBrowserWindow("http://www.baidu.com/", webkitSettings);
        //createBrowserWindow("/home/zgh/CuprumBrowser/WebKitBrowser/WebKitBuild/Release/bin/resources/index.html",NULL);
        gchar indexpage[BUFSIZE] = {0};
        gchar *uri;
        gchar *strval;
        int ivalue;
        g_object_get(webkitSettings,
                 key[PROP_ON_STARTUP], &ivalue,
                 NULL);

        //default url:::  http://nfs-cloud.cn:81/appCenter/open/softcenter
        /*Depending on_startup radiobutton to loading corresponding url. sunhaiming add */
        switch (ivalue) {
        case 0:
            strcat(indexpage, get_cuprum_dir());
            strcat(indexpage, "/resources/assets/newtab.html");
            printf("%s\n", indexpage);
            uri = indexpage;
            break;
        case 1:
            uri = "http://nfs-cloud.cn:81/appCenter/open/softcenter";
            break;
        case 2:  
            g_object_get(webkitSettings,
                     key[PROP_HOME_PAGE], &strval,
                     NULL);
            if (!g_strcmp0(strval, "")) {
                uri = "http://nfs-cloud.cn:81/appCenter/open/softcenter";
            } else {
                uri = strval;
            }
            break;
        default:
            printf("error, read PROP_ON_STARTUP  ivalue = %i\n", ivalue);
            break;
        }
        createBrowserWindow(uri, webkitSettings);
    }

    g_clear_object(&webkitSettings);

    gtk_main();

    return 0;
}