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

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: 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 webkit_glue { 17 namespace webkit_glue {
17 struct FormData; 18 struct FormData;
18 struct FormField;
19 } // namespace webkit_glue 19 } // namespace webkit_glue
20 20
21 // TODO(csharp): A lot of the logic in this class is copied from autofillagent.
22 // Once Autofill is moved out of WebKit this class should be the only home for
23 // this logic.
Ilya Sherman 2011/11/17 02:24:37 nit: Please add a link to http://crbug.com/51644
csharp 2011/11/18 18:15:10 Done.
24
21 // Delegate for external processing of Autocomplete and Autofill 25 // Delegate for external processing of Autocomplete and Autofill
22 // display and selection. 26 // display and selection.
23 class AutofillExternalDelegate { 27 class AutofillExternalDelegate {
24 public: 28 public:
25 virtual ~AutofillExternalDelegate(); 29 virtual ~AutofillExternalDelegate();
26 30
27 // When using an external Autofill delegate. Allows Chrome to tell 31 // When using an external Autofill delegate. Allows Chrome to tell
28 // WebKit which Autofill selection has been chosen. 32 // WebKit which Autofill selection has been chosen.
29 // TODO(jrg): add feedback mechanism for hover on relevant platforms. 33 // TODO(jrg): add feedback mechanism for hover on relevant platforms.
30 void SelectAutofillSuggestionAtIndex(int listIndex); 34 void SelectAutofillSuggestionAtIndex(int listIndex);
31 35
32 // Records and associates a query_id with web form data. Called 36 // Records and associates a query_id with web form data. Called
33 // when the renderer posts an Autofill query to the browser. 37 // when the renderer posts an Autofill query to the browser.
34 virtual void OnQuery(int query_id, 38 virtual void OnQuery(int query_id,
35 const webkit_glue::FormData& form, 39 const webkit_glue::FormData& form,
36 const webkit_glue::FormField& field) = 0; 40 const webkit_glue::FormField& field,
41 bool display_warning);
Ilya Sherman 2011/11/17 02:24:37 nit: Please describe the role of |display_warning|
csharp 2011/11/18 18:15:10 Done.
37 42
38 // Records query results. Displays them to the user with an external 43 // Records query results and correctly formats them before sending them off
39 // Autofill popup that lives completely in the browser. Called when 44 // to be displayed. Called when an Autofill query result is available.
40 // an Autofill query result is available.
41 virtual void OnSuggestionsReturned( 45 virtual void OnSuggestionsReturned(
42 int query_id, 46 int query_id,
43 const std::vector<string16>& autofill_values, 47 const std::vector<string16>& autofill_values,
44 const std::vector<string16>& autofill_labels, 48 const std::vector<string16>& autofill_labels,
45 const std::vector<string16>& autofill_icons, 49 const std::vector<string16>& autofill_icons,
46 const std::vector<int>& autofill_unique_ids) = 0; 50 const std::vector<int>& autofill_unique_ids);
47 51
48 // Platforms that wish to implement an external Autofill delegate 52 // Platforms that wish to implement an external Autofill delegate
49 // MUST implement this. The 1st arg is the tab contents that owns 53 // MUST implement this. The 1st arg is the tab contents that owns
50 // this delegate; the second is the Autofill manager owned by the 54 // this delegate; the second is the Autofill manager owned by the
51 // tab contents. 55 // tab contents.
52 static AutofillExternalDelegate* Create(TabContentsWrapper*, 56 static AutofillExternalDelegate* Create(TabContentsWrapper*,
53 AutofillManager*); 57 AutofillManager*);
54 58
59 // Inform the delegate that the text field editing has ended, this is
60 // used to help record the metrics of when a new popup is shown.
61 void SetDidEndTextFieldEditing();
62
55 protected: 63 protected:
56 explicit AutofillExternalDelegate(TabContentsWrapper* tab_contents_wrapper); 64 explicit AutofillExternalDelegate(TabContentsWrapper* tab_contents_wrapper);
57 65
66 // Displays the the Autofill results to the user with an external
67 // Autofill popup that lives completely in the browser. The suggestions
68 // have be correctly formatted by this point.
69 virtual void ApplyAutofillSuggestions(
70 const std::vector<string16>& autofill_values,
71 const std::vector<string16>& autofill_labels,
72 const std::vector<string16>& autofill_icons,
73 const std::vector<int>& autofill_unique_ids,
74 int separator_index) = 0;
75
76 // Handle instance specific OnQueryCode.
77 virtual void OnQueryPlatformSpecific(int query_id,
78 const webkit_glue::FormData& form,
79 const webkit_glue::FormField& field) = 0;
80
58 private: 81 private:
59 TabContentsWrapper* tab_contents_wrapper_; // weak; owns me. 82 TabContentsWrapper* tab_contents_wrapper_; // weak; owns me.
60 83
84 // The ID of the last request sent for form field Autofill. Used to ignore
85 // out of date responses.
86 int autofill_query_id_;
87
88 // The current field selected by Autofill.
89 webkit_glue::FormField autofill_query_field_;
90
91 // Should we display a warning if autofill is disabled?
92 bool display_warning_if_disabled_;
93
94 // The menu index of the "Clear" menu item.
95 int suggestions_clear_index_;
96
97 // The menu index of the "Autofill options..." menu item.
98 int suggestions_options_index_;
Ilya Sherman 2011/11/17 02:24:37 I'm not sure that we'll need these indices for the
csharp 2011/11/18 18:15:10 Good point, I've taken them out. On 2011/11/17 02
99
100 // Have we already shown Autofill suggestions for the field the user is
101 // currently editing? Used to keep track of state for metrics logging.
102 bool has_shown_autofill_popup_for_current_edit_;
103
61 DISALLOW_COPY_AND_ASSIGN(AutofillExternalDelegate); 104 DISALLOW_COPY_AND_ASSIGN(AutofillExternalDelegate);
62 }; 105 };
63 106
64 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_EXTERNAL_DELEGATE_H_ 107 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_EXTERNAL_DELEGATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698