Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(157)

Unified Diff: components/autofill/ios/browser/resources/autofill_controller.js

Issue 1137403002: Add upstream bits necessary for iOS card unmask prompt. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add clearActiveElement to autofill_controller.js Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/autofill/ios/browser/js_autofill_manager.mm ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/autofill/ios/browser/resources/autofill_controller.js
diff --git a/components/autofill/ios/browser/resources/autofill_controller.js b/components/autofill/ios/browser/resources/autofill_controller.js
index 9e53e2d5b4ef067e456b4bc41bdb206519489152..e4bb095c9645fe7c9de6dc8db76641cc9c99815b 100644
--- a/components/autofill/ios/browser/resources/autofill_controller.js
+++ b/components/autofill/ios/browser/resources/autofill_controller.js
@@ -8,7 +8,8 @@
// representing an array of objects, each of which represents an Autofill form
// with information about a form to be filled and/or submitted and it can be
// translated to struct FormData
-// (chromium/src/components/autofill/common/form_data.h) for further processing.
+// (chromium/src/components/autofill/core/common/form_data.h) for further
+// processing.
/**
* Namespace for this file. It depends on |__gCrWeb| having already been
@@ -98,6 +99,11 @@ __gCrWeb.autofill.EXTRACT_MASK_OPTIONS = 1 << 2;
__gCrWeb.autofill.lastAutoFilledElement = null;
/**
+ * The last element that was active (used to restore focus if necessary).
+ */
+__gCrWeb.autofill.lastActiveElement = null;
+
+/**
* Scans DOM and returns a JSON string representation of forms and form
* extraction results.
* @param {int} requiredFields The minimum number of fields forms must have to
@@ -126,12 +132,34 @@ __gCrWeb.autofill['extractForms'] = function(requiredFields, requirements) {
};
/**
- * Fills data into the active form field.
+ * Stores the current active element. This is used to make the element active
+ * again in case the web view loses focus when a dialog is presented over it.
+ */
+__gCrWeb.autofill['storeActiveElement'] = function() {
Dan Beam 2015/05/20 23:31:52 why are you missing ['braces'] and .dot notation?
Dan Beam 2015/05/20 23:32:06 s/missing/mixing
Justin Donnelly 2015/05/21 00:36:01 I don't know, I'm pretty new to working with this
dconnelly 2015/05/21 07:27:54 Yeah, it's some Closure compiler thing. The functi
+ __gCrWeb.autofill.lastActiveElement = document.activeElement;
+}
+
+/**
+ * Clears the current active element by setting it to null.
+ */
+__gCrWeb.autofill['clearActiveElement'] = function() {
+ __gCrWeb.autofill.lastActiveElement = null;
+}
+
+/**
+ * Fills data into the active form field. The active form field is either
+ * document.activeElement or the value of lastActiveElement if that value is
+ * non-null.
*
* @param {Object} data The data to fill in.
*/
__gCrWeb.autofill['fillActiveFormField'] = function(data) {
var activeElement = document.activeElement;
+ if (__gCrWeb.autofill.lastActiveElement) {
+ activeElement = __gCrWeb.autofill.lastActiveElement;
+ activeElement.focus();
+ __gCrWeb.autofill.lastActiveElement = null;
+ }
if (data['name'] !== __gCrWeb['common'].nameForAutofill(activeElement)) {
return;
}
« no previous file with comments | « components/autofill/ios/browser/js_autofill_manager.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698