ozone: evdev: Sync caps lock LED state to evdev
[chromium-blink-merge.git] / components / autofill / core / browser / autocomplete_history_manager.h
blob151b2e797ce5eb44f282509c1363ba0956844cc0
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOCOMPLETE_HISTORY_MANAGER_H_
6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOCOMPLETE_HISTORY_MANAGER_H_
8 #include <vector>
10 #include "base/gtest_prod_util.h"
11 #include "base/prefs/pref_member.h"
12 #include "components/autofill/core/browser/suggestion.h"
13 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h"
14 #include "components/webdata/common/web_data_service_consumer.h"
16 namespace autofill {
18 class AutofillDriver;
19 class AutofillExternalDelegate;
20 class AutofillClient;
21 struct FormData;
23 // Per-tab Autocomplete history manager. Handles receiving form data
24 // from the renderer and the storing and retrieving of form data
25 // through WebDataServiceBase.
26 class AutocompleteHistoryManager : public WebDataServiceConsumer {
27 public:
28 AutocompleteHistoryManager(AutofillDriver* driver,
29 AutofillClient* autofill_client);
30 ~AutocompleteHistoryManager() override;
32 // WebDataServiceConsumer implementation.
33 void OnWebDataServiceRequestDone(WebDataServiceBase::Handle h,
34 const WDTypedResult* result) override;
36 // Pass-through functions that are called by AutofillManager, after it has
37 // dispatched a message.
38 virtual void OnGetAutocompleteSuggestions(
39 int query_id,
40 const base::string16& name,
41 const base::string16& prefix,
42 const std::string& form_control_type,
43 const std::vector<Suggestion>& suggestions);
44 virtual void OnFormSubmitted(const FormData& form);
46 // Cancels the currently pending WebDataService query, if there is one.
47 void CancelPendingQuery();
49 // Must be public for the external delegate to use.
50 void OnRemoveAutocompleteEntry(const base::string16& name,
51 const base::string16& value);
53 // Sets our external delegate.
54 void SetExternalDelegate(AutofillExternalDelegate* delegate);
56 protected:
57 friend class AutofillManagerTest;
59 // Sends the stored suggestions plus the new autocomplete results for display
60 // in the Autofill popup. The parameter may be null if there are no new
61 // autocomplete additions.
62 void SendSuggestions(const std::vector<base::string16>* new_results);
64 private:
65 // Provides driver-level context. Must outlive this object.
66 AutofillDriver* driver_;
67 scoped_refptr<AutofillWebDataService> database_;
69 // When the manager makes a request from WebDataServiceBase, the database is
70 // queried on another thread, we record the query handle until we get called
71 // back. We also store the autofill results so we can send them together.
72 WebDataServiceBase::Handle pending_query_handle_;
73 int query_id_;
74 std::vector<Suggestion> autofill_suggestions_;
76 // Delegate to perform external processing (display, selection) on
77 // our behalf. Weak.
78 AutofillExternalDelegate* external_delegate_;
80 // Delegate to provide whether or not autocomplete functionality is enabled.
81 AutofillClient* const autofill_client_;
83 // Whether IPC is sent.
84 bool send_ipc_;
86 DISALLOW_COPY_AND_ASSIGN(AutocompleteHistoryManager);
89 } // namespace autofill
91 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOCOMPLETE_HISTORY_MANAGER_H_