- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / webui / ntp / suggestions_source_top_sites.h
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 "chrome/browser/common/cancelable_request.h"
12 #include "chrome/browser/history/history_types.h"
13 #include "chrome/browser/history/visit_filter.h"
14 #include "chrome/browser/ui/webui/ntp/suggestions_source.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   virtual ~SuggestionsSourceTopSites();
29
30  protected:
31   // SuggestionsSource overrides:
32   virtual void SetDebug(bool enable) OVERRIDE;
33   virtual int GetWeight() OVERRIDE;
34   virtual int GetItemCount() OVERRIDE;
35   virtual base::DictionaryValue* PopItem() OVERRIDE;
36   virtual void FetchItems(Profile* profile) OVERRIDE;
37   virtual void SetCombiner(SuggestionsCombiner* combiner) OVERRIDE;
38
39   void OnSuggestionsUrlsAvailable(
40       CancelableRequestProvider::Handle handle,
41       const history::FilteredURLList& data);
42
43  private:
44
45   // Gets the sorting order from the command-line arguments. Defaults to
46   // |ORDER_BY_RECENCY| if there are no command-line argument specifying a
47   // sorting order.
48   static history::VisitFilter::SortingOrder GetSortingOrder();
49
50   // Gets the filter width from the command-line arguments. Defaults to one
51   // hour if there are no command-line argument setting the filter width.
52   static base::TimeDelta GetFilterWidth();
53
54   // Our combiner.
55   SuggestionsCombiner* combiner_;
56
57   // Keep the results of the db query here.
58   std::deque<base::DictionaryValue*> items_;
59
60   // Whether the source should provide additional debug information or not.
61   bool debug_;
62
63   CancelableRequestConsumer history_consumer_;
64
65   DISALLOW_COPY_AND_ASSIGN(SuggestionsSourceTopSites);
66 };
67
68 #endif  // CHROME_BROWSER_UI_WEBUI_NTP_SUGGESTIONS_SOURCE_TOP_SITES_H_