| 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 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 | 207 |
| 208 void AutofillAgent::FocusedNodeChanged(const WebNode& node) { | 208 void AutofillAgent::FocusedNodeChanged(const WebNode& node) { |
| 209 HidePopup(); | 209 HidePopup(); |
| 210 | 210 |
| 211 if (node.isNull() || !node.isElementNode()) | 211 if (node.isNull() || !node.isElementNode()) |
| 212 return; | 212 return; |
| 213 | 213 |
| 214 if (node.document().frame() != render_frame()->GetWebFrame()) | 214 if (node.document().frame() != render_frame()->GetWebFrame()) |
| 215 return; | 215 return; |
| 216 | 216 |
| 217 if (password_generation_agent_ && | |
| 218 password_generation_agent_->FocusedNodeHasChanged(node)) { | |
| 219 is_popup_possibly_visible_ = true; | |
| 220 return; | |
| 221 } | |
| 222 | |
| 223 WebElement web_element = node.toConst<WebElement>(); | 217 WebElement web_element = node.toConst<WebElement>(); |
| 224 | 218 |
| 225 if (!web_element.document().frame()) | 219 if (!web_element.document().frame()) |
| 226 return; | 220 return; |
| 227 | 221 |
| 228 const WebInputElement* element = toWebInputElement(&web_element); | 222 const WebInputElement* element = toWebInputElement(&web_element); |
| 229 | 223 |
| 230 if (!element || !element->isEnabled() || element->isReadOnly() || | 224 if (!element || !element->isEnabled() || element->isReadOnly() || |
| 231 !element->isTextField() || element->isPasswordField()) | 225 !element->isTextField()) |
| 232 return; | 226 return; |
| 233 | 227 |
| 234 element_ = *element; | 228 element_ = *element; |
| 235 } | 229 } |
| 236 | 230 |
| 237 void AutofillAgent::Resized() { | 231 void AutofillAgent::FocusedElementMovedOnResize() { |
| 238 HidePopup(); | 232 HidePopup(); |
| 239 } | 233 } |
| 240 | 234 |
| 235 void AutofillAgent::FocusChangeComplete() { |
| 236 if (!element_.isNull() && password_generation_agent_ && |
| 237 password_generation_agent_->FocusedNodeHasChanged(element_)) { |
| 238 is_popup_possibly_visible_ = true; |
| 239 } |
| 240 } |
| 241 |
| 241 void AutofillAgent::didRequestAutocomplete( | 242 void AutofillAgent::didRequestAutocomplete( |
| 242 const WebFormElement& form) { | 243 const WebFormElement& form) { |
| 243 DCHECK_EQ(form.document().frame(), render_frame()->GetWebFrame()); | 244 DCHECK_EQ(form.document().frame(), render_frame()->GetWebFrame()); |
| 244 | 245 |
| 245 // Disallow the dialog over non-https or broken https, except when the | 246 // Disallow the dialog over non-https or broken https, except when the |
| 246 // ignore SSL flag is passed. See http://crbug.com/272512. | 247 // ignore SSL flag is passed. See http://crbug.com/272512. |
| 247 // TODO(palmer): this should be moved to the browser process after frames | 248 // TODO(palmer): this should be moved to the browser process after frames |
| 248 // get their own processes. | 249 // get their own processes. |
| 249 GURL url(form.document().url()); | 250 GURL url(form.document().url()); |
| 250 content::SSLStatus ssl_status = | 251 content::SSLStatus ssl_status = |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 | 310 |
| 310 ShowSuggestionsOptions options; | 311 ShowSuggestionsOptions options; |
| 311 options.autofill_on_empty_values = true; | 312 options.autofill_on_empty_values = true; |
| 312 options.display_warning_if_disabled = true; | 313 options.display_warning_if_disabled = true; |
| 313 options.show_full_suggestion_list = element.isAutofilled(); | 314 options.show_full_suggestion_list = element.isAutofilled(); |
| 314 | 315 |
| 315 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | 316 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 316 switches::kEnableSingleClickAutofill)) { | 317 switches::kEnableSingleClickAutofill)) { |
| 317 // Show full suggestions when clicking on an already-focused form field. On | 318 // Show full suggestions when clicking on an already-focused form field. On |
| 318 // the initial click (not focused yet), only show password suggestions. | 319 // the initial click (not focused yet), only show password suggestions. |
| 319 #if defined(OS_ANDROID) | |
| 320 // TODO(gcasto): Remove after crbug.com/430318 has been fixed. | |
| 321 if (!was_focused) | |
| 322 return; | |
| 323 #endif | |
| 324 | |
| 325 options.show_full_suggestion_list = | 320 options.show_full_suggestion_list = |
| 326 options.show_full_suggestion_list || was_focused; | 321 options.show_full_suggestion_list || was_focused; |
| 327 options.show_password_suggestions_only = !was_focused; | 322 options.show_password_suggestions_only = !was_focused; |
| 328 } | 323 } |
| 329 ShowSuggestions(element, options); | 324 ShowSuggestions(element, options); |
| 330 } | 325 } |
| 331 | 326 |
| 332 void AutofillAgent::textFieldDidEndEditing(const WebInputElement& element) { | 327 void AutofillAgent::textFieldDidEndEditing(const WebInputElement& element) { |
| 333 password_autofill_agent_->TextFieldDidEndEditing(element); | 328 password_autofill_agent_->TextFieldDidEndEditing(element); |
| 334 has_shown_autofill_popup_for_current_edit_ = false; | 329 has_shown_autofill_popup_for_current_edit_ = false; |
| (...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 778 | 773 |
| 779 void AutofillAgent::LegacyAutofillAgent::OnDestruct() { | 774 void AutofillAgent::LegacyAutofillAgent::OnDestruct() { |
| 780 // No-op. Don't delete |this|. | 775 // No-op. Don't delete |this|. |
| 781 } | 776 } |
| 782 | 777 |
| 783 void AutofillAgent::LegacyAutofillAgent::FocusedNodeChanged( | 778 void AutofillAgent::LegacyAutofillAgent::FocusedNodeChanged( |
| 784 const WebNode& node) { | 779 const WebNode& node) { |
| 785 agent_->FocusedNodeChanged(node); | 780 agent_->FocusedNodeChanged(node); |
| 786 } | 781 } |
| 787 | 782 |
| 788 void AutofillAgent::LegacyAutofillAgent::Resized() { | 783 void AutofillAgent::LegacyAutofillAgent::FocusedElementMovedOnResize() { |
| 789 agent_->Resized(); | 784 agent_->FocusedElementMovedOnResize(); |
| 785 } |
| 786 |
| 787 void AutofillAgent::LegacyAutofillAgent::FocusChangeComplete() { |
| 788 agent_->FocusChangeComplete(); |
| 790 } | 789 } |
| 791 | 790 |
| 792 } // namespace autofill | 791 } // namespace autofill |
| OLD | NEW |