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

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: Fixing problem with autofillAgent browser tests 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(string16 value,
66 int unique_id,
67 unsigned index);
68
69 // Informs the delegate that the Autofill previewed form should be cleared.
70 virtual void ClearPreviewedForm();
71
64 // Hide the Autofill poup. 72 // Hide the Autofill poup.
65 virtual void HideAutofillPopup() = 0; 73 virtual 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 virtual void HideAutofillPopupInternal() = 0;
103
98 private: 104 private:
105 // Fills the form with the Autofill data corresponding to |unique_id|.
106 // If |is_preview| is true then this is just a preview to show the user what
107 // would be selected and if |is_preview| is false then the user has selected
108 // this data.
109 void FillAutofillFormData(int unique_id, bool is_preview);
110
99 TabContentsWrapper* tab_contents_wrapper_; // weak; owns me. 111 TabContentsWrapper* tab_contents_wrapper_; // weak; owns me.
100 AutofillManager* autofill_manager_; // weak. 112 AutofillManager* autofill_manager_; // weak.
101 113
102 // The ID of the last request sent for form field Autofill. Used to ignore 114 // The ID of the last request sent for form field Autofill. Used to ignore
103 // out of date responses. 115 // out of date responses.
104 int autofill_query_id_; 116 int autofill_query_id_;
105 117
106 // The current field selected by Autofill. 118 // The current form and field selected by Autofill.
119 webkit::forms::FormData autofill_query_form_;
107 webkit::forms::FormField autofill_query_field_; 120 webkit::forms::FormField autofill_query_field_;
108 121
109 // Should we display a warning if Autofill is disabled? 122 // Should we display a warning if Autofill is disabled?
110 bool display_warning_if_disabled_; 123 bool display_warning_if_disabled_;
111 124
112 // Have we already shown Autofill suggestions for the field the user is 125 // Have we already shown Autofill suggestions for the field the user is
113 // currently editing? Used to keep track of state for metrics logging. 126 // currently editing? Used to keep track of state for metrics logging.
114 bool has_shown_autofill_popup_for_current_edit_; 127 bool has_shown_autofill_popup_for_current_edit_;
115 128
129 // The menu index of the "Clear" menu item.
130 int suggestions_clear_index_;
131
132 // The menu index of the "Autofill options..." menu item.
133 int suggestions_options_index_;
134
116 DISALLOW_COPY_AND_ASSIGN(AutofillExternalDelegate); 135 DISALLOW_COPY_AND_ASSIGN(AutofillExternalDelegate);
117 }; 136 };
118 137
119 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_EXTERNAL_DELEGATE_H_ 138 #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