Commit 55b2d5eb authored by Michael Catanzaro's avatar Michael Catanzaro

web-extension: Try harder not to remember passwords when disabled

When the remember passwords setting is disabled, we should try harder to
avoid executing any related code.
parent a86e74ca
Pipeline #69641 passed with stages
in 5 minutes
......@@ -255,7 +255,6 @@ web_page_form_controls_associated (WebKitWebPage *web_page,
g_autoptr(JSCValue) js_ephy = NULL;
g_autoptr(JSCValue) js_serializer = NULL;
g_autoptr(JSCValue) js_result = NULL;
gboolean remember_passwords;
guint i;
frame = webkit_web_page_get_main_frame (web_page);
......@@ -272,16 +271,13 @@ web_page_form_controls_associated (WebKitWebPage *web_page,
js_serializer = jsc_value_new_function (js_context,
"sensitiveFormMessageSerializer",
G_CALLBACK (sensitive_form_message_serializer), NULL, NULL,
G_TYPE_STRING, 2,
G_TYPE_UINT64, G_TYPE_BOOLEAN);
remember_passwords = !extension->is_private_profile &&
g_settings_get_boolean (EPHY_SETTINGS_WEB_EXTENSION_WEB, EPHY_PREFS_WEB_REMEMBER_PASSWORDS);
G_TYPE_STRING, 1,
G_TYPE_UINT64);
js_result = jsc_value_object_invoke_method (js_ephy,
"formControlsAssociated",
G_TYPE_UINT64, webkit_web_page_get_id (web_page),
G_TYPE_PTR_ARRAY, form_controls,
JSC_TYPE_VALUE, js_serializer,
G_TYPE_BOOLEAN, remember_passwords,
G_TYPE_NONE);
}
......@@ -647,6 +643,14 @@ js_is_edited (JSCValue *js_element)
return webkit_dom_element_html_input_element_is_user_edited (WEBKIT_DOM_ELEMENT (node));
}
static gboolean
js_should_remember_passwords (EphyWebExtension *extension)
{
g_assert (EPHY_IS_WEB_EXTENSION (extension));
return !extension->is_private_profile && g_settings_get_boolean (EPHY_SETTINGS_WEB_EXTENSION_WEB, EPHY_PREFS_WEB_REMEMBER_PASSWORDS);
}
static void
js_exception_handler (JSCContext *context,
JSCException *exception)
......@@ -763,6 +767,14 @@ window_object_cleared_cb (WebKitScriptWorld *world,
JSC_TYPE_VALUE);
jsc_value_object_set_property (js_ephy, "isEdited", js_function);
g_clear_object (&js_function);
js_function = jsc_value_new_function (js_context,
"shouldRememberPasswords",
G_CALLBACK (js_should_remember_passwords),
g_object_ref (extension), g_object_unref,
G_TYPE_BOOLEAN, 0);
jsc_value_object_set_property (js_ephy, "shouldRememberPasswords", js_function);
g_clear_object (&js_function);
}
void
......
......@@ -248,7 +248,7 @@ Ephy.PreFillUserMenu = class PreFillUserMenu
}
}
Ephy.formControlsAssociated = function(pageID, forms, serializer, rememberPasswords)
Ephy.formControlsAssociated = function(pageID, forms, serializer)
{
Ephy.formManagers = [];
......@@ -257,8 +257,7 @@ Ephy.formControlsAssociated = function(pageID, forms, serializer, rememberPasswo
continue;
let formManager = new Ephy.FormManager(pageID, forms[i]);
formManager.handleSensitiveElement(serializer);
if (rememberPasswords)
formManager.preFillForms();
formManager.preFillForms();
Ephy.formManagers.push(formManager);
}
}
......@@ -425,6 +424,9 @@ Ephy.FormManager = class FormManager
preFillForms()
{
if (!Ephy.shouldRememberPasswords())
return;
let formAuth = this._generateFormAuth(true);
if (!formAuth) {
Ephy.log('No pre-fillable/hookable form found');
......@@ -448,6 +450,9 @@ Ephy.FormManager = class FormManager
preFill(formAuth)
{
if (!Ephy.shouldRememberPasswords())
return;
Ephy.passwordManager.query(
formAuth.origin,
formAuth.targetOrigin,
......@@ -478,6 +483,9 @@ Ephy.FormManager = class FormManager
handleFormSubmission()
{
if (!Ephy.shouldRememberPasswords())
return;
let formAuth = this._generateFormAuth(false);
if (!formAuth || !formAuth.password)
return;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment