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

Side by Side Diff: ios/chrome/browser/passwords/resources/password_controller.js

Issue 2814773002: Move password-related methods from core.js to password_controller.js. (Closed)
Patch Set: Address reviewer comment (fix verb tense in test comment) Created 3 years, 8 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
« no previous file with comments | « ios/chrome/browser/passwords/password_controller_unittest.mm ('k') | ios/web/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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 // This file adheres to closure-compiler conventions in order to enable 5 // This file adheres to closure-compiler conventions in order to enable
6 // compilation with ADVANCED_OPTIMIZATIONS. See http://goo.gl/FwOgy 6 // compilation with ADVANCED_OPTIMIZATIONS. See http://goo.gl/FwOgy
7 // 7 //
8 // Installs password management functions on the |__gCrWeb| object. 8 // Installs password management functions on the |__gCrWeb| object.
9 // 9 //
10 // Finds all password forms in the current document and extracts 10 // Finds all password forms in the current document and extracts
(...skipping 10 matching lines...) Expand all
21 // Only install the password management functions once. 21 // Only install the password management functions once.
22 if (__gCrWeb && !__gCrWeb['fillPasswordForm']) { 22 if (__gCrWeb && !__gCrWeb['fillPasswordForm']) {
23 23
24 /** 24 /**
25 * Finds all password forms in the window and returns form data as a JSON 25 * Finds all password forms in the window and returns form data as a JSON
26 * string. 26 * string.
27 * @return {string} Form data as a JSON string. 27 * @return {string} Form data as a JSON string.
28 */ 28 */
29 __gCrWeb['findPasswordForms'] = function() { 29 __gCrWeb['findPasswordForms'] = function() {
30 var formDataList = []; 30 var formDataList = [];
31 if (__gCrWeb.hasPasswordField()) { 31 if (hasPasswordField_(window)) {
32 __gCrWeb.getPasswordFormDataList(formDataList, window); 32 __gCrWeb.getPasswordFormDataList(formDataList, window);
33 } 33 }
34 return __gCrWeb.stringify(formDataList); 34 return __gCrWeb.stringify(formDataList);
35 }; 35 };
36 36
37 /** 37 /**
38 * Returns true if the top window or any frames inside contain an input field
39 * of type 'password'. This method is only used for unit tests and are only
40 * kept for legacy reasons. Prefer to use the private
41 * {@code hasPasswordField_} within this file.
42 * @return {boolean} Whether a password field exists.
43 *
44 * TODO(crbug.com/614092): investigate if this method can be completely
45 * removed from the gCrWeb public interface.
46 */
47 __gCrWeb['hasPasswordField'] = function() {
48 return hasPasswordField_(window);
49 };
50
51 /** Returns true if the supplied window or any frames inside contain an input
52 * field of type 'password'.
53 * @private
54 */
55 var hasPasswordField_ = function(win) {
56 var doc = win.document;
57
58 // We may will not be allowed to read the 'document' property from a frame
59 // that is in a different domain.
60 if (!doc) {
61 return false;
62 }
63
64 if (doc.querySelector('input[type=password]')) {
65 return true;
66 }
67
68 var frames = win.frames;
69 for (var i = 0; i < frames.length; i++) {
70 if (hasPasswordField_(frames[i])) {
71 return true;
72 }
73 }
74
75 return false;
76 };
77
78 /**
38 * Returns the password form with the given |name| as a JSON string. 79 * Returns the password form with the given |name| as a JSON string.
39 * @param {string} name The name of the form to extract. 80 * @param {string} name The name of the form to extract.
40 * @return {string} The password form. 81 * @return {string} The password form.
41 */ 82 */
42 __gCrWeb['getPasswordForm'] = function(name) { 83 __gCrWeb['getPasswordForm'] = function(name) {
43 var el = __gCrWeb.common.getFormElementFromIdentifier(name); 84 var el = __gCrWeb.common.getFormElementFromIdentifier(name);
44 if (!el) 85 if (!el)
45 return 'noPasswordsFound'; 86 return 'noPasswordsFound';
46 var formData = __gCrWeb.getPasswordFormData(el); 87 var formData = __gCrWeb.getPasswordFormData(el);
47 if (!formData) 88 if (!formData)
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 'method': formElement.getAttribute('method'), 467 'method': formElement.getAttribute('method'),
427 'name': __gCrWeb.common.getFormIdentifier(formElement), 468 'name': __gCrWeb.common.getFormIdentifier(formElement),
428 'origin': origin, 469 'origin': origin,
429 'fields': fields, 470 'fields': fields,
430 'usernameElement': usernameElement, 471 'usernameElement': usernameElement,
431 'usernameValue': usernameValue, 472 'usernameValue': usernameValue,
432 'passwords': passwords 473 'passwords': passwords
433 }; 474 };
434 }; 475 };
435 } 476 }
OLDNEW
« no previous file with comments | « ios/chrome/browser/passwords/password_controller_unittest.mm ('k') | ios/web/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698