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

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: Respond to comments 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
« no previous file with comments | « chrome/browser/autofill/DEPS ('k') | chrome/browser/autofill/autocomplete_history_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_service.h"
13 #include "chrome/browser/api/webdata/web_data_service_consumer.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 scoped_ptr<AutofillWebDataService> 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:
79 Profile* profile_; 81 Profile* profile_;
80 scoped_refptr<WebDataService> web_data_service_; 82 scoped_ptr<AutofillWebDataService> autofill_data_;
81 83
82 BooleanPrefMember autofill_enabled_; 84 BooleanPrefMember autofill_enabled_;
83 85
84 // When the manager makes a request from WebDataService, the database is 86 // 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 87 // 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. 88 // back. We also store the autofill results so we can send them together.
87 WebDataService::Handle pending_query_handle_; 89 WebDataServiceBase::Handle pending_query_handle_;
88 int query_id_; 90 int query_id_;
89 std::vector<string16> autofill_values_; 91 std::vector<string16> autofill_values_;
90 std::vector<string16> autofill_labels_; 92 std::vector<string16> autofill_labels_;
91 std::vector<string16> autofill_icons_; 93 std::vector<string16> autofill_icons_;
92 std::vector<int> autofill_unique_ids_; 94 std::vector<int> autofill_unique_ids_;
93 95
94 // Delegate to perform external processing (display, selection) on 96 // Delegate to perform external processing (display, selection) on
95 // our behalf. Weak. 97 // our behalf. Weak.
96 AutofillExternalDelegate* external_delegate_; 98 AutofillExternalDelegate* external_delegate_;
97 99
98 DISALLOW_COPY_AND_ASSIGN(AutocompleteHistoryManager); 100 DISALLOW_COPY_AND_ASSIGN(AutocompleteHistoryManager);
99 }; 101 };
100 102
101 #endif // CHROME_BROWSER_AUTOFILL_AUTOCOMPLETE_HISTORY_MANAGER_H_ 103 #endif // CHROME_BROWSER_AUTOFILL_AUTOCOMPLETE_HISTORY_MANAGER_H_
OLDNEW
« no previous file with comments | « chrome/browser/autofill/DEPS ('k') | chrome/browser/autofill/autocomplete_history_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698