OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_UI_WEBUI_NTP_SUGGESTIONS_SOURCE_TOP_SITES_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_NTP_SUGGESTIONS_SOURCE_TOP_SITES_H_ |
6 #define CHROME_BROWSER_UI_WEBUI_NTP_SUGGESTIONS_SOURCE_TOP_SITES_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_NTP_SUGGESTIONS_SOURCE_TOP_SITES_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <deque> | 9 #include <deque> |
10 | 10 |
11 #include "chrome/browser/cancelable_request.h" | 11 #include "chrome/browser/cancelable_request.h" |
12 #include "chrome/browser/history/history_types.h" | 12 #include "chrome/browser/history/history_types.h" |
| 13 #include "chrome/browser/history/visit_filter.h" |
13 #include "chrome/browser/ui/webui/ntp/suggestions_source.h" | 14 #include "chrome/browser/ui/webui/ntp/suggestions_source.h" |
14 | 15 |
15 class SuggestionsCombiner; | 16 class SuggestionsCombiner; |
16 class Profile; | 17 class Profile; |
17 | 18 |
18 namespace base { | 19 namespace base { |
19 class DictionaryValue; | 20 class DictionaryValue; |
20 } | 21 } |
21 | 22 |
22 // A SuggestionsSource that uses the local TopSites database to provide | 23 // A SuggestionsSource that uses the local TopSites database to provide |
23 // suggestions. | 24 // suggestions. |
24 class SuggestionsSourceTopSites : public SuggestionsSource { | 25 class SuggestionsSourceTopSites : public SuggestionsSource { |
25 public: | 26 public: |
26 SuggestionsSourceTopSites(); | 27 SuggestionsSourceTopSites(); |
27 virtual ~SuggestionsSourceTopSites(); | 28 virtual ~SuggestionsSourceTopSites(); |
28 | 29 |
29 protected: | 30 protected: |
30 // SuggestionsSource overrides: | 31 // SuggestionsSource overrides: |
31 virtual int GetWeight() OVERRIDE; | 32 virtual int GetWeight() OVERRIDE; |
32 virtual int GetItemCount() OVERRIDE; | 33 virtual int GetItemCount() OVERRIDE; |
33 virtual base::DictionaryValue* PopItem() OVERRIDE; | 34 virtual base::DictionaryValue* PopItem() OVERRIDE; |
34 virtual void FetchItems(Profile* profile) OVERRIDE; | 35 virtual void FetchItems(Profile* profile) OVERRIDE; |
35 virtual void SetCombiner(SuggestionsCombiner* combiner) OVERRIDE; | 36 virtual void SetCombiner(SuggestionsCombiner* combiner) OVERRIDE; |
36 | 37 |
37 void OnSuggestionsURLsAvailable( | 38 void OnSuggestionsURLsAvailable( |
38 CancelableRequestProvider::Handle handle, | 39 CancelableRequestProvider::Handle handle, |
39 const history::FilteredURLList& data); | 40 const history::FilteredURLList& data); |
40 | 41 |
41 private: | 42 private: |
| 43 |
| 44 // Gets the sorting order from the command-line arguments. Defaults to |
| 45 // |ORDER_BY_RECENCY| if there are no command-line argument specifying a |
| 46 // sorting order. |
| 47 static history::VisitFilter::SortingOrder GetSortingOrder(); |
| 48 |
| 49 // Gets the filter width from the command-line arguments. Defaults to one |
| 50 // hour if there are no command-line argument setting the filter width. |
| 51 static base::TimeDelta GetFilterWidth(); |
| 52 |
42 // Our combiner. | 53 // Our combiner. |
43 SuggestionsCombiner* combiner_; | 54 SuggestionsCombiner* combiner_; |
44 | 55 |
45 // Keep the results of the db query here. | 56 // Keep the results of the db query here. |
46 std::deque<base::DictionaryValue*> items_; | 57 std::deque<base::DictionaryValue*> items_; |
47 | 58 |
48 CancelableRequestConsumer history_consumer_; | 59 CancelableRequestConsumer history_consumer_; |
49 | 60 |
50 DISALLOW_COPY_AND_ASSIGN(SuggestionsSourceTopSites); | 61 DISALLOW_COPY_AND_ASSIGN(SuggestionsSourceTopSites); |
51 }; | 62 }; |
52 | 63 |
53 #endif // CHROME_BROWSER_UI_WEBUI_NTP_SUGGESTIONS_SOURCE_TOP_SITES_H_ | 64 #endif // CHROME_BROWSER_UI_WEBUI_NTP_SUGGESTIONS_SOURCE_TOP_SITES_H_ |
OLD | NEW |