Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(167)

Side by Side Diff: components/autofill/content/renderer/autofill_agent.cc

Issue 715733002: [Android] Show autofill popup after animation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 password_generation_agent_(password_generation_agent), 127 password_generation_agent_(password_generation_agent),
128 autofill_query_id_(0), 128 autofill_query_id_(0),
129 web_view_(render_view->GetWebView()), 129 web_view_(render_view->GetWebView()),
130 display_warning_if_disabled_(false), 130 display_warning_if_disabled_(false),
131 was_query_node_autofilled_(false), 131 was_query_node_autofilled_(false),
132 has_shown_autofill_popup_for_current_edit_(false), 132 has_shown_autofill_popup_for_current_edit_(false),
133 did_set_node_text_(false), 133 did_set_node_text_(false),
134 ignore_text_changes_(false), 134 ignore_text_changes_(false),
135 is_popup_possibly_visible_(false), 135 is_popup_possibly_visible_(false),
136 main_frame_processed_(false), 136 main_frame_processed_(false),
137 clicked_form_control_element_was_focused_(false),
137 weak_ptr_factory_(this) { 138 weak_ptr_factory_(this) {
138 render_view->GetWebView()->setAutofillClient(this); 139 render_view->GetWebView()->setAutofillClient(this);
139 140
140 // The PageClickTracker is a RenderViewObserver, and hence will be freed when 141 // The PageClickTracker is a RenderViewObserver, and hence will be freed when
141 // the RenderView is destroyed. 142 // the RenderView is destroyed.
142 new PageClickTracker(render_view, this); 143 new PageClickTracker(render_view, this);
143 } 144 }
144 145
145 AutofillAgent::~AutofillAgent() {} 146 AutofillAgent::~AutofillAgent() {}
146 147
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 EXTRACT_VALUE | EXTRACT_OPTION_TEXT), 211 EXTRACT_VALUE | EXTRACT_OPTION_TEXT),
211 &form_data, 212 &form_data,
212 NULL)) { 213 NULL)) {
213 Send(new AutofillHostMsg_FormSubmitted(routing_id(), form_data, 214 Send(new AutofillHostMsg_FormSubmitted(routing_id(), form_data,
214 base::TimeTicks::Now())); 215 base::TimeTicks::Now()));
215 } 216 }
216 } 217 }
217 218
218 void AutofillAgent::FocusedNodeChanged(const WebNode& node) { 219 void AutofillAgent::FocusedNodeChanged(const WebNode& node) {
219 HidePopup(); 220 HidePopup();
221 changed_focused_node_ = node;
220 222
221 if (password_generation_agent_ && 223 #if !defined(OS_ANDROID)
222 password_generation_agent_->FocusedNodeHasChanged(node)) { 224 OnAnimationCompleted();
223 is_popup_possibly_visible_ = true; 225 #endif
224 return; 226 }
225 }
226 227
227 if (node.isNull() || !node.isElementNode()) 228 void AutofillAgent::WillAnimatePageScale(bool will_animate) {
228 return; 229 if (!will_animate)
229 230 OnAnimationCompleted();
230 WebElement web_element = node.toConst<WebElement>();
231
232 if (!web_element.document().frame())
233 return;
234
235 const WebInputElement* element = toWebInputElement(&web_element);
236
237 if (!element || !element->isEnabled() || element->isReadOnly() ||
238 !element->isTextField() || element->isPasswordField())
239 return;
240
241 element_ = *element;
242 } 231 }
243 232
244 void AutofillAgent::OrientationChangeEvent() { 233 void AutofillAgent::OrientationChangeEvent() {
245 HidePopup(); 234 HidePopup();
246 } 235 }
247 236
248 void AutofillAgent::Resized() { 237 void AutofillAgent::Resized() {
238 #if !defined(OS_ANDROID)
aelias_OOO_until_Jul13 2014/11/22 03:38:11 Why? Shouldn't we hide on resize on Android, if w
please use gerrit instead 2014/11/24 20:22:31 This is to fix the autofill popup momentarily show
aelias_OOO_until_Jul13 2014/11/25 01:26:34 OK, then should we not hide on resize on all platf
please use gerrit instead 2014/12/15 18:39:55 I solved the issue slightly differently that does
aelias_OOO_until_Jul13 2014/12/15 21:59:14 Hmm, I don't like the new timeout stuff in Content
please use gerrit instead 2014/12/16 02:17:08 I like the first-principles approach and have cook
aelias_OOO_until_Jul13 2014/12/16 02:35:52 Assuming that Javascript usually will do that chan
249 HidePopup(); 239 HidePopup();
240 #endif
250 } 241 }
251 242
252 void AutofillAgent::DidChangeScrollOffset(WebLocalFrame*) { 243 void AutofillAgent::DidChangeScrollOffset(WebLocalFrame*) {
253 HidePopup(); 244 HidePopup();
254 } 245 }
255 246
247 void AutofillAgent::DidCompletePageScaleAnimation() {
248 OnAnimationCompleted();
249 }
250
256 void AutofillAgent::didRequestAutocomplete( 251 void AutofillAgent::didRequestAutocomplete(
257 const WebFormElement& form) { 252 const WebFormElement& form) {
258 // Disallow the dialog over non-https or broken https, except when the 253 // Disallow the dialog over non-https or broken https, except when the
259 // ignore SSL flag is passed. See http://crbug.com/272512. 254 // ignore SSL flag is passed. See http://crbug.com/272512.
260 // TODO(palmer): this should be moved to the browser process after frames 255 // TODO(palmer): this should be moved to the browser process after frames
261 // get their own processes. 256 // get their own processes.
262 GURL url(form.document().url()); 257 GURL url(form.document().url());
263 content::SSLStatus ssl_status = 258 content::SSLStatus ssl_status =
264 render_view()->GetSSLStatusOfFrame(form.document().frame()); 259 render_view()->GetSSLStatusOfFrame(form.document().frame());
265 bool is_safe = url.SchemeIs(url::kHttpsScheme) && 260 bool is_safe = url.SchemeIs(url::kHttpsScheme) &&
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 ignore_text_changes_ = ignore; 304 ignore_text_changes_ = ignore;
310 } 305 }
311 306
312 void AutofillAgent::FormControlElementClicked( 307 void AutofillAgent::FormControlElementClicked(
313 const WebFormControlElement& element, 308 const WebFormControlElement& element,
314 bool was_focused) { 309 bool was_focused) {
315 const WebInputElement* input_element = toWebInputElement(&element); 310 const WebInputElement* input_element = toWebInputElement(&element);
316 if (!input_element && !IsTextAreaElement(element)) 311 if (!input_element && !IsTextAreaElement(element))
317 return; 312 return;
318 313
319 bool show_full_suggestion_list = element.isAutofilled() || was_focused; 314 clicked_form_control_element_ = element;
320 bool show_password_suggestions_only = !was_focused; 315 clicked_form_control_element_was_focused_ = was_focused;
321 316
322 // TODO(gcasto): Remove after crbug.com/430318 has been fixed. 317 #if !defined(OS_ANDROID)
323 bool show_suggestions = true; 318 OnAnimationCompleted();
324 #if defined(OS_ANDROID)
325 show_suggestions = was_focused;
326 #endif 319 #endif
327
328 if (show_suggestions) {
329 ShowSuggestions(element,
330 true,
331 false,
332 true,
333 false,
334 show_full_suggestion_list,
335 show_password_suggestions_only);
336 }
337 } 320 }
338 321
339 void AutofillAgent::textFieldDidEndEditing(const WebInputElement& element) { 322 void AutofillAgent::textFieldDidEndEditing(const WebInputElement& element) {
340 password_autofill_agent_->TextFieldDidEndEditing(element); 323 password_autofill_agent_->TextFieldDidEndEditing(element);
341 has_shown_autofill_popup_for_current_edit_ = false; 324 has_shown_autofill_popup_for_current_edit_ = false;
342 Send(new AutofillHostMsg_DidEndTextFieldEditing(routing_id())); 325 Send(new AutofillHostMsg_DidEndTextFieldEditing(routing_id()));
343 } 326 }
344 327
345 void AutofillAgent::textFieldDidChange(const WebFormControlElement& element) { 328 void AutofillAgent::textFieldDidChange(const WebFormControlElement& element) {
346 if (ignore_text_changes_) 329 if (ignore_text_changes_)
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 454
472 void AutofillAgent::OnPreviewForm(int query_id, const FormData& form) { 455 void AutofillAgent::OnPreviewForm(int query_id, const FormData& form) {
473 if (!render_view()->GetWebView() || query_id != autofill_query_id_) 456 if (!render_view()->GetWebView() || query_id != autofill_query_id_)
474 return; 457 return;
475 458
476 was_query_node_autofilled_ = element_.isAutofilled(); 459 was_query_node_autofilled_ = element_.isAutofilled();
477 PreviewForm(form, element_); 460 PreviewForm(form, element_);
478 Send(new AutofillHostMsg_DidPreviewAutofillFormData(routing_id())); 461 Send(new AutofillHostMsg_DidPreviewAutofillFormData(routing_id()));
479 } 462 }
480 463
464 void AutofillAgent::OnAnimationCompleted() {
465 if (!clicked_form_control_element_.isNull()) {
466 OnAnimationCompletedAfterFormControlElementClicked(
467 clicked_form_control_element_,
468 clicked_form_control_element_was_focused_);
469 clicked_form_control_element_.reset();
470 }
471
472 if (!changed_focused_node_.isNull()) {
473 OnAnimationCompletedAfterFocusedNodeChanged(changed_focused_node_);
474 changed_focused_node_.reset();
475 }
476 }
477
478 void AutofillAgent::OnAnimationCompletedAfterFormControlElementClicked(
479 const blink::WebFormControlElement& element,
480 bool was_focused) {
481 bool show_full_suggestion_list = element.isAutofilled() || was_focused;
482 bool show_password_suggestions_only = !was_focused;
483 ShowSuggestions(element,
484 true,
485 false,
486 true,
487 false,
488 show_full_suggestion_list,
489 show_password_suggestions_only);
490 }
491
492 void AutofillAgent::OnAnimationCompletedAfterFocusedNodeChanged(
493 const blink::WebNode& node) {
494 if (password_generation_agent_ &&
495 password_generation_agent_->FocusedNodeHasChanged(node)) {
496 is_popup_possibly_visible_ = true;
497 return;
498 }
499
500 if (!node.isElementNode())
501 return;
502
503 WebElement web_element = changed_focused_node_.toConst<WebElement>();
504
505 if (!web_element.document().frame())
506 return;
507
508 const WebInputElement* element = toWebInputElement(&web_element);
509
510 if (!element || !element->isEnabled() || element->isReadOnly() ||
511 !element->isTextField() || element->isPasswordField()) {
512 return;
513 }
514
515 element_ = *element;
516 }
517
481 void AutofillAgent::OnClearForm() { 518 void AutofillAgent::OnClearForm() {
482 form_cache_.ClearFormWithElement(element_); 519 form_cache_.ClearFormWithElement(element_);
483 } 520 }
484 521
485 void AutofillAgent::OnClearPreviewedForm() { 522 void AutofillAgent::OnClearPreviewedForm() {
486 if (!element_.isNull()) { 523 if (!element_.isNull()) {
487 if (password_autofill_agent_->DidClearAutofillSelection(element_)) 524 if (password_autofill_agent_->DidClearAutofillSelection(element_))
488 return; 525 return;
489 526
490 ClearPreviewedFormWithElement(element_, was_query_node_autofilled_); 527 ClearPreviewedFormWithElement(element_, was_query_node_autofilled_);
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
745 ProcessForms(*frame); 782 ProcessForms(*frame);
746 password_autofill_agent_->OnDynamicFormsSeen(frame); 783 password_autofill_agent_->OnDynamicFormsSeen(frame);
747 if (password_generation_agent_) 784 if (password_generation_agent_)
748 password_generation_agent_->OnDynamicFormsSeen(frame); 785 password_generation_agent_->OnDynamicFormsSeen(frame);
749 return; 786 return;
750 } 787 }
751 } 788 }
752 } 789 }
753 790
754 } // namespace autofill 791 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698