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

Side by Side Diff: chrome/browser/autofill/autofill_external_delegate.h

Issue 9235072: Adding Mouse Support for new GTK Autofill (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: First Draft Created 8 years, 10 months 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/compiler_specific.h"
11 #include "base/string16.h" 12 #include "base/string16.h"
13 #include "webkit/forms/form_data.h"
12 #include "webkit/forms/form_field.h" 14 #include "webkit/forms/form_field.h"
13 15
14 class AutofillManager; 16 class AutofillManager;
15 class TabContentsWrapper; 17 class TabContentsWrapper;
16 18
17 namespace gfx { 19 namespace gfx {
18 class Rect; 20 class Rect;
19 } 21 }
20 22
21 namespace webkit {
22 namespace forms {
23 struct FormData;
24 }
25 }
26
27 // TODO(csharp): A lot of the logic in this class is copied from autofillagent. 23 // TODO(csharp): A lot of the logic in this class is copied from autofillagent.
28 // Once Autofill is moved out of WebKit this class should be the only home for 24 // Once Autofill is moved out of WebKit this class should be the only home for
29 // this logic. See http://crbug.com/51644 25 // this logic. See http://crbug.com/51644
30 26
31 // Delegate for external processing of Autocomplete and Autofill 27 // Delegate for external processing of Autocomplete and Autofill
32 // display and selection. 28 // display and selection.
33 class AutofillExternalDelegate { 29 class AutofillExternalDelegate {
34 public: 30 public:
35 virtual ~AutofillExternalDelegate(); 31 virtual ~AutofillExternalDelegate();
36 32
37 // When using an external Autofill delegate. Allows Chrome to tell 33 // When using an external Autofill delegate. Allows Chrome to tell
38 // WebKit which Autofill selection has been chosen. 34 // WebKit which Autofill selection has been chosen.
39 // TODO(jrg): add feedback mechanism for hover on relevant platforms. 35 // TODO(jrg): add feedback mechanism for hover on relevant platforms.
40 void SelectAutofillSuggestionAtIndex(int listIndex); 36 virtual void SelectAutofillSuggestionAtIndex(int unique_id, int list_index);
41 37
42 // Records and associates a query_id with web form data. Called 38 // Records and associates a query_id with web form data. Called
43 // when the renderer posts an Autofill query to the browser. |bounds| 39 // when the renderer posts an Autofill query to the browser. |bounds|
44 // is window relative. |display_warning_if_disabled| tells us if we should 40 // is window relative. |display_warning_if_disabled| tells us if we should
45 // display warnings (such as autofill is disabled, but had suggestions). 41 // display warnings (such as autofill is disabled, but had suggestions).
46 // We might not want to display the warning if a website has disabled 42 // We might not want to display the warning if a website has disabled
47 // Autocomplete because they have their own popup, and showing our popup 43 // Autocomplete because they have their own popup, and showing our popup
48 // on to of theirs would be a poor user experience. 44 // on to of theirs would be a poor user experience.
49 virtual void OnQuery(int query_id, 45 virtual void OnQuery(int query_id,
50 const webkit::forms::FormData& form, 46 const webkit::forms::FormData& form,
51 const webkit::forms::FormField& field, 47 const webkit::forms::FormField& field,
52 const gfx::Rect& bounds, 48 const gfx::Rect& bounds,
53 bool display_warning_if_disabled); 49 bool display_warning_if_disabled);
54 50
55 // Records query results and correctly formats them before sending them off 51 // Records query results and correctly formats them before sending them off
56 // to be displayed. Called when an Autofill query result is available. 52 // to be displayed. Called when an Autofill query result is available.
57 virtual void OnSuggestionsReturned( 53 virtual void OnSuggestionsReturned(
58 int query_id, 54 int query_id,
59 const std::vector<string16>& autofill_values, 55 const std::vector<string16>& autofill_values,
60 const std::vector<string16>& autofill_labels, 56 const std::vector<string16>& autofill_labels,
61 const std::vector<string16>& autofill_icons, 57 const std::vector<string16>& autofill_icons,
62 const std::vector<int>& autofill_unique_ids); 58 const std::vector<int>& autofill_unique_ids);
63 59
60 // Inform the delegate that the text field editing has ended, this is
61 // used to help record the metrics of when a new popup is shown.
62 void DidEndTextFieldEditing();
63
64 // Inform the delegate that an autofill suggestion have been chosen.
65 void didAcceptAutofillSuggestions(
Ilya Sherman 2012/02/04 04:10:52 nit: "didAccept..." -> "DidAccept"
csharp 2012/02/07 22:30:58 Done.
66 string16 value,int unique_id, unsigned index);
Ilya Sherman 2012/02/04 04:10:52 nit: Since this is a header file, the parameters s
csharp 2012/02/07 22:30:58 Done.
67
68 // Informs the delegate that the Autofill selection has been cleared
69 // (i.e. there is now Autofill selection now).
Ilya Sherman 2012/02/04 04:10:52 nit: "there is now" -> "there is no"
csharp 2012/02/07 22:30:58 Done.
70 virtual void ClearAutofillSelection();
71
64 // Hide the Autofill poup. 72 // Hide the Autofill poup.
65 virtual void HideAutofillPopup() = 0; 73 void HideAutofillPopup();
66 74
67 // Platforms that wish to implement an external Autofill delegate 75 // Platforms that wish to implement an external Autofill delegate
68 // MUST implement this. The 1st arg is the tab contents that owns 76 // MUST implement this. The 1st arg is the tab contents that owns
69 // this delegate; the second is the Autofill manager owned by the 77 // this delegate; the second is the Autofill manager owned by the
70 // tab contents. 78 // tab contents.
71 static AutofillExternalDelegate* Create(TabContentsWrapper*, 79 static AutofillExternalDelegate* Create(TabContentsWrapper*,
72 AutofillManager*); 80 AutofillManager*);
73
74 // Inform the delegate that the text field editing has ended, this is
75 // used to help record the metrics of when a new popup is shown.
76 void DidEndTextFieldEditing();
77
78 protected: 81 protected:
79 explicit AutofillExternalDelegate(TabContentsWrapper* tab_contents_wrapper, 82 explicit AutofillExternalDelegate(TabContentsWrapper* tab_contents_wrapper,
80 AutofillManager* autofill_manager); 83 AutofillManager* autofill_manager);
81 84
82 // Displays the the Autofill results to the user with an external 85 // Displays the the Autofill results to the user with an external
83 // Autofill popup that lives completely in the browser. The suggestions 86 // Autofill popup that lives completely in the browser. The suggestions
84 // have be correctly formatted by this point. 87 // have be correctly formatted by this point.
85 virtual void ApplyAutofillSuggestions( 88 virtual void ApplyAutofillSuggestions(
86 const std::vector<string16>& autofill_values, 89 const std::vector<string16>& autofill_values,
87 const std::vector<string16>& autofill_labels, 90 const std::vector<string16>& autofill_labels,
88 const std::vector<string16>& autofill_icons, 91 const std::vector<string16>& autofill_icons,
89 const std::vector<int>& autofill_unique_ids, 92 const std::vector<int>& autofill_unique_ids,
90 int separator_index) = 0; 93 int separator_index) = 0;
91 94
92 // Handle instance specific OnQueryCode. 95 // Handle instance specific OnQueryCode.
93 virtual void OnQueryPlatformSpecific(int query_id, 96 virtual void OnQueryPlatformSpecific(int query_id,
94 const webkit::forms::FormData& form, 97 const webkit::forms::FormData& form,
95 const webkit::forms::FormField& field, 98 const webkit::forms::FormField& field,
96 const gfx::Rect& bounds) = 0; 99 const gfx::Rect& bounds) = 0;
97 100
101 // Handle platform-dependent hiding.
102 void virtual HideAutofillPopupInternal() = 0;
Ilya Sherman 2012/02/04 04:10:52 nit: "void virtual" -> "virtual void"
csharp 2012/02/07 22:30:58 Done.
103
98 private: 104 private:
105 // Sends the Autofill data to Autofill manager as well as telling the renderer
106 // if the form is a preview. If |is_preview| is true we are just showing a
Ilya Sherman 2012/02/04 04:10:52 nit: I find this first sentence a bit hard to make
csharp 2012/02/07 22:30:58 Done.
107 // preview of the form, otherwise we are filling it.
108 void FillAutofillFormData(int unique_id, bool is_preview);
109
99 TabContentsWrapper* tab_contents_wrapper_; // weak; owns me. 110 TabContentsWrapper* tab_contents_wrapper_; // weak; owns me.
100 AutofillManager* autofill_manager_; // weak. 111 AutofillManager* autofill_manager_; // weak.
101 112
102 // The ID of the last request sent for form field Autofill. Used to ignore 113 // The ID of the last request sent for form field Autofill. Used to ignore
103 // out of date responses. 114 // out of date responses.
104 int autofill_query_id_; 115 int autofill_query_id_;
105 116
106 // The current field selected by Autofill. 117 // The current form and field selected by Autofill.
118 webkit::forms::FormData autofill_query_form_;
107 webkit::forms::FormField autofill_query_field_; 119 webkit::forms::FormField autofill_query_field_;
108 120
109 // Should we display a warning if Autofill is disabled? 121 // Should we display a warning if Autofill is disabled?
110 bool display_warning_if_disabled_; 122 bool display_warning_if_disabled_;
111 123
112 // Have we already shown Autofill suggestions for the field the user is 124 // Have we already shown Autofill suggestions for the field the user is
113 // currently editing? Used to keep track of state for metrics logging. 125 // currently editing? Used to keep track of state for metrics logging.
114 bool has_shown_autofill_popup_for_current_edit_; 126 bool has_shown_autofill_popup_for_current_edit_;
115 127
128 // The menu index of the "Clear" menu item.
129 int suggestions_clear_index_;
130
131 // The menu index of the "Autofill options..." menu item.
132 int suggestions_options_index_;
133
116 DISALLOW_COPY_AND_ASSIGN(AutofillExternalDelegate); 134 DISALLOW_COPY_AND_ASSIGN(AutofillExternalDelegate);
117 }; 135 };
118 136
119 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_EXTERNAL_DELEGATE_H_ 137 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_EXTERNAL_DELEGATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698