NaCl: Update revision in DEPS, r12770 -> r12773
[chromium-blink-merge.git] / chrome / browser / ui / app_list / search / history.h
blob0464461550f7048c18325c26d54e401464cd9764
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_
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 "chrome/browser/ui/app_list/search/history_data_observer.h"
15 #include "chrome/browser/ui/app_list/search/history_types.h"
16 #include "components/browser_context_keyed_service/browser_context_keyed_service.h"
18 namespace content {
19 class BrowserContext;
22 namespace app_list {
24 class HistoryData;
25 class HistoryDataStore;
27 namespace test {
28 class SearchHistoryTest;
31 // History tracks the launch events of the search results and uses HistoryData
32 // to build user learning data out of these events. The learning data is stored
33 // as associations between user typed query and launched result id. There are
34 // primary and secondary associations. See HistoryData comments to see how
35 // they are built. The learning data is sent to the mixer to boost results that
36 // have been launched before.
37 class History : public BrowserContextKeyedService,
38 public HistoryDataObserver {
39 public:
40 explicit History(content::BrowserContext* context);
41 virtual ~History();
43 // Returns true if the service is ready.
44 bool IsReady() const;
46 // Adds a launch event to the learning data.
47 void AddLaunchEvent(const std::string& query, const std::string& result_id);
49 // Gets all known search results that were launched using the given |query|
50 // or using queries that |query| is a prefix of.
51 scoped_ptr<KnownResults> GetKnownResults(const std::string& query) const;
53 private:
54 friend class app_list::test::SearchHistoryTest;
56 // HistoryDataObserver overrides:
57 virtual void OnHistoryDataLoadedFromStore() OVERRIDE;
59 content::BrowserContext* browser_context_;
60 scoped_ptr<HistoryData> data_;
61 scoped_refptr<HistoryDataStore> store_;
62 bool data_loaded_;
64 DISALLOW_COPY_AND_ASSIGN(History);
67 } // namespace app_list
69 #endif // CHROME_BROWSER_UI_APP_LIST_SEARCH_HISTORY_H_