[epiphany/gnome-3-22] Make password autofill compatible with Angular forms



commit c9010256a0501459ac0b2451628d85d779ccf60f
Author: Michael Catanzaro <mcatanzaro gnome org>
Date:   Thu Oct 6 15:57:14 2016 -0500

    Make password autofill compatible with Angular forms
    
    Honestly, I have no clue what I've done here, but it's what Chromium
    does when it autofills a form, and it makes an Angular password form
    work on one of our internal sites, so it's probably good right?
    
    This is a squash of my original patch, plus three fixup commits,
    including an important regression fix by Sergio.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=772530
    https://bugzilla.gnome.org/show_bug.cgi?id=773830

 embed/web-extension/ephy-web-extension.c |   21 +++++++++++++++------
 1 files changed, 15 insertions(+), 6 deletions(-)
---
diff --git a/embed/web-extension/ephy-web-extension.c b/embed/web-extension/ephy-web-extension.c
index 0b915c3..cccb89a 100644
--- a/embed/web-extension/ephy-web-extension.c
+++ b/embed/web-extension/ephy-web-extension.c
@@ -364,20 +364,26 @@ fill_form_cb (const char *username,
               gpointer    user_data)
 {
   EphyEmbedFormAuth *form_auth = EPHY_EMBED_FORM_AUTH (user_data);
-  WebKitDOMNode *username_node;
+  WebKitDOMHTMLInputElement *username_node;
+  WebKitDOMHTMLInputElement *password_node;
 
   if (username == NULL && password == NULL) {
     LOG ("No result");
     return;
   }
 
-  username_node = ephy_embed_form_auth_get_username_node (form_auth);
+  username_node = WEBKIT_DOM_HTML_INPUT_ELEMENT (ephy_embed_form_auth_get_username_node (form_auth));
+  password_node = WEBKIT_DOM_HTML_INPUT_ELEMENT (ephy_embed_form_auth_get_password_node (form_auth));
 
   LOG ("Found: user %s pass (hidden)", username_node ? username : "(none)");
-  if (username_node)
-    g_object_set (username_node, "value", username, NULL);
-  g_object_set (ephy_embed_form_auth_get_password_node (form_auth),
-                "value", password, NULL);
+  if (username_node) {
+    g_object_set_data (G_OBJECT (username_node), "ephy-is-auto-filling", GINT_TO_POINTER (TRUE));
+    webkit_dom_html_input_element_set_auto_filled (username_node, TRUE);
+    webkit_dom_html_input_element_set_editing_value (username_node, username);
+    g_object_set_data (G_OBJECT (username_node), "ephy-is-auto-filling", GINT_TO_POINTER (FALSE));
+  }
+  webkit_dom_html_input_element_set_auto_filled (password_node, TRUE);
+  webkit_dom_html_input_element_set_editing_value (password_node, password);
 }
 
 static gint
@@ -884,6 +890,9 @@ username_node_input_cb (WebKitDOMNode  *username_node,
   WebKitDOMDocument *document;
   WebKitDOMElement *main_div;
 
+  if (g_object_get_data (G_OBJECT (username_node), "ephy-is-auto-filling"))
+    return TRUE;
+
   g_object_set_data (G_OBJECT (username_node), "ephy-user-ever-edited", GINT_TO_POINTER (TRUE));
   document = webkit_web_page_get_dom_document (web_page);
   remove_user_choices (document);


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