[email protected] | f07e444 | 2013-06-06 23:03:48 | [diff] [blame] | 1 | // Copyright 2013 The Chromium Authors. All rights reserved. |
[email protected] | 679f128f | 2010-07-22 22:57:44 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
[email protected] | f07e444 | 2013-06-06 23:03:48 | [diff] [blame] | 5 | #include "components/autofill/content/renderer/autofill_agent.h" |
[email protected] | 679f128f | 2010-07-22 22:57:44 | [diff] [blame] | 6 | |
[email protected] | a1cb57f | 2011-09-28 22:41:29 | [diff] [blame] | 7 | #include "base/bind.h" |
[email protected] | f920d6e | 2013-03-12 20:20:50 | [diff] [blame] | 8 | #include "base/command_line.h" |
[email protected] | c50a693 | 2013-07-17 22:16:13 | [diff] [blame] | 9 | #include "base/message_loop/message_loop.h" |
[email protected] | 1988e1c | 2013-02-28 20:27:42 | [diff] [blame] | 10 | #include "base/strings/string_split.h" |
[email protected] | c72674b | 2013-06-11 04:16:43 | [diff] [blame] | 11 | #include "base/strings/string_util.h" |
[email protected] | d2d79d5 | 2013-06-07 22:23:48 | [diff] [blame] | 12 | #include "base/strings/utf_string_conversions.h" |
[email protected] | bbd8da9 | 2013-06-28 02:12:20 | [diff] [blame] | 13 | #include "base/time/time.h" |
[email protected] | 45b53fb | 2013-12-12 19:28:06 | [diff] [blame] | 14 | #include "components/autofill/content/common/autofill_messages.h" |
[email protected] | f07e444 | 2013-06-06 23:03:48 | [diff] [blame] | 15 | #include "components/autofill/content/renderer/form_autofill_util.h" |
| 16 | #include "components/autofill/content/renderer/page_click_tracker.h" |
| 17 | #include "components/autofill/content/renderer/password_autofill_agent.h" |
[email protected] | 3cbdf936 | 2014-01-31 23:12:23 | [diff] [blame] | 18 | #include "components/autofill/content/renderer/password_generation_agent.h" |
[email protected] | d04f8191 | 2013-06-18 14:52:13 | [diff] [blame] | 19 | #include "components/autofill/core/common/autofill_constants.h" |
[email protected] | d86263dcd | 2014-01-09 10:35:21 | [diff] [blame] | 20 | #include "components/autofill/core/common/autofill_data_validation.h" |
[email protected] | d04f8191 | 2013-06-18 14:52:13 | [diff] [blame] | 21 | #include "components/autofill/core/common/autofill_switches.h" |
| 22 | #include "components/autofill/core/common/form_data.h" |
| 23 | #include "components/autofill/core/common/form_data_predictions.h" |
| 24 | #include "components/autofill/core/common/form_field_data.h" |
[email protected] | e620d36 | 2013-09-09 08:01:53 | [diff] [blame] | 25 | #include "components/autofill/core/common/password_form.h" |
[email protected] | d04f8191 | 2013-06-18 14:52:13 | [diff] [blame] | 26 | #include "components/autofill/core/common/web_element_descriptor.h" |
[email protected] | fed9d4f | 2013-12-17 21:32:47 | [diff] [blame] | 27 | #include "content/public/common/content_switches.h" |
[email protected] | e449521 | 2012-12-06 03:09:12 | [diff] [blame] | 28 | #include "content/public/common/ssl_status.h" |
[email protected] | ca5190f | 2013-07-08 11:10:31 | [diff] [blame] | 29 | #include "content/public/common/url_constants.h" |
estade | b1bc9bd | 2014-12-02 22:44:11 | [diff] [blame] | 30 | #include "content/public/renderer/render_frame.h" |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 31 | #include "content/public/renderer/render_view.h" |
[email protected] | ca5190f | 2013-07-08 11:10:31 | [diff] [blame] | 32 | #include "net/cert/cert_status_flags.h" |
[email protected] | f07e444 | 2013-06-06 23:03:48 | [diff] [blame] | 33 | #include "third_party/WebKit/public/platform/WebRect.h" |
| 34 | #include "third_party/WebKit/public/platform/WebURLRequest.h" |
[email protected] | dbdd6027 | 2014-04-14 22:48:40 | [diff] [blame] | 35 | #include "third_party/WebKit/public/web/WebConsoleMessage.h" |
[email protected] | a0962a9 | 2013-06-20 18:27:34 | [diff] [blame] | 36 | #include "third_party/WebKit/public/web/WebDataSource.h" |
| 37 | #include "third_party/WebKit/public/web/WebDocument.h" |
[email protected] | 961783a | 2014-02-07 18:38:05 | [diff] [blame] | 38 | #include "third_party/WebKit/public/web/WebElementCollection.h" |
[email protected] | a0962a9 | 2013-06-20 18:27:34 | [diff] [blame] | 39 | #include "third_party/WebKit/public/web/WebFormControlElement.h" |
| 40 | #include "third_party/WebKit/public/web/WebFormElement.h" |
[email protected] | a0962a9 | 2013-06-20 18:27:34 | [diff] [blame] | 41 | #include "third_party/WebKit/public/web/WebInputEvent.h" |
[email protected] | 8050465 | 2014-04-18 04:41:50 | [diff] [blame] | 42 | #include "third_party/WebKit/public/web/WebLocalFrame.h" |
[email protected] | a0962a9 | 2013-06-20 18:27:34 | [diff] [blame] | 43 | #include "third_party/WebKit/public/web/WebNode.h" |
[email protected] | a0962a9 | 2013-06-20 18:27:34 | [diff] [blame] | 44 | #include "third_party/WebKit/public/web/WebOptionElement.h" |
[email protected] | e9d29d39 | 2014-03-25 01:15:15 | [diff] [blame] | 45 | #include "third_party/WebKit/public/web/WebTextAreaElement.h" |
[email protected] | a0962a9 | 2013-06-20 18:27:34 | [diff] [blame] | 46 | #include "third_party/WebKit/public/web/WebView.h" |
[email protected] | c051a1b | 2011-01-21 23:30:17 | [diff] [blame] | 47 | #include "ui/base/l10n/l10n_util.h" |
[email protected] | 7e9acd08 | 2013-09-17 23:31:16 | [diff] [blame] | 48 | #include "ui/events/keycodes/keyboard_codes.h" |
[email protected] | 679f128f | 2010-07-22 22:57:44 | [diff] [blame] | 49 | |
[email protected] | a1221aea | 2013-11-07 01:31:30 | [diff] [blame] | 50 | using blink::WebAutofillClient; |
[email protected] | dbdd6027 | 2014-04-14 22:48:40 | [diff] [blame] | 51 | using blink::WebConsoleMessage; |
[email protected] | 5e7e861 | 2014-03-20 14:43:19 | [diff] [blame] | 52 | using blink::WebElement; |
| 53 | using blink::WebElementCollection; |
[email protected] | a1221aea | 2013-11-07 01:31:30 | [diff] [blame] | 54 | using blink::WebFormControlElement; |
| 55 | using blink::WebFormElement; |
| 56 | using blink::WebFrame; |
| 57 | using blink::WebInputElement; |
| 58 | using blink::WebKeyboardEvent; |
[email protected] | c5041c32 | 2014-04-08 05:06:47 | [diff] [blame] | 59 | using blink::WebLocalFrame; |
[email protected] | a1221aea | 2013-11-07 01:31:30 | [diff] [blame] | 60 | using blink::WebNode; |
[email protected] | a1221aea | 2013-11-07 01:31:30 | [diff] [blame] | 61 | using blink::WebOptionElement; |
| 62 | using blink::WebString; |
[email protected] | e9d29d39 | 2014-03-25 01:15:15 | [diff] [blame] | 63 | using blink::WebTextAreaElement; |
[email protected] | 5e7e861 | 2014-03-20 14:43:19 | [diff] [blame] | 64 | using blink::WebVector; |
[email protected] | 679f128f | 2010-07-22 22:57:44 | [diff] [blame] | 65 | |
[email protected] | d86263dcd | 2014-01-09 10:35:21 | [diff] [blame] | 66 | namespace autofill { |
| 67 | |
[email protected] | e47aec5 | 2010-08-12 00:50:30 | [diff] [blame] | 68 | namespace { |
| 69 | |
[email protected] | 45a0794 | 2013-07-26 08:28:21 | [diff] [blame] | 70 | // Gets all the data list values (with corresponding label) for the given |
| 71 | // element. |
[email protected] | 5e7e861 | 2014-03-20 14:43:19 | [diff] [blame] | 72 | void GetDataListSuggestions(const WebInputElement& element, |
[email protected] | efeb565f | 2013-12-12 17:16:41 | [diff] [blame] | 73 | bool ignore_current_value, |
[email protected] | 45a0794 | 2013-07-26 08:28:21 | [diff] [blame] | 74 | std::vector<base::string16>* values, |
| 75 | std::vector<base::string16>* labels) { |
[email protected] | 961783a | 2014-02-07 18:38:05 | [diff] [blame] | 76 | WebElementCollection options = element.dataListOptions(); |
[email protected] | bef7f927 | 2012-04-17 10:47:49 | [diff] [blame] | 77 | if (options.isNull()) |
| 78 | return; |
| 79 | |
[email protected] | efeb565f | 2013-12-12 17:16:41 | [diff] [blame] | 80 | base::string16 prefix; |
| 81 | if (!ignore_current_value) { |
| 82 | prefix = element.editingValue(); |
[email protected] | 7bc4453 | 2014-07-10 16:02:15 | [diff] [blame] | 83 | if (element.isMultiple() && element.isEmailField()) { |
[email protected] | efeb565f | 2013-12-12 17:16:41 | [diff] [blame] | 84 | std::vector<base::string16> parts; |
| 85 | base::SplitStringDontTrim(prefix, ',', &parts); |
[email protected] | 8af69c6c | 2014-03-03 19:05:31 | [diff] [blame] | 86 | if (parts.size() > 0) { |
| 87 | base::TrimWhitespace(parts[parts.size() - 1], base::TRIM_LEADING, |
| 88 | &prefix); |
| 89 | } |
[email protected] | efeb565f | 2013-12-12 17:16:41 | [diff] [blame] | 90 | } |
[email protected] | 71a90b3 | 2012-05-18 09:16:53 | [diff] [blame] | 91 | } |
[email protected] | bef7f927 | 2012-04-17 10:47:49 | [diff] [blame] | 92 | for (WebOptionElement option = options.firstItem().to<WebOptionElement>(); |
[email protected] | 71a90b3 | 2012-05-18 09:16:53 | [diff] [blame] | 93 | !option.isNull(); option = options.nextItem().to<WebOptionElement>()) { |
| 94 | if (!StartsWith(option.value(), prefix, false) || |
| 95 | option.value() == prefix || |
[email protected] | 3f81263 | 2012-05-16 04:13:36 | [diff] [blame] | 96 | !element.isValidValue(option.value())) |
[email protected] | bef7f927 | 2012-04-17 10:47:49 | [diff] [blame] | 97 | continue; |
| 98 | |
| 99 | values->push_back(option.value()); |
| 100 | if (option.value() != option.label()) |
| 101 | labels->push_back(option.label()); |
| 102 | else |
[email protected] | d5ca8fb | 2013-04-11 17:54:31 | [diff] [blame] | 103 | labels->push_back(base::string16()); |
[email protected] | bef7f927 | 2012-04-17 10:47:49 | [diff] [blame] | 104 | } |
| 105 | } |
| 106 | |
[email protected] | ead7fb0 | 2013-07-18 18:50:12 | [diff] [blame] | 107 | // Trim the vector before sending it to the browser process to ensure we |
[email protected] | 5c8de6b9 | 2012-06-08 21:24:08 | [diff] [blame] | 108 | // don't send too much data through the IPC. |
[email protected] | ead7fb0 | 2013-07-18 18:50:12 | [diff] [blame] | 109 | void TrimStringVectorForIPC(std::vector<base::string16>* strings) { |
| 110 | // Limit the size of the vector. |
[email protected] | d86263dcd | 2014-01-09 10:35:21 | [diff] [blame] | 111 | if (strings->size() > kMaxListSize) |
| 112 | strings->resize(kMaxListSize); |
[email protected] | 5c8de6b9 | 2012-06-08 21:24:08 | [diff] [blame] | 113 | |
[email protected] | ead7fb0 | 2013-07-18 18:50:12 | [diff] [blame] | 114 | // Limit the size of the strings in the vector. |
| 115 | for (size_t i = 0; i < strings->size(); ++i) { |
[email protected] | d86263dcd | 2014-01-09 10:35:21 | [diff] [blame] | 116 | if ((*strings)[i].length() > kMaxDataLength) |
| 117 | (*strings)[i].resize(kMaxDataLength); |
[email protected] | 5c8de6b9 | 2012-06-08 21:24:08 | [diff] [blame] | 118 | } |
| 119 | } |
| 120 | |
[email protected] | e47aec5 | 2010-08-12 00:50:30 | [diff] [blame] | 121 | } // namespace |
| 122 | |
brettw | b505b7a | 2014-11-26 22:05:32 | [diff] [blame] | 123 | AutofillAgent::ShowSuggestionsOptions::ShowSuggestionsOptions() |
| 124 | : autofill_on_empty_values(false), |
| 125 | requires_caret_at_end(false), |
| 126 | display_warning_if_disabled(false), |
| 127 | datalist_only(false), |
| 128 | show_full_suggestion_list(false), |
| 129 | show_password_suggestions_only(false) { |
| 130 | } |
| 131 | |
estade | b1bc9bd | 2014-12-02 22:44:11 | [diff] [blame] | 132 | AutofillAgent::AutofillAgent(content::RenderFrame* render_frame, |
[email protected] | 3cbdf936 | 2014-01-31 23:12:23 | [diff] [blame] | 133 | PasswordAutofillAgent* password_autofill_agent, |
| 134 | PasswordGenerationAgent* password_generation_agent) |
estade | b1bc9bd | 2014-12-02 22:44:11 | [diff] [blame] | 135 | : content::RenderFrameObserver(render_frame), |
[email protected] | ad19b30 | 2013-04-03 07:42:19 | [diff] [blame] | 136 | password_autofill_agent_(password_autofill_agent), |
[email protected] | 3cbdf936 | 2014-01-31 23:12:23 | [diff] [blame] | 137 | password_generation_agent_(password_generation_agent), |
estade | b1bc9bd | 2014-12-02 22:44:11 | [diff] [blame] | 138 | legacy_(render_frame->GetRenderView(), this), |
| 139 | page_click_tracker_(render_frame->GetRenderView(), this), |
[email protected] | 679f128f | 2010-07-22 22:57:44 | [diff] [blame] | 140 | autofill_query_id_(0), |
[email protected] | 6bcd58a | 2010-11-25 02:31:20 | [diff] [blame] | 141 | display_warning_if_disabled_(false), |
[email protected] | d77ddc806 | 2010-11-24 01:14:06 | [diff] [blame] | 142 | was_query_node_autofilled_(false), |
[email protected] | e4dce0af | 2011-09-19 22:22:28 | [diff] [blame] | 143 | has_shown_autofill_popup_for_current_edit_(false), |
[email protected] | b37043c | 2012-05-31 17:08:12 | [diff] [blame] | 144 | did_set_node_text_(false), |
[email protected] | 90f2625 | 2013-02-15 19:48:32 | [diff] [blame] | 145 | ignore_text_changes_(false), |
[email protected] | b648f24 | 2014-02-25 13:49:06 | [diff] [blame] | 146 | is_popup_possibly_visible_(false), |
[email protected] | 2c30525 | 2013-04-26 19:57:05 | [diff] [blame] | 147 | weak_ptr_factory_(this) { |
estade | b1bc9bd | 2014-12-02 22:44:11 | [diff] [blame] | 148 | render_frame->GetWebFrame()->setAutofillClient(this); |
[email protected] | 679f128f | 2010-07-22 22:57:44 | [diff] [blame] | 149 | } |
| 150 | |
[email protected] | a64fdc3 | 2013-07-31 09:21:13 | [diff] [blame] | 151 | AutofillAgent::~AutofillAgent() {} |
[email protected] | d2f05d0 | 2011-01-27 18:51:01 | [diff] [blame] | 152 | |
[email protected] | 663bd9e | 2011-03-21 01:07:01 | [diff] [blame] | 153 | bool AutofillAgent::OnMessageReceived(const IPC::Message& message) { |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 154 | bool handled = true; |
[email protected] | 663bd9e | 2011-03-21 01:07:01 | [diff] [blame] | 155 | IPC_BEGIN_MESSAGE_MAP(AutofillAgent, message) |
estade | b1bc9bd | 2014-12-02 22:44:11 | [diff] [blame] | 156 | IPC_MESSAGE_HANDLER(AutofillMsg_FirstUserGestureObservedInTab, |
| 157 | OnFirstUserGestureObservedInTab) |
[email protected] | 8527a78f | 2014-06-12 12:49:15 | [diff] [blame] | 158 | IPC_MESSAGE_HANDLER(AutofillMsg_Ping, OnPing) |
[email protected] | 63560b3 | 2014-03-04 07:06:26 | [diff] [blame] | 159 | IPC_MESSAGE_HANDLER(AutofillMsg_FillForm, OnFillForm) |
| 160 | IPC_MESSAGE_HANDLER(AutofillMsg_PreviewForm, OnPreviewForm) |
[email protected] | 3eb5728c | 2011-06-20 22:32:24 | [diff] [blame] | 161 | IPC_MESSAGE_HANDLER(AutofillMsg_FieldTypePredictionsAvailable, |
| 162 | OnFieldTypePredictionsAvailable) |
[email protected] | 93f2e50 | 2013-12-20 09:47:25 | [diff] [blame] | 163 | IPC_MESSAGE_HANDLER(AutofillMsg_ClearForm, OnClearForm) |
[email protected] | 93f2e50 | 2013-12-20 09:47:25 | [diff] [blame] | 164 | IPC_MESSAGE_HANDLER(AutofillMsg_ClearPreviewedForm, OnClearPreviewedForm) |
[email protected] | ac9b92f | 2014-03-15 00:48:32 | [diff] [blame] | 165 | IPC_MESSAGE_HANDLER(AutofillMsg_FillFieldWithValue, OnFillFieldWithValue) |
| 166 | IPC_MESSAGE_HANDLER(AutofillMsg_PreviewFieldWithValue, |
| 167 | OnPreviewFieldWithValue) |
[email protected] | 5c8de6b9 | 2012-06-08 21:24:08 | [diff] [blame] | 168 | IPC_MESSAGE_HANDLER(AutofillMsg_AcceptDataListSuggestion, |
| 169 | OnAcceptDataListSuggestion) |
[email protected] | 126b1ad | 2014-05-21 22:37:33 | [diff] [blame] | 170 | IPC_MESSAGE_HANDLER(AutofillMsg_FillPasswordSuggestion, |
| 171 | OnFillPasswordSuggestion) |
| 172 | IPC_MESSAGE_HANDLER(AutofillMsg_PreviewPasswordSuggestion, |
| 173 | OnPreviewPasswordSuggestion) |
[email protected] | 82fc1b1 | 2013-01-12 00:53:56 | [diff] [blame] | 174 | IPC_MESSAGE_HANDLER(AutofillMsg_RequestAutocompleteResult, |
| 175 | OnRequestAutocompleteResult) |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 176 | IPC_MESSAGE_UNHANDLED(handled = false) |
| 177 | IPC_END_MESSAGE_MAP() |
| 178 | return handled; |
| 179 | } |
| 180 | |
estade | b1bc9bd | 2014-12-02 22:44:11 | [diff] [blame] | 181 | void AutofillAgent::DidCommitProvisionalLoad(bool is_new_navigation) { |
| 182 | // TODO(estade): |form_cache_| shouldn't track multiple frames. |
| 183 | form_cache_.ResetFrame(*render_frame()->GetWebFrame()); |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 184 | } |
| 185 | |
estade | b1bc9bd | 2014-12-02 22:44:11 | [diff] [blame] | 186 | void AutofillAgent::DidFinishDocumentLoad() { |
| 187 | ProcessForms(); |
[email protected] | 3609c96 | 2014-07-11 03:18:25 | [diff] [blame] | 188 | } |
| 189 | |
[email protected] | d7908be | 2013-01-22 16:50:18 | [diff] [blame] | 190 | void AutofillAgent::FrameDetached(WebFrame* frame) { |
estade | b1bc9bd | 2014-12-02 22:44:11 | [diff] [blame] | 191 | if (frame != render_frame()->GetWebFrame()) |
[email protected] | 5e7e861 | 2014-03-20 14:43:19 | [diff] [blame] | 192 | return; |
| 193 | |
estade | b1bc9bd | 2014-12-02 22:44:11 | [diff] [blame] | 194 | form_cache_.ResetFrame(*frame); |
[email protected] | 5e7e861 | 2014-03-20 14:43:19 | [diff] [blame] | 195 | } |
| 196 | |
[email protected] | c5041c32 | 2014-04-08 05:06:47 | [diff] [blame] | 197 | void AutofillAgent::WillSubmitForm(WebLocalFrame* frame, |
[email protected] | 2a5b173 | 2011-04-01 23:55:55 | [diff] [blame] | 198 | const WebFormElement& form) { |
estade | b1bc9bd | 2014-12-02 22:44:11 | [diff] [blame] | 199 | if (frame != render_frame()->GetWebFrame()) |
| 200 | return; |
| 201 | |
[email protected] | 2a5b173 | 2011-04-01 23:55:55 | [diff] [blame] | 202 | FormData form_data; |
[email protected] | aaa80c9 | 2011-09-16 00:23:54 | [diff] [blame] | 203 | if (WebFormElementToFormData(form, |
| 204 | WebFormControlElement(), |
[email protected] | c6292f8 | 2014-07-24 10:49:05 | [diff] [blame] | 205 | REQUIRE_NONE, |
[email protected] | aaa80c9 | 2011-09-16 00:23:54 | [diff] [blame] | 206 | static_cast<ExtractMask>( |
| 207 | EXTRACT_VALUE | EXTRACT_OPTION_TEXT), |
| 208 | &form_data, |
| 209 | NULL)) { |
[email protected] | 1d14f58 | 2011-09-02 20:42:04 | [diff] [blame] | 210 | Send(new AutofillHostMsg_FormSubmitted(routing_id(), form_data, |
| 211 | base::TimeTicks::Now())); |
[email protected] | 2a5b173 | 2011-04-01 23:55:55 | [diff] [blame] | 212 | } |
| 213 | } |
| 214 | |
estade | b1bc9bd | 2014-12-02 22:44:11 | [diff] [blame] | 215 | void AutofillAgent::DidChangeScrollOffset(WebLocalFrame* frame) { |
| 216 | if (frame != render_frame()->GetWebFrame()) |
| 217 | return; |
| 218 | |
| 219 | HidePopup(); |
| 220 | } |
| 221 | |
[email protected] | 5e7e861 | 2014-03-20 14:43:19 | [diff] [blame] | 222 | void AutofillAgent::FocusedNodeChanged(const WebNode& node) { |
[email protected] | 91dcc6d3 | 2014-07-30 00:01:33 | [diff] [blame] | 223 | HidePopup(); |
| 224 | |
estade | b1bc9bd | 2014-12-02 22:44:11 | [diff] [blame] | 225 | if (node.isNull() || !node.isElementNode()) |
| 226 | return; |
| 227 | |
| 228 | if (node.document().frame() != render_frame()->GetWebFrame()) |
| 229 | return; |
| 230 | |
[email protected] | 7e04827 | 2014-04-17 03:38:52 | [diff] [blame] | 231 | if (password_generation_agent_ && |
| 232 | password_generation_agent_->FocusedNodeHasChanged(node)) { |
| 233 | is_popup_possibly_visible_ = true; |
| 234 | return; |
| 235 | } |
| 236 | |
[email protected] | 5e7e861 | 2014-03-20 14:43:19 | [diff] [blame] | 237 | WebElement web_element = node.toConst<WebElement>(); |
[email protected] | f920d6e | 2013-03-12 20:20:50 | [diff] [blame] | 238 | |
| 239 | if (!web_element.document().frame()) |
estade | b1bc9bd | 2014-12-02 22:44:11 | [diff] [blame] | 240 | return; |
[email protected] | f920d6e | 2013-03-12 20:20:50 | [diff] [blame] | 241 | |
| 242 | const WebInputElement* element = toWebInputElement(&web_element); |
| 243 | |
| 244 | if (!element || !element->isEnabled() || element->isReadOnly() || |
| 245 | !element->isTextField() || element->isPasswordField()) |
| 246 | return; |
| 247 | |
[email protected] | e5057a2 | 2013-04-22 12:41:39 | [diff] [blame] | 248 | element_ = *element; |
[email protected] | e5057a2 | 2013-04-22 12:41:39 | [diff] [blame] | 249 | } |
| 250 | |
[email protected] | fcdc564 | 2014-05-09 14:32:24 | [diff] [blame] | 251 | void AutofillAgent::OrientationChangeEvent() { |
[email protected] | b648f24 | 2014-02-25 13:49:06 | [diff] [blame] | 252 | HidePopup(); |
[email protected] | 652ad83 | 2013-08-16 11:47:04 | [diff] [blame] | 253 | } |
| 254 | |
estade | 48c8588 | 2014-08-25 18:26:50 | [diff] [blame] | 255 | void AutofillAgent::Resized() { |
| 256 | HidePopup(); |
| 257 | } |
| 258 | |
estade | b1bc9bd | 2014-12-02 22:44:11 | [diff] [blame] | 259 | void AutofillAgent::LegacyFrameWillClose(blink::WebFrame* frame) { |
| 260 | if (in_flight_request_form_.isNull()) |
| 261 | return; |
| 262 | |
| 263 | for (blink::WebFrame* temp = render_frame()->GetWebFrame(); temp; |
| 264 | temp = temp->parent()) { |
| 265 | if (temp == frame) { |
| 266 | Send(new AutofillHostMsg_CancelRequestAutocomplete(routing_id())); |
| 267 | break; |
| 268 | } |
| 269 | } |
[email protected] | 2b942c33 | 2012-04-25 16:26:26 | [diff] [blame] | 270 | } |
| 271 | |
[email protected] | 1c6269a6 | 2014-04-12 03:17:14 | [diff] [blame] | 272 | void AutofillAgent::didRequestAutocomplete( |
[email protected] | 304130f | 2014-05-23 22:58:55 | [diff] [blame] | 273 | const WebFormElement& form) { |
estade | b1bc9bd | 2014-12-02 22:44:11 | [diff] [blame] | 274 | DCHECK_EQ(form.document().frame(), render_frame()->GetWebFrame()); |
| 275 | |
[email protected] | fed9d4f | 2013-12-17 21:32:47 | [diff] [blame] | 276 | // Disallow the dialog over non-https or broken https, except when the |
| 277 | // ignore SSL flag is passed. See http://crbug.com/272512. |
| 278 | // TODO(palmer): this should be moved to the browser process after frames |
| 279 | // get their own processes. |
[email protected] | 1c6269a6 | 2014-04-12 03:17:14 | [diff] [blame] | 280 | GURL url(form.document().url()); |
| 281 | content::SSLStatus ssl_status = |
estade | b1bc9bd | 2014-12-02 22:44:11 | [diff] [blame] | 282 | render_frame()->GetRenderView()->GetSSLStatusOfFrame( |
| 283 | form.document().frame()); |
[email protected] | e8ca69c | 2014-05-07 15:31:19 | [diff] [blame] | 284 | bool is_safe = url.SchemeIs(url::kHttpsScheme) && |
[email protected] | fed9d4f | 2013-12-17 21:32:47 | [diff] [blame] | 285 | !net::IsCertStatusError(ssl_status.cert_status); |
brettw | b505b7a | 2014-11-26 22:05:32 | [diff] [blame] | 286 | bool allow_unsafe = base::CommandLine::ForCurrentProcess()->HasSwitch( |
[email protected] | fed9d4f | 2013-12-17 21:32:47 | [diff] [blame] | 287 | ::switches::kReduceSecurityForTesting); |
| 288 | |
[email protected] | 81cd5233 | 2012-11-05 20:36:07 | [diff] [blame] | 289 | FormData form_data; |
[email protected] | a3d81cf | 2014-04-15 23:26:16 | [diff] [blame] | 290 | std::string error_message; |
| 291 | if (!in_flight_request_form_.isNull()) { |
| 292 | error_message = "already active."; |
| 293 | } else if (!is_safe && !allow_unsafe) { |
| 294 | error_message = |
| 295 | "must use a secure connection or --reduce-security-for-testing."; |
| 296 | } else if (!WebFormElementToFormData(form, |
| 297 | WebFormControlElement(), |
| 298 | REQUIRE_AUTOCOMPLETE, |
[email protected] | 191279cb | 2014-06-26 08:02:11 | [diff] [blame] | 299 | static_cast<ExtractMask>( |
| 300 | EXTRACT_VALUE | |
| 301 | EXTRACT_OPTION_TEXT | |
| 302 | EXTRACT_OPTIONS), |
[email protected] | a3d81cf | 2014-04-15 23:26:16 | [diff] [blame] | 303 | &form_data, |
| 304 | NULL)) { |
| 305 | error_message = "failed to parse form."; |
| 306 | } |
| 307 | |
| 308 | if (!error_message.empty()) { |
| 309 | WebConsoleMessage console_message = WebConsoleMessage( |
| 310 | WebConsoleMessage::LevelLog, |
| 311 | WebString(base::ASCIIToUTF16("requestAutocomplete: ") + |
| 312 | base::ASCIIToUTF16(error_message))); |
[email protected] | b221bd6 | 2014-06-06 10:16:37 | [diff] [blame] | 313 | form.document().frame()->addMessageToConsole(console_message); |
[email protected] | 81cd5233 | 2012-11-05 20:36:07 | [diff] [blame] | 314 | WebFormElement(form).finishRequestAutocomplete( |
[email protected] | 82fc1b1 | 2013-01-12 00:53:56 | [diff] [blame] | 315 | WebFormElement::AutocompleteResultErrorDisabled); |
[email protected] | 81cd5233 | 2012-11-05 20:36:07 | [diff] [blame] | 316 | return; |
| 317 | } |
| 318 | |
| 319 | // Cancel any pending Autofill requests and hide any currently showing popups. |
| 320 | ++autofill_query_id_; |
[email protected] | b648f24 | 2014-02-25 13:49:06 | [diff] [blame] | 321 | HidePopup(); |
[email protected] | 81cd5233 | 2012-11-05 20:36:07 | [diff] [blame] | 322 | |
| 323 | in_flight_request_form_ = form; |
[email protected] | ca5190f | 2013-07-08 11:10:31 | [diff] [blame] | 324 | Send(new AutofillHostMsg_RequestAutocomplete(routing_id(), form_data, url)); |
[email protected] | 81cd5233 | 2012-11-05 20:36:07 | [diff] [blame] | 325 | } |
| 326 | |
[email protected] | 90f2625 | 2013-02-15 19:48:32 | [diff] [blame] | 327 | void AutofillAgent::setIgnoreTextChanges(bool ignore) { |
| 328 | ignore_text_changes_ = ignore; |
| 329 | } |
| 330 | |
[email protected] | e9d29d39 | 2014-03-25 01:15:15 | [diff] [blame] | 331 | void AutofillAgent::FormControlElementClicked( |
| 332 | const WebFormControlElement& element, |
| 333 | bool was_focused) { |
estade | b1bc9bd | 2014-12-02 22:44:11 | [diff] [blame] | 334 | // TODO(estade): Remove this check when PageClickTracker is per-frame. |
| 335 | if (element.document().frame() != render_frame()->GetWebFrame()) |
| 336 | return; |
| 337 | |
[email protected] | e9d29d39 | 2014-03-25 01:15:15 | [diff] [blame] | 338 | const WebInputElement* input_element = toWebInputElement(&element); |
| 339 | if (!input_element && !IsTextAreaElement(element)) |
| 340 | return; |
| 341 | |
brettw | b505b7a | 2014-11-26 22:05:32 | [diff] [blame] | 342 | ShowSuggestionsOptions options; |
| 343 | options.autofill_on_empty_values = true; |
| 344 | options.display_warning_if_disabled = true; |
| 345 | options.show_full_suggestion_list = element.isAutofilled(); |
gcasto | 2c646227 | 2014-11-04 01:14:11 | [diff] [blame] | 346 | |
brettw | b505b7a | 2014-11-26 22:05:32 | [diff] [blame] | 347 | if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 348 | switches::kEnableSingleClickAutofill)) { |
| 349 | // Show full suggestions when clicking on an already-focused form field. On |
| 350 | // the initial click (not focused yet), only show password suggestions. |
gcasto | 2c646227 | 2014-11-04 01:14:11 | [diff] [blame] | 351 | #if defined(OS_ANDROID) |
brettw | b505b7a | 2014-11-26 22:05:32 | [diff] [blame] | 352 | // TODO(gcasto): Remove after crbug.com/430318 has been fixed. |
| 353 | if (!was_focused) |
| 354 | return; |
gcasto | 2c646227 | 2014-11-04 01:14:11 | [diff] [blame] | 355 | #endif |
| 356 | |
brettw | b505b7a | 2014-11-26 22:05:32 | [diff] [blame] | 357 | options.show_full_suggestion_list = |
| 358 | options.show_full_suggestion_list || was_focused; |
| 359 | options.show_password_suggestions_only = !was_focused; |
gcasto | 2c646227 | 2014-11-04 01:14:11 | [diff] [blame] | 360 | } |
brettw | b505b7a | 2014-11-26 22:05:32 | [diff] [blame] | 361 | ShowSuggestions(element, options); |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 362 | } |
| 363 | |
[email protected] | 2fa18c2 | 2011-06-14 23:40:43 | [diff] [blame] | 364 | void AutofillAgent::textFieldDidEndEditing(const WebInputElement& element) { |
[email protected] | ad19b30 | 2013-04-03 07:42:19 | [diff] [blame] | 365 | password_autofill_agent_->TextFieldDidEndEditing(element); |
[email protected] | 7d24db7 | 2011-08-26 06:02:31 | [diff] [blame] | 366 | has_shown_autofill_popup_for_current_edit_ = false; |
[email protected] | 2739e0e | 2011-11-22 22:49:11 | [diff] [blame] | 367 | Send(new AutofillHostMsg_DidEndTextFieldEditing(routing_id())); |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 368 | } |
| 369 | |
[email protected] | e9d29d39 | 2014-03-25 01:15:15 | [diff] [blame] | 370 | void AutofillAgent::textFieldDidChange(const WebFormControlElement& element) { |
[email protected] | 90f2625 | 2013-02-15 19:48:32 | [diff] [blame] | 371 | if (ignore_text_changes_) |
| 372 | return; |
| 373 | |
[email protected] | e9d29d39 | 2014-03-25 01:15:15 | [diff] [blame] | 374 | DCHECK(toWebInputElement(&element) || IsTextAreaElement(element)); |
| 375 | |
[email protected] | b37043c | 2012-05-31 17:08:12 | [diff] [blame] | 376 | if (did_set_node_text_) { |
[email protected] | b96a1d1 | 2012-11-30 22:44:32 | [diff] [blame] | 377 | did_set_node_text_ = false; |
| 378 | return; |
[email protected] | b37043c | 2012-05-31 17:08:12 | [diff] [blame] | 379 | } |
| 380 | |
[email protected] | 663bd9e | 2011-03-21 01:07:01 | [diff] [blame] | 381 | // We post a task for doing the Autofill as the caret position is not set |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 382 | // properly at this point (http://bugs.webkit.org/show_bug.cgi?id=16976) and |
| 383 | // it is needed to trigger autofill. |
[email protected] | 5219146e | 2013-02-28 11:42:30 | [diff] [blame] | 384 | weak_ptr_factory_.InvalidateWeakPtrs(); |
[email protected] | d14c5b3 | 2013-05-06 05:25:11 | [diff] [blame] | 385 | base::MessageLoop::current()->PostTask( |
| 386 | FROM_HERE, |
| 387 | base::Bind(&AutofillAgent::TextFieldDidChangeImpl, |
| 388 | weak_ptr_factory_.GetWeakPtr(), |
| 389 | element)); |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 390 | } |
| 391 | |
[email protected] | e9d29d39 | 2014-03-25 01:15:15 | [diff] [blame] | 392 | void AutofillAgent::TextFieldDidChangeImpl( |
| 393 | const WebFormControlElement& element) { |
[email protected] | f9af283 | 2012-12-14 04:20:43 | [diff] [blame] | 394 | // If the element isn't focused then the changes don't matter. This check is |
| 395 | // required to properly handle IME interactions. |
| 396 | if (!element.focused()) |
| 397 | return; |
| 398 | |
[email protected] | e9d29d39 | 2014-03-25 01:15:15 | [diff] [blame] | 399 | const WebInputElement* input_element = toWebInputElement(&element); |
| 400 | if (input_element) { |
| 401 | if (password_generation_agent_ && |
| 402 | password_generation_agent_->TextDidChangeInTextField(*input_element)) { |
[email protected] | 7e04827 | 2014-04-17 03:38:52 | [diff] [blame] | 403 | is_popup_possibly_visible_ = true; |
[email protected] | e9d29d39 | 2014-03-25 01:15:15 | [diff] [blame] | 404 | return; |
| 405 | } |
[email protected] | 3cbdf936 | 2014-01-31 23:12:23 | [diff] [blame] | 406 | |
[email protected] | e9d29d39 | 2014-03-25 01:15:15 | [diff] [blame] | 407 | if (password_autofill_agent_->TextDidChangeInTextField(*input_element)) { |
| 408 | element_ = element; |
| 409 | return; |
| 410 | } |
[email protected] | e7e8347 | 2012-04-05 02:56:26 | [diff] [blame] | 411 | } |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 412 | |
brettw | b505b7a | 2014-11-26 22:05:32 | [diff] [blame] | 413 | ShowSuggestionsOptions options; |
| 414 | options.requires_caret_at_end = true; |
| 415 | ShowSuggestions(element, options); |
[email protected] | 7d24db7 | 2011-08-26 06:02:31 | [diff] [blame] | 416 | |
[email protected] | 1ecbe86 | 2012-10-05 01:29:14 | [diff] [blame] | 417 | FormData form; |
| 418 | FormFieldData field; |
[email protected] | e9d29d39 | 2014-03-25 01:15:15 | [diff] [blame] | 419 | if (FindFormAndFieldForFormControlElement(element, |
| 420 | &form, |
| 421 | &field, |
| 422 | REQUIRE_NONE)) { |
[email protected] | 1d14f58 | 2011-09-02 20:42:04 | [diff] [blame] | 423 | Send(new AutofillHostMsg_TextFieldDidChange(routing_id(), form, field, |
| 424 | base::TimeTicks::Now())); |
| 425 | } |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 426 | } |
| 427 | |
[email protected] | 2fa18c2 | 2011-06-14 23:40:43 | [diff] [blame] | 428 | void AutofillAgent::textFieldDidReceiveKeyDown(const WebInputElement& element, |
| 429 | const WebKeyboardEvent& event) { |
[email protected] | ad19b30 | 2013-04-03 07:42:19 | [diff] [blame] | 430 | if (password_autofill_agent_->TextFieldHandlingKeyDown(element, event)) { |
[email protected] | bef7f927 | 2012-04-17 10:47:49 | [diff] [blame] | 431 | element_ = element; |
[email protected] | fc1964a | 2011-01-20 19:33:07 | [diff] [blame] | 432 | return; |
[email protected] | e7e8347 | 2012-04-05 02:56:26 | [diff] [blame] | 433 | } |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 434 | |
| 435 | if (event.windowsKeyCode == ui::VKEY_DOWN || |
brettw | b505b7a | 2014-11-26 22:05:32 | [diff] [blame] | 436 | event.windowsKeyCode == ui::VKEY_UP) { |
| 437 | ShowSuggestionsOptions options; |
| 438 | options.autofill_on_empty_values = true; |
| 439 | options.requires_caret_at_end = true; |
| 440 | options.display_warning_if_disabled = true; |
| 441 | ShowSuggestions(element, options); |
| 442 | } |
[email protected] | efeb565f | 2013-12-12 17:16:41 | [diff] [blame] | 443 | } |
| 444 | |
| 445 | void AutofillAgent::openTextDataListChooser(const WebInputElement& element) { |
brettw | b505b7a | 2014-11-26 22:05:32 | [diff] [blame] | 446 | ShowSuggestionsOptions options; |
| 447 | options.autofill_on_empty_values = true; |
| 448 | options.datalist_only = true; |
| 449 | ShowSuggestions(element, options); |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 450 | } |
| 451 | |
estade | df5088a | 2014-12-15 02:04:07 | [diff] [blame^] | 452 | void AutofillAgent::dataListOptionsChanged(const WebInputElement& element) { |
| 453 | if (!is_popup_possibly_visible_ || !element.focused()) |
| 454 | return; |
| 455 | |
| 456 | TextFieldDidChangeImpl(element); |
| 457 | } |
| 458 | |
[email protected] | fc22ae5 | 2014-04-23 13:48:04 | [diff] [blame] | 459 | void AutofillAgent::firstUserGestureObserved() { |
| 460 | password_autofill_agent_->FirstUserGestureObserved(); |
estade | b1bc9bd | 2014-12-02 22:44:11 | [diff] [blame] | 461 | Send(new AutofillHostMsg_FirstUserGestureObserved(routing_id())); |
[email protected] | fc22ae5 | 2014-04-23 13:48:04 | [diff] [blame] | 462 | } |
| 463 | |
[email protected] | d5ca8fb | 2013-04-11 17:54:31 | [diff] [blame] | 464 | void AutofillAgent::AcceptDataListSuggestion( |
| 465 | const base::string16& suggested_value) { |
[email protected] | e9d29d39 | 2014-03-25 01:15:15 | [diff] [blame] | 466 | WebInputElement* input_element = toWebInputElement(&element_); |
| 467 | DCHECK(input_element); |
[email protected] | d5ca8fb | 2013-04-11 17:54:31 | [diff] [blame] | 468 | base::string16 new_value = suggested_value; |
[email protected] | 71a90b3 | 2012-05-18 09:16:53 | [diff] [blame] | 469 | // If this element takes multiple values then replace the last part with |
| 470 | // the suggestion. |
[email protected] | 7bc4453 | 2014-07-10 16:02:15 | [diff] [blame] | 471 | if (input_element->isMultiple() && input_element->isEmailField()) { |
[email protected] | d5ca8fb | 2013-04-11 17:54:31 | [diff] [blame] | 472 | std::vector<base::string16> parts; |
[email protected] | 71a90b3 | 2012-05-18 09:16:53 | [diff] [blame] | 473 | |
[email protected] | e9d29d39 | 2014-03-25 01:15:15 | [diff] [blame] | 474 | base::SplitStringDontTrim(input_element->editingValue(), ',', &parts); |
[email protected] | 71a90b3 | 2012-05-18 09:16:53 | [diff] [blame] | 475 | if (parts.size() == 0) |
[email protected] | d5ca8fb | 2013-04-11 17:54:31 | [diff] [blame] | 476 | parts.push_back(base::string16()); |
[email protected] | 71a90b3 | 2012-05-18 09:16:53 | [diff] [blame] | 477 | |
[email protected] | d5ca8fb | 2013-04-11 17:54:31 | [diff] [blame] | 478 | base::string16 last_part = parts.back(); |
[email protected] | 71a90b3 | 2012-05-18 09:16:53 | [diff] [blame] | 479 | // We want to keep just the leading whitespace. |
| 480 | for (size_t i = 0; i < last_part.size(); ++i) { |
| 481 | if (!IsWhitespace(last_part[i])) { |
| 482 | last_part = last_part.substr(0, i); |
| 483 | break; |
| 484 | } |
| 485 | } |
| 486 | last_part.append(suggested_value); |
| 487 | parts[parts.size() - 1] = last_part; |
| 488 | |
| 489 | new_value = JoinString(parts, ','); |
| 490 | } |
[email protected] | e9d29d39 | 2014-03-25 01:15:15 | [diff] [blame] | 491 | FillFieldWithValue(new_value, input_element); |
[email protected] | 71a90b3 | 2012-05-18 09:16:53 | [diff] [blame] | 492 | } |
| 493 | |
[email protected] | 3eb5728c | 2011-06-20 22:32:24 | [diff] [blame] | 494 | void AutofillAgent::OnFieldTypePredictionsAvailable( |
| 495 | const std::vector<FormDataPredictions>& forms) { |
| 496 | for (size_t i = 0; i < forms.size(); ++i) { |
[email protected] | aaa80c9 | 2011-09-16 00:23:54 | [diff] [blame] | 497 | form_cache_.ShowPredictions(forms[i]); |
[email protected] | 3eb5728c | 2011-06-20 22:32:24 | [diff] [blame] | 498 | } |
| 499 | } |
| 500 | |
[email protected] | 63560b3 | 2014-03-04 07:06:26 | [diff] [blame] | 501 | void AutofillAgent::OnFillForm(int query_id, const FormData& form) { |
estade | b1bc9bd | 2014-12-02 22:44:11 | [diff] [blame] | 502 | if (query_id != autofill_query_id_) |
[email protected] | 63560b3 | 2014-03-04 07:06:26 | [diff] [blame] | 503 | return; |
| 504 | |
| 505 | was_query_node_autofilled_ = element_.isAutofilled(); |
| 506 | FillForm(form, element_); |
| 507 | Send(new AutofillHostMsg_DidFillAutofillFormData(routing_id(), |
| 508 | base::TimeTicks::Now())); |
| 509 | } |
| 510 | |
estade | b1bc9bd | 2014-12-02 22:44:11 | [diff] [blame] | 511 | void AutofillAgent::OnFirstUserGestureObservedInTab() { |
| 512 | password_autofill_agent_->FirstUserGestureObserved(); |
| 513 | } |
| 514 | |
[email protected] | 8527a78f | 2014-06-12 12:49:15 | [diff] [blame] | 515 | void AutofillAgent::OnPing() { |
| 516 | Send(new AutofillHostMsg_PingAck(routing_id())); |
| 517 | } |
| 518 | |
[email protected] | 63560b3 | 2014-03-04 07:06:26 | [diff] [blame] | 519 | void AutofillAgent::OnPreviewForm(int query_id, const FormData& form) { |
estade | b1bc9bd | 2014-12-02 22:44:11 | [diff] [blame] | 520 | if (query_id != autofill_query_id_) |
[email protected] | 63560b3 | 2014-03-04 07:06:26 | [diff] [blame] | 521 | return; |
| 522 | |
| 523 | was_query_node_autofilled_ = element_.isAutofilled(); |
| 524 | PreviewForm(form, element_); |
| 525 | Send(new AutofillHostMsg_DidPreviewAutofillFormData(routing_id())); |
[email protected] | 6f001a6cf | 2012-02-09 15:21:53 | [diff] [blame] | 526 | } |
| 527 | |
| 528 | void AutofillAgent::OnClearForm() { |
[email protected] | bef7f927 | 2012-04-17 10:47:49 | [diff] [blame] | 529 | form_cache_.ClearFormWithElement(element_); |
[email protected] | 6f001a6cf | 2012-02-09 15:21:53 | [diff] [blame] | 530 | } |
| 531 | |
[email protected] | 6f001a6cf | 2012-02-09 15:21:53 | [diff] [blame] | 532 | void AutofillAgent::OnClearPreviewedForm() { |
[email protected] | 93f2e50 | 2013-12-20 09:47:25 | [diff] [blame] | 533 | if (!element_.isNull()) { |
[email protected] | b5b1d69f | 2014-01-23 23:49:32 | [diff] [blame] | 534 | if (password_autofill_agent_->DidClearAutofillSelection(element_)) |
| 535 | return; |
| 536 | |
[email protected] | 93f2e50 | 2013-12-20 09:47:25 | [diff] [blame] | 537 | ClearPreviewedFormWithElement(element_, was_query_node_autofilled_); |
| 538 | } else { |
| 539 | // TODO(isherman): There seem to be rare cases where this code *is* |
| 540 | // reachable: see [ http://crbug.com/96321#c6 ]. Ideally we would |
| 541 | // understand those cases and fix the code to avoid them. However, so far I |
| 542 | // have been unable to reproduce such a case locally. If you hit this |
| 543 | // NOTREACHED(), please file a bug against me. |
| 544 | NOTREACHED(); |
| 545 | } |
[email protected] | 6f001a6cf | 2012-02-09 15:21:53 | [diff] [blame] | 546 | } |
| 547 | |
[email protected] | ac9b92f | 2014-03-15 00:48:32 | [diff] [blame] | 548 | void AutofillAgent::OnFillFieldWithValue(const base::string16& value) { |
[email protected] | e9d29d39 | 2014-03-25 01:15:15 | [diff] [blame] | 549 | WebInputElement* input_element = toWebInputElement(&element_); |
ziran.sun | ee0fd443 | 2014-08-27 10:10:49 | [diff] [blame] | 550 | if (input_element) { |
[email protected] | e9d29d39 | 2014-03-25 01:15:15 | [diff] [blame] | 551 | FillFieldWithValue(value, input_element); |
ziran.sun | ee0fd443 | 2014-08-27 10:10:49 | [diff] [blame] | 552 | input_element->setAutofilled(true); |
| 553 | } |
[email protected] | ac9b92f | 2014-03-15 00:48:32 | [diff] [blame] | 554 | } |
| 555 | |
| 556 | void AutofillAgent::OnPreviewFieldWithValue(const base::string16& value) { |
[email protected] | e9d29d39 | 2014-03-25 01:15:15 | [diff] [blame] | 557 | WebInputElement* input_element = toWebInputElement(&element_); |
| 558 | if (input_element) |
| 559 | PreviewFieldWithValue(value, input_element); |
[email protected] | 6f001a6cf | 2012-02-09 15:21:53 | [diff] [blame] | 560 | } |
| 561 | |
[email protected] | d5ca8fb | 2013-04-11 17:54:31 | [diff] [blame] | 562 | void AutofillAgent::OnAcceptDataListSuggestion(const base::string16& value) { |
[email protected] | 5c8de6b9 | 2012-06-08 21:24:08 | [diff] [blame] | 563 | AcceptDataListSuggestion(value); |
| 564 | } |
| 565 | |
[email protected] | 126b1ad | 2014-05-21 22:37:33 | [diff] [blame] | 566 | void AutofillAgent::OnFillPasswordSuggestion(const base::string16& username, |
| 567 | const base::string16& password) { |
| 568 | bool handled = password_autofill_agent_->FillSuggestion( |
| 569 | element_, |
| 570 | username, |
| 571 | password); |
| 572 | DCHECK(handled); |
| 573 | } |
| 574 | |
| 575 | void AutofillAgent::OnPreviewPasswordSuggestion( |
[email protected] | c281d50 | 2014-04-24 21:07:36 | [diff] [blame] | 576 | const base::string16& username, |
| 577 | const base::string16& password) { |
[email protected] | 126b1ad | 2014-05-21 22:37:33 | [diff] [blame] | 578 | bool handled = password_autofill_agent_->PreviewSuggestion( |
[email protected] | bef7f927 | 2012-04-17 10:47:49 | [diff] [blame] | 579 | element_, |
[email protected] | c281d50 | 2014-04-24 21:07:36 | [diff] [blame] | 580 | username, |
| 581 | password); |
[email protected] | e7e8347 | 2012-04-05 02:56:26 | [diff] [blame] | 582 | DCHECK(handled); |
| 583 | } |
| 584 | |
[email protected] | 82fc1b1 | 2013-01-12 00:53:56 | [diff] [blame] | 585 | void AutofillAgent::OnRequestAutocompleteResult( |
[email protected] | 5e7e861 | 2014-03-20 14:43:19 | [diff] [blame] | 586 | WebFormElement::AutocompleteResult result, |
[email protected] | dbdd6027 | 2014-04-14 22:48:40 | [diff] [blame] | 587 | const base::string16& message, |
[email protected] | 5e7e861 | 2014-03-20 14:43:19 | [diff] [blame] | 588 | const FormData& form_data) { |
[email protected] | 364481b | 2013-01-29 01:52:28 | [diff] [blame] | 589 | if (in_flight_request_form_.isNull()) |
| 590 | return; |
| 591 | |
[email protected] | 9793fb23 | 2013-06-21 10:25:35 | [diff] [blame] | 592 | if (result == WebFormElement::AutocompleteResultSuccess) { |
[email protected] | 82fc1b1 | 2013-01-12 00:53:56 | [diff] [blame] | 593 | FillFormIncludingNonFocusableElements(form_data, in_flight_request_form_); |
[email protected] | 3bf260a | 2014-04-16 19:37:12 | [diff] [blame] | 594 | if (!in_flight_request_form_.checkValidity()) |
[email protected] | 9793fb23 | 2013-06-21 10:25:35 | [diff] [blame] | 595 | result = WebFormElement::AutocompleteResultErrorInvalid; |
| 596 | } |
[email protected] | 364481b | 2013-01-29 01:52:28 | [diff] [blame] | 597 | |
[email protected] | 81cd5233 | 2012-11-05 20:36:07 | [diff] [blame] | 598 | in_flight_request_form_.finishRequestAutocomplete(result); |
[email protected] | dbdd6027 | 2014-04-14 22:48:40 | [diff] [blame] | 599 | |
| 600 | if (!message.empty()) { |
| 601 | const base::string16 prefix(base::ASCIIToUTF16("requestAutocomplete: ")); |
| 602 | WebConsoleMessage console_message = WebConsoleMessage( |
| 603 | WebConsoleMessage::LevelLog, WebString(prefix + message)); |
| 604 | in_flight_request_form_.document().frame()->addMessageToConsole( |
| 605 | console_message); |
| 606 | } |
| 607 | |
[email protected] | 81cd5233 | 2012-11-05 20:36:07 | [diff] [blame] | 608 | in_flight_request_form_.reset(); |
| 609 | } |
| 610 | |
[email protected] | e9d29d39 | 2014-03-25 01:15:15 | [diff] [blame] | 611 | void AutofillAgent::ShowSuggestions(const WebFormControlElement& element, |
brettw | b505b7a | 2014-11-26 22:05:32 | [diff] [blame] | 612 | const ShowSuggestionsOptions& options) { |
[email protected] | e9d29d39 | 2014-03-25 01:15:15 | [diff] [blame] | 613 | if (!element.isEnabled() || element.isReadOnly()) |
[email protected] | efeb565f | 2013-12-12 17:16:41 | [diff] [blame] | 614 | return; |
brettw | b505b7a | 2014-11-26 22:05:32 | [diff] [blame] | 615 | if (!options.datalist_only && !element.suggestedValue().isEmpty()) |
[email protected] | 580c3805 | 2014-07-16 07:28:09 | [diff] [blame] | 616 | return; |
[email protected] | e9d29d39 | 2014-03-25 01:15:15 | [diff] [blame] | 617 | |
| 618 | const WebInputElement* input_element = toWebInputElement(&element); |
| 619 | if (input_element) { |
jww | 2035507 | 2014-12-12 21:00:55 | [diff] [blame] | 620 | if (!input_element->isTextField()) |
[email protected] | e9d29d39 | 2014-03-25 01:15:15 | [diff] [blame] | 621 | return; |
brettw | b505b7a | 2014-11-26 22:05:32 | [diff] [blame] | 622 | if (!options.datalist_only && !input_element->suggestedValue().isEmpty()) |
[email protected] | e9d29d39 | 2014-03-25 01:15:15 | [diff] [blame] | 623 | return; |
| 624 | } else { |
| 625 | DCHECK(IsTextAreaElement(element)); |
| 626 | if (!element.toConst<WebTextAreaElement>().suggestedValue().isEmpty()) |
| 627 | return; |
| 628 | } |
[email protected] | e47aec5 | 2010-08-12 00:50:30 | [diff] [blame] | 629 | |
[email protected] | 1c69f8b7 | 2012-03-14 03:18:50 | [diff] [blame] | 630 | // Don't attempt to autofill with values that are too large or if filling |
| 631 | // criteria are not met. |
[email protected] | 71a90b3 | 2012-05-18 09:16:53 | [diff] [blame] | 632 | WebString value = element.editingValue(); |
brettw | b505b7a | 2014-11-26 22:05:32 | [diff] [blame] | 633 | if (!options.datalist_only && |
[email protected] | d86263dcd | 2014-01-09 10:35:21 | [diff] [blame] | 634 | (value.length() > kMaxDataLength || |
brettw | b505b7a | 2014-11-26 22:05:32 | [diff] [blame] | 635 | (!options.autofill_on_empty_values && value.isEmpty()) || |
| 636 | (options.requires_caret_at_end && |
[email protected] | efeb565f | 2013-12-12 17:16:41 | [diff] [blame] | 637 | (element.selectionStart() != element.selectionEnd() || |
| 638 | element.selectionEnd() != static_cast<int>(value.length()))))) { |
[email protected] | 1c69f8b7 | 2012-03-14 03:18:50 | [diff] [blame] | 639 | // Any popup currently showing is obsolete. |
[email protected] | b648f24 | 2014-02-25 13:49:06 | [diff] [blame] | 640 | HidePopup(); |
[email protected] | e47aec5 | 2010-08-12 00:50:30 | [diff] [blame] | 641 | return; |
[email protected] | 1c69f8b7 | 2012-03-14 03:18:50 | [diff] [blame] | 642 | } |
[email protected] | e47aec5 | 2010-08-12 00:50:30 | [diff] [blame] | 643 | |
[email protected] | bef7f927 | 2012-04-17 10:47:49 | [diff] [blame] | 644 | element_ = element; |
[email protected] | 580c3805 | 2014-07-16 07:28:09 | [diff] [blame] | 645 | if (IsAutofillableInputElement(input_element) && |
brettw | b505b7a | 2014-11-26 22:05:32 | [diff] [blame] | 646 | (password_autofill_agent_->ShowSuggestions( |
| 647 | *input_element, options.show_full_suggestion_list) || |
| 648 | options.show_password_suggestions_only)) { |
[email protected] | b648f24 | 2014-02-25 13:49:06 | [diff] [blame] | 649 | is_popup_possibly_visible_ = true; |
[email protected] | c66ba98 | 2013-04-05 09:56:17 | [diff] [blame] | 650 | return; |
[email protected] | b648f24 | 2014-02-25 13:49:06 | [diff] [blame] | 651 | } |
[email protected] | bef7f927 | 2012-04-17 10:47:49 | [diff] [blame] | 652 | |
jww | 2035507 | 2014-12-12 21:00:55 | [diff] [blame] | 653 | // Password field elements should only have suggestions shown by the password |
| 654 | // autofill agent. |
| 655 | if (input_element && input_element->isPasswordField()) |
| 656 | return; |
| 657 | |
[email protected] | 33915c1 | 2013-07-11 23:16:33 | [diff] [blame] | 658 | // If autocomplete is disabled at the field level, ensure that the native |
| 659 | // UI won't try to show a warning, since that may conflict with a custom |
| 660 | // popup. Note that we cannot use the WebKit method element.autoComplete() |
[email protected] | 5af43c13 | 2012-11-06 07:03:44 | [diff] [blame] | 661 | // as it does not allow us to distinguish the case where autocomplete is |
| 662 | // disabled for *both* the element and for the form. |
brettw | b505b7a | 2014-11-26 22:05:32 | [diff] [blame] | 663 | bool display_warning = options.display_warning_if_disabled; |
| 664 | if (display_warning) { |
| 665 | const base::string16 autocomplete_attribute = |
| 666 | element.getAttribute("autocomplete"); |
| 667 | if (LowerCaseEqualsASCII(autocomplete_attribute, "off")) |
| 668 | display_warning = false; |
| 669 | } |
[email protected] | bef7f927 | 2012-04-17 10:47:49 | [diff] [blame] | 670 | |
brettw | b505b7a | 2014-11-26 22:05:32 | [diff] [blame] | 671 | QueryAutofillSuggestions(element, display_warning, options.datalist_only); |
[email protected] | 77bb0da | 2010-11-20 01:55:30 | [diff] [blame] | 672 | } |
| 673 | |
[email protected] | e9d29d39 | 2014-03-25 01:15:15 | [diff] [blame] | 674 | void AutofillAgent::QueryAutofillSuggestions( |
| 675 | const WebFormControlElement& element, |
| 676 | bool display_warning_if_disabled, |
| 677 | bool datalist_only) { |
[email protected] | e69b5f7 | 2013-01-24 00:59:13 | [diff] [blame] | 678 | if (!element.document().frame()) |
| 679 | return; |
| 680 | |
[email protected] | e9d29d39 | 2014-03-25 01:15:15 | [diff] [blame] | 681 | DCHECK(toWebInputElement(&element) || IsTextAreaElement(element)); |
| 682 | |
[email protected] | 77bb0da | 2010-11-20 01:55:30 | [diff] [blame] | 683 | static int query_counter = 0; |
| 684 | autofill_query_id_ = query_counter++; |
[email protected] | 6bcd58a | 2010-11-25 02:31:20 | [diff] [blame] | 685 | display_warning_if_disabled_ = display_warning_if_disabled; |
[email protected] | 77bb0da | 2010-11-20 01:55:30 | [diff] [blame] | 686 | |
[email protected] | 5af43c13 | 2012-11-06 07:03:44 | [diff] [blame] | 687 | // If autocomplete is disabled at the form level, we want to see if there |
| 688 | // would have been any suggestions were it enabled, so that we can show a |
| 689 | // warning. Otherwise, we want to ignore fields that disable autocomplete, so |
| 690 | // that the suggestions list does not include suggestions for these form |
| 691 | // fields -- see comment 1 on http://crbug.com/69914 |
estade | 0ee9126 | 2014-10-23 19:29:19 | [diff] [blame] | 692 | RequirementsMask requirements = |
[email protected] | 5af43c13 | 2012-11-06 07:03:44 | [diff] [blame] | 693 | element.autoComplete() ? REQUIRE_AUTOCOMPLETE : REQUIRE_NONE; |
| 694 | |
estade | 0ee9126 | 2014-10-23 19:29:19 | [diff] [blame] | 695 | // If we're ignoring autocomplete="off", always extract everything. |
estade | 3142073 | 2014-11-17 20:04:16 | [diff] [blame] | 696 | if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 697 | switches::kRespectAutocompleteOffForAutofill)) { |
estade | 0ee9126 | 2014-10-23 19:29:19 | [diff] [blame] | 698 | requirements = REQUIRE_NONE; |
| 699 | } |
| 700 | |
[email protected] | 1ecbe86 | 2012-10-05 01:29:14 | [diff] [blame] | 701 | FormData form; |
| 702 | FormFieldData field; |
[email protected] | e9d29d39 | 2014-03-25 01:15:15 | [diff] [blame] | 703 | if (!FindFormAndFieldForFormControlElement(element, &form, &field, |
| 704 | requirements)) { |
[email protected] | 7837be6 | 2011-01-18 23:45:08 | [diff] [blame] | 705 | // If we didn't find the cached form, at least let autocomplete have a shot |
| 706 | // at providing suggestions. |
[email protected] | aaa80c9 | 2011-09-16 00:23:54 | [diff] [blame] | 707 | WebFormControlElementToFormField(element, EXTRACT_VALUE, &field); |
[email protected] | 7837be6 | 2011-01-18 23:45:08 | [diff] [blame] | 708 | } |
[email protected] | efeb565f | 2013-12-12 17:16:41 | [diff] [blame] | 709 | if (datalist_only) |
| 710 | field.should_autocomplete = false; |
[email protected] | 77bb0da | 2010-11-20 01:55:30 | [diff] [blame] | 711 | |
estade | b1bc9bd | 2014-12-02 22:44:11 | [diff] [blame] | 712 | gfx::RectF bounding_box_scaled = GetScaledBoundingBox( |
| 713 | render_frame()->GetRenderView()->GetWebView()->pageScaleFactor(), |
| 714 | &element_); |
[email protected] | 73a087f | 2013-02-06 07:02:06 | [diff] [blame] | 715 | |
[email protected] | 7d0ea536 | 2014-05-01 23:39:43 | [diff] [blame] | 716 | std::vector<base::string16> data_list_values; |
| 717 | std::vector<base::string16> data_list_labels; |
[email protected] | e9d29d39 | 2014-03-25 01:15:15 | [diff] [blame] | 718 | const WebInputElement* input_element = toWebInputElement(&element); |
| 719 | if (input_element) { |
| 720 | // Find the datalist values and send them to the browser process. |
[email protected] | e9d29d39 | 2014-03-25 01:15:15 | [diff] [blame] | 721 | GetDataListSuggestions(*input_element, |
| 722 | datalist_only, |
| 723 | &data_list_values, |
| 724 | &data_list_labels); |
| 725 | TrimStringVectorForIPC(&data_list_values); |
| 726 | TrimStringVectorForIPC(&data_list_labels); |
[email protected] | e9d29d39 | 2014-03-25 01:15:15 | [diff] [blame] | 727 | } |
[email protected] | 5c8de6b9 | 2012-06-08 21:24:08 | [diff] [blame] | 728 | |
[email protected] | b648f24 | 2014-02-25 13:49:06 | [diff] [blame] | 729 | is_popup_possibly_visible_ = true; |
[email protected] | 7d0ea536 | 2014-05-01 23:39:43 | [diff] [blame] | 730 | Send(new AutofillHostMsg_SetDataList(routing_id(), |
| 731 | data_list_values, |
| 732 | data_list_labels)); |
| 733 | |
[email protected] | 2739e0e | 2011-11-22 22:49:11 | [diff] [blame] | 734 | Send(new AutofillHostMsg_QueryFormFieldAutofill(routing_id(), |
| 735 | autofill_query_id_, |
| 736 | form, |
| 737 | field, |
[email protected] | 73a087f | 2013-02-06 07:02:06 | [diff] [blame] | 738 | bounding_box_scaled, |
[email protected] | 2739e0e | 2011-11-22 22:49:11 | [diff] [blame] | 739 | display_warning_if_disabled)); |
[email protected] | e47aec5 | 2010-08-12 00:50:30 | [diff] [blame] | 740 | } |
| 741 | |
[email protected] | ac9b92f | 2014-03-15 00:48:32 | [diff] [blame] | 742 | void AutofillAgent::FillFieldWithValue(const base::string16& value, |
[email protected] | 5e7e861 | 2014-03-20 14:43:19 | [diff] [blame] | 743 | WebInputElement* node) { |
[email protected] | b37043c | 2012-05-31 17:08:12 | [diff] [blame] | 744 | did_set_node_text_ = true; |
[email protected] | 2ee19ec | 2014-02-25 12:44:31 | [diff] [blame] | 745 | node->setEditingValue(value.substr(0, node->maxLength())); |
[email protected] | ac9b92f | 2014-03-15 00:48:32 | [diff] [blame] | 746 | } |
| 747 | |
| 748 | void AutofillAgent::PreviewFieldWithValue(const base::string16& value, |
[email protected] | 5e7e861 | 2014-03-20 14:43:19 | [diff] [blame] | 749 | WebInputElement* node) { |
[email protected] | ac9b92f | 2014-03-15 00:48:32 | [diff] [blame] | 750 | was_query_node_autofilled_ = element_.isAutofilled(); |
| 751 | node->setSuggestedValue(value.substr(0, node->maxLength())); |
| 752 | node->setAutofilled(true); |
[email protected] | f47d302 | 2014-03-24 21:24:18 | [diff] [blame] | 753 | node->setSelectionRange(node->value().length(), |
| 754 | node->suggestedValue().length()); |
[email protected] | 6f001a6cf | 2012-02-09 15:21:53 | [diff] [blame] | 755 | } |
| 756 | |
estade | b1bc9bd | 2014-12-02 22:44:11 | [diff] [blame] | 757 | void AutofillAgent::ProcessForms() { |
[email protected] | 5193ea5 | 2014-05-14 01:10:02 | [diff] [blame] | 758 | // Record timestamp of when the forms are first seen. This is used to |
| 759 | // measure the overhead of the Autofill feature. |
| 760 | base::TimeTicks forms_seen_timestamp = base::TimeTicks::Now(); |
| 761 | |
estade | b1bc9bd | 2014-12-02 22:44:11 | [diff] [blame] | 762 | WebLocalFrame* frame = render_frame()->GetWebFrame(); |
| 763 | std::vector<FormData> forms = form_cache_.ExtractNewForms(*frame); |
[email protected] | 5193ea5 | 2014-05-14 01:10:02 | [diff] [blame] | 764 | |
| 765 | // Always communicate to browser process for topmost frame. |
estade | b1bc9bd | 2014-12-02 22:44:11 | [diff] [blame] | 766 | if (!forms.empty() || !frame->parent()) { |
[email protected] | 5193ea5 | 2014-05-14 01:10:02 | [diff] [blame] | 767 | Send(new AutofillHostMsg_FormsSeen(routing_id(), forms, |
| 768 | forms_seen_timestamp)); |
| 769 | } |
[email protected] | 5193ea5 | 2014-05-14 01:10:02 | [diff] [blame] | 770 | } |
| 771 | |
[email protected] | b648f24 | 2014-02-25 13:49:06 | [diff] [blame] | 772 | void AutofillAgent::HidePopup() { |
| 773 | if (!is_popup_possibly_visible_) |
| 774 | return; |
| 775 | |
[email protected] | b5b1d69f | 2014-01-23 23:49:32 | [diff] [blame] | 776 | if (!element_.isNull()) |
| 777 | OnClearPreviewedForm(); |
| 778 | |
[email protected] | b648f24 | 2014-02-25 13:49:06 | [diff] [blame] | 779 | is_popup_possibly_visible_ = false; |
| 780 | Send(new AutofillHostMsg_HidePopup(routing_id())); |
[email protected] | 81cd5233 | 2012-11-05 20:36:07 | [diff] [blame] | 781 | } |
| 782 | |
[email protected] | 5e7e861 | 2014-03-20 14:43:19 | [diff] [blame] | 783 | void AutofillAgent::didAssociateFormControls(const WebVector<WebNode>& nodes) { |
[email protected] | 704b623 | 2013-09-16 21:19:12 | [diff] [blame] | 784 | for (size_t i = 0; i < nodes.size(); ++i) { |
[email protected] | 5193ea5 | 2014-05-14 01:10:02 | [diff] [blame] | 785 | WebLocalFrame* frame = nodes[i].document().frame(); |
[email protected] | 704b623 | 2013-09-16 21:19:12 | [diff] [blame] | 786 | // Only monitors dynamic forms created in the top frame. Dynamic forms |
[email protected] | 5193ea5 | 2014-05-14 01:10:02 | [diff] [blame] | 787 | // inserted in iframes are not captured yet. Frame is only processed |
| 788 | // if it has finished loading, otherwise you can end up with a partially |
| 789 | // parsed form. |
estade | b1bc9bd | 2014-12-02 22:44:11 | [diff] [blame] | 790 | if (frame && !frame->isLoading()) { |
| 791 | ProcessForms(); |
| 792 | password_autofill_agent_->OnDynamicFormsSeen(); |
gcasto | 93a9650 | 2014-10-21 04:15:30 | [diff] [blame] | 793 | if (password_generation_agent_) |
estade | b1bc9bd | 2014-12-02 22:44:11 | [diff] [blame] | 794 | password_generation_agent_->OnDynamicFormsSeen(); |
[email protected] | 704b623 | 2013-09-16 21:19:12 | [diff] [blame] | 795 | return; |
| 796 | } |
| 797 | } |
[email protected] | 17b6be7 | 2013-04-30 21:33:08 | [diff] [blame] | 798 | } |
| 799 | |
estade | b1bc9bd | 2014-12-02 22:44:11 | [diff] [blame] | 800 | // LegacyAutofillAgent --------------------------------------------------------- |
| 801 | |
| 802 | AutofillAgent::LegacyAutofillAgent::LegacyAutofillAgent( |
| 803 | content::RenderView* render_view, |
| 804 | AutofillAgent* agent) |
| 805 | : content::RenderViewObserver(render_view), agent_(agent) { |
| 806 | } |
| 807 | |
| 808 | AutofillAgent::LegacyAutofillAgent::~LegacyAutofillAgent() { |
| 809 | } |
| 810 | |
| 811 | void AutofillAgent::LegacyAutofillAgent::OnDestruct() { |
| 812 | // No-op. Don't delete |this|. |
| 813 | } |
| 814 | |
| 815 | void AutofillAgent::LegacyAutofillAgent::FrameDetached(WebFrame* frame) { |
| 816 | agent_->FrameDetached(frame); |
| 817 | } |
| 818 | |
| 819 | void AutofillAgent::LegacyAutofillAgent::WillSubmitForm( |
| 820 | WebLocalFrame* frame, |
| 821 | const WebFormElement& form) { |
| 822 | agent_->WillSubmitForm(frame, form); |
| 823 | } |
| 824 | |
| 825 | void AutofillAgent::LegacyAutofillAgent::DidChangeScrollOffset( |
| 826 | WebLocalFrame* frame) { |
| 827 | agent_->DidChangeScrollOffset(frame); |
| 828 | } |
| 829 | |
| 830 | void AutofillAgent::LegacyAutofillAgent::FocusedNodeChanged( |
| 831 | const WebNode& node) { |
| 832 | agent_->FocusedNodeChanged(node); |
| 833 | } |
| 834 | |
| 835 | void AutofillAgent::LegacyAutofillAgent::OrientationChangeEvent() { |
| 836 | agent_->OrientationChangeEvent(); |
| 837 | } |
| 838 | |
| 839 | void AutofillAgent::LegacyAutofillAgent::Resized() { |
| 840 | agent_->Resized(); |
| 841 | } |
| 842 | |
| 843 | void AutofillAgent::LegacyAutofillAgent::FrameWillClose( |
| 844 | blink::WebFrame* frame) { |
| 845 | agent_->LegacyFrameWillClose(frame); |
| 846 | } |
| 847 | |
[email protected] | 7819208 | 2011-01-29 05:43:44 | [diff] [blame] | 848 | } // namespace autofill |