OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_UI_WEBUI_NTP_SUGGESTIONS_SOURCE_TOP_SITES_H_ | |
6 #define CHROME_BROWSER_UI_WEBUI_NTP_SUGGESTIONS_SOURCE_TOP_SITES_H_ | |
7 | |
8 #include <deque> | |
9 | |
10 #include "base/basictypes.h" | |
11 #include "base/task/cancelable_task_tracker.h" | |
12 #include "chrome/browser/ui/webui/ntp/suggestions_source.h" | |
13 #include "components/history/core/browser/history_types.h" | |
14 #include "components/history/core/browser/visit_filter.h" | |
15 | |
16 class SuggestionsCombiner; | |
17 class Profile; | |
18 | |
19 namespace base { | |
20 class DictionaryValue; | |
21 } | |
22 | |
23 // A SuggestionsSource that uses the local TopSites database to provide | |
24 // suggestions. | |
25 class SuggestionsSourceTopSites : public SuggestionsSource { | |
26 public: | |
27 SuggestionsSourceTopSites(); | |
28 ~SuggestionsSourceTopSites() override; | |
29 | |
30 protected: | |
31 // SuggestionsSource overrides: | |
32 void SetDebug(bool enable) override; | |
33 int GetWeight() override; | |
34 int GetItemCount() override; | |
35 base::DictionaryValue* PopItem() override; | |
36 void FetchItems(Profile* profile) override; | |
37 void SetCombiner(SuggestionsCombiner* combiner) override; | |
38 | |
39 void OnSuggestionsUrlsAvailable(const history::FilteredURLList* data); | |
40 | |
41 private: | |
42 | |
43 // Gets the sorting order from the command-line arguments. Defaults to | |
44 // |ORDER_BY_RECENCY| if there are no command-line argument specifying a | |
45 // sorting order. | |
46 static history::VisitFilter::SortingOrder GetSortingOrder(); | |
47 | |
48 // Gets the filter width from the command-line arguments. Defaults to one | |
49 // hour if there are no command-line argument setting the filter width. | |
50 static base::TimeDelta GetFilterWidth(); | |
51 | |
52 // Our combiner. | |
53 SuggestionsCombiner* combiner_; | |
54 | |
55 // Keep the results of the db query here. | |
56 std::deque<base::DictionaryValue*> items_; | |
57 | |
58 // Whether the source should provide additional debug information or not. | |
59 bool debug_; | |
60 | |
61 base::CancelableTaskTracker history_tracker_; | |
62 | |
63 DISALLOW_COPY_AND_ASSIGN(SuggestionsSourceTopSites); | |
64 }; | |
65 | |
66 #endif // CHROME_BROWSER_UI_WEBUI_NTP_SUGGESTIONS_SOURCE_TOP_SITES_H_ | |
OLD | NEW |