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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #ifndef CHROME_BROWSER_AUTOFILL_AUTOFILL_EXTERNAL_DELEGATE_H_ 5 #ifndef CHROME_BROWSER_AUTOFILL_AUTOFILL_EXTERNAL_DELEGATE_H_
6 #define CHROME_BROWSER_AUTOFILL_AUTOFILL_EXTERNAL_DELEGATE_H_ 6 #define CHROME_BROWSER_AUTOFILL_AUTOFILL_EXTERNAL_DELEGATE_H_
7 #pragma once 7 #pragma once
8 8
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/string16.h" 11 #include "base/string16.h"
12 #include "webkit/glue/form_field.h"
12 13
13 class AutofillManager; 14 class AutofillManager;
14 class TabContentsWrapper; 15 class TabContentsWrapper;
15 16
16 namespace gfx { 17 namespace gfx {
17 class Rect; 18 class Rect;
18 } 19 }
19 20
20 namespace webkit_glue { 21 namespace webkit_glue {
21 struct FormData; 22 struct FormData;
22 struct FormField;
23 } // namespace webkit_glue 23 } // namespace webkit_glue
24 24
25 // TODO(csharp): A lot of the logic in this class is copied from autofillagent.
26 // Once Autofill is moved out of WebKit this class should be the only home for
27 // this logic. See http://crbug.com/51644
28
25 // Delegate for external processing of Autocomplete and Autofill 29 // Delegate for external processing of Autocomplete and Autofill
26 // display and selection. 30 // display and selection.
27 class AutofillExternalDelegate { 31 class AutofillExternalDelegate {
28 public: 32 public:
29 virtual ~AutofillExternalDelegate(); 33 virtual ~AutofillExternalDelegate();
30 34
31 // When using an external Autofill delegate. Allows Chrome to tell 35 // When using an external Autofill delegate. Allows Chrome to tell
32 // WebKit which Autofill selection has been chosen. 36 // WebKit which Autofill selection has been chosen.
33 // TODO(jrg): add feedback mechanism for hover on relevant platforms. 37 // TODO(jrg): add feedback mechanism for hover on relevant platforms.
34 void SelectAutofillSuggestionAtIndex(int listIndex); 38 void SelectAutofillSuggestionAtIndex(int listIndex);
35 39
36 // Records and associates a query_id with web form data. Called 40 // Records and associates a query_id with web form data. Called
37 // when the renderer posts an Autofill query to the browser. |bounds| 41 // when the renderer posts an Autofill query to the browser. |bounds|
38 // is window relative. 42 // is window relative. |display_warning_if_disabled| tells us if we should
43 // display warnings (such as autofill is disabled, but had suggestions).
44 // We might not want to display the warning if a website has disabled
45 // Autocomplete because they have their own popup, and showing our popup
46 // on to of theirs would be a poor user experience.
39 virtual void OnQuery(int query_id, 47 virtual void OnQuery(int query_id,
40 const webkit_glue::FormData& form, 48 const webkit_glue::FormData& form,
41 const webkit_glue::FormField& field, 49 const webkit_glue::FormField& field,
42 const gfx::Rect& bounds) = 0; 50 const gfx::Rect& bounds,
51 bool display_warning_if_disabled);
43 52
44 // Records query results. Displays them to the user with an external 53 // Records query results and correctly formats them before sending them off
45 // Autofill popup that lives completely in the browser. Called when 54 // to be displayed. Called when an Autofill query result is available.
46 // an Autofill query result is available.
47 // TODO(csharp): This should contain the logic found in
48 // AutofillAgent::OnSuggestionsReturned.
49 // See http://crbug.com/51644
50 virtual void OnSuggestionsReturned( 55 virtual void OnSuggestionsReturned(
51 int query_id, 56 int query_id,
52 const std::vector<string16>& autofill_values, 57 const std::vector<string16>& autofill_values,
53 const std::vector<string16>& autofill_labels, 58 const std::vector<string16>& autofill_labels,
54 const std::vector<string16>& autofill_icons, 59 const std::vector<string16>& autofill_icons,
55 const std::vector<int>& autofill_unique_ids) = 0; 60 const std::vector<int>& autofill_unique_ids);
56 61
57 // Hide the Autofill poup. 62 // Hide the Autofill poup.
58 virtual void HideAutofillPopup() = 0; 63 virtual void HideAutofillPopup() = 0;
59 64
60 // Platforms that wish to implement an external Autofill delegate 65 // Platforms that wish to implement an external Autofill delegate
61 // MUST implement this. The 1st arg is the tab contents that owns 66 // MUST implement this. The 1st arg is the tab contents that owns
62 // this delegate; the second is the Autofill manager owned by the 67 // this delegate; the second is the Autofill manager owned by the
63 // tab contents. 68 // tab contents.
64 static AutofillExternalDelegate* Create(TabContentsWrapper*, 69 static AutofillExternalDelegate* Create(TabContentsWrapper*,
65 AutofillManager*); 70 AutofillManager*);
66 71
72 // Inform the delegate that the text field editing has ended, this is
73 // used to help record the metrics of when a new popup is shown.
74 void DidEndTextFieldEditing();
75
67 protected: 76 protected:
68 explicit AutofillExternalDelegate(TabContentsWrapper* tab_contents_wrapper); 77 explicit AutofillExternalDelegate(TabContentsWrapper* tab_contents_wrapper);
69 78
79 // Displays the the Autofill results to the user with an external
80 // Autofill popup that lives completely in the browser. The suggestions
81 // have be correctly formatted by this point.
82 virtual void ApplyAutofillSuggestions(
83 const std::vector<string16>& autofill_values,
84 const std::vector<string16>& autofill_labels,
85 const std::vector<string16>& autofill_icons,
86 const std::vector<int>& autofill_unique_ids,
87 int separator_index) = 0;
88
89 // Handle instance specific OnQueryCode.
90 virtual void OnQueryPlatformSpecific(int query_id,
91 const webkit_glue::FormData& form,
92 const webkit_glue::FormField& field) = 0;
93
70 private: 94 private:
71 TabContentsWrapper* tab_contents_wrapper_; // weak; owns me. 95 TabContentsWrapper* tab_contents_wrapper_; // weak; owns me.
72 96
97 // The ID of the last request sent for form field Autofill. Used to ignore
98 // out of date responses.
99 int autofill_query_id_;
100
101 // The current field selected by Autofill.
102 webkit_glue::FormField autofill_query_field_;
103
104 // Should we display a warning if Autofill is disabled?
105 bool display_warning_if_disabled_;
106
107 // Have we already shown Autofill suggestions for the field the user is
108 // currently editing? Used to keep track of state for metrics logging.
109 bool has_shown_autofill_popup_for_current_edit_;
110
73 DISALLOW_COPY_AND_ASSIGN(AutofillExternalDelegate); 111 DISALLOW_COPY_AND_ASSIGN(AutofillExternalDelegate);
74 }; 112 };
75 113
76 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_EXTERNAL_DELEGATE_H_ 114 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_EXTERNAL_DELEGATE_H_
OLDNEW
« 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