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/renderer/autofill_agent.h" | 5 #include "components/autofill/content/renderer/autofill_agent.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/strings/string_split.h" | 10 #include "base/strings/string_split.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 #include "ui/events/keycodes/keyboard_codes.h" | 47 #include "ui/events/keycodes/keyboard_codes.h" |
48 | 48 |
49 using blink::WebAutofillClient; | 49 using blink::WebAutofillClient; |
50 using blink::WebElement; | 50 using blink::WebElement; |
51 using blink::WebElementCollection; | 51 using blink::WebElementCollection; |
52 using blink::WebFormControlElement; | 52 using blink::WebFormControlElement; |
53 using blink::WebFormElement; | 53 using blink::WebFormElement; |
54 using blink::WebFrame; | 54 using blink::WebFrame; |
55 using blink::WebInputElement; | 55 using blink::WebInputElement; |
56 using blink::WebKeyboardEvent; | 56 using blink::WebKeyboardEvent; |
| 57 using blink::WebLocalFrame; |
57 using blink::WebNode; | 58 using blink::WebNode; |
58 using blink::WebOptionElement; | 59 using blink::WebOptionElement; |
59 using blink::WebString; | 60 using blink::WebString; |
60 using blink::WebTextAreaElement; | 61 using blink::WebTextAreaElement; |
61 using blink::WebVector; | 62 using blink::WebVector; |
62 | 63 |
63 namespace autofill { | 64 namespace autofill { |
64 | 65 |
65 namespace { | 66 namespace { |
66 | 67 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 OnAcceptDataListSuggestion) | 160 OnAcceptDataListSuggestion) |
160 IPC_MESSAGE_HANDLER(AutofillMsg_AcceptPasswordAutofillSuggestion, | 161 IPC_MESSAGE_HANDLER(AutofillMsg_AcceptPasswordAutofillSuggestion, |
161 OnAcceptPasswordAutofillSuggestion) | 162 OnAcceptPasswordAutofillSuggestion) |
162 IPC_MESSAGE_HANDLER(AutofillMsg_RequestAutocompleteResult, | 163 IPC_MESSAGE_HANDLER(AutofillMsg_RequestAutocompleteResult, |
163 OnRequestAutocompleteResult) | 164 OnRequestAutocompleteResult) |
164 IPC_MESSAGE_UNHANDLED(handled = false) | 165 IPC_MESSAGE_UNHANDLED(handled = false) |
165 IPC_END_MESSAGE_MAP() | 166 IPC_END_MESSAGE_MAP() |
166 return handled; | 167 return handled; |
167 } | 168 } |
168 | 169 |
169 void AutofillAgent::DidFinishDocumentLoad(WebFrame* frame) { | 170 void AutofillAgent::DidFinishDocumentLoad(WebLocalFrame* frame) { |
170 // Record timestamp on document load. This is used to record overhead of | 171 // Record timestamp on document load. This is used to record overhead of |
171 // Autofill feature. | 172 // Autofill feature. |
172 forms_seen_timestamp_ = base::TimeTicks::Now(); | 173 forms_seen_timestamp_ = base::TimeTicks::Now(); |
173 | 174 |
174 // The document has now been fully loaded. Scan for forms to be sent up to | 175 // The document has now been fully loaded. Scan for forms to be sent up to |
175 // the browser. | 176 // the browser. |
176 std::vector<FormData> forms; | 177 std::vector<FormData> forms; |
177 bool has_more_forms = false; | 178 bool has_more_forms = false; |
178 if (!frame->parent()) { | 179 if (!frame->parent()) { |
179 form_elements_.clear(); | 180 form_elements_.clear(); |
(...skipping 24 matching lines...) Expand all Loading... |
204 | 205 |
205 for (WebFrame* temp = in_flight_request_form_.document().frame(); | 206 for (WebFrame* temp = in_flight_request_form_.document().frame(); |
206 temp; temp = temp->parent()) { | 207 temp; temp = temp->parent()) { |
207 if (temp == frame) { | 208 if (temp == frame) { |
208 Send(new AutofillHostMsg_CancelRequestAutocomplete(routing_id())); | 209 Send(new AutofillHostMsg_CancelRequestAutocomplete(routing_id())); |
209 break; | 210 break; |
210 } | 211 } |
211 } | 212 } |
212 } | 213 } |
213 | 214 |
214 void AutofillAgent::WillSubmitForm(WebFrame* frame, | 215 void AutofillAgent::WillSubmitForm(WebLocalFrame* frame, |
215 const WebFormElement& form) { | 216 const WebFormElement& form) { |
216 FormData form_data; | 217 FormData form_data; |
217 if (WebFormElementToFormData(form, | 218 if (WebFormElementToFormData(form, |
218 WebFormControlElement(), | 219 WebFormControlElement(), |
219 REQUIRE_AUTOCOMPLETE, | 220 REQUIRE_AUTOCOMPLETE, |
220 static_cast<ExtractMask>( | 221 static_cast<ExtractMask>( |
221 EXTRACT_VALUE | EXTRACT_OPTION_TEXT), | 222 EXTRACT_VALUE | EXTRACT_OPTION_TEXT), |
222 &form_data, | 223 &form_data, |
223 NULL)) { | 224 NULL)) { |
224 Send(new AutofillHostMsg_FormSubmitted(routing_id(), form_data, | 225 Send(new AutofillHostMsg_FormSubmitted(routing_id(), form_data, |
(...skipping 23 matching lines...) Expand all Loading... |
248 !element->isTextField() || element->isPasswordField()) | 249 !element->isTextField() || element->isPasswordField()) |
249 return; | 250 return; |
250 | 251 |
251 element_ = *element; | 252 element_ = *element; |
252 } | 253 } |
253 | 254 |
254 void AutofillAgent::OrientationChangeEvent(int orientation) { | 255 void AutofillAgent::OrientationChangeEvent(int orientation) { |
255 HidePopup(); | 256 HidePopup(); |
256 } | 257 } |
257 | 258 |
258 void AutofillAgent::DidChangeScrollOffset(WebFrame*) { | 259 void AutofillAgent::DidChangeScrollOffset(WebLocalFrame*) { |
259 HidePopup(); | 260 HidePopup(); |
260 } | 261 } |
261 | 262 |
262 void AutofillAgent::didRequestAutocomplete(WebFrame* frame, | 263 void AutofillAgent::didRequestAutocomplete(WebLocalFrame* frame, |
263 const WebFormElement& form) { | 264 const WebFormElement& form) { |
264 // Disallow the dialog over non-https or broken https, except when the | 265 // Disallow the dialog over non-https or broken https, except when the |
265 // ignore SSL flag is passed. See http://crbug.com/272512. | 266 // ignore SSL flag is passed. See http://crbug.com/272512. |
266 // TODO(palmer): this should be moved to the browser process after frames | 267 // TODO(palmer): this should be moved to the browser process after frames |
267 // get their own processes. | 268 // get their own processes. |
268 GURL url(frame->document().url()); | 269 GURL url(frame->document().url()); |
269 content::SSLStatus ssl_status = render_view()->GetSSLStatusOfFrame(frame); | 270 content::SSLStatus ssl_status = render_view()->GetSSLStatusOfFrame(frame); |
270 bool is_safe = url.SchemeIs(content::kHttpsScheme) && | 271 bool is_safe = url.SchemeIs(content::kHttpsScheme) && |
271 !net::IsCertStatusError(ssl_status.cert_status); | 272 !net::IsCertStatusError(ssl_status.cert_status); |
272 bool allow_unsafe = CommandLine::ForCurrentProcess()->HasSwitch( | 273 bool allow_unsafe = CommandLine::ForCurrentProcess()->HasSwitch( |
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
668 // Only monitors dynamic forms created in the top frame. Dynamic forms | 669 // Only monitors dynamic forms created in the top frame. Dynamic forms |
669 // inserted in iframes are not captured yet. | 670 // inserted in iframes are not captured yet. |
670 if (frame && !frame->parent()) { | 671 if (frame && !frame->parent()) { |
671 password_autofill_agent_->OnDynamicFormsSeen(frame); | 672 password_autofill_agent_->OnDynamicFormsSeen(frame); |
672 return; | 673 return; |
673 } | 674 } |
674 } | 675 } |
675 } | 676 } |
676 | 677 |
677 } // namespace autofill | 678 } // namespace autofill |
OLD | NEW |