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 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
221 | 221 |
222 void AutofillAgent::FocusedNodeChanged(const WebNode& node) { | 222 void AutofillAgent::FocusedNodeChanged(const WebNode& node) { |
223 HidePopup(); | 223 HidePopup(); |
224 | 224 |
225 if (node.isNull() || !node.isElementNode()) | 225 if (node.isNull() || !node.isElementNode()) |
226 return; | 226 return; |
227 | 227 |
228 if (node.document().frame() != render_frame()->GetWebFrame()) | 228 if (node.document().frame() != render_frame()->GetWebFrame()) |
229 return; | 229 return; |
230 | 230 |
231 if (password_generation_agent_ && | |
232 password_generation_agent_->FocusedNodeHasChanged(node)) { | |
233 is_popup_possibly_visible_ = true; | |
234 return; | |
235 } | |
236 | |
237 WebElement web_element = node.toConst<WebElement>(); | 231 WebElement web_element = node.toConst<WebElement>(); |
238 | 232 |
239 if (!web_element.document().frame()) | 233 if (!web_element.document().frame()) |
240 return; | 234 return; |
241 | 235 |
242 const WebInputElement* element = toWebInputElement(&web_element); | 236 const WebInputElement* element = toWebInputElement(&web_element); |
243 | 237 |
244 if (!element || !element->isEnabled() || element->isReadOnly() || | 238 if (!element || !element->isEnabled() || element->isReadOnly() || |
245 !element->isTextField() || element->isPasswordField()) | 239 !element->isTextField() || element->isPasswordField()) |
246 return; | 240 return; |
247 | 241 |
248 element_ = *element; | 242 element_ = *element; |
249 } | 243 } |
250 | 244 |
251 void AutofillAgent::OrientationChangeEvent() { | 245 void AutofillAgent::OrientationChangeEvent() { |
aelias_OOO_until_Jul13
2014/12/16 23:15:49
Can we delete this one? It seems redundant with t
please use gerrit instead
2014/12/16 23:39:22
Evan is removing it in https://codereview.chromium
| |
252 HidePopup(); | 246 HidePopup(); |
253 } | 247 } |
254 | 248 |
255 void AutofillAgent::Resized() { | 249 void AutofillAgent::FocusedElementMovedOnResize() { |
256 HidePopup(); | 250 HidePopup(); |
257 } | 251 } |
258 | 252 |
259 void AutofillAgent::LegacyFrameWillClose(blink::WebFrame* frame) { | 253 void AutofillAgent::LegacyFrameWillClose(blink::WebFrame* frame) { |
260 if (in_flight_request_form_.isNull()) | 254 if (in_flight_request_form_.isNull()) |
261 return; | 255 return; |
262 | 256 |
263 for (blink::WebFrame* temp = render_frame()->GetWebFrame(); temp; | 257 for (blink::WebFrame* temp = render_frame()->GetWebFrame(); temp; |
264 temp = temp->parent()) { | 258 temp = temp->parent()) { |
265 if (temp == frame) { | 259 if (temp == frame) { |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
332 const WebFormControlElement& element, | 326 const WebFormControlElement& element, |
333 bool was_focused) { | 327 bool was_focused) { |
334 // TODO(estade): Remove this check when PageClickTracker is per-frame. | 328 // TODO(estade): Remove this check when PageClickTracker is per-frame. |
335 if (element.document().frame() != render_frame()->GetWebFrame()) | 329 if (element.document().frame() != render_frame()->GetWebFrame()) |
336 return; | 330 return; |
337 | 331 |
338 const WebInputElement* input_element = toWebInputElement(&element); | 332 const WebInputElement* input_element = toWebInputElement(&element); |
339 if (!input_element && !IsTextAreaElement(element)) | 333 if (!input_element && !IsTextAreaElement(element)) |
340 return; | 334 return; |
341 | 335 |
336 if (password_generation_agent_ && | |
337 password_generation_agent_->FocusedNodeHasChanged(*input_element)) { | |
338 is_popup_possibly_visible_ = true; | |
339 return; | |
340 } | |
341 | |
342 ShowSuggestionsOptions options; | 342 ShowSuggestionsOptions options; |
343 options.autofill_on_empty_values = true; | 343 options.autofill_on_empty_values = true; |
344 options.display_warning_if_disabled = true; | 344 options.display_warning_if_disabled = true; |
345 options.show_full_suggestion_list = element.isAutofilled(); | 345 options.show_full_suggestion_list = element.isAutofilled(); |
346 | 346 |
347 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | 347 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
348 switches::kEnableSingleClickAutofill)) { | 348 switches::kEnableSingleClickAutofill)) { |
349 // Show full suggestions when clicking on an already-focused form field. On | 349 // Show full suggestions when clicking on an already-focused form field. On |
350 // the initial click (not focused yet), only show password suggestions. | 350 // the initial click (not focused yet), only show password suggestions. |
351 #if defined(OS_ANDROID) | |
352 // TODO(gcasto): Remove after crbug.com/430318 has been fixed. | |
353 if (!was_focused) | |
354 return; | |
355 #endif | |
356 | |
357 options.show_full_suggestion_list = | 351 options.show_full_suggestion_list = |
358 options.show_full_suggestion_list || was_focused; | 352 options.show_full_suggestion_list || was_focused; |
359 options.show_password_suggestions_only = !was_focused; | 353 options.show_password_suggestions_only = !was_focused; |
360 } | 354 } |
361 ShowSuggestions(element, options); | 355 ShowSuggestions(element, options); |
362 } | 356 } |
363 | 357 |
364 void AutofillAgent::textFieldDidEndEditing(const WebInputElement& element) { | 358 void AutofillAgent::textFieldDidEndEditing(const WebInputElement& element) { |
365 password_autofill_agent_->TextFieldDidEndEditing(element); | 359 password_autofill_agent_->TextFieldDidEndEditing(element); |
366 has_shown_autofill_popup_for_current_edit_ = false; | 360 has_shown_autofill_popup_for_current_edit_ = false; |
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
829 | 823 |
830 void AutofillAgent::LegacyAutofillAgent::FocusedNodeChanged( | 824 void AutofillAgent::LegacyAutofillAgent::FocusedNodeChanged( |
831 const WebNode& node) { | 825 const WebNode& node) { |
832 agent_->FocusedNodeChanged(node); | 826 agent_->FocusedNodeChanged(node); |
833 } | 827 } |
834 | 828 |
835 void AutofillAgent::LegacyAutofillAgent::OrientationChangeEvent() { | 829 void AutofillAgent::LegacyAutofillAgent::OrientationChangeEvent() { |
836 agent_->OrientationChangeEvent(); | 830 agent_->OrientationChangeEvent(); |
837 } | 831 } |
838 | 832 |
839 void AutofillAgent::LegacyAutofillAgent::Resized() { | 833 void AutofillAgent::LegacyAutofillAgent::FocusedElementMovedOnResize() { |
840 agent_->Resized(); | 834 agent_->FocusedElementMovedOnResize(); |
841 } | 835 } |
842 | 836 |
843 void AutofillAgent::LegacyAutofillAgent::FrameWillClose( | 837 void AutofillAgent::LegacyAutofillAgent::FrameWillClose( |
844 blink::WebFrame* frame) { | 838 blink::WebFrame* frame) { |
845 agent_->LegacyFrameWillClose(frame); | 839 agent_->LegacyFrameWillClose(frame); |
846 } | 840 } |
847 | 841 |
848 } // namespace autofill | 842 } // namespace autofill |
OLD | NEW |