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; }
static void testWebContextDefault(Test* test, gconstpointer) { // Check there's a single instance of the default web context. g_assert(webkit_web_context_get_default() == webkit_web_context_get_default()); }
SecurityPolicyTest() : m_manager(webkit_web_context_get_security_manager(webkit_web_context_get_default())) { }
void registerURISchemeHandler(const char* scheme, const char* reply, int replyLength, const char* mimeType) { m_handlersMap.set(String::fromUTF8(scheme), URISchemeHandler(reply, replyLength, mimeType)); webkit_web_context_register_uri_scheme(webkit_web_context_get_default(), scheme, uriSchemeRequestCallback, this, 0); }