OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_AUTOCOMPLETE_HISTORY_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_AUTOCOMPLETE_HISTORY_MANAGER_H_ |
6 #define CHROME_BROWSER_AUTOCOMPLETE_HISTORY_MANAGER_H_ | 6 #define CHROME_BROWSER_AUTOCOMPLETE_HISTORY_MANAGER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "chrome/browser/prefs/pref_member.h" | 9 #include "chrome/browser/prefs/pref_member.h" |
10 #include "chrome/browser/renderer_host/render_view_host_delegate.h" | 10 #include "chrome/browser/renderer_host/render_view_host_delegate.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 // renderer and the storing and retrieving of form data through WebDataService. | 21 // renderer and the storing and retrieving of form data through WebDataService. |
22 class AutocompleteHistoryManager | 22 class AutocompleteHistoryManager |
23 : public RenderViewHostDelegate::Autocomplete, | 23 : public RenderViewHostDelegate::Autocomplete, |
24 public WebDataServiceConsumer { | 24 public WebDataServiceConsumer { |
25 public: | 25 public: |
26 explicit AutocompleteHistoryManager(TabContents* tab_contents); | 26 explicit AutocompleteHistoryManager(TabContents* tab_contents); |
27 virtual ~AutocompleteHistoryManager(); | 27 virtual ~AutocompleteHistoryManager(); |
28 | 28 |
29 // RenderViewHostDelegate::Autocomplete implementation. | 29 // RenderViewHostDelegate::Autocomplete implementation. |
30 virtual void FormSubmitted(const webkit_glue::FormData& form); | 30 virtual void FormSubmitted(const webkit_glue::FormData& form); |
31 virtual bool GetAutocompleteSuggestions(int query_id, | 31 virtual void GetAutocompleteSuggestions(const string16& name, |
32 const string16& name, | |
33 const string16& prefix); | 32 const string16& prefix); |
34 virtual void RemoveAutocompleteEntry(const string16& name, | 33 virtual void RemoveAutocompleteEntry(const string16& name, |
35 const string16& value); | 34 const string16& value); |
36 | 35 |
37 // WebDataServiceConsumer implementation. | 36 // WebDataServiceConsumer implementation. |
38 virtual void OnWebDataServiceRequestDone(WebDataService::Handle h, | 37 virtual void OnWebDataServiceRequestDone(WebDataService::Handle h, |
39 const WDTypedResult* result); | 38 const WDTypedResult* result); |
40 | 39 |
41 protected: | 40 protected: |
42 friend class AutocompleteHistoryManagerTest; | 41 friend class AutocompleteHistoryManagerTest; |
43 | 42 |
44 // For tests. | 43 // For tests. |
45 AutocompleteHistoryManager(Profile* profile, WebDataService* wds); | 44 AutocompleteHistoryManager(Profile* profile, WebDataService* wds); |
46 | 45 |
47 private: | 46 private: |
48 void CancelPendingQuery(); | 47 void CancelPendingQuery(); |
49 void StoreFormEntriesInWebDatabase(const webkit_glue::FormData& form); | 48 void StoreFormEntriesInWebDatabase(const webkit_glue::FormData& form); |
50 void SendSuggestions(const WDTypedResult* suggestions); | 49 void SendSuggestions(const WDTypedResult* suggestions); |
51 | 50 |
52 TabContents* tab_contents_; | 51 TabContents* tab_contents_; |
53 Profile* profile_; | 52 Profile* profile_; |
54 scoped_refptr<WebDataService> web_data_service_; | 53 scoped_refptr<WebDataService> web_data_service_; |
55 | 54 |
56 BooleanPrefMember autofill_enabled_; | 55 BooleanPrefMember autofill_enabled_; |
57 | 56 |
58 // When the manager makes a request from WebDataService, the database | 57 // When the manager makes a request from WebDataService, the database |
59 // is queried on another thread, we record the query handle until we | 58 // is queried on another thread, we record the query handle until we |
60 // get called back. | 59 // get called back. |
61 WebDataService::Handle pending_query_handle_; | 60 WebDataService::Handle pending_query_handle_; |
62 int query_id_; | |
63 | 61 |
64 DISALLOW_COPY_AND_ASSIGN(AutocompleteHistoryManager); | 62 DISALLOW_COPY_AND_ASSIGN(AutocompleteHistoryManager); |
65 }; | 63 }; |
66 | 64 |
67 #endif // CHROME_BROWSER_AUTOCOMPLETE_HISTORY_MANAGER_H_ | 65 #endif // CHROME_BROWSER_AUTOCOMPLETE_HISTORY_MANAGER_H_ |
OLD | NEW |