Commit e2c706ef authored by Vadym Doroshenko's avatar Vadym Doroshenko Committed by Commit Bot

password_controller.js small improvements.

This CL contains 3 small cleanups.
1.Removed unused functions isAutofilled/setAutofilled (setAutofilled is used,
but isAutofilled is not used, so no reasons to keep them)
2.Removed try/catch in getPasswordFormDataList, this function is called only
for main frame or same origin iframes. So no need in try/catch. Moreover
function fillPasswordFormWithData_, which is called in the same circumstances,
doesn't have try/catch.
3.Rewritten for loop by iframes with one line with call of .some().

Bug: 782224
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: I72a07181ffd643329b7217825ec182e948b3c57b
Reviewed-on: https://chromium-review.googlesource.com/825998Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Commit-Queue: Vadym Doroshenko <dvadym@chromium.org>
Cr-Commit-Position: refs/heads/master@{#524133}
parent 928f1632
...@@ -51,14 +51,7 @@ if (__gCrWeb && !__gCrWeb['fillPasswordForm']) { ...@@ -51,14 +51,7 @@ if (__gCrWeb && !__gCrWeb['fillPasswordForm']) {
return true; return true;
} }
var frames = getSameOriginFrames_(win); return getSameOriginFrames_(win).some(hasPasswordField_);
for (var i = 0; i < frames.length; i++) {
if (hasPasswordField_(frames[i])) {
return true;
}
}
return false;
}; };
/** /**
...@@ -228,7 +221,6 @@ if (__gCrWeb && !__gCrWeb['fillPasswordForm']) { ...@@ -228,7 +221,6 @@ if (__gCrWeb && !__gCrWeb['fillPasswordForm']) {
if (usernameInput.readOnly) { if (usernameInput.readOnly) {
if (usernameInput.value == username) { if (usernameInput.value == username) {
passwordInput.value = password; passwordInput.value = password;
__gCrWeb.setAutofilled(passwordInput, true);
filled = true; filled = true;
} }
} else { } else {
...@@ -241,8 +233,6 @@ if (__gCrWeb && !__gCrWeb['fillPasswordForm']) { ...@@ -241,8 +233,6 @@ if (__gCrWeb && !__gCrWeb['fillPasswordForm']) {
usernameInput.value = username; usernameInput.value = username;
passwordInput.focus(); passwordInput.focus();
passwordInput.value = password; passwordInput.value = password;
__gCrWeb.setAutofilled(passwordInput, true);
__gCrWeb.setAutofilled(usernameInput, true);
filled = true; filled = true;
} }
} }
...@@ -259,27 +249,6 @@ if (__gCrWeb && !__gCrWeb['fillPasswordForm']) { ...@@ -259,27 +249,6 @@ if (__gCrWeb && !__gCrWeb['fillPasswordForm']) {
return filled; return filled;
}; };
/**
* Returns true if the supplied field |inputElement| was autofilled.
* @param {Element} inputElement The form field for which we need to
* acquire the autofilled indicator.
* @return {boolean} Whether inputElement was autofilled.
*/
__gCrWeb.isAutofilled = function(inputElement) {
return inputElement['__gCrWebAutofilled'];
};
/**
* Marks the supplied field as autofilled or not depending on the
* |value|.
* @param {Element} inputElement The form field for which the indicator
* needs to be set.
* @param {boolean} value The new value of the indicator.
*/
__gCrWeb.setAutofilled = function(inputElement, value) {
inputElement['__gCrWebAutofilled'] = value;
};
/** /**
* Finds all forms with passwords in the supplied window or frame and appends * Finds all forms with passwords in the supplied window or frame and appends
* JS objects containing the form data to |formDataList|. * JS objects containing the form data to |formDataList|.
...@@ -289,18 +258,7 @@ if (__gCrWeb && !__gCrWeb['fillPasswordForm']) { ...@@ -289,18 +258,7 @@ if (__gCrWeb && !__gCrWeb['fillPasswordForm']) {
* look for password forms. * look for password forms.
*/ */
__gCrWeb.getPasswordFormDataList = function(formDataList, win) { __gCrWeb.getPasswordFormDataList = function(formDataList, win) {
var doc = null; var doc = win.document;
try {
// Security violations may generate an exception or null to be returned.
doc = win.document;
} catch(e) {
}
if (!doc) {
return;
}
var forms = doc.forms; var forms = doc.forms;
for (var i = 0; i < forms.length; i++) { for (var i = 0; i < forms.length; i++) {
var formData = __gCrWeb.getPasswordFormData(forms[i]); var formData = __gCrWeb.getPasswordFormData(forms[i]);
......
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