[gnome-online-accounts] oauth: Remove support for using an external browser



commit bfe9de9586a1a726480142b25ad5c4c9996353ab
Author: Debarshi Ray <debarshir gnome org>
Date:   Wed May 21 16:26:32 2014 +0200

    oauth: Remove support for using an external browser
    
    We really do want to use the embedded web view, and we have never used
    the external browser option in any provider that is worth using. Now
    that we are giving the dialogs a facelift by using header bars, it is a
    good opportunity to also get rid of this unused code because there is
    no way to test it.
    
    Fixes: https://bugzilla.gnome.org/729638

 doc/goa-sections.txt               |    1 -
 src/goabackend/goaflickrprovider.c |    9 ---
 src/goabackend/goaoauthprovider.c  |  136 +++++------------------------------
 src/goabackend/goaoauthprovider.h  |    3 -
 src/goabackend/goayahooprovider.c  |    7 --
 5 files changed, 20 insertions(+), 136 deletions(-)
---
diff --git a/doc/goa-sections.txt b/doc/goa-sections.txt
index 11d679d..fc4f62c 100644
--- a/doc/goa-sections.txt
+++ b/doc/goa-sections.txt
@@ -513,7 +513,6 @@ goa_oauth_provider_get_callback_uri
 goa_oauth_provider_get_consumer_key
 goa_oauth_provider_get_consumer_secret
 goa_oauth_provider_build_authorization_uri
-goa_oauth_provider_get_use_external_browser
 goa_oauth_provider_get_use_mobile_browser
 goa_oauth_provider_is_deny_node
 goa_oauth_provider_is_identity_node
diff --git a/src/goabackend/goaflickrprovider.c b/src/goabackend/goaflickrprovider.c
index 3b2009a..8132be4 100644
--- a/src/goabackend/goaflickrprovider.c
+++ b/src/goabackend/goaflickrprovider.c
@@ -393,14 +393,6 @@ build_object (GoaProvider         *provider,
 
 /* ---------------------------------------------------------------------------------------------------- */
 
-static gboolean
-get_use_external_browser (GoaOAuthProvider *provider)
-{
-  return FALSE;
-}
-
-/* ---------------------------------------------------------------------------------------------------- */
-
 static void
 show_account (GoaProvider         *provider,
               GoaClient           *client,
@@ -464,7 +456,6 @@ goa_flickr_provider_class_init (GoaFlickrProviderClass *klass)
   oauth_class->get_token_uri            = get_token_uri;
   oauth_class->get_callback_uri         = get_callback_uri;
   oauth_class->get_authentication_cookie = get_authentication_cookie;
-  oauth_class->get_use_external_browser = get_use_external_browser;
   oauth_class->parse_request_token_error = parse_request_token_error;
   oauth_class->add_account_key_values    = add_account_key_values;
 }
diff --git a/src/goabackend/goaoauthprovider.c b/src/goabackend/goaoauthprovider.c
index 2a262a9..f0dc5e9 100644
--- a/src/goabackend/goaoauthprovider.c
+++ b/src/goabackend/goaoauthprovider.c
@@ -86,40 +86,6 @@ is_authorization_error (GError *error)
 /* ---------------------------------------------------------------------------------------------------- */
 
 static gboolean
-goa_oauth_provider_get_use_external_browser_default (GoaOAuthProvider  *provider)
-{
-  return FALSE;
-}
-
-/**
- * goa_oauth_provider_get_use_external_browser:
- * @provider: A #GoaOAuthProvider.
- *
- * Returns whether an external browser (the users default browser)
- * should be used for user interaction.
- *
- * If an external browser is used, then the dialogs presented in
- * goa_provider_add_account() and
- * goa_provider_refresh_account() will show a simple "Paste
- * authorization code here" instructions along with an entry and
- * button.
- *
- * This is a virtual method where the default implementation returns
- * %FALSE.
- *
- * Returns: %TRUE if the user interaction should happen in an external
- * browser, %FALSE to use an embedded browser widget.
- */
-gboolean
-goa_oauth_provider_get_use_external_browser (GoaOAuthProvider *provider)
-{
-  g_return_val_if_fail (GOA_IS_OAUTH_PROVIDER (provider), FALSE);
-  return GOA_OAUTH_PROVIDER_GET_CLASS (provider)->get_use_external_browser (provider);
-}
-
-/* ---------------------------------------------------------------------------------------------------- */
-
-static gboolean
 goa_oauth_provider_get_use_mobile_browser_default (GoaOAuthProvider  *provider)
 {
   return FALSE;
@@ -815,19 +781,6 @@ on_web_view_navigation_policy_decision_requested (WebKitWebView             *web
 }
 
 static void
-on_entry_changed (GtkEditable *editable,
-                  gpointer     user_data)
-{
-  IdentifyData *data = user_data;
-  gboolean sensitive;
-
-  g_free (data->oauth_verifier);
-  data->oauth_verifier = g_strdup (gtk_entry_get_text (GTK_ENTRY (editable)));
-  sensitive = data->oauth_verifier != NULL && (strlen (data->oauth_verifier) > 0);
-  gtk_dialog_set_response_sensitive (data->dialog, GTK_RESPONSE_OK, sensitive);
-}
-
-static void
 rest_proxy_call_cb (RestProxyCall *call, const GError *error, GObject *weak_object, gpointer user_data)
 {
   IdentifyData *data = user_data;
@@ -857,9 +810,10 @@ get_tokens_and_identity (GoaOAuthProvider *provider,
   RestProxy *proxy;
   RestProxyCall *call;
   GHashTable *f;
+  GtkWidget *embed;
   GtkWidget *grid;
   GtkWidget *spinner;
-  gboolean use_external_browser;
+  GtkWidget *web_view;
   gchar **request_params;
   guint n;
 
@@ -877,8 +831,6 @@ get_tokens_and_identity (GoaOAuthProvider *provider,
   url = NULL;
   request_params = NULL;
 
-  use_external_browser = goa_oauth_provider_get_use_external_browser (provider);
-
   /* TODO: check with NM whether we're online, if not - return error */
 
   memset (&data, '\0', sizeof (IdentifyData));
@@ -892,10 +844,7 @@ get_tokens_and_identity (GoaOAuthProvider *provider,
                            goa_oauth_provider_get_request_uri (provider), FALSE);
   call = rest_proxy_new_call (proxy);
   rest_proxy_call_set_method (call, "POST");
-  if (use_external_browser)
-    rest_proxy_call_add_param (call, "oauth_callback", "oob");
-  else
-    rest_proxy_call_add_param (call, "oauth_callback", goa_oauth_provider_get_callback_uri (provider));
+  rest_proxy_call_add_param (call, "oauth_callback", goa_oauth_provider_get_callback_uri (provider));
 
   request_params = goa_oauth_provider_get_request_uri_params (provider);
   if (request_params != NULL)
@@ -964,67 +913,23 @@ get_tokens_and_identity (GoaOAuthProvider *provider,
   url = goa_oauth_provider_build_authorization_uri (provider,
                                                             goa_oauth_provider_get_authorization_uri 
(provider),
                                                             escaped_request_token);
-  if (use_external_browser)
-    {
-      GtkWidget *label;
-      GtkWidget *entry;
-      gchar *escaped_url;
-      gchar *markup;
-
-      escaped_url = g_markup_escape_text (url, -1);
-      /* Translators: The verb "Paste" is used when asking the user to paste a string from a web browser 
window */
-      markup = g_strdup_printf (_("Paste token obtained from the <a href=\"%s\">authorization page</a>:"),
-                                escaped_url);
-      g_free (escaped_url);
-
-      label = gtk_label_new (NULL);
-      gtk_label_set_markup (GTK_LABEL (label), markup);
-      g_free (markup);
-      gtk_container_add (GTK_CONTAINER (grid), label);
-      entry = gtk_entry_new ();
-      gtk_entry_set_activates_default (GTK_ENTRY (entry), TRUE);
-      gtk_container_add (GTK_CONTAINER (grid), entry);
-      gtk_widget_grab_focus (entry);
-      gtk_widget_show_all (GTK_WIDGET (vbox));
-
-      gtk_dialog_add_button (dialog, _("_OK"), GTK_RESPONSE_OK);
-      gtk_dialog_set_default_response (dialog, GTK_RESPONSE_OK);
-      gtk_dialog_set_response_sensitive (dialog, GTK_RESPONSE_OK, FALSE);
-      g_signal_connect (entry, "changed", G_CALLBACK (on_entry_changed), &data);
-
-      if (!gtk_show_uri (NULL,
-                         url,
-                         GDK_CURRENT_TIME,
-                         &data.error))
-        {
-          goto out;
-        }
-    }
-  else
-    {
-      GtkWidget *web_view;
-      GtkWidget *embed;
-
-      web_view = goa_web_view_new ();
-      gtk_widget_set_hexpand (web_view, TRUE);
-      gtk_widget_set_vexpand (web_view, TRUE);
-      embed = goa_web_view_get_view (GOA_WEB_VIEW (web_view));
-
-      if (goa_oauth_provider_get_use_mobile_browser (provider))
-        goa_web_view_fake_mobile (GOA_WEB_VIEW (web_view));
-
-      webkit_web_view_load_uri (WEBKIT_WEB_VIEW (embed), url);
-      g_signal_connect (embed,
-                        "document-load-finished",
-                        G_CALLBACK (on_web_view_document_load_finished),
-                        &data);
-      g_signal_connect (embed,
-                        "navigation-policy-decision-requested",
-                        G_CALLBACK (on_web_view_navigation_policy_decision_requested),
-                        &data);
-
-      gtk_container_add (GTK_CONTAINER (grid), web_view);
-    }
+
+  web_view = goa_web_view_new ();
+  gtk_widget_set_hexpand (web_view, TRUE);
+  gtk_widget_set_vexpand (web_view, TRUE);
+  embed = goa_web_view_get_view (GOA_WEB_VIEW (web_view));
+
+  if (goa_oauth_provider_get_use_mobile_browser (provider))
+    goa_web_view_fake_mobile (GOA_WEB_VIEW (web_view));
+
+  webkit_web_view_load_uri (WEBKIT_WEB_VIEW (embed), url);
+  g_signal_connect (embed, "document-load-finished", G_CALLBACK (on_web_view_document_load_finished), &data);
+  g_signal_connect (embed,
+                    "navigation-policy-decision-requested",
+                    G_CALLBACK (on_web_view_navigation_policy_decision_requested),
+                    &data);
+
+  gtk_container_add (GTK_CONTAINER (grid), web_view);
 
   gtk_widget_show_all (GTK_WIDGET (vbox));
   gtk_dialog_run (GTK_DIALOG (dialog));
@@ -1814,7 +1719,6 @@ goa_oauth_provider_class_init (GoaOAuthProviderClass *klass)
   provider_class->ensure_credentials_sync    = goa_oauth_provider_ensure_credentials_sync;
 
   klass->build_authorization_uri  = goa_oauth_provider_build_authorization_uri_default;
-  klass->get_use_external_browser = goa_oauth_provider_get_use_external_browser_default;
   klass->get_use_mobile_browser   = goa_oauth_provider_get_use_mobile_browser_default;
   klass->is_password_node         = goa_oauth_provider_is_password_node_default;
   klass->get_request_uri_params   = goa_oauth_provider_get_request_uri_params_default;
diff --git a/src/goabackend/goaoauthprovider.h b/src/goabackend/goaoauthprovider.h
index d62c3ae..82ca20a 100644
--- a/src/goabackend/goaoauthprovider.h
+++ b/src/goabackend/goaoauthprovider.h
@@ -68,7 +68,6 @@ struct _GoaOAuthProvider
  * @get_identity_sync: Virtual function for goa_oauth_provider_get_identity_sync().
  * @parse_request_token_error: Virtual function for goa_oauth_provider_parse_request_token_error().
  * @build_authorization_uri: Virtual function for goa_oauth_provider_build_authorization_uri().
- * @get_use_external_browser: Virtual function for goa_oauth_provider_get_use_external_browser().
  * @get_use_mobile_browser: Virtual function for goa_oauth_provider_get_use_mobile_browser().
  * @get_request_uri_params: Virtual function for goa_oauth_provider_get_request_uri_params().
  * @add_account_key_values: Virtual function for goa_oauth_provider_add_account_key_values().
@@ -105,7 +104,6 @@ struct _GoaOAuthProviderClass
   gchar       *(*build_authorization_uri)      (GoaOAuthProvider             *provider,
                                                 const gchar                  *authorization_uri,
                                                 const gchar                  *escaped_oauth_token);
-  gboolean     (*get_use_external_browser)     (GoaOAuthProvider             *provider);
   gboolean     (*get_use_mobile_browser)       (GoaOAuthProvider             *provider);
   gchar      **(*get_request_uri_params)       (GoaOAuthProvider             *provider);
   void         (*add_account_key_values)       (GoaOAuthProvider             *provider,
@@ -159,7 +157,6 @@ gchar       *goa_oauth_provider_get_access_token_sync        (GoaOAuthProvider
 gchar       *goa_oauth_provider_build_authorization_uri      (GoaOAuthProvider             *provider,
                                                               const gchar                  
*authorization_uri,
                                                               const gchar                  
*escaped_oauth_token);
-gboolean     goa_oauth_provider_get_use_external_browser     (GoaOAuthProvider             *provider);
 gboolean     goa_oauth_provider_get_use_mobile_browser       (GoaOAuthProvider             *provider);
 void         goa_oauth_provider_add_account_key_values       (GoaOAuthProvider             *provider,
                                                               GVariantBuilder              *builder);
diff --git a/src/goabackend/goayahooprovider.c b/src/goabackend/goayahooprovider.c
index 54fa24f..29a684d 100644
--- a/src/goabackend/goayahooprovider.c
+++ b/src/goabackend/goayahooprovider.c
@@ -378,12 +378,6 @@ build_object (GoaProvider         *provider,
   return ret;
 }
 
-static gboolean
-get_use_external_browser (GoaOAuthProvider *provider)
-{
-  return FALSE;
-}
-
 /* ---------------------------------------------------------------------------------------------------- */
 
 static void
@@ -435,6 +429,5 @@ goa_yahoo_provider_class_init (GoaYahooProviderClass *klass)
   oauth_class->get_token_uri            = get_token_uri;
   oauth_class->get_callback_uri         = get_callback_uri;
   oauth_class->get_authentication_cookie = get_authentication_cookie;
-  oauth_class->get_use_external_browser = get_use_external_browser;
   oauth_class->parse_request_token_error = parse_request_token_error;
 }


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