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

Side by Side Diff: components/autofill/browser/autocomplete_history_manager.h

Issue 15097004: Enable Autocomplete feature for chromium webview (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@setSaveFormData2
Patch Set: rebased for IPC changes Created 7 years, 6 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 COMPONENTS_AUTOFILL_BROWSER_AUTOCOMPLETE_HISTORY_MANAGER_H_ 5 #ifndef COMPONENTS_AUTOFILL_BROWSER_AUTOCOMPLETE_HISTORY_MANAGER_H_
6 #define COMPONENTS_AUTOFILL_BROWSER_AUTOCOMPLETE_HISTORY_MANAGER_H_ 6 #define COMPONENTS_AUTOFILL_BROWSER_AUTOCOMPLETE_HISTORY_MANAGER_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/gtest_prod_util.h" 10 #include "base/gtest_prod_util.h"
11 #include "base/prefs/pref_member.h"
12 #include "components/autofill/browser/webdata/autofill_webdata_service.h" 11 #include "components/autofill/browser/webdata/autofill_webdata_service.h"
13 #include "components/webdata/common/web_data_service_consumer.h" 12 #include "components/webdata/common/web_data_service_consumer.h"
14 13
15 namespace content { 14 namespace content {
16 class BrowserContext; 15 class BrowserContext;
17 class WebContents; 16 class WebContents;
18 } 17 }
19 18
20 namespace autofill { 19 namespace autofill {
21 20
22 class AutofillDriver; 21 class AutofillDriver;
23 class AutofillExternalDelegate; 22 class AutofillExternalDelegate;
23 class AutofillManagerDelegate;
24 struct FormData; 24 struct FormData;
25 25
26 // Per-tab Autocomplete history manager. Handles receiving form data 26 // Per-tab Autocomplete history manager. Handles receiving form data
27 // from the renderer and the storing and retrieving of form data 27 // from the renderer and the storing and retrieving of form data
28 // through WebDataServiceBase. 28 // through WebDataServiceBase.
29 class AutocompleteHistoryManager : public WebDataServiceConsumer { 29 class AutocompleteHistoryManager : public WebDataServiceConsumer {
30 public: 30 public:
31 explicit AutocompleteHistoryManager(AutofillDriver* driver); 31 AutocompleteHistoryManager(AutofillDriver* driver,
32 autofill::AutofillManagerDelegate* delegate);
Ilya Sherman 2013/06/19 00:38:27 nit: This declaration is already in the autofill::
sgurun-gerrit only 2013/06/19 17:56:23 Done.
32 virtual ~AutocompleteHistoryManager(); 33 virtual ~AutocompleteHistoryManager();
33 34
34 // WebDataServiceConsumer implementation. 35 // WebDataServiceConsumer implementation.
35 virtual void OnWebDataServiceRequestDone( 36 virtual void OnWebDataServiceRequestDone(
36 WebDataServiceBase::Handle h, 37 WebDataServiceBase::Handle h,
37 const WDTypedResult* result) OVERRIDE; 38 const WDTypedResult* result) OVERRIDE;
38 39
39 // Pass-through functions that are called by AutofillManager, after it has 40 // Pass-through functions that are called by AutofillManager, after it has
40 // dispatched a message. 41 // dispatched a message.
41 void OnGetAutocompleteSuggestions( 42 void OnGetAutocompleteSuggestions(
42 int query_id, 43 int query_id,
43 const base::string16& name, 44 const base::string16& name,
44 const base::string16& prefix, 45 const base::string16& prefix,
45 const std::vector<base::string16>& autofill_values, 46 const std::vector<base::string16>& autofill_values,
46 const std::vector<base::string16>& autofill_labels, 47 const std::vector<base::string16>& autofill_labels,
47 const std::vector<base::string16>& autofill_icons, 48 const std::vector<base::string16>& autofill_icons,
48 const std::vector<int>& autofill_unique_ids); 49 const std::vector<int>& autofill_unique_ids);
49 void OnFormSubmitted(const FormData& form); 50 virtual void OnFormSubmitted(const FormData& form);
50 51
51 // Must be public for the external delegate to use. 52 // Must be public for the external delegate to use.
52 void OnRemoveAutocompleteEntry(const base::string16& name, 53 void OnRemoveAutocompleteEntry(const base::string16& name,
53 const base::string16& value); 54 const base::string16& value);
54 55
55 // Sets our external delegate. 56 // Sets our external delegate.
56 void SetExternalDelegate(AutofillExternalDelegate* delegate); 57 void SetExternalDelegate(AutofillExternalDelegate* delegate);
57 58
58 protected: 59 protected:
59 friend class AutofillManagerTest; 60 friend class AutofillManagerTest;
60 61
61 // Sends the given |suggestions| for display in the Autofill popup. 62 // Sends the given |suggestions| for display in the Autofill popup.
62 void SendSuggestions(const std::vector<base::string16>* suggestions); 63 void SendSuggestions(const std::vector<base::string16>* suggestions);
63 64
64 // Used by tests to disable sending IPC. 65 // Used by tests to disable sending IPC.
65 void set_send_ipc(bool send_ipc) { send_ipc_ = send_ipc; } 66 void set_send_ipc(bool send_ipc) { send_ipc_ = send_ipc; }
66 67
67 private: 68 private:
68 // Cancels the currently pending WebDataService query, if there is one. 69 // Cancels the currently pending WebDataService query, if there is one.
69 void CancelPendingQuery(); 70 void CancelPendingQuery();
70 71
71 content::BrowserContext* browser_context_; 72 content::BrowserContext* browser_context_;
72 // Provides driver-level context. Must outlive this object. 73 // Provides driver-level context. Must outlive this object.
73 AutofillDriver* driver_; 74 AutofillDriver* driver_;
74 scoped_refptr<AutofillWebDataService> autofill_data_; 75 scoped_refptr<AutofillWebDataService> autofill_data_;
75 76
76 BooleanPrefMember autofill_enabled_;
77
78 // When the manager makes a request from WebDataServiceBase, the database is 77 // When the manager makes a request from WebDataServiceBase, the database is
79 // queried on another thread, we record the query handle until we get called 78 // queried on another thread, we record the query handle until we get called
80 // back. We also store the autofill results so we can send them together. 79 // back. We also store the autofill results so we can send them together.
81 WebDataServiceBase::Handle pending_query_handle_; 80 WebDataServiceBase::Handle pending_query_handle_;
82 int query_id_; 81 int query_id_;
83 std::vector<base::string16> autofill_values_; 82 std::vector<base::string16> autofill_values_;
84 std::vector<base::string16> autofill_labels_; 83 std::vector<base::string16> autofill_labels_;
85 std::vector<base::string16> autofill_icons_; 84 std::vector<base::string16> autofill_icons_;
86 std::vector<int> autofill_unique_ids_; 85 std::vector<int> autofill_unique_ids_;
87 86
88 // Delegate to perform external processing (display, selection) on 87 // Delegate to perform external processing (display, selection) on
89 // our behalf. Weak. 88 // our behalf. Weak.
90 AutofillExternalDelegate* external_delegate_; 89 AutofillExternalDelegate* external_delegate_;
90 autofill::AutofillManagerDelegate* const manager_delegate_;
Ilya Sherman 2013/06/19 00:38:27 nit: Please leave a blank line above this member v
sgurun-gerrit only 2013/06/19 17:56:23 Done.
91 91
92 // Whether IPC is sent. 92 // Whether IPC is sent.
93 bool send_ipc_; 93 bool send_ipc_;
94 94
95 DISALLOW_COPY_AND_ASSIGN(AutocompleteHistoryManager); 95 DISALLOW_COPY_AND_ASSIGN(AutocompleteHistoryManager);
96 }; 96 };
97 97
98 } // namespace autofill 98 } // namespace autofill
99 99
100 #endif // COMPONENTS_AUTOFILL_BROWSER_AUTOCOMPLETE_HISTORY_MANAGER_H_ 100 #endif // COMPONENTS_AUTOFILL_BROWSER_AUTOCOMPLETE_HISTORY_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698