OLD | NEW |
---|---|
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 #include "components/autofill/content/browser/request_autocomplete_manager.h" | 5 #include "components/autofill/content/browser/request_autocomplete_manager.h" |
6 | 6 |
7 #include "components/autofill/content/browser/content_autofill_driver.h" | 7 #include "components/autofill/content/browser/content_autofill_driver.h" |
8 #include "components/autofill/content/common/autofill_messages.h" | 8 #include "components/autofill/content/common/autofill_messages.h" |
9 #include "components/autofill/core/browser/form_structure.h" | 9 #include "components/autofill/core/browser/form_structure.h" |
10 #include "components/autofill/core/common/autofill_data_validation.h" | 10 #include "components/autofill/core/common/autofill_data_validation.h" |
(...skipping 17 matching lines...) Expand all Loading... | |
28 case AutofillClient::AutocompleteResultErrorCancel: | 28 case AutofillClient::AutocompleteResultErrorCancel: |
29 return blink::WebFormElement::AutocompleteResultErrorCancel; | 29 return blink::WebFormElement::AutocompleteResultErrorCancel; |
30 case AutofillClient::AutocompleteResultErrorInvalid: | 30 case AutofillClient::AutocompleteResultErrorInvalid: |
31 return blink::WebFormElement::AutocompleteResultErrorInvalid; | 31 return blink::WebFormElement::AutocompleteResultErrorInvalid; |
32 } | 32 } |
33 | 33 |
34 NOTREACHED(); | 34 NOTREACHED(); |
35 return blink::WebFormElement::AutocompleteResultErrorDisabled; | 35 return blink::WebFormElement::AutocompleteResultErrorDisabled; |
36 } | 36 } |
37 | 37 |
38 // Helper function to check whether form having input |field| or not. | |
vabr (Chromium)
2014/10/13 12:30:52
nit: form -> a form, having -> has
Having said tha
Pritam Nikam
2014/10/16 12:55:12
Done.
| |
39 bool HasInputField(const FormFieldData& field) { | |
vabr (Chromium)
2014/10/13 12:30:52
The name does not match what is computed.
What abo
Pritam Nikam
2014/10/16 12:55:12
Done.
| |
40 return !field.name.empty(); | |
41 } | |
42 | |
43 // Helper function to set or reset the |is_autofilled| property. | |
vabr (Chromium)
2014/10/13 12:30:52
|is_autofilled| property... of what?
Please specif
Pritam Nikam
2014/10/16 12:55:12
Done.
| |
44 void SetFormFieldsAutocompleted(FormData& form_data, bool is_autofilled) { | |
vabr (Chromium)
2014/10/13 12:30:52
Not non-const references. Use FormData* instead of
vabr (Chromium)
2014/10/13 12:30:52
So is it Autocompleted or autofilled? :)
Please be
Pritam Nikam
2014/10/16 12:55:12
Done.
Pritam Nikam
2014/10/16 12:55:12
Done.
| |
45 if (HasInputField(form_data.username)) | |
46 form_data.username.is_autofilled = is_autofilled; | |
47 | |
48 if (HasInputField(form_data.password)) | |
49 form_data.password.is_autofilled = is_autofilled; | |
50 | |
51 // TODO (pritam.nikam): Make sure we remove |fields|, and add form fields | |
52 // for all possible autofillable input fields. | |
53 for (size_t i = 0; i < form_data.fields.size(); ++i) { | |
54 if (!form_data.fields[i].value.empty()) | |
vabr (Chromium)
2014/10/13 12:30:52
It looks suspicious, that above the FormFieldData:
Pritam Nikam
2014/10/16 12:55:12
Done.
| |
55 form_data.fields[i].is_autofilled = is_autofilled; | |
56 } | |
57 } | |
Ilya Sherman
2014/10/13 23:49:32
Are the username and password fields ever used wit
Pritam Nikam
2014/10/16 12:55:13
Yes, I didn't see this is getting called.
| |
58 | |
38 } // namespace | 59 } // namespace |
39 | 60 |
40 RequestAutocompleteManager::RequestAutocompleteManager( | 61 RequestAutocompleteManager::RequestAutocompleteManager( |
41 ContentAutofillDriver* autofill_driver) | 62 ContentAutofillDriver* autofill_driver) |
42 : autofill_driver_(autofill_driver), weak_ptr_factory_(this) { | 63 : autofill_driver_(autofill_driver), weak_ptr_factory_(this) { |
43 DCHECK(autofill_driver_); | 64 DCHECK(autofill_driver_); |
44 } | 65 } |
45 | 66 |
46 RequestAutocompleteManager::~RequestAutocompleteManager() {} | 67 RequestAutocompleteManager::~RequestAutocompleteManager() {} |
47 | 68 |
(...skipping 24 matching lines...) Expand all Loading... | |
72 return; | 93 return; |
73 | 94 |
74 content::RenderViewHost* host = | 95 content::RenderViewHost* host = |
75 autofill_driver_->web_contents()->GetRenderViewHost(); | 96 autofill_driver_->web_contents()->GetRenderViewHost(); |
76 if (!host) | 97 if (!host) |
77 return; | 98 return; |
78 | 99 |
79 FormData form_data; | 100 FormData form_data; |
80 if (form_structure) { | 101 if (form_structure) { |
81 form_data = form_structure->ToFormData(); | 102 form_data = form_structure->ToFormData(); |
82 for (size_t i = 0; i < form_data.fields.size(); ++i) { | 103 SetFormFieldsAutocompleted(form_data, true); |
83 if(!form_data.fields[i].value.empty()) | |
84 form_data.fields[i].is_autofilled = true; | |
85 } | |
86 } | 104 } |
87 | 105 |
88 host->Send(new AutofillMsg_RequestAutocompleteResult( | 106 host->Send(new AutofillMsg_RequestAutocompleteResult( |
89 host->GetRoutingID(), | 107 host->GetRoutingID(), |
90 ToWebkitAutocompleteResult(result), | 108 ToWebkitAutocompleteResult(result), |
91 debug_message, | 109 debug_message, |
92 form_data)); | 110 form_data)); |
93 } | 111 } |
94 | 112 |
95 void RequestAutocompleteManager::ShowRequestAutocompleteDialog( | 113 void RequestAutocompleteManager::ShowRequestAutocompleteDialog( |
96 const FormData& form, | 114 const FormData& form, |
97 const GURL& source_url, | 115 const GURL& source_url, |
98 const AutofillClient::ResultCallback& callback) { | 116 const AutofillClient::ResultCallback& callback) { |
99 AutofillClient* client = autofill_driver_->autofill_manager()->client(); | 117 AutofillClient* client = autofill_driver_->autofill_manager()->client(); |
100 client->ShowRequestAutocompleteDialog(form, source_url, callback); | 118 client->ShowRequestAutocompleteDialog(form, source_url, callback); |
101 } | 119 } |
102 | 120 |
103 } // namespace autofill | 121 } // namespace autofill |
OLD | NEW |