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

Unified 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, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: components/autofill/content/renderer/autofill_agent.cc
diff --git a/components/autofill/content/renderer/autofill_agent.cc b/components/autofill/content/renderer/autofill_agent.cc
index 6efe69df0e4b526dc435421536787edbc9bc2a20..9865f60d95a8b73a1cf948a3d01f7e413076b0f0 100644
--- a/components/autofill/content/renderer/autofill_agent.cc
+++ b/components/autofill/content/renderer/autofill_agent.cc
@@ -134,6 +134,7 @@ AutofillAgent::AutofillAgent(content::RenderView* render_view,
ignore_text_changes_(false),
is_popup_possibly_visible_(false),
main_frame_processed_(false),
+ clicked_form_control_element_was_focused_(false),
weak_ptr_factory_(this) {
render_view->GetWebView()->setAutofillClient(this);
@@ -217,28 +218,16 @@ void AutofillAgent::WillSubmitForm(WebLocalFrame* frame,
void AutofillAgent::FocusedNodeChanged(const WebNode& node) {
HidePopup();
+ changed_focused_node_ = node;
- if (password_generation_agent_ &&
- password_generation_agent_->FocusedNodeHasChanged(node)) {
- is_popup_possibly_visible_ = true;
- return;
- }
-
- if (node.isNull() || !node.isElementNode())
- return;
-
- WebElement web_element = node.toConst<WebElement>();
-
- if (!web_element.document().frame())
- return;
-
- const WebInputElement* element = toWebInputElement(&web_element);
-
- if (!element || !element->isEnabled() || element->isReadOnly() ||
- !element->isTextField() || element->isPasswordField())
- return;
+#if !defined(OS_ANDROID)
+ OnAnimationCompleted();
+#endif
+}
- element_ = *element;
+void AutofillAgent::WillAnimatePageScale(bool will_animate) {
+ if (!will_animate)
+ OnAnimationCompleted();
}
void AutofillAgent::OrientationChangeEvent() {
@@ -246,13 +235,19 @@ void AutofillAgent::OrientationChangeEvent() {
}
void AutofillAgent::Resized() {
+#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
HidePopup();
+#endif
}
void AutofillAgent::DidChangeScrollOffset(WebLocalFrame*) {
HidePopup();
}
+void AutofillAgent::DidCompletePageScaleAnimation() {
+ OnAnimationCompleted();
+}
+
void AutofillAgent::didRequestAutocomplete(
const WebFormElement& form) {
// Disallow the dialog over non-https or broken https, except when the
@@ -316,24 +311,12 @@ void AutofillAgent::FormControlElementClicked(
if (!input_element && !IsTextAreaElement(element))
return;
- bool show_full_suggestion_list = element.isAutofilled() || was_focused;
- bool show_password_suggestions_only = !was_focused;
+ clicked_form_control_element_ = element;
+ clicked_form_control_element_was_focused_ = was_focused;
- // TODO(gcasto): Remove after crbug.com/430318 has been fixed.
- bool show_suggestions = true;
-#if defined(OS_ANDROID)
- show_suggestions = was_focused;
+#if !defined(OS_ANDROID)
+ OnAnimationCompleted();
#endif
-
- if (show_suggestions) {
- ShowSuggestions(element,
- true,
- false,
- true,
- false,
- show_full_suggestion_list,
- show_password_suggestions_only);
- }
}
void AutofillAgent::textFieldDidEndEditing(const WebInputElement& element) {
@@ -478,6 +461,60 @@ void AutofillAgent::OnPreviewForm(int query_id, const FormData& form) {
Send(new AutofillHostMsg_DidPreviewAutofillFormData(routing_id()));
}
+void AutofillAgent::OnAnimationCompleted() {
+ if (!clicked_form_control_element_.isNull()) {
+ OnAnimationCompletedAfterFormControlElementClicked(
+ clicked_form_control_element_,
+ clicked_form_control_element_was_focused_);
+ clicked_form_control_element_.reset();
+ }
+
+ if (!changed_focused_node_.isNull()) {
+ OnAnimationCompletedAfterFocusedNodeChanged(changed_focused_node_);
+ changed_focused_node_.reset();
+ }
+}
+
+void AutofillAgent::OnAnimationCompletedAfterFormControlElementClicked(
+ const blink::WebFormControlElement& element,
+ bool was_focused) {
+ bool show_full_suggestion_list = element.isAutofilled() || was_focused;
+ bool show_password_suggestions_only = !was_focused;
+ ShowSuggestions(element,
+ true,
+ false,
+ true,
+ false,
+ show_full_suggestion_list,
+ show_password_suggestions_only);
+}
+
+void AutofillAgent::OnAnimationCompletedAfterFocusedNodeChanged(
+ const blink::WebNode& node) {
+ if (password_generation_agent_ &&
+ password_generation_agent_->FocusedNodeHasChanged(node)) {
+ is_popup_possibly_visible_ = true;
+ return;
+ }
+
+ if (!node.isElementNode())
+ return;
+
+ WebElement web_element = changed_focused_node_.toConst<WebElement>();
+
+ if (!web_element.document().frame())
+ return;
+
+ const WebInputElement* element = toWebInputElement(&web_element);
+
+ if (!element || !element->isEnabled() || element->isReadOnly() ||
+ !element->isTextField() || element->isPasswordField()) {
+ return;
+ }
+
+ element_ = *element;
+}
+
void AutofillAgent::OnClearForm() {
form_cache_.ClearFormWithElement(element_);
}

Powered by Google App Engine
This is Rietveld 408576698