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

Side by Side Diff: components/autofill/ios/browser/resources/autofill_controller.js

Issue 2146523004: Make full-form autofill the only implementation on iOS. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Installs Autofill management functions on the |__gCrWeb| object. 5 // Installs Autofill management functions on the |__gCrWeb| object.
6 // 6 //
7 // It scans the DOM, extracting and storing forms and returns a JSON string 7 // It scans the DOM, extracting and storing forms and returns a JSON string
8 // representing an array of objects, each of which represents an Autofill form 8 // representing an array of objects, each of which represents an Autofill form
9 // with information about a form to be filled and/or submitted and it can be 9 // with information about a form to be filled and/or submitted and it can be
10 // translated to struct FormData 10 // translated to struct FormData
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 __gCrWeb.autofill.ROLE_ATTRIBUTE_PRESENTATION = 0; 130 __gCrWeb.autofill.ROLE_ATTRIBUTE_PRESENTATION = 0;
131 131
132 /** 132 /**
133 * The last element that was autofilled. 133 * The last element that was autofilled.
134 * 134 *
135 * @type {Element} 135 * @type {Element}
136 */ 136 */
137 __gCrWeb.autofill.lastAutoFilledElement = null; 137 __gCrWeb.autofill.lastAutoFilledElement = null;
138 138
139 /** 139 /**
140 * The last element that was active (used to restore focus if necessary).
141 *
142 * @type {Element}
143 */
144 __gCrWeb.autofill.lastActiveElement = null;
145
146 /**
147 * Whether CSS for autofilled elements has been injected into the page. 140 * Whether CSS for autofilled elements has been injected into the page.
148 * 141 *
149 * @type {boolean} 142 * @type {boolean}
150 */ 143 */
151 __gCrWeb.autofill.styleInjected = false; 144 __gCrWeb.autofill.styleInjected = false;
152 145
153 /** 146 /**
154 * Searches an element's ancestors to see if the element is inside a <form> or 147 * Searches an element's ancestors to see if the element is inside a <form> or
155 * <fieldset>. 148 * <fieldset>.
156 * 149 *
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 * @return {string} A JSON encoded object with object['forms'] containing the 542 * @return {string} A JSON encoded object with object['forms'] containing the
550 * forms data. 543 * forms data.
551 */ 544 */
552 __gCrWeb.autofill['extractForms'] = function(requiredFields) { 545 __gCrWeb.autofill['extractForms'] = function(requiredFields) {
553 var results = new __gCrWeb.common.JSONSafeObject; 546 var results = new __gCrWeb.common.JSONSafeObject;
554 results['forms'] = __gCrWeb.autofill.extractNewForms(requiredFields); 547 results['forms'] = __gCrWeb.autofill.extractNewForms(requiredFields);
555 return __gCrWeb.stringify(results); 548 return __gCrWeb.stringify(results);
556 }; 549 };
557 550
558 /** 551 /**
559 * Stores the current active element. This is used to make the element active 552 * Fills data into the active form field.
560 * again in case the web view loses focus when a dialog is presented over it.
561 */
562 __gCrWeb.autofill['storeActiveElement'] = function() {
563 __gCrWeb.autofill.lastActiveElement = document.activeElement;
564 }
565
566 /**
567 * Clears the current active element by setting it to null.
568 */
569 __gCrWeb.autofill['clearActiveElement'] = function() {
570 __gCrWeb.autofill.lastActiveElement = null;
571 }
572
573 /**
574 * Fills data into the active form field. The active form field is either
575 * document.activeElement or the value of lastActiveElement if that value is
576 * non-null.
577 * 553 *
578 * @param {AutofillFormFieldData} data The data to fill in. 554 * @param {AutofillFormFieldData} data The data to fill in.
579 */ 555 */
580 __gCrWeb.autofill['fillActiveFormField'] = function(data) { 556 __gCrWeb.autofill['fillActiveFormField'] = function(data) {
581 var activeElement = document.activeElement; 557 var activeElement = document.activeElement;
582 if (__gCrWeb.autofill.lastActiveElement) {
583 activeElement = __gCrWeb.autofill.lastActiveElement;
584 activeElement.focus();
585 __gCrWeb.autofill.lastActiveElement = null;
586 }
587 if (data['name'] !== __gCrWeb['common'].nameForAutofill(activeElement)) { 558 if (data['name'] !== __gCrWeb['common'].nameForAutofill(activeElement)) {
588 return; 559 return;
589 } 560 }
590 __gCrWeb.autofill.lastAutoFilledElement = activeElement; 561 __gCrWeb.autofill.lastAutoFilledElement = activeElement;
591 __gCrWeb.autofill.fillFormField(data, activeElement); 562 __gCrWeb.autofill.fillFormField(data, activeElement);
592 }; 563 };
593 564
594 /** 565 /**
595 * Fills a number of fields in the same named form for full-form Autofill. 566 * Fills a number of fields in the same named form for full-form Autofill.
596 * Applies Autofill CSS (i.e. yellow background) to filled elements. 567 * Applies Autofill CSS (i.e. yellow background) to filled elements.
(...skipping 1487 matching lines...) Expand 10 before | Expand all | Expand 10 after
2084 continue; 2055 continue;
2085 } 2056 }
2086 var elementName = __gCrWeb['common'].nameForAutofill(element); 2057 var elementName = __gCrWeb['common'].nameForAutofill(element);
2087 var value = formData[elementName]; 2058 var value = formData[elementName];
2088 if (value) { 2059 if (value) {
2089 element.placeholder = value; 2060 element.placeholder = value;
2090 } 2061 }
2091 } 2062 }
2092 } 2063 }
2093 }; 2064 };
OLDNEW
« no previous file with comments | « components/autofill/ios/browser/js_autofill_manager.mm ('k') | ios/chrome/browser/about_flags.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698