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

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: Uncommenting HideAutofillPopup call 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| tells us if we should display
43 // warnings (such as autofill is disabled, but had suggestions).
Ilya Sherman 2011/11/18 23:16:04 nit: I would elaborate on this explanation for |di
csharp 2011/11/21 14:42:14 Done.
39 virtual void OnQuery(int query_id, 44 virtual void OnQuery(int query_id,
40 const webkit_glue::FormData& form, 45 const webkit_glue::FormData& form,
41 const webkit_glue::FormField& field, 46 const webkit_glue::FormField& field,
42 const gfx::Rect& bounds) = 0; 47 const gfx::Rect& bounds,
48 bool display_warning);
Ilya Sherman 2011/11/18 23:16:04 nit: Let's name this |display_warning_if_disabled|
csharp 2011/11/21 14:42:14 Done.
43 49
44 // Records query results. Displays them to the user with an external 50 // Records query results and correctly formats them before sending them off
45 // Autofill popup that lives completely in the browser. Called when 51 // 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( 52 virtual void OnSuggestionsReturned(
51 int query_id, 53 int query_id,
52 const std::vector<string16>& autofill_values, 54 const std::vector<string16>& autofill_values,
53 const std::vector<string16>& autofill_labels, 55 const std::vector<string16>& autofill_labels,
54 const std::vector<string16>& autofill_icons, 56 const std::vector<string16>& autofill_icons,
55 const std::vector<int>& autofill_unique_ids) = 0; 57 const std::vector<int>& autofill_unique_ids);
56 58
57 // Hide the Autofill poup. 59 // Hide the Autofill poup.
58 virtual void HideAutofillPopup() = 0; 60 virtual void HideAutofillPopup() = 0;
59 61
60 // Platforms that wish to implement an external Autofill delegate 62 // Platforms that wish to implement an external Autofill delegate
61 // MUST implement this. The 1st arg is the tab contents that owns 63 // MUST implement this. The 1st arg is the tab contents that owns
62 // this delegate; the second is the Autofill manager owned by the 64 // this delegate; the second is the Autofill manager owned by the
63 // tab contents. 65 // tab contents.
64 static AutofillExternalDelegate* Create(TabContentsWrapper*, 66 static AutofillExternalDelegate* Create(TabContentsWrapper*,
65 AutofillManager*); 67 AutofillManager*);
66 68
69 // Inform the delegate that the text field editing has ended, this is
70 // used to help record the metrics of when a new popup is shown.
71 void SetDidEndTextFieldEditing();
Ilya Sherman 2011/11/18 23:16:04 nit: Here as well, I would omit the "Set" in the n
csharp 2011/11/21 14:42:14 Done.
72
67 protected: 73 protected:
68 explicit AutofillExternalDelegate(TabContentsWrapper* tab_contents_wrapper); 74 explicit AutofillExternalDelegate(TabContentsWrapper* tab_contents_wrapper);
69 75
76 // Displays the the Autofill results to the user with an external
77 // Autofill popup that lives completely in the browser. The suggestions
78 // have be correctly formatted by this point.
79 virtual void ApplyAutofillSuggestions(
80 const std::vector<string16>& autofill_values,
81 const std::vector<string16>& autofill_labels,
82 const std::vector<string16>& autofill_icons,
83 const std::vector<int>& autofill_unique_ids,
84 int separator_index) = 0;
85
86 // Handle instance specific OnQueryCode.
87 virtual void OnQueryPlatformSpecific(int query_id,
88 const webkit_glue::FormData& form,
89 const webkit_glue::FormField& field) = 0;
90
70 private: 91 private:
71 TabContentsWrapper* tab_contents_wrapper_; // weak; owns me. 92 TabContentsWrapper* tab_contents_wrapper_; // weak; owns me.
72 93
94 // The ID of the last request sent for form field Autofill. Used to ignore
95 // out of date responses.
96 int autofill_query_id_;
97
98 // The current field selected by Autofill.
99 webkit_glue::FormField autofill_query_field_;
100
101 // Should we display a warning if autofill is disabled?
Ilya Sherman 2011/11/18 23:16:04 nit: "autofill" -> "Autofill"
csharp 2011/11/21 14:42:14 Done.
102 bool display_warning_if_disabled_;
103
104 // Have we already shown Autofill suggestions for the field the user is
105 // currently editing? Used to keep track of state for metrics logging.
106 bool has_shown_autofill_popup_for_current_edit_;
107
73 DISALLOW_COPY_AND_ASSIGN(AutofillExternalDelegate); 108 DISALLOW_COPY_AND_ASSIGN(AutofillExternalDelegate);
74 }; 109 };
75 110
76 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_EXTERNAL_DELEGATE_H_ 111 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_EXTERNAL_DELEGATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698