OLD | NEW |
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 16 matching lines...) Expand all Loading... |
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 (hasPasswordField_(window)) { | 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 /** | |
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 | 37 /** Returns true if the supplied window or any frames inside contain an input |
52 * field of type 'password'. | 38 * field of type 'password'. |
53 * @private | 39 * @private |
54 */ | 40 */ |
55 var hasPasswordField_ = function(win) { | 41 var hasPasswordField_ = function(win) { |
56 var doc = win.document; | 42 var doc = win.document; |
57 | 43 |
58 // We may will not be allowed to read the 'document' property from a frame | 44 // We may will not be allowed to read the 'document' property from a frame |
59 // that is in a different domain. | 45 // that is in a different domain. |
60 if (!doc) { | 46 if (!doc) { |
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
467 'method': formElement.getAttribute('method'), | 453 'method': formElement.getAttribute('method'), |
468 'name': __gCrWeb.common.getFormIdentifier(formElement), | 454 'name': __gCrWeb.common.getFormIdentifier(formElement), |
469 'origin': origin, | 455 'origin': origin, |
470 'fields': fields, | 456 'fields': fields, |
471 'usernameElement': usernameElement, | 457 'usernameElement': usernameElement, |
472 'usernameValue': usernameValue, | 458 'usernameValue': usernameValue, |
473 'passwords': passwords | 459 'passwords': passwords |
474 }; | 460 }; |
475 }; | 461 }; |
476 } | 462 } |
OLD | NEW |