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

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

Issue 16286020: Abstract WebContentsObserver from Autofill shared code (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebase to fix conflict Created 7 years, 6 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
« no previous file with comments | « components/autofill.gypi ('k') | components/autofill/browser/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 COMPONENTS_AUTOFILL_BROWSER_AUTOCOMPLETE_HISTORY_MANAGER_H_ 5 #ifndef COMPONENTS_AUTOFILL_BROWSER_AUTOCOMPLETE_HISTORY_MANAGER_H_
6 #define COMPONENTS_AUTOFILL_BROWSER_AUTOCOMPLETE_HISTORY_MANAGER_H_ 6 #define COMPONENTS_AUTOFILL_BROWSER_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 "base/prefs/pref_member.h" 11 #include "base/prefs/pref_member.h"
12 #include "components/autofill/browser/webdata/autofill_webdata_service.h" 12 #include "components/autofill/browser/webdata/autofill_webdata_service.h"
13 #include "components/webdata/common/web_data_service_consumer.h" 13 #include "components/webdata/common/web_data_service_consumer.h"
14 #include "content/public/browser/web_contents_observer.h"
15 14
16 namespace content { 15 namespace content {
17 class BrowserContext; 16 class BrowserContext;
17 class WebContents;
18 } 18 }
19 19
20 namespace autofill { 20 namespace autofill {
21 21
22 class AutofillDriver;
22 class AutofillExternalDelegate; 23 class AutofillExternalDelegate;
23 struct FormData; 24 struct FormData;
24 25
25 // Per-tab Autocomplete history manager. Handles receiving form data 26 // Per-tab Autocomplete history manager. Handles receiving form data
26 // from the renderer and the storing and retrieving of form data 27 // from the renderer and the storing and retrieving of form data
27 // through WebDataServiceBase. 28 // through WebDataServiceBase.
28 class AutocompleteHistoryManager : public content::WebContentsObserver, 29 class AutocompleteHistoryManager : public WebDataServiceConsumer {
29 public WebDataServiceConsumer {
30 public: 30 public:
31 explicit AutocompleteHistoryManager(content::WebContents* web_contents); 31 explicit AutocompleteHistoryManager(AutofillDriver* driver);
32 virtual ~AutocompleteHistoryManager(); 32 virtual ~AutocompleteHistoryManager();
33 33
34 // content::WebContentsObserver implementation.
35 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
36
37 // WebDataServiceConsumer implementation. 34 // WebDataServiceConsumer implementation.
38 virtual void OnWebDataServiceRequestDone( 35 virtual void OnWebDataServiceRequestDone(
39 WebDataServiceBase::Handle h, 36 WebDataServiceBase::Handle h,
40 const WDTypedResult* result) OVERRIDE; 37 const WDTypedResult* result) OVERRIDE;
41 38
42 // Pass-through functions that are called by AutofillManager, after it has 39 // Pass-through functions that are called by AutofillManager, after it has
43 // dispatched a message. 40 // dispatched a message.
44 void OnGetAutocompleteSuggestions( 41 void OnGetAutocompleteSuggestions(
45 int query_id, 42 int query_id,
46 const base::string16& name, 43 const base::string16& name,
(...skipping 10 matching lines...) Expand all
57 54
58 // Sets our external delegate. 55 // Sets our external delegate.
59 void SetExternalDelegate(AutofillExternalDelegate* delegate); 56 void SetExternalDelegate(AutofillExternalDelegate* delegate);
60 57
61 protected: 58 protected:
62 friend class AutofillManagerTest; 59 friend class AutofillManagerTest;
63 60
64 // Sends the given |suggestions| for display in the Autofill popup. 61 // Sends the given |suggestions| for display in the Autofill popup.
65 void SendSuggestions(const std::vector<base::string16>* suggestions); 62 void SendSuggestions(const std::vector<base::string16>* suggestions);
66 63
64 // Used by tests to disable sending IPC.
65 void set_send_ipc(bool send_ipc) { send_ipc_ = send_ipc; }
66
67 private: 67 private:
68 // Cancels the currently pending WebDataService query, if there is one. 68 // Cancels the currently pending WebDataService query, if there is one.
69 void CancelPendingQuery(); 69 void CancelPendingQuery();
70 70
71 content::BrowserContext* browser_context_; 71 content::BrowserContext* browser_context_;
72 // Provides driver-level context. Must outlive this object.
73 AutofillDriver* driver_;
72 scoped_refptr<AutofillWebDataService> autofill_data_; 74 scoped_refptr<AutofillWebDataService> autofill_data_;
73 75
74 BooleanPrefMember autofill_enabled_; 76 BooleanPrefMember autofill_enabled_;
75 77
76 // When the manager makes a request from WebDataServiceBase, the database is 78 // When the manager makes a request from WebDataServiceBase, the database is
77 // queried on another thread, we record the query handle until we get called 79 // queried on another thread, we record the query handle until we get called
78 // back. We also store the autofill results so we can send them together. 80 // back. We also store the autofill results so we can send them together.
79 WebDataServiceBase::Handle pending_query_handle_; 81 WebDataServiceBase::Handle pending_query_handle_;
80 int query_id_; 82 int query_id_;
81 std::vector<base::string16> autofill_values_; 83 std::vector<base::string16> autofill_values_;
82 std::vector<base::string16> autofill_labels_; 84 std::vector<base::string16> autofill_labels_;
83 std::vector<base::string16> autofill_icons_; 85 std::vector<base::string16> autofill_icons_;
84 std::vector<int> autofill_unique_ids_; 86 std::vector<int> autofill_unique_ids_;
85 87
86 // Delegate to perform external processing (display, selection) on 88 // Delegate to perform external processing (display, selection) on
87 // our behalf. Weak. 89 // our behalf. Weak.
88 AutofillExternalDelegate* external_delegate_; 90 AutofillExternalDelegate* external_delegate_;
89 91
92 // Whether IPC is sent.
93 bool send_ipc_;
94
90 DISALLOW_COPY_AND_ASSIGN(AutocompleteHistoryManager); 95 DISALLOW_COPY_AND_ASSIGN(AutocompleteHistoryManager);
91 }; 96 };
92 97
93 } // namespace autofill 98 } // namespace autofill
94 99
95 #endif // COMPONENTS_AUTOFILL_BROWSER_AUTOCOMPLETE_HISTORY_MANAGER_H_ 100 #endif // COMPONENTS_AUTOFILL_BROWSER_AUTOCOMPLETE_HISTORY_MANAGER_H_
OLDNEW
« no previous file with comments | « components/autofill.gypi ('k') | components/autofill/browser/autocomplete_history_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698