Chromium Code Reviews| 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*) { HidePopup(); } |
|
jam
2014/04/05 00:12:39
ditto
jam
2014/04/07 16:33:59
this goes against the style guide, which says that
dcheng
2014/04/07 16:46:58
Maybe I'm missing something, but I think the open
jam
2014/04/07 21:16:33
the doc says the open curly brace is at the _end_,
dcheng
2014/04/07 22:19:20
Ah. I missed that bit. Filing a clang-format bug a
| |
| 259 HidePopup(); | |
| 260 } | |
| 261 | 260 |
| 262 void AutofillAgent::didRequestAutocomplete(WebFrame* frame, | 261 void AutofillAgent::didRequestAutocomplete(WebLocalFrame* frame, |
| 263 const WebFormElement& form) { | 262 const WebFormElement& form) { |
| 264 // Disallow the dialog over non-https or broken https, except when the | 263 // Disallow the dialog over non-https or broken https, except when the |
| 265 // ignore SSL flag is passed. See http://crbug.com/272512. | 264 // ignore SSL flag is passed. See http://crbug.com/272512. |
| 266 // TODO(palmer): this should be moved to the browser process after frames | 265 // TODO(palmer): this should be moved to the browser process after frames |
| 267 // get their own processes. | 266 // get their own processes. |
| 268 GURL url(frame->document().url()); | 267 GURL url(frame->document().url()); |
| 269 content::SSLStatus ssl_status = render_view()->GetSSLStatusOfFrame(frame); | 268 content::SSLStatus ssl_status = render_view()->GetSSLStatusOfFrame(frame); |
| 270 bool is_safe = url.SchemeIs(content::kHttpsScheme) && | 269 bool is_safe = url.SchemeIs(content::kHttpsScheme) && |
| 271 !net::IsCertStatusError(ssl_status.cert_status); | 270 !net::IsCertStatusError(ssl_status.cert_status); |
| 272 bool allow_unsafe = CommandLine::ForCurrentProcess()->HasSwitch( | 271 bool allow_unsafe = CommandLine::ForCurrentProcess()->HasSwitch( |
| (...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 661 // Only monitors dynamic forms created in the top frame. Dynamic forms | 660 // Only monitors dynamic forms created in the top frame. Dynamic forms |
| 662 // inserted in iframes are not captured yet. | 661 // inserted in iframes are not captured yet. |
| 663 if (frame && !frame->parent()) { | 662 if (frame && !frame->parent()) { |
| 664 password_autofill_agent_->OnDynamicFormsSeen(frame); | 663 password_autofill_agent_->OnDynamicFormsSeen(frame); |
| 665 return; | 664 return; |
| 666 } | 665 } |
| 667 } | 666 } |
| 668 } | 667 } |
| 669 | 668 |
| 670 } // namespace autofill | 669 } // namespace autofill |
| OLD | NEW |