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 CHROME_BROWSER_UI_APP_LIST_SEARCH_HISTORY_H_
6 #define CHROME_BROWSER_UI_APP_LIST_SEARCH_HISTORY_H_
11 #include "base/basictypes.h"
12 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "chrome/browser/ui/app_list/search/history_data_observer.h"
15 #include "chrome/browser/ui/app_list/search/history_types.h"
16 #include "components/keyed_service/core/keyed_service.h"
21 class HistoryDataStore;
24 class SearchHistoryTest;
27 // History tracks the launch events of the search results and uses HistoryData
28 // to build user learning data out of these events. The learning data is stored
29 // as associations between user typed query and launched result id. There are
30 // primary and secondary associations. See HistoryData comments to see how
31 // they are built. The learning data is sent to the mixer to boost results that
32 // have been launched before.
33 class History : public KeyedService, public HistoryDataObserver {
35 explicit History(scoped_refptr<HistoryDataStore> store);
38 // Returns true if the service is ready.
41 // Adds a launch event to the learning data.
42 void AddLaunchEvent(const std::string& query, const std::string& result_id);
44 // Gets all known search results that were launched using the given |query|
45 // or using queries that |query| is a prefix of.
46 scoped_ptr<KnownResults> GetKnownResults(const std::string& query) const;
49 friend class app_list::test::SearchHistoryTest;
51 // HistoryDataObserver overrides:
52 virtual void OnHistoryDataLoadedFromStore() OVERRIDE;
54 scoped_ptr<HistoryData> data_;
55 scoped_refptr<HistoryDataStore> store_;
58 DISALLOW_COPY_AND_ASSIGN(History);
61 } // namespace app_list
63 #endif // CHROME_BROWSER_UI_APP_LIST_SEARCH_HISTORY_H_