[epiphany] sync: Store target_origin for password records
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany] sync: Store target_origin for password records
- Date: Fri, 25 Aug 2017 18:48:34 +0000 (UTC)
commit 809b3e4c5d27227469b95b4da0047596109f0843
Author: Exalm <exalm7659 gmail com>
Date: Fri Aug 25 11:13:08 2017 +0500
sync: Store target_origin for password records
Since it matches formSubmitURL from Firefox sync spec,
rename form_submit_url field in EphyPasswordRecord
https://bugzilla.gnome.org/show_bug.cgi?id=666326
embed/web-extension/ephy-embed-form-auth.c | 11 ++++++
embed/web-extension/ephy-embed-form-auth.h | 2 +
embed/web-extension/ephy-web-extension.c | 43 ++++++++++++++++++++++--
lib/sync/ephy-password-manager.c | 51 +++++++++++++++++++--------
lib/sync/ephy-password-manager.h | 3 ++
lib/sync/ephy-password-record.c | 40 +++++++++++++++-------
lib/sync/ephy-password-record.h | 2 +
src/passwords-dialog.c | 2 +-
8 files changed, 122 insertions(+), 32 deletions(-)
---
diff --git a/embed/web-extension/ephy-embed-form-auth.c b/embed/web-extension/ephy-embed-form-auth.c
index ae36027..6a74b87 100644
--- a/embed/web-extension/ephy-embed-form-auth.c
+++ b/embed/web-extension/ephy-embed-form-auth.c
@@ -26,6 +26,7 @@ struct _EphyEmbedFormAuth {
guint64 page_id;
SoupURI *uri;
+ SoupURI *target_origin;
WebKitDOMNode *username_node;
WebKitDOMNode *password_node;
char *username;
@@ -41,6 +42,8 @@ ephy_embed_form_auth_finalize (GObject *object)
if (form_auth->uri)
soup_uri_free (form_auth->uri);
+ if (form_auth->target_origin)
+ soup_uri_free (form_auth->target_origin);
g_clear_object (&form_auth->username_node);
g_clear_object (&form_auth->password_node);
@@ -62,6 +65,7 @@ ephy_embed_form_auth_class_init (EphyEmbedFormAuthClass *klass)
EphyEmbedFormAuth *
ephy_embed_form_auth_new (WebKitWebPage *web_page,
+ const char *target_origin,
WebKitDOMNode *username_node,
WebKitDOMNode *password_node,
const char *username)
@@ -74,6 +78,7 @@ ephy_embed_form_auth_new (WebKitWebPage *web_page,
form_auth->page_id = webkit_web_page_get_id (web_page);
form_auth->uri = soup_uri_new (webkit_web_page_get_uri (web_page));
+ form_auth->target_origin = soup_uri_new (target_origin);
form_auth->username_node = username_node;
form_auth->password_node = password_node;
form_auth->username = g_strdup (username);
@@ -81,6 +86,12 @@ ephy_embed_form_auth_new (WebKitWebPage *web_page,
return form_auth;
}
+char *
+ephy_embed_form_auth_get_target_origin (EphyEmbedFormAuth *form_auth)
+{
+ return soup_uri_to_string (form_auth->target_origin, FALSE);
+}
+
WebKitDOMNode *
ephy_embed_form_auth_get_username_node (EphyEmbedFormAuth *form_auth)
{
diff --git a/embed/web-extension/ephy-embed-form-auth.h b/embed/web-extension/ephy-embed-form-auth.h
index 3266771..2725eaf 100644
--- a/embed/web-extension/ephy-embed-form-auth.h
+++ b/embed/web-extension/ephy-embed-form-auth.h
@@ -31,11 +31,13 @@ G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (EphyEmbedFormAuth, ephy_embed_form_auth, EPHY, EMBED_FORM_AUTH, GObject)
EphyEmbedFormAuth *ephy_embed_form_auth_new (WebKitWebPage *web_page,
+ const char *target_origin,
WebKitDOMNode *username_node,
WebKitDOMNode *password_node,
const char *username);
WebKitDOMNode *ephy_embed_form_auth_get_username_node (EphyEmbedFormAuth *form_auth);
WebKitDOMNode *ephy_embed_form_auth_get_password_node (EphyEmbedFormAuth *form_auth);
+char *ephy_embed_form_auth_get_target_origin (EphyEmbedFormAuth *form_auth);
SoupURI *ephy_embed_form_auth_get_uri (EphyEmbedFormAuth *form_auth);
guint64 ephy_embed_form_auth_get_page_id (EphyEmbedFormAuth *form_auth);
const char *ephy_embed_form_auth_get_username (EphyEmbedFormAuth *form_auth);
diff --git a/embed/web-extension/ephy-web-extension.c b/embed/web-extension/ephy-web-extension.c
index a9709ae..66a7812 100644
--- a/embed/web-extension/ephy-web-extension.c
+++ b/embed/web-extension/ephy-web-extension.c
@@ -266,6 +266,7 @@ store_password (EphyEmbedFormAuth *form_auth)
{
SoupURI *uri;
char *uri_str;
+ char *target_origin;
char *username_field_name = NULL;
char *username_field_value = NULL;
char *password_field_name = NULL;
@@ -287,9 +288,11 @@ store_password (EphyEmbedFormAuth *form_auth)
uri = ephy_embed_form_auth_get_uri (form_auth);
uri_str = soup_uri_to_string (uri, FALSE);
+ target_origin = ephy_embed_form_auth_get_target_origin (form_auth);
password_updated = ephy_embed_form_auth_get_password_updated (form_auth);
ephy_password_manager_save (extension->password_manager,
uri_str,
+ target_origin,
username_field_value,
password_field_value,
username_field_name,
@@ -297,6 +300,7 @@ store_password (EphyEmbedFormAuth *form_auth)
!password_updated);
g_free (uri_str);
+ g_free (target_origin);
g_free (username_field_name);
g_free (username_field_value);
g_free (password_field_name);
@@ -456,12 +460,14 @@ form_submitted_cb (WebKitDOMHTMLFormElement *dom_form,
EphyWebExtension *extension = ephy_web_extension_get ();
EphyEmbedFormAuth *form_auth;
SoupURI *uri;
+ char *target_origin;
WebKitDOMNode *username_node = NULL;
WebKitDOMNode *password_node = NULL;
char *username_field_name = NULL;
char *username_field_value = NULL;
char *password_field_name = NULL;
char *uri_str;
+ char *form_action;
if (!ephy_web_dom_utils_find_form_auth_elements (dom_form, &username_node, &password_node))
return TRUE;
@@ -472,8 +478,17 @@ form_submitted_cb (WebKitDOMHTMLFormElement *dom_form,
NULL);
}
+ form_action = webkit_dom_html_form_element_get_action (dom_form);
+ if (form_action == NULL)
+ form_action = g_strdup (webkit_web_page_get_uri (web_page));
+ target_origin = ephy_uri_to_security_origin (form_action);
+
/* EphyEmbedFormAuth takes ownership of the nodes */
- form_auth = ephy_embed_form_auth_new (web_page, username_node, password_node, username_field_value);
+ form_auth = ephy_embed_form_auth_new (web_page,
+ target_origin,
+ username_node,
+ password_node,
+ username_field_value);
uri = ephy_embed_form_auth_get_uri (form_auth);
soup_uri_set_query (uri, NULL);
@@ -485,12 +500,15 @@ form_submitted_cb (WebKitDOMHTMLFormElement *dom_form,
ephy_password_manager_query (extension->password_manager,
NULL,
uri_str,
+ target_origin,
username_field_value,
username_field_name,
password_field_name,
should_store_cb,
form_auth);
+ g_free (form_action);
+ g_free (target_origin);
g_free (username_field_name);
g_free (username_field_value);
g_free (password_field_name);
@@ -537,6 +555,7 @@ pre_fill_form (EphyEmbedFormAuth *form_auth)
{
SoupURI *uri;
char *uri_str;
+ char *target_origin;
char *username = NULL;
char *username_field_name = NULL;
char *password_field_name = NULL;
@@ -563,9 +582,12 @@ pre_fill_form (EphyEmbedFormAuth *form_auth)
if (username != NULL && g_str_equal (username, ""))
g_clear_pointer (&username, g_free);
+ target_origin = ephy_embed_form_auth_get_target_origin (form_auth);
+
ephy_password_manager_query (extension->password_manager,
NULL,
uri_str,
+ target_origin,
username,
username_field_name,
password_field_name,
@@ -573,6 +595,7 @@ pre_fill_form (EphyEmbedFormAuth *form_auth)
form_auth);
g_free (uri_str);
+ g_free (target_origin);
g_free (username);
g_free (username_field_name);
g_free (password_field_name);
@@ -1115,11 +1138,24 @@ web_page_form_controls_associated (WebKitWebPage *web_page,
EphyEmbedFormAuth *form_auth;
GList *cached_users;
const char *uri;
+ char *form_action;
+ char *target_origin;
+
+ uri = webkit_web_page_get_uri (web_page);
+
+ form_action = webkit_dom_html_form_element_get_action (form);
+ if (form_action == NULL)
+ form_action = g_strdup (uri);
+ target_origin = ephy_uri_to_security_origin (form_action);
LOG ("Hooking and pre-filling a form");
/* EphyEmbedFormAuth takes ownership of the nodes */
- form_auth = ephy_embed_form_auth_new (web_page, username_node, password_node, NULL);
+ form_auth = ephy_embed_form_auth_new (web_page,
+ target_origin,
+ username_node,
+ password_node,
+ NULL);
webkit_dom_event_target_add_event_listener (WEBKIT_DOM_EVENT_TARGET (form), "submit",
G_CALLBACK (form_submitted_cb), FALSE,
web_page);
@@ -1130,7 +1166,6 @@ web_page_form_controls_associated (WebKitWebPage *web_page,
}
/* Plug in the user autocomplete */
- uri = webkit_web_page_get_uri (web_page);
cached_users = ephy_password_manager_get_cached_users_for_uri (extension->password_manager, uri);
if (cached_users && cached_users->next && username_node) {
@@ -1158,6 +1193,8 @@ web_page_form_controls_associated (WebKitWebPage *web_page,
pre_fill_form (form_auth);
+ g_free (form_action);
+ g_free (target_origin);
g_object_weak_ref (G_OBJECT (form), form_destroyed_cb, form_auth);
} else
LOG ("No pre-fillable/hookable form found");
diff --git a/lib/sync/ephy-password-manager.c b/lib/sync/ephy-password-manager.c
index c145a8c..99a1f59 100644
--- a/lib/sync/ephy-password-manager.c
+++ b/lib/sync/ephy-password-manager.c
@@ -38,6 +38,7 @@ ephy_password_manager_get_password_schema (void)
{
{ ID_KEY, SECRET_SCHEMA_ATTRIBUTE_STRING },
{ HOSTNAME_KEY, SECRET_SCHEMA_ATTRIBUTE_STRING },
+ { TARGET_ORIGIN_KEY, SECRET_SCHEMA_ATTRIBUTE_STRING },
{ USERNAME_FIELD_KEY, SECRET_SCHEMA_ATTRIBUTE_STRING },
{ PASSWORD_FIELD_KEY, SECRET_SCHEMA_ATTRIBUTE_STRING },
{ USERNAME_KEY, SECRET_SCHEMA_ATTRIBUTE_STRING },
@@ -184,6 +185,7 @@ replace_record_async_data_free (ReplaceRecordAsyncData *data)
static GHashTable *
get_attributes_table (const char *id,
const char *uri,
+ const char *target_origin,
const char *username,
const char *username_field,
const char *password_field,
@@ -199,6 +201,10 @@ get_attributes_table (const char *id,
g_hash_table_insert (attributes,
g_strdup (HOSTNAME_KEY),
ephy_uri_to_security_origin (uri));
+ if (target_origin)
+ g_hash_table_insert (attributes,
+ g_strdup (TARGET_ORIGIN_KEY),
+ ephy_uri_to_security_origin (target_origin));
if (username)
g_hash_table_insert (attributes,
g_strdup (USERNAME_KEY),
@@ -324,7 +330,7 @@ ephy_password_manager_init (EphyPasswordManager *self)
{
LOG ("Loading usernames into internal cache...");
self->cache = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
- ephy_password_manager_query (self, NULL, NULL, NULL, NULL, NULL,
+ ephy_password_manager_query (self, NULL, NULL, NULL, NULL, NULL, NULL,
populate_cache_cb, self);
}
@@ -428,6 +434,7 @@ ephy_password_manager_store_record (EphyPasswordManager *self,
username = ephy_password_record_get_username (record);
attributes = get_attributes_table (ephy_password_record_get_id (record),
hostname,
+ ephy_password_record_get_target_origin (record),
username,
ephy_password_record_get_username_field (record),
ephy_password_record_get_password_field (record),
@@ -461,6 +468,7 @@ update_password_cb (GList *records,
void
ephy_password_manager_save (EphyPasswordManager *self,
const char *uri,
+ const char *target_origin,
const char *username,
const char *password,
const char *username_field,
@@ -475,15 +483,16 @@ ephy_password_manager_save (EphyPasswordManager *self,
g_return_if_fail (EPHY_IS_PASSWORD_MANAGER (self));
g_return_if_fail (uri);
+ g_return_if_fail (target_origin);
g_return_if_fail (password);
g_return_if_fail (!username_field || username);
g_return_if_fail (!password_field || password);
if (!is_new) {
- LOG ("Updating password for (%s, %s, %s, %s)",
- uri, username, username_field, password_field);
+ LOG ("Updating password for (%s, %s, %s, %s, %s)",
+ uri, target_origin, username, username_field, password_field);
ephy_password_manager_query (self, NULL,
- uri, username,
+ uri, target_origin, username,
username_field, password_field,
update_password_cb,
update_password_async_data_new (self, password));
@@ -494,7 +503,7 @@ ephy_password_manager_save (EphyPasswordManager *self,
id = g_strdup_printf ("{%s}", uuid);
timestamp = g_get_real_time () / 1000;
hostname = ephy_uri_to_security_origin (uri);
- record = ephy_password_record_new (id, hostname,
+ record = ephy_password_record_new (id, hostname, target_origin,
username, password,
username_field, password_field,
timestamp, timestamp);
@@ -529,6 +538,7 @@ secret_service_search_cb (SecretService *service,
SecretValue *value = secret_item_get_secret (item);
const char *id = g_hash_table_lookup (attributes, ID_KEY);
const char *hostname = g_hash_table_lookup (attributes, HOSTNAME_KEY);
+ const char *target_origin = g_hash_table_lookup (attributes, TARGET_ORIGIN_KEY);
const char *username = g_hash_table_lookup (attributes, USERNAME_KEY);
const char *username_field = g_hash_table_lookup (attributes, USERNAME_FIELD_KEY);
const char *password_field = g_hash_table_lookup (attributes, PASSWORD_FIELD_KEY);
@@ -537,10 +547,10 @@ secret_service_search_cb (SecretService *service,
double server_time_modified;
EphyPasswordRecord *record;
- LOG ("Found password record for (%s, %s, %s, %s)",
- hostname, username, username_field, password_field);
+ LOG ("Found password record for (%s, %s, %s, %s, %s)",
+ hostname, target_origin, username, username_field, password_field);
- record = ephy_password_record_new (id, hostname,
+ record = ephy_password_record_new (id, hostname, target_origin,
username, password,
username_field, password_field,
secret_item_get_created (item) * 1000,
@@ -565,6 +575,7 @@ void
ephy_password_manager_query (EphyPasswordManager *self,
const char *id,
const char *uri,
+ const char *target_origin,
const char *username,
const char *username_field,
const char *password_field,
@@ -579,7 +590,7 @@ ephy_password_manager_query (EphyPasswordManager *self,
LOG ("Querying password records for (%s, %s, %s, %s)",
uri, username, username_field, password_field);
- attributes = get_attributes_table (id, uri, username,
+ attributes = get_attributes_table (id, uri, target_origin, username,
username_field, password_field, -1);
data = query_async_data_new (callback, user_data);
@@ -610,7 +621,7 @@ ephy_password_manager_store_raw (const char *uri,
g_return_if_fail (!username_field || username);
g_return_if_fail (!password_field || password);
- attributes = get_attributes_table (NULL, uri, username,
+ attributes = get_attributes_table (NULL, uri, uri, username,
username_field, password_field, -1);
store_internal (password, attributes, callback, user_data);
@@ -660,13 +671,15 @@ ephy_password_manager_forget_record (EphyPasswordManager *self,
attributes = get_attributes_table (ephy_password_record_get_id (record),
ephy_password_record_get_hostname (record),
+ ephy_password_record_get_target_origin (record),
ephy_password_record_get_username (record),
ephy_password_record_get_username_field (record),
ephy_password_record_get_password_field (record),
-1);
- LOG ("Forgetting password record for (%s, %s, %s, %s)",
+ LOG ("Forgetting password record for (%s, %s, %s, %s, %s)",
ephy_password_record_get_hostname (record),
+ ephy_password_record_get_target_origin (record),
ephy_password_record_get_username (record),
ephy_password_record_get_username_field (record),
ephy_password_record_get_password_field (record));
@@ -709,7 +722,7 @@ ephy_password_manager_forget (EphyPasswordManager *self,
* therefore we need to obtain the password record first and then emit
* the signal before clearing the password from the secret schema. */
ephy_password_manager_query (self, id,
- NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL,
forget_cb, self);
}
@@ -741,7 +754,7 @@ ephy_password_manager_forget_all (EphyPasswordManager *self)
/* synchronizable-deleted signal needs an EphySynchronizable object, therefore
* we need to obtain the password records first and emit the signal for each
* one before clearing the secret schema. */
- ephy_password_manager_query (self, NULL, NULL, NULL, NULL, NULL,
+ ephy_password_manager_query (self, NULL, NULL, NULL, NULL, NULL, NULL,
forget_all_cb, self);
}
@@ -826,7 +839,7 @@ ephy_password_manager_replace_existing (EphyPasswordManager *self,
g_assert (EPHY_IS_PASSWORD_RECORD (record));
ephy_password_manager_query (self, ephy_password_record_get_id (record),
- NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL,
replace_existing_cb,
replace_record_async_data_new (self, record));
}
@@ -858,6 +871,7 @@ get_record_by_id (GList *records,
static EphyPasswordRecord *
get_record_by_parameters (GList *records,
const char *hostname,
+ const char *target_origin,
const char *username,
const char *username_field,
const char *password_field)
@@ -865,6 +879,7 @@ get_record_by_parameters (GList *records,
for (GList *l = records; l && l->data; l = l->next) {
if (!g_strcmp0 (ephy_password_record_get_username (l->data), username) &&
!g_strcmp0 (ephy_password_record_get_hostname (l->data), hostname) &&
+ !g_strcmp0 (ephy_password_record_get_target_origin (l->data), target_origin) &&
!g_strcmp0 (ephy_password_record_get_username_field (l->data), username_field) &&
!g_strcmp0 (ephy_password_record_get_password_field (l->data), password_field))
return l->data;
@@ -898,6 +913,7 @@ ephy_password_manager_handle_initial_merge (EphyPasswordManager *self,
GList *to_upload = NULL;
const char *remote_id;
const char *remote_hostname;
+ const char *remote_target_origin;
const char *remote_username;
const char *remote_password;
const char *remote_username_field;
@@ -921,6 +937,7 @@ ephy_password_manager_handle_initial_merge (EphyPasswordManager *self,
for (GList *l = remote_records; l && l->data; l = l->next) {
remote_id = ephy_password_record_get_id (l->data);
remote_hostname = ephy_password_record_get_hostname (l->data);
+ remote_target_origin = ephy_password_record_get_target_origin (l->data);
remote_username = ephy_password_record_get_username (l->data);
remote_password = ephy_password_record_get_password (l->data);
remote_username_field = ephy_password_record_get_username_field (l->data);
@@ -954,6 +971,7 @@ ephy_password_manager_handle_initial_merge (EphyPasswordManager *self,
} else {
record = get_record_by_parameters (local_records,
remote_hostname,
+ remote_target_origin,
remote_username,
remote_username_field,
remote_password_field);
@@ -998,6 +1016,7 @@ ephy_password_manager_handle_regular_merge (EphyPasswordManager *self,
GList *to_upload = NULL;
const char *remote_id;
const char *remote_hostname;
+ const char *remote_target_origin;
const char *remote_username;
const char *remote_username_field;
const char *remote_password_field;
@@ -1019,6 +1038,7 @@ ephy_password_manager_handle_regular_merge (EphyPasswordManager *self,
for (GList *l = updated_records; l && l->data; l = l->next) {
remote_id = ephy_password_record_get_id (l->data);
remote_hostname = ephy_password_record_get_hostname (l->data);
+ remote_target_origin = ephy_password_record_get_target_origin (l->data);
remote_username = ephy_password_record_get_username (l->data);
remote_username_field = ephy_password_record_get_username_field (l->data);
remote_password_field = ephy_password_record_get_password_field (l->data);
@@ -1031,6 +1051,7 @@ ephy_password_manager_handle_regular_merge (EphyPasswordManager *self,
} else {
record = get_record_by_parameters (*local_records,
remote_hostname,
+ remote_target_origin,
remote_username,
remote_username_field,
remote_password_field);
@@ -1088,7 +1109,7 @@ synchronizable_manager_merge (EphySynchronizableManager *manager,
{
EphyPasswordManager *self = EPHY_PASSWORD_MANAGER (manager);
- ephy_password_manager_query (self, NULL, NULL, NULL, NULL, NULL,
+ ephy_password_manager_query (self, NULL, NULL, NULL, NULL, NULL, NULL,
merge_cb,
merge_passwords_async_data_new (self,
is_initial,
diff --git a/lib/sync/ephy-password-manager.h b/lib/sync/ephy-password-manager.h
index 5afd4e6..598350a 100644
--- a/lib/sync/ephy-password-manager.h
+++ b/lib/sync/ephy-password-manager.h
@@ -31,6 +31,7 @@ const SecretSchema *ephy_password_manager_get_password_schema (void) G_GNUC_CONS
#define ID_KEY "id"
#define HOSTNAME_KEY "uri"
+#define TARGET_ORIGIN_KEY "target_origin"
#define USERNAME_FIELD_KEY "form_username"
#define PASSWORD_FIELD_KEY "form_password"
#define USERNAME_KEY "username"
@@ -49,6 +50,7 @@ GList *ephy_password_manager_get_cached_users_for_uri (EphyPasswor
const char *uri);
void ephy_password_manager_save (EphyPasswordManager *self,
const char *uri,
+ const char *target_origin,
const char *username,
const char *password,
const char *username_field,
@@ -57,6 +59,7 @@ void ephy_password_manager_save (EphyPasswor
void ephy_password_manager_query (EphyPasswordManager *self,
const char *id,
const char *uri,
+ const char
*target_origin,
const char
*username,
const char
*username_field,
const char
*password_field,
diff --git a/lib/sync/ephy-password-record.c b/lib/sync/ephy-password-record.c
index ac6c029..21b94ff 100644
--- a/lib/sync/ephy-password-record.c
+++ b/lib/sync/ephy-password-record.c
@@ -28,7 +28,7 @@ struct _EphyPasswordRecord {
char *id;
char *hostname;
- char *form_submit_url;
+ char *target_origin;
char *username;
char *password;
char *username_field;
@@ -52,7 +52,7 @@ enum {
PROP_0,
PROP_ID, /* Firefox Sync */
PROP_HOSTNAME, /* Epiphany && Firefox Sync */
- PROP_FORM_SUBMIT_URL, /* Firefox Sync */
+ PROP_TARGET_ORIGIN, /* Epiphany && Firefox Sync */
PROP_USERNAME, /* Epiphany && Firefox Sync */
PROP_PASSWORD, /* Epiphany && Firefox Sync */
PROP_USERNAME_FIELD, /* Epiphany && Firefox Sync */
@@ -81,9 +81,9 @@ ephy_password_record_set_property (GObject *object,
g_free (self->hostname);
self->hostname = g_strdup (g_value_get_string (value));
break;
- case PROP_FORM_SUBMIT_URL:
- g_free (self->form_submit_url);
- self->form_submit_url = g_strdup (g_value_get_string (value));
+ case PROP_TARGET_ORIGIN:
+ g_free (self->target_origin);
+ self->target_origin = g_strdup (g_value_get_string (value));
break;
case PROP_USERNAME:
g_free (self->username);
@@ -127,8 +127,8 @@ ephy_password_record_get_property (GObject *object,
case PROP_HOSTNAME:
g_value_set_string (value, self->hostname);
break;
- case PROP_FORM_SUBMIT_URL:
- g_value_set_string (value, self->form_submit_url);
+ case PROP_TARGET_ORIGIN:
+ g_value_set_string (value, self->target_origin);
break;
case PROP_USERNAME:
g_value_set_string (value, self->username);
@@ -160,7 +160,7 @@ ephy_password_record_finalize (GObject *object)
g_free (self->id);
g_free (self->hostname);
- g_free (self->form_submit_url);
+ g_free (self->target_origin);
g_free (self->username);
g_free (self->password);
g_free (self->username_field);
@@ -178,6 +178,8 @@ ephy_password_record_class_init (EphyPasswordRecordClass *klass)
object_class->get_property = ephy_password_record_get_property;
object_class->finalize = ephy_password_record_finalize;
+ /* The property names must match Firefox password object structure, see
+ * https://mozilla-services.readthedocs.io/en/latest/sync/objectformats.html#passwords */
obj_properties[PROP_ID] =
g_param_spec_string ("id",
"Id",
@@ -190,11 +192,14 @@ ephy_password_record_class_init (EphyPasswordRecordClass *klass)
"Hostname url that password is applicable at",
"Default hostname",
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS);
- obj_properties[PROP_FORM_SUBMIT_URL] =
+ /* Target origin matches formSubmitURL field from Firefox.
+ * Despite its name, it's actually an origin, so call it appropriately, see
+ *
https://dxr.mozilla.org/mozilla-central/rev/892c8916ba32b7733e06bfbfdd4083ffae3ca028/toolkit/components/passwordmgr/LoginManagerContent.jsm#928
*/
+ obj_properties[PROP_TARGET_ORIGIN] =
g_param_spec_string ("formSubmitURL",
- "Form submit URL",
- "Submission URL set by form",
- "Default form submit URL",
+ "Target origin",
+ "The target origin of the URI where that password is applicable at",
+ "Default target origin URI",
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS);
obj_properties[PROP_USERNAME] =
g_param_spec_string ("username",
@@ -248,6 +253,7 @@ ephy_password_record_init (EphyPasswordRecord *self)
EphyPasswordRecord *
ephy_password_record_new (const char *id,
const char *hostname,
+ const char *target_origin,
const char *username,
const char *password,
const char *username_field,
@@ -258,7 +264,7 @@ ephy_password_record_new (const char *id,
return EPHY_PASSWORD_RECORD (g_object_new (EPHY_TYPE_PASSWORD_RECORD,
"id", id,
"hostname", hostname,
- "formSubmitURL", hostname,
+ "formSubmitURL", target_origin,
"username", username,
"password", password,
"usernameField", username_field,
@@ -285,6 +291,14 @@ ephy_password_record_get_hostname (EphyPasswordRecord *self)
}
const char *
+ephy_password_record_get_target_origin (EphyPasswordRecord *self)
+{
+ g_return_val_if_fail (EPHY_IS_PASSWORD_RECORD (self), NULL);
+
+ return self->target_origin;
+}
+
+const char *
ephy_password_record_get_username (EphyPasswordRecord *self)
{
g_return_val_if_fail (EPHY_IS_PASSWORD_RECORD (self), NULL);
diff --git a/lib/sync/ephy-password-record.h b/lib/sync/ephy-password-record.h
index 211c15b..3364359 100644
--- a/lib/sync/ephy-password-record.h
+++ b/lib/sync/ephy-password-record.h
@@ -30,6 +30,7 @@ G_DECLARE_FINAL_TYPE (EphyPasswordRecord, ephy_password_record, EPHY, PASSWORD_R
EphyPasswordRecord *ephy_password_record_new (const char *id,
const char *hostname,
+ const char *target_origin,
const char *username,
const char *password,
const char *username_field,
@@ -38,6 +39,7 @@ EphyPasswordRecord *ephy_password_record_new (const char
guint64 time_password_changed);
const char *ephy_password_record_get_id (EphyPasswordRecord *self);
const char *ephy_password_record_get_hostname (EphyPasswordRecord *self);
+const char *ephy_password_record_get_target_origin (EphyPasswordRecord *self);
const char *ephy_password_record_get_username (EphyPasswordRecord *self);
const char *ephy_password_record_get_password (EphyPasswordRecord *self);
void ephy_password_record_set_password (EphyPasswordRecord *self,
diff --git a/src/passwords-dialog.c b/src/passwords-dialog.c
index 953cc78..9d7cf8a 100644
--- a/src/passwords-dialog.c
+++ b/src/passwords-dialog.c
@@ -435,7 +435,7 @@ populate_model (EphyPasswordsDialog *dialog)
/* Ask for all password records. */
ephy_password_manager_query (dialog->manager,
- NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL,
populate_model_cb, dialog);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]