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

Side by Side Diff: components/autofill/content/renderer/password_form_conversion_utils.h

Issue 2148303005: [Password Generation] Sends the flag whether a field has nonempty user input (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changes addressed to reviewer comments Created 4 years, 4 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 #ifndef COMPONENTS_AUTOFILL_CONTENT_RENDERER_PASSWORD_FORM_CONVERSION_UTILS_H_ 5 #ifndef COMPONENTS_AUTOFILL_CONTENT_RENDERER_PASSWORD_FORM_CONVERSION_UTILS_H_
6 #define COMPONENTS_AUTOFILL_CONTENT_RENDERER_PASSWORD_FORM_CONVERSION_UTILS_H_ 6 #define COMPONENTS_AUTOFILL_CONTENT_RENDERER_PASSWORD_FORM_CONVERSION_UTILS_H_
7 7
8 #include <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 #include <vector> 10 #include <vector>
11 11
12 #include <components/autofill/core/common/password_form.h>
12 #include "components/autofill/core/common/password_form_field_prediction_map.h" 13 #include "components/autofill/core/common/password_form_field_prediction_map.h"
13 #include "third_party/WebKit/public/platform/WebString.h" 14 #include "third_party/WebKit/public/platform/WebString.h"
14 #include "url/gurl.h" 15 #include "url/gurl.h"
15 16
16 namespace blink { 17 namespace blink {
17 class WebDocument; 18 class WebDocument;
18 class WebFormElement; 19 class WebFormElement;
19 class WebFormControlElement; 20 class WebFormControlElement;
20 class WebFrame; 21 class WebFrame;
21 class WebInputElement; 22 class WebInputElement;
22 } 23 }
23 24
24 namespace autofill { 25 namespace autofill {
25 26
26 struct FormData; 27 struct FormData;
27 struct FormFieldData; 28 struct FormFieldData;
28 struct PasswordForm; 29 struct PasswordForm;
29 30
30 // Tests whether the given form is a GAIA reauthentication form. The form is 31 // Tests whether the given form is a GAIA reauthentication form. The form is
31 // not passed directly as WebFormElement, but by specifying its |origin| and 32 // not passed directly as WebFormElement, but by specifying its |origin| and
32 // |control_elements|. This is for better performance and easier testing. 33 // |control_elements|. This is for better performance and easier testing.
33 // TODO(msramek): Move this logic to the browser. 34 // TODO(msramek): Move this logic to the browser.
34 bool IsGaiaReauthenticationForm( 35 bool IsGaiaReauthenticationForm(
35 const GURL& origin, 36 const GURL& origin,
36 const std::vector<blink::WebFormControlElement>& control_elements); 37 const std::vector<blink::WebFormControlElement>& control_elements);
37 38
38 typedef std::map<const blink::WebInputElement, 39 typedef std::map<const blink::WebFormControlElement,
39 blink::WebString> ModifiedValues; 40 std::pair<base::string16, FieldPropertiesMask>>
41 FieldValueAndPropertiesMaskMap;
40 42
41 // Create a PasswordForm from DOM form. Webkit doesn't allow storing 43 // Create a PasswordForm from DOM form. Webkit doesn't allow storing
42 // custom metadata to DOM nodes, so we have to do this every time an event 44 // custom metadata to DOM nodes, so we have to do this every time an event
43 // happens with a given form and compare against previously Create'd forms 45 // happens with a given form and compare against previously Create'd forms
44 // to identify..which sucks. 46 // to identify..which sucks.
45 // If an element of |form| has an entry in |nonscript_modified_values|, the 47 // If an element of |form| has an entry in |nonscript_modified_values|, the
46 // associated string is used instead of the element's value to create 48 // associated string is used instead of the element's value to create
47 // the PasswordForm. 49 // the PasswordForm.
48 // |form_predictions| is Autofill server response, if present it's used for 50 // |form_predictions| is Autofill server response, if present it's used for
49 // overwriting default username element selection. 51 // overwriting default username element selection.
50 std::unique_ptr<PasswordForm> CreatePasswordFormFromWebForm( 52 std::unique_ptr<PasswordForm> CreatePasswordFormFromWebForm(
51 const blink::WebFormElement& form, 53 const blink::WebFormElement& form,
52 const ModifiedValues* nonscript_modified_values, 54 const FieldValueAndPropertiesMaskMap* nonscript_modified_values,
53 const FormsPredictionsMap* form_predictions); 55 const FormsPredictionsMap* form_predictions);
54 56
55 // Same as CreatePasswordFormFromWebForm() but for input elements that are not 57 // Same as CreatePasswordFormFromWebForm() but for input elements that are not
56 // enclosed in <form> element. 58 // enclosed in <form> element.
57 std::unique_ptr<PasswordForm> CreatePasswordFormFromUnownedInputElements( 59 std::unique_ptr<PasswordForm> CreatePasswordFormFromUnownedInputElements(
58 const blink::WebFrame& frame, 60 const blink::WebFrame& frame,
59 const ModifiedValues* nonscript_modified_values, 61 const FieldValueAndPropertiesMaskMap* nonscript_modified_values,
60 const FormsPredictionsMap* form_predictions); 62 const FormsPredictionsMap* form_predictions);
61 63
62 // Checks in a case-insensitive way if the autocomplete attribute for the given 64 // Checks in a case-insensitive way if the autocomplete attribute for the given
63 // |element| is present and has the specified |value_in_lowercase|. 65 // |element| is present and has the specified |value_in_lowercase|.
64 bool HasAutocompleteAttributeValue(const blink::WebInputElement& element, 66 bool HasAutocompleteAttributeValue(const blink::WebInputElement& element,
65 const char* value_in_lowercase); 67 const char* value_in_lowercase);
66 68
67 } // namespace autofill 69 } // namespace autofill
68 70
69 #endif // COMPONENTS_AUTOFILL_CONTENT_RENDERER_PASSWORD_FORM_CONVERSION_UTILS_H __ 71 #endif // COMPONENTS_AUTOFILL_CONTENT_RENDERER_PASSWORD_FORM_CONVERSION_UTILS_H __
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698