Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "content/public/browser/web_contents_observer.h" | 13 #include "content/public/browser/web_contents_observer.h" |
| 14 | 14 |
| 15 namespace webkit { | 15 namespace webkit { |
| 16 namespace forms { | 16 namespace forms { |
| 17 struct FormData; | 17 struct FormData; |
| 18 } | 18 } |
| 19 } | 19 } |
| 20 | 20 |
| 21 class AutofillExternalDelegate; | 21 class AutofillExternalDelegate; |
| 22 class Profile; | 22 class Profile; |
| 23 | 23 |
| 24 // Per-tab Autocomplete history manager. Handles receiving form data from the | 24 // Per-tab Autocomplete history manager. Handles receiving form data |
| 25 // renderer and the storing and retrieving of form data through WebDataService. | 25 // from the renderer and the storing and retrieving of form data |
| 26 // through WebDataServiceBase. | |
| 26 class AutocompleteHistoryManager : public content::WebContentsObserver, | 27 class AutocompleteHistoryManager : public content::WebContentsObserver, |
| 27 public WebDataServiceConsumer { | 28 public WebDataServiceConsumer { |
| 28 public: | 29 public: |
| 29 explicit AutocompleteHistoryManager(content::WebContents* web_contents); | 30 explicit AutocompleteHistoryManager(content::WebContents* web_contents); |
| 30 virtual ~AutocompleteHistoryManager(); | 31 virtual ~AutocompleteHistoryManager(); |
| 31 | 32 |
| 32 // content::WebContentsObserver implementation. | 33 // content::WebContentsObserver implementation. |
| 33 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 34 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 34 | 35 |
| 35 // WebDataServiceConsumer implementation. | 36 // WebDataServiceConsumer implementation. |
| 36 virtual void OnWebDataServiceRequestDone( | 37 virtual void OnWebDataServiceRequestDone( |
| 37 WebDataService::Handle h, | 38 WebDataServiceBase::Handle h, |
| 38 const WDTypedResult* result) OVERRIDE; | 39 const WDTypedResult* result) OVERRIDE; |
| 39 | 40 |
| 40 // Pass-through functions that are called by AutofillManager, after it has | 41 // Pass-through functions that are called by AutofillManager, after it has |
| 41 // dispatched a message. | 42 // dispatched a message. |
| 42 void OnGetAutocompleteSuggestions( | 43 void OnGetAutocompleteSuggestions( |
| 43 int query_id, | 44 int query_id, |
| 44 const string16& name, | 45 const string16& name, |
| 45 const string16& prefix, | 46 const string16& prefix, |
| 46 const std::vector<string16>& autofill_values, | 47 const std::vector<string16>& autofill_values, |
| 47 const std::vector<string16>& autofill_labels, | 48 const std::vector<string16>& autofill_labels, |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 58 protected: | 59 protected: |
| 59 friend class AutocompleteHistoryManagerTest; | 60 friend class AutocompleteHistoryManagerTest; |
| 60 friend class AutofillManagerTest; | 61 friend class AutofillManagerTest; |
| 61 FRIEND_TEST_ALL_PREFIXES(AutocompleteHistoryManagerTest, ExternalDelegate); | 62 FRIEND_TEST_ALL_PREFIXES(AutocompleteHistoryManagerTest, ExternalDelegate); |
| 62 FRIEND_TEST_ALL_PREFIXES(AutofillManagerTest, | 63 FRIEND_TEST_ALL_PREFIXES(AutofillManagerTest, |
| 63 TestTabContentsWithExternalDelegate); | 64 TestTabContentsWithExternalDelegate); |
| 64 | 65 |
| 65 // For tests. | 66 // For tests. |
| 66 AutocompleteHistoryManager(content::WebContents* web_contents, | 67 AutocompleteHistoryManager(content::WebContents* web_contents, |
| 67 Profile* profile, | 68 Profile* profile, |
| 68 WebDataService* wds); | 69 AutofillWebDataService* wds); |
|
dhollowa
2012/09/07 16:04:01
nit: I liked your change to using |service| as the
| |
| 69 | 70 |
| 70 void SendSuggestions(const std::vector<string16>* suggestions); | 71 void SendSuggestions(const std::vector<string16>* suggestions); |
| 71 void CancelPendingQuery(); | 72 void CancelPendingQuery(); |
| 72 | 73 |
| 73 // Exposed for testing. | 74 // Exposed for testing. |
| 74 AutofillExternalDelegate* external_delegate() { | 75 AutofillExternalDelegate* external_delegate() { |
| 75 return external_delegate_; | 76 return external_delegate_; |
| 76 } | 77 } |
| 77 | 78 |
| 78 private: | 79 private: |
| 79 Profile* profile_; | 80 Profile* profile_; |
| 80 scoped_refptr<WebDataService> web_data_service_; | 81 scoped_ptr<AutofillWebDataService> autofill_data_; |
|
dhollowa
2012/09/07 16:04:01
nit: |service_| or |data_service_|?
| |
| 81 | 82 |
| 82 BooleanPrefMember autofill_enabled_; | 83 BooleanPrefMember autofill_enabled_; |
| 83 | 84 |
| 84 // When the manager makes a request from WebDataService, the database is | 85 // 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 | 86 // 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. | 87 // back. We also store the autofill results so we can send them together. |
| 87 WebDataService::Handle pending_query_handle_; | 88 WebDataServiceBase::Handle pending_query_handle_; |
| 88 int query_id_; | 89 int query_id_; |
| 89 std::vector<string16> autofill_values_; | 90 std::vector<string16> autofill_values_; |
| 90 std::vector<string16> autofill_labels_; | 91 std::vector<string16> autofill_labels_; |
| 91 std::vector<string16> autofill_icons_; | 92 std::vector<string16> autofill_icons_; |
| 92 std::vector<int> autofill_unique_ids_; | 93 std::vector<int> autofill_unique_ids_; |
| 93 | 94 |
| 94 // Delegate to perform external processing (display, selection) on | 95 // Delegate to perform external processing (display, selection) on |
| 95 // our behalf. Weak. | 96 // our behalf. Weak. |
| 96 AutofillExternalDelegate* external_delegate_; | 97 AutofillExternalDelegate* external_delegate_; |
| 97 | 98 |
| 98 DISALLOW_COPY_AND_ASSIGN(AutocompleteHistoryManager); | 99 DISALLOW_COPY_AND_ASSIGN(AutocompleteHistoryManager); |
| 99 }; | 100 }; |
| 100 | 101 |
| 101 #endif // CHROME_BROWSER_AUTOFILL_AUTOCOMPLETE_HISTORY_MANAGER_H_ | 102 #endif // CHROME_BROWSER_AUTOFILL_AUTOCOMPLETE_HISTORY_MANAGER_H_ |
| OLD | NEW |