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

Unified Diff: chrome/browser/autofill/autofill_external_delegate.h

Issue 8488011: Moving AutofillAgent Logic into Browser (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Initializing form_field variables Created 9 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: chrome/browser/autofill/autofill_external_delegate.h
diff --git a/chrome/browser/autofill/autofill_external_delegate.h b/chrome/browser/autofill/autofill_external_delegate.h
index edc4104867d94db644245bca4fbd12f2c5be5879..c9bc4dcabc6d180a989829974d728ff09ff337ca 100644
--- a/chrome/browser/autofill/autofill_external_delegate.h
+++ b/chrome/browser/autofill/autofill_external_delegate.h
@@ -9,6 +9,7 @@
#include <vector>
#include "base/string16.h"
+#include "webkit/glue/form_field.h"
class AutofillManager;
class TabContentsWrapper;
@@ -19,9 +20,12 @@ class Rect;
namespace webkit_glue {
struct FormData;
-struct FormField;
} // namespace webkit_glue
+// TODO(csharp): A lot of the logic in this class is copied from autofillagent.
+// Once Autofill is moved out of WebKit this class should be the only home for
+// this logic. See http://crbug.com/51644
+
// Delegate for external processing of Autocomplete and Autofill
// display and selection.
class AutofillExternalDelegate {
@@ -35,24 +39,25 @@ class AutofillExternalDelegate {
// Records and associates a query_id with web form data. Called
// when the renderer posts an Autofill query to the browser. |bounds|
- // is window relative.
+ // is window relative. |display_warning_if_disabled| tells us if we should
+ // display warnings (such as autofill is disabled, but had suggestions).
+ // We might not want to display the warning if a website has disabled
+ // Autocomplete because they have their own popup, and showing our popup
+ // on to of theirs would be a poor user experience.
virtual void OnQuery(int query_id,
const webkit_glue::FormData& form,
const webkit_glue::FormField& field,
- const gfx::Rect& bounds) = 0;
-
- // Records query results. Displays them to the user with an external
- // Autofill popup that lives completely in the browser. Called when
- // an Autofill query result is available.
- // TODO(csharp): This should contain the logic found in
- // AutofillAgent::OnSuggestionsReturned.
- // See http://crbug.com/51644
+ const gfx::Rect& bounds,
+ bool display_warning_if_disabled);
+
+ // Records query results and correctly formats them before sending them off
+ // to be displayed. Called when an Autofill query result is available.
virtual void OnSuggestionsReturned(
int query_id,
const std::vector<string16>& autofill_values,
const std::vector<string16>& autofill_labels,
const std::vector<string16>& autofill_icons,
- const std::vector<int>& autofill_unique_ids) = 0;
+ const std::vector<int>& autofill_unique_ids);
// Hide the Autofill poup.
virtual void HideAutofillPopup() = 0;
@@ -64,12 +69,45 @@ class AutofillExternalDelegate {
static AutofillExternalDelegate* Create(TabContentsWrapper*,
AutofillManager*);
+ // Inform the delegate that the text field editing has ended, this is
+ // used to help record the metrics of when a new popup is shown.
+ void DidEndTextFieldEditing();
+
protected:
explicit AutofillExternalDelegate(TabContentsWrapper* tab_contents_wrapper);
+ // Displays the the Autofill results to the user with an external
+ // Autofill popup that lives completely in the browser. The suggestions
+ // have be correctly formatted by this point.
+ virtual void ApplyAutofillSuggestions(
+ const std::vector<string16>& autofill_values,
+ const std::vector<string16>& autofill_labels,
+ const std::vector<string16>& autofill_icons,
+ const std::vector<int>& autofill_unique_ids,
+ int separator_index) = 0;
+
+ // Handle instance specific OnQueryCode.
+ virtual void OnQueryPlatformSpecific(int query_id,
+ const webkit_glue::FormData& form,
+ const webkit_glue::FormField& field) = 0;
+
private:
TabContentsWrapper* tab_contents_wrapper_; // weak; owns me.
+ // The ID of the last request sent for form field Autofill. Used to ignore
+ // out of date responses.
+ int autofill_query_id_;
+
+ // The current field selected by Autofill.
+ webkit_glue::FormField autofill_query_field_;
+
+ // Should we display a warning if Autofill is disabled?
+ bool display_warning_if_disabled_;
+
+ // Have we already shown Autofill suggestions for the field the user is
+ // currently editing? Used to keep track of state for metrics logging.
+ bool has_shown_autofill_popup_for_current_edit_;
+
DISALLOW_COPY_AND_ASSIGN(AutofillExternalDelegate);
};
« no previous file with comments | « chrome/browser/autocomplete_history_manager_unittest.cc ('k') | chrome/browser/autofill/autofill_external_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698