[epiphany] prefs-dialog: Do not use the default web context



commit 23e788dad0ea0d3a8fa9ddf18322d92ce6a52abf
Author: Michael Catanzaro <mcatanzaro gnome org>
Date:   Sun Jan 29 22:41:04 2017 -0600

    prefs-dialog: Do not use the default web context
    
    Instead, create a new web context just for the sync web view and get
    preferred languages from the Epiphany embed web context. Use
    g_object_get/set_data() as a workaround for the lack of a
    webkit_web_context_get_preferred_languages().
    
    https://bugzilla.gnome.org/show_bug.cgi?id=777736

 embed/ephy-embed-prefs.c |    8 ++++----
 src/prefs-dialog.c       |   11 +++++++++++
 2 files changed, 15 insertions(+), 4 deletions(-)
---
diff --git a/embed/ephy-embed-prefs.c b/embed/ephy-embed-prefs.c
index 78c1fc1..1f3b6fe 100644
--- a/embed/ephy-embed-prefs.c
+++ b/embed/ephy-embed-prefs.c
@@ -369,10 +369,10 @@ webkit_pref_callback_accept_languages (GSettings  *settings,
   ephy_langs_sanitise (array);
 
   webkit_web_context_set_preferred_languages (web_context, (const char * const *)(void *)array->data);
-
-  /* Set preferred languages also for the default web context, used by the sync
-   * tab in the preferences dialog. It doesn't need spellchecking. */
-  webkit_web_context_set_preferred_languages (webkit_web_context_get_default (), (const char * const *)(void 
*)array->data);
+  /* Used by the Firefox Sync web view in prefs-dialog.c. */
+  g_object_set_data_full (G_OBJECT (web_context), "preferred-languages",
+                          g_strdupv ((char **)(void *)array->data),
+                          (GDestroyNotify)g_strfreev);
 
   if (g_settings_get_boolean (EPHY_SETTINGS_WEB, EPHY_PREFS_WEB_ENABLE_SPELL_CHECKING)) {
     char **normalized = normalize_languages ((char **)(void *)array->data);
diff --git a/src/prefs-dialog.c b/src/prefs-dialog.c
index d1c16a4..23f765b 100644
--- a/src/prefs-dialog.c
+++ b/src/prefs-dialog.c
@@ -468,6 +468,9 @@ out:
 static void
 setup_fxa_sign_in_view (PrefsDialog *dialog)
 {
+  EphyEmbedShell *shell;
+  WebKitWebContext *embed_context;
+  WebKitWebContext *sync_context;
   const char *js = "\"use strict\";"
                    "function handleAccountsCommand(evt) {"
                    "  let j = {type: evt.type, detail: evt.detail};"
@@ -488,10 +491,18 @@ setup_fxa_sign_in_view (PrefsDialog *dialog)
   webkit_user_content_manager_register_script_message_handler (dialog->fxa_manager,
                                                                "accountsCommandHandler");
 
+  shell = ephy_embed_shell_get_default ();
+  embed_context = ephy_embed_shell_get_web_context (shell);
+
+  sync_context = webkit_web_context_new ();
+  webkit_web_context_set_preferred_languages (sync_context,
+                                              g_object_get_data (G_OBJECT (embed_context), 
"preferred-languages"));
   dialog->fxa_web_view = WEBKIT_WEB_VIEW (g_object_new (WEBKIT_TYPE_WEB_VIEW,
                                                         "user-content-manager", dialog->fxa_manager,
                                                         "settings", ephy_embed_prefs_get_settings (),
+                                                        "web-context", sync_context,
                                                         NULL));
+  g_object_unref (sync_context);
 
   gtk_widget_set_visible (GTK_WIDGET (dialog->fxa_web_view), TRUE);
   gtk_widget_set_size_request (GTK_WIDGET (dialog->fxa_web_view), 450, 450);


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