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

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

Issue 10908065: Introduce a couple of abstract bases for WebDataService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 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 | Annotate | Revision Log
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_AUTOCOMPLETE_HISTORY_MANAGER_H_ 5 #ifndef CHROME_BROWSER_AUTOFILL_AUTOCOMPLETE_HISTORY_MANAGER_H_
6 #define CHROME_BROWSER_AUTOFILL_AUTOCOMPLETE_HISTORY_MANAGER_H_ 6 #define CHROME_BROWSER_AUTOFILL_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 "chrome/browser/api/prefs/pref_member.h" 11 #include "chrome/browser/api/prefs/pref_member.h"
12 #include "chrome/browser/webdata/web_data_service.h" 12 #include "chrome/browser/api/webdata/autofill_web_data.h"
13 #include "chrome/browser/api/webdata/web_data_service_base.h"
13 #include "content/public/browser/web_contents_observer.h" 14 #include "content/public/browser/web_contents_observer.h"
14 15
15 namespace webkit { 16 namespace webkit {
16 namespace forms { 17 namespace forms {
17 struct FormData; 18 struct FormData;
18 } 19 }
19 } 20 }
20 21
21 class AutofillExternalDelegate; 22 class AutofillExternalDelegate;
22 class Profile; 23 class Profile;
23 24
24 // Per-tab Autocomplete history manager. Handles receiving form data from the 25 // Per-tab Autocomplete history manager. Handles receiving form data
25 // renderer and the storing and retrieving of form data through WebDataService. 26 // from the renderer and the storing and retrieving of form data
27 // through WebDataServiceBase.
26 class AutocompleteHistoryManager : public content::WebContentsObserver, 28 class AutocompleteHistoryManager : public content::WebContentsObserver,
27 public WebDataServiceConsumer { 29 public WebDataServiceConsumer {
28 public: 30 public:
29 explicit AutocompleteHistoryManager(content::WebContents* web_contents); 31 explicit AutocompleteHistoryManager(content::WebContents* web_contents);
30 virtual ~AutocompleteHistoryManager(); 32 virtual ~AutocompleteHistoryManager();
31 33
32 // content::WebContentsObserver implementation. 34 // content::WebContentsObserver implementation.
33 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 35 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
34 36
35 // WebDataServiceConsumer implementation. 37 // WebDataServiceConsumer implementation.
36 virtual void OnWebDataServiceRequestDone( 38 virtual void OnWebDataServiceRequestDone(
37 WebDataService::Handle h, 39 WebDataServiceBase::Handle h,
38 const WDTypedResult* result) OVERRIDE; 40 const WDTypedResult* result) OVERRIDE;
39 41
40 // Pass-through functions that are called by AutofillManager, after it has 42 // Pass-through functions that are called by AutofillManager, after it has
41 // dispatched a message. 43 // dispatched a message.
42 void OnGetAutocompleteSuggestions( 44 void OnGetAutocompleteSuggestions(
43 int query_id, 45 int query_id,
44 const string16& name, 46 const string16& name,
45 const string16& prefix, 47 const string16& prefix,
46 const std::vector<string16>& autofill_values, 48 const std::vector<string16>& autofill_values,
47 const std::vector<string16>& autofill_labels, 49 const std::vector<string16>& autofill_labels,
(...skipping 10 matching lines...) Expand all
58 protected: 60 protected:
59 friend class AutocompleteHistoryManagerTest; 61 friend class AutocompleteHistoryManagerTest;
60 friend class AutofillManagerTest; 62 friend class AutofillManagerTest;
61 FRIEND_TEST_ALL_PREFIXES(AutocompleteHistoryManagerTest, ExternalDelegate); 63 FRIEND_TEST_ALL_PREFIXES(AutocompleteHistoryManagerTest, ExternalDelegate);
62 FRIEND_TEST_ALL_PREFIXES(AutofillManagerTest, 64 FRIEND_TEST_ALL_PREFIXES(AutofillManagerTest,
63 TestTabContentsWithExternalDelegate); 65 TestTabContentsWithExternalDelegate);
64 66
65 // For tests. 67 // For tests.
66 AutocompleteHistoryManager(content::WebContents* web_contents, 68 AutocompleteHistoryManager(content::WebContents* web_contents,
67 Profile* profile, 69 Profile* profile,
68 WebDataService* wds); 70 WebDataServiceBase* wds);
69 71
70 void SendSuggestions(const std::vector<string16>* suggestions); 72 void SendSuggestions(const std::vector<string16>* suggestions);
71 void CancelPendingQuery(); 73 void CancelPendingQuery();
72 74
73 // Exposed for testing. 75 // Exposed for testing.
74 AutofillExternalDelegate* external_delegate() { 76 AutofillExternalDelegate* external_delegate() {
75 return external_delegate_; 77 return external_delegate_;
76 } 78 }
77 79
78 private: 80 private:
81 AutofillWebData* autofill_data() {
82 return AutofillWebData::ForService(web_data_service_.get());
83 }
84
79 Profile* profile_; 85 Profile* profile_;
80 scoped_refptr<WebDataService> web_data_service_; 86 scoped_refptr<WebDataServiceBase> web_data_service_;
81 87
82 BooleanPrefMember autofill_enabled_; 88 BooleanPrefMember autofill_enabled_;
83 89
84 // When the manager makes a request from WebDataService, the database is 90 // When the manager makes a request from WebDataServiceBase, the database is
85 // queried on another thread, we record the query handle until we get called 91 // queried on another thread, we record the query handle until we get called
86 // back. We also store the autofill results so we can send them together. 92 // back. We also store the autofill results so we can send them together.
87 WebDataService::Handle pending_query_handle_; 93 WebDataServiceBase::Handle pending_query_handle_;
88 int query_id_; 94 int query_id_;
89 std::vector<string16> autofill_values_; 95 std::vector<string16> autofill_values_;
90 std::vector<string16> autofill_labels_; 96 std::vector<string16> autofill_labels_;
91 std::vector<string16> autofill_icons_; 97 std::vector<string16> autofill_icons_;
92 std::vector<int> autofill_unique_ids_; 98 std::vector<int> autofill_unique_ids_;
93 99
94 // Delegate to perform external processing (display, selection) on 100 // Delegate to perform external processing (display, selection) on
95 // our behalf. Weak. 101 // our behalf. Weak.
96 AutofillExternalDelegate* external_delegate_; 102 AutofillExternalDelegate* external_delegate_;
97 103
98 DISALLOW_COPY_AND_ASSIGN(AutocompleteHistoryManager); 104 DISALLOW_COPY_AND_ASSIGN(AutocompleteHistoryManager);
99 }; 105 };
100 106
101 #endif // CHROME_BROWSER_AUTOFILL_AUTOCOMPLETE_HISTORY_MANAGER_H_ 107 #endif // CHROME_BROWSER_AUTOFILL_AUTOCOMPLETE_HISTORY_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698