Commit d8cd489e authored by Carlos Garcia Campos's avatar Carlos Garcia Campos Committed by Carlos Garcia Campos

Fix popup windows in multiprocess mode

The web views created for popups should share the same web process
than the view opening the popup. For that we use
webkit_web_view_new_with_related_view() to create the popup view.

https://bugzilla.gnome.org/show_bug.cgi?id=724052
parent 236f6ea4
......@@ -88,6 +88,7 @@ struct _EphyEmbedPrivate
enum
{
PROP_0,
PROP_WEB_VIEW,
PROP_OVERVIEW_MODE,
};
......@@ -396,6 +397,9 @@ ephy_embed_set_property (GObject *object,
switch (prop_id)
{
case PROP_WEB_VIEW:
embed->priv->web_view = g_value_get_object (value);
break;
case PROP_OVERVIEW_MODE:
ephy_embed_set_overview_mode (embed, g_value_get_boolean (value));
break;
......@@ -415,6 +419,9 @@ ephy_embed_get_property (GObject *object,
switch (prop_id)
{
case PROP_WEB_VIEW:
g_value_set_object (value, ephy_embed_get_web_view (embed));
break;
case PROP_OVERVIEW_MODE:
g_value_set_boolean (value, ephy_embed_get_overview_mode (embed));
break;
......@@ -448,6 +455,13 @@ ephy_embed_class_init (EphyEmbedClass *klass)
object_class->get_property = ephy_embed_get_property;
widget_class->grab_focus = ephy_embed_grab_focus;
g_object_class_install_property (object_class,
PROP_WEB_VIEW,
g_param_spec_object ("web-view",
"Web View",
"The WebView contained in the embed",
EPHY_TYPE_WEB_VIEW,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
/**
* EphyEmbed:overview-mode:
*
......@@ -638,7 +652,6 @@ ephy_embed_constructed (GObject *object)
EphyEmbedPrivate *priv = embed->priv;
EphyEmbedShell *shell = ephy_embed_shell_get_default ();
GtkWidget *paned;
WebKitWebView *web_view;
WebKitWebInspector *inspector;
GtkWidget *overlay;
......@@ -649,13 +662,12 @@ ephy_embed_constructed (GObject *object)
G_CALLBACK (ephy_embed_mapped_cb), NULL);
/* Skeleton */
web_view = WEBKIT_WEB_VIEW (ephy_web_view_new ());
overlay = gtk_overlay_new ();
gtk_widget_add_events (overlay,
GDK_ENTER_NOTIFY_MASK |
GDK_LEAVE_NOTIFY_MASK);
gtk_container_add (GTK_CONTAINER (overlay), GTK_WIDGET (web_view));
gtk_container_add (GTK_CONTAINER (overlay), GTK_WIDGET (priv->web_view));
/* The overview. In incognito mode we don't use it. */
if (ephy_embed_shell_get_mode (ephy_embed_shell_get_default ()) !=
......@@ -705,8 +717,7 @@ ephy_embed_constructed (GObject *object)
paned = GTK_WIDGET (priv->paned);
priv->web_view = web_view;
priv->progress_update_handler_id = g_signal_connect (web_view, "notify::estimated-load-progress",
priv->progress_update_handler_id = g_signal_connect (priv->web_view, "notify::estimated-load-progress",
G_CALLBACK (progress_update), object);
gtk_paned_pack1 (GTK_PANED (paned), GTK_WIDGET (overlay),
TRUE, FALSE);
......@@ -717,21 +728,21 @@ ephy_embed_constructed (GObject *object)
gtk_box_pack_start (GTK_BOX (embed), paned, TRUE, TRUE, 0);
gtk_widget_show (GTK_WIDGET (priv->top_widgets_vbox));
gtk_widget_show (GTK_WIDGET (web_view));
gtk_widget_show (GTK_WIDGET (priv->web_view));
gtk_widget_show_all (paned);
g_object_connect (web_view,
g_object_connect (priv->web_view,
"signal::load-changed", G_CALLBACK (load_changed_cb), embed,
"signal::enter-fullscreen", G_CALLBACK (entering_fullscreen_cb), embed,
"signal::leave-fullscreen", G_CALLBACK (leaving_fullscreen_cb), embed,
NULL);
priv->status_handler_id = g_signal_connect (web_view, "notify::status-message",
priv->status_handler_id = g_signal_connect (priv->web_view, "notify::status-message",
G_CALLBACK (status_message_notify_cb),
embed);
/* The inspector */
inspector = webkit_web_view_get_inspector (web_view);
inspector = webkit_web_view_get_inspector (priv->web_view);
g_signal_connect (inspector, "attach",
G_CALLBACK (ephy_embed_attach_inspector_cb),
......
......@@ -2043,6 +2043,15 @@ ephy_web_view_new (void)
NULL);
}
GtkWidget *
ephy_web_view_new_with_related_view (WebKitWebView *related_view)
{
return g_object_new (EPHY_TYPE_WEB_VIEW,
"related-view", related_view,
"group", ephy_embed_prefs_get_web_view_group (),
NULL);
}
static gboolean
is_public_domain (EphyWebView *view, const char *url)
{
......
......@@ -114,6 +114,7 @@ GType ephy_web_view_get_type (void);
GType ephy_web_view_chrome_get_type (void);
GType ephy_web_view_security_level_get_type (void);
GtkWidget * ephy_web_view_new (void);
GtkWidget *ephy_web_view_new_with_related_view (WebKitWebView *related_view);
void ephy_web_view_load_request (EphyWebView *view,
WebKitURIRequest *request);
void ephy_web_view_load_url (EphyWebView *view,
......
......@@ -389,6 +389,7 @@ session_maybe_open_window (EphySession *session,
if (ephy_shell_get_n_windows (shell) == 0)
{
ephy_shell_new_tab_full (shell,
NULL /* related view */,
NULL /* window */, NULL /* tab */,
NULL /* NetworkRequest */,
EPHY_NEW_TAB_IN_NEW_WINDOW |
......
......@@ -658,6 +658,7 @@ ephy_shell_get_default (void)
**/
EphyEmbed *
ephy_shell_new_tab_full (EphyShell *shell,
WebKitWebView *related_view,
EphyWindow *parent_window,
EphyEmbed *previous_embed,
WebKitURIRequest *request,
......@@ -730,7 +731,17 @@ ephy_shell_new_tab_full (EphyShell *shell,
}
if (active_is_blank == FALSE) {
embed = EPHY_EMBED (g_object_new (EPHY_TYPE_EMBED, NULL));
GtkWidget *web_view;
#ifdef HAVE_WEBKIT_WEB_VIEW_NEW_WITH_RELATED_VIEW
if (related_view)
web_view = ephy_web_view_new_with_related_view (related_view);
else
web_view = ephy_web_view_new ();
#else
web_view = ephy_web_view_new ();
#endif
embed = EPHY_EMBED (g_object_new (EPHY_TYPE_EMBED, "web-view", web_view, NULL));
g_assert (embed != NULL);
gtk_widget_show (GTK_WIDGET (embed));
......@@ -814,7 +825,7 @@ ephy_shell_new_tab (EphyShell *shell,
EphyEmbed *embed;
WebKitURIRequest *request = url ? webkit_uri_request_new (url) : NULL;
embed = ephy_shell_new_tab_full (shell, parent_window,
embed = ephy_shell_new_tab_full (shell, NULL, parent_window,
previous_embed, request, flags,
0);
......@@ -1126,6 +1137,7 @@ ephy_shell_open_uris_idle (OpenURIsData *data)
}
embed = ephy_shell_new_tab_full (ephy_shell_get_default (),
NULL,
data->window,
data->previous_embed,
request,
......
......@@ -147,6 +147,7 @@ EphyEmbed *ephy_shell_new_tab (EphyShell *shell,
EphyNewTabFlags flags);
EphyEmbed *ephy_shell_new_tab_full (EphyShell *shell,
WebKitWebView *related_view,
EphyWindow *parent_window,
EphyEmbed *previous_embed,
WebKitURIRequest *request,
......
......@@ -2049,6 +2049,7 @@ create_web_view_cb (WebKitWebView *web_view,
}
embed = ephy_shell_new_tab_full (ephy_shell_get_default (),
web_view,
parent_window,
EPHY_GET_EMBED_FROM_EPHY_WEB_VIEW (web_view),
NULL,
......@@ -2213,6 +2214,7 @@ decide_policy_cb (WebKitWebView *web_view,
(EPHY_EMBED_CONTAINER (window));
ephy_shell_new_tab_full (ephy_shell_get_default (),
NULL,
window,
embed,
request,
......
......@@ -54,6 +54,7 @@ test_ephy_shell_basic_embeds (void)
/* Both embed and window should be created. */
embed1 = ephy_shell_new_tab_full
(ephy_shell,
NULL, /* related view */
NULL, /* window */
NULL, /* embed */
NULL, /* network-request */
......@@ -71,6 +72,7 @@ test_ephy_shell_basic_embeds (void)
/* Only the embed should be created */
embed2 = ephy_shell_new_tab_full
(ephy_shell,
NULL, /* related view */
EPHY_WINDOW (window), /* window */
NULL, /* embed */
NULL, /* network-request */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment