/* * update_tabs_visibility: Hide tabs if there is only one tab * and the pref is not set or when in application mode. */ static void update_tabs_visibility (EphyNotebook *nb, gboolean before_inserting) { EphyEmbedShellMode mode; gboolean show_tabs = FALSE; guint num; EphyPrefsUITabsBarVisibilityPolicy policy; mode = ephy_embed_shell_get_mode (EPHY_EMBED_SHELL (ephy_shell_get_default ())); num = gtk_notebook_get_n_pages (GTK_NOTEBOOK (nb)); if (before_inserting) num++; policy = g_settings_get_enum (EPHY_SETTINGS_UI, EPHY_PREFS_UI_TABS_BAR_VISIBILITY_POLICY); if (mode != EPHY_EMBED_SHELL_MODE_APPLICATION && nb->adaptive_mode != EPHY_ADAPTIVE_MODE_NARROW && ((policy == EPHY_PREFS_UI_TABS_BAR_VISIBILITY_POLICY_MORE_THAN_ONE && num > 1) || policy == EPHY_PREFS_UI_TABS_BAR_VISIBILITY_POLICY_ALWAYS)) show_tabs = TRUE; /* Only show the tabs when the "tabs-allowed" property is TRUE. */ gtk_notebook_set_show_tabs (GTK_NOTEBOOK (nb), nb->tabs_allowed && show_tabs); }
static void ephy_embed_shell_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { EphyEmbedShellPrivate *priv = ephy_embed_shell_get_instance_private (EPHY_EMBED_SHELL (object)); switch (prop_id) { case PROP_MODE: g_value_set_enum (value, priv->mode); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); } }
static void ephy_embed_shell_constructed (GObject *object) { EphyEmbedShell *embed_shell; EphyEmbedShellPrivate *priv; G_OBJECT_CLASS (ephy_embed_shell_parent_class)->constructed (object); embed_shell = EPHY_EMBED_SHELL (object); priv = ephy_embed_shell_get_instance_private (embed_shell); /* These do not run the EmbedShell application instance, so make sure that there is a web context and a user content manager for them. */ if (ephy_embed_shell_get_mode (embed_shell) == EPHY_EMBED_SHELL_MODE_TEST || ephy_embed_shell_get_mode (embed_shell) == EPHY_EMBED_SHELL_MODE_SEARCH_PROVIDER) { ephy_embed_shell_create_web_context (embed_shell); priv->user_content = webkit_user_content_manager_new (); } }
static void ephy_embed_shell_dispose (GObject *object) { EphyEmbedShellPrivate *priv = ephy_embed_shell_get_instance_private (EPHY_EMBED_SHELL (object)); if (priv->update_overview_timeout_id > 0) { g_source_remove (priv->update_overview_timeout_id); priv->update_overview_timeout_id = 0; } g_clear_object (&priv->encodings); g_clear_object (&priv->page_setup); g_clear_object (&priv->print_settings); g_clear_object (&priv->global_history_service); g_clear_object (&priv->about_handler); g_clear_object (&priv->user_content); g_clear_object (&priv->downloads_manager); g_clear_object (&priv->web_context); G_OBJECT_CLASS (ephy_embed_shell_parent_class)->dispose (object); }
static void ephy_embed_shell_shutdown (GApplication* application) { EphyEmbedShellPrivate *priv = ephy_embed_shell_get_instance_private (EPHY_EMBED_SHELL (application)); G_APPLICATION_CLASS (ephy_embed_shell_parent_class)->shutdown (application); webkit_user_content_manager_unregister_script_message_handler (priv->user_content, "overview"); webkit_user_content_manager_unregister_script_message_handler (priv->user_content, "tlsErrorPage"); webkit_user_content_manager_unregister_script_message_handler (priv->user_content, "formAuthData"); webkit_user_content_manager_unregister_script_message_handler (priv->user_content, "aboutApps"); if (priv->web_extensions_page_created_signal_id > 0) { g_dbus_connection_signal_unsubscribe (priv->bus, priv->web_extensions_page_created_signal_id); priv->web_extensions_page_created_signal_id = 0; } g_list_foreach (priv->web_extensions, (GFunc)ephy_embed_shell_unwatch_web_extension, application); g_object_unref (ephy_embed_prefs_get_settings ()); ephy_embed_utils_shutdown (); }
static void ephy_embed_shell_startup (GApplication* application) { EphyEmbedShell *shell = EPHY_EMBED_SHELL (application); EphyEmbedShellPrivate *priv = ephy_embed_shell_get_instance_private (shell); char *favicon_db_path; WebKitCookieManager *cookie_manager; char *filename; char *cookie_policy; G_APPLICATION_CLASS (ephy_embed_shell_parent_class)->startup (application); /* We're not remoting, setup the Web Context if we are not running in a test. Tests already do this after construction. */ if (priv->mode != EPHY_EMBED_SHELL_MODE_TEST) ephy_embed_shell_create_web_context (embed_shell); ephy_embed_shell_setup_web_extensions_connection (shell); /* User content manager */ if (priv->mode != EPHY_EMBED_SHELL_MODE_TEST) priv->user_content = webkit_user_content_manager_new (); webkit_user_content_manager_register_script_message_handler (priv->user_content, "overview"); g_signal_connect (priv->user_content, "script-message-received::overview", G_CALLBACK (web_extension_overview_message_received_cb), shell); webkit_user_content_manager_register_script_message_handler (priv->user_content, "tlsErrorPage"); g_signal_connect (priv->user_content, "script-message-received::tlsErrorPage", G_CALLBACK (web_extension_tls_error_page_message_received_cb), shell); webkit_user_content_manager_register_script_message_handler (priv->user_content, "formAuthData"); g_signal_connect (priv->user_content, "script-message-received::formAuthData", G_CALLBACK (web_extension_form_auth_data_message_received_cb), shell); webkit_user_content_manager_register_script_message_handler (priv->user_content, "aboutApps"); g_signal_connect (priv->user_content, "script-message-received::aboutApps", G_CALLBACK (web_extension_about_apps_message_received_cb), shell); ephy_embed_shell_setup_process_model (shell); g_signal_connect (priv->web_context, "initialize-web-extensions", G_CALLBACK (initialize_web_extensions), shell); /* Favicon Database */ favicon_db_path = g_build_filename (EPHY_EMBED_SHELL_MODE_HAS_PRIVATE_PROFILE (priv->mode) ? ephy_dot_dir () : g_get_user_cache_dir (), "icondatabase", NULL); webkit_web_context_set_favicon_database_directory (priv->web_context, favicon_db_path); g_free (favicon_db_path); /* Do not ignore TLS errors. */ webkit_web_context_set_tls_errors_policy (priv->web_context, WEBKIT_TLS_ERRORS_POLICY_FAIL); /* about: URIs handler */ priv->about_handler = ephy_about_handler_new (); webkit_web_context_register_uri_scheme (priv->web_context, EPHY_ABOUT_SCHEME, (WebKitURISchemeRequestCallback)about_request_cb, shell, NULL); /* Register about scheme as local so that it can contain file resources */ webkit_security_manager_register_uri_scheme_as_local (webkit_web_context_get_security_manager (priv->web_context), EPHY_ABOUT_SCHEME); /* ephy-resource handler */ webkit_web_context_register_uri_scheme (priv->web_context, "ephy-resource", (WebKitURISchemeRequestCallback)ephy_resource_request_cb, NULL, NULL); /* Store cookies in moz-compatible SQLite format */ cookie_manager = webkit_web_context_get_cookie_manager (priv->web_context); filename = g_build_filename (ephy_dot_dir (), "cookies.sqlite", NULL); webkit_cookie_manager_set_persistent_storage (cookie_manager, filename, WEBKIT_COOKIE_PERSISTENT_STORAGE_SQLITE); g_free (filename); cookie_policy = g_settings_get_string (EPHY_SETTINGS_WEB, EPHY_PREFS_WEB_COOKIES_POLICY); ephy_embed_prefs_set_cookie_accept_policy (cookie_manager, cookie_policy); g_free (cookie_policy); }