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

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

Issue 10919066: Use BrowserContext as key in API. Switch Autofill to use BC in place of Profile. (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/api/webdata/autofill_web_data.h" 12 #include "chrome/browser/api/webdata/autofill_web_data.h"
13 #include "chrome/browser/api/webdata/web_data_service_base.h" 13 #include "chrome/browser/api/webdata/web_data_service_base.h"
14 #include "content/public/browser/web_contents_observer.h" 14 #include "content/public/browser/web_contents_observer.h"
15 15
16 namespace content {
17 class BrowserContext;
18 }
19
16 namespace webkit { 20 namespace webkit {
17 namespace forms { 21 namespace forms {
18 struct FormData; 22 struct FormData;
19 } 23 }
20 } 24 }
21 25
22 class AutofillExternalDelegate; 26 class AutofillExternalDelegate;
23 class Profile;
24 27
25 // Per-tab Autocomplete history manager. Handles receiving form data 28 // Per-tab Autocomplete history manager. Handles receiving form data
26 // from the renderer and the storing and retrieving of form data 29 // from the renderer and the storing and retrieving of form data
27 // through WebDataServiceBase. 30 // through WebDataServiceBase.
28 class AutocompleteHistoryManager : public content::WebContentsObserver, 31 class AutocompleteHistoryManager : public content::WebContentsObserver,
29 public WebDataServiceConsumer { 32 public WebDataServiceConsumer {
30 public: 33 public:
31 explicit AutocompleteHistoryManager(content::WebContents* web_contents); 34 explicit AutocompleteHistoryManager(content::WebContents* web_contents);
32 virtual ~AutocompleteHistoryManager(); 35 virtual ~AutocompleteHistoryManager();
33 36
(...skipping 25 matching lines...) Expand all
59 62
60 protected: 63 protected:
61 friend class AutocompleteHistoryManagerTest; 64 friend class AutocompleteHistoryManagerTest;
62 friend class AutofillManagerTest; 65 friend class AutofillManagerTest;
63 FRIEND_TEST_ALL_PREFIXES(AutocompleteHistoryManagerTest, ExternalDelegate); 66 FRIEND_TEST_ALL_PREFIXES(AutocompleteHistoryManagerTest, ExternalDelegate);
64 FRIEND_TEST_ALL_PREFIXES(AutofillManagerTest, 67 FRIEND_TEST_ALL_PREFIXES(AutofillManagerTest,
65 TestTabContentsWithExternalDelegate); 68 TestTabContentsWithExternalDelegate);
66 69
67 // For tests. 70 // For tests.
68 AutocompleteHistoryManager(content::WebContents* web_contents, 71 AutocompleteHistoryManager(content::WebContents* web_contents,
69 Profile* profile, 72 content::BrowserContext* context,
70 WebDataServiceBase* wds); 73 WebDataServiceBase* wds);
71 74
72 void SendSuggestions(const std::vector<string16>* suggestions); 75 void SendSuggestions(const std::vector<string16>* suggestions);
73 void CancelPendingQuery(); 76 void CancelPendingQuery();
74 77
75 // Exposed for testing. 78 // Exposed for testing.
76 AutofillExternalDelegate* external_delegate() { 79 AutofillExternalDelegate* external_delegate() {
77 return external_delegate_; 80 return external_delegate_;
78 } 81 }
79 82
80 private: 83 private:
81 AutofillWebData* autofill_data() { 84 AutofillWebData* autofill_data() {
82 return AutofillWebData::ForService(web_data_service_.get()); 85 return AutofillWebData::ForService(web_data_service_.get());
83 } 86 }
84 87
85 Profile* profile_; 88 content::BrowserContext* browser_context_;
86 scoped_refptr<WebDataServiceBase> web_data_service_; 89 scoped_refptr<WebDataServiceBase> web_data_service_;
87 90
88 BooleanPrefMember autofill_enabled_; 91 BooleanPrefMember autofill_enabled_;
89 92
90 // When the manager makes a request from WebDataServiceBase, the database is 93 // When the manager makes a request from WebDataServiceBase, the database is
91 // queried on another thread, we record the query handle until we get called 94 // queried on another thread, we record the query handle until we get called
92 // back. We also store the autofill results so we can send them together. 95 // back. We also store the autofill results so we can send them together.
93 WebDataServiceBase::Handle pending_query_handle_; 96 WebDataServiceBase::Handle pending_query_handle_;
94 int query_id_; 97 int query_id_;
95 std::vector<string16> autofill_values_; 98 std::vector<string16> autofill_values_;
96 std::vector<string16> autofill_labels_; 99 std::vector<string16> autofill_labels_;
97 std::vector<string16> autofill_icons_; 100 std::vector<string16> autofill_icons_;
98 std::vector<int> autofill_unique_ids_; 101 std::vector<int> autofill_unique_ids_;
99 102
100 // Delegate to perform external processing (display, selection) on 103 // Delegate to perform external processing (display, selection) on
101 // our behalf. Weak. 104 // our behalf. Weak.
102 AutofillExternalDelegate* external_delegate_; 105 AutofillExternalDelegate* external_delegate_;
103 106
104 DISALLOW_COPY_AND_ASSIGN(AutocompleteHistoryManager); 107 DISALLOW_COPY_AND_ASSIGN(AutocompleteHistoryManager);
105 }; 108 };
106 109
107 #endif // CHROME_BROWSER_AUTOFILL_AUTOCOMPLETE_HISTORY_MANAGER_H_ 110 #endif // CHROME_BROWSER_AUTOFILL_AUTOCOMPLETE_HISTORY_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698