Supervised user whitelists: Cleanup
[chromium-blink-merge.git] / ui / app_list / search / history.h
blob4026ec10616324be3035872fc5f725ee187be1fc
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 UI_APP_LIST_SEARCH_HISTORY_H_
6 #define UI_APP_LIST_SEARCH_HISTORY_H_
8 #include <map>
9 #include <string>
11 #include "base/basictypes.h"
12 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "components/keyed_service/core/keyed_service.h"
15 #include "ui/app_list/app_list_export.h"
16 #include "ui/app_list/search/history_data_observer.h"
17 #include "ui/app_list/search/history_types.h"
19 namespace app_list {
21 class HistoryData;
22 class HistoryDataStore;
24 namespace test {
25 class SearchHistoryTest;
28 // History tracks the launch events of the search results and uses HistoryData
29 // to build user learning data out of these events. The learning data is stored
30 // as associations between user typed query and launched result id. There are
31 // primary and secondary associations. See HistoryData comments to see how
32 // they are built. The learning data is sent to the mixer to boost results that
33 // have been launched before.
34 class APP_LIST_EXPORT History : public KeyedService,
35 public HistoryDataObserver {
36 public:
37 explicit History(scoped_refptr<HistoryDataStore> store);
38 ~History() override;
40 // Returns true if the service is ready.
41 bool IsReady() const;
43 // Adds a launch event to the learning data.
44 void AddLaunchEvent(const std::string& query, const std::string& result_id);
46 // Gets all known search results that were launched using the given |query|
47 // or using queries that |query| is a prefix of.
48 scoped_ptr<KnownResults> GetKnownResults(const std::string& query) const;
50 private:
51 friend class app_list::test::SearchHistoryTest;
53 // HistoryDataObserver overrides:
54 void OnHistoryDataLoadedFromStore() override;
56 scoped_ptr<HistoryData> data_;
57 scoped_refptr<HistoryDataStore> store_;
58 bool data_loaded_;
60 DISALLOW_COPY_AND_ASSIGN(History);
63 } // namespace app_list
65 #endif // UI_APP_LIST_SEARCH_HISTORY_H_