[epiphany] Fix popup windows in multiprocess mode



commit d8cd489e43c849c4b3e2c333f5d40218dba85e8f
Author: Carlos Garcia Campos <cgarcia igalia com>
Date:   Mon Feb 10 17:55:27 2014 +0100

    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

 embed/ephy-embed.c      |   29 ++++++++++++++++++++---------
 embed/ephy-web-view.c   |    9 +++++++++
 embed/ephy-web-view.h   |    1 +
 src/ephy-session.c      |    1 +
 src/ephy-shell.c        |   16 ++++++++++++++--
 src/ephy-shell.h        |    1 +
 src/ephy-window.c       |    2 ++
 tests/ephy-shell-test.c |    2 ++
 8 files changed, 50 insertions(+), 11 deletions(-)
---
diff --git a/embed/ephy-embed.c b/embed/ephy-embed.c
index 5fd3f5f..4360021 100644
--- a/embed/ephy-embed.c
+++ b/embed/ephy-embed.c
@@ -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),
diff --git a/embed/ephy-web-view.c b/embed/ephy-web-view.c
index 874b7d6..f4e47a9 100644
--- a/embed/ephy-web-view.c
+++ b/embed/ephy-web-view.c
@@ -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)
 {
diff --git a/embed/ephy-web-view.h b/embed/ephy-web-view.h
index 5c817eb..38cc4a5 100644
--- a/embed/ephy-web-view.h
+++ b/embed/ephy-web-view.h
@@ -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,
diff --git a/src/ephy-session.c b/src/ephy-session.c
index 0a7747b..71ff32e 100644
--- a/src/ephy-session.c
+++ b/src/ephy-session.c
@@ -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 |
diff --git a/src/ephy-shell.c b/src/ephy-shell.c
index 8bd40f2..20aa5e1 100644
--- a/src/ephy-shell.c
+++ b/src/ephy-shell.c
@@ -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,
diff --git a/src/ephy-shell.h b/src/ephy-shell.h
index cd901bb..2cb6fc8 100644
--- a/src/ephy-shell.h
+++ b/src/ephy-shell.h
@@ -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,
diff --git a/src/ephy-window.c b/src/ephy-window.c
index c174c0f..55fdf89 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -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,
diff --git a/tests/ephy-shell-test.c b/tests/ephy-shell-test.c
index a96607d..a1bea9a 100644
--- a/tests/ephy-shell-test.c
+++ b/tests/ephy-shell-test.c
@@ -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 */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]