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.
5 #ifndef CHROME_BROWSER_UI_WEBUI_NTP_SUGGESTIONS_SOURCE_H_
6 #define CHROME_BROWSER_UI_WEBUI_NTP_SUGGESTIONS_SOURCE_H_
8 #include "base/basictypes.h"
11 class SuggestionsCombiner
;
14 class DictionaryValue
;
17 // Interface for a source of suggested pages. The various sources will be
18 // combined by the SuggestionsCombiner.
19 class SuggestionsSource
{
22 virtual ~SuggestionsSource() {}
25 SuggestionsSource() {}
27 friend class SuggestionsCombiner
;
29 // Enables or disables debug mode for the current source. The source is
30 // expected to provide additional data when debug mode is enabled.
31 virtual void SetDebug(bool enable
) = 0;
33 // The source's weight indicates how many items from this source will be
34 // selected by the combiner. If a source weight is x and the total weight of
35 // all the sources is y, then the combiner will select x/y items from it.
36 virtual int GetWeight() = 0;
38 // Returns the number of items this source can produce.
39 virtual int GetItemCount() = 0;
41 // Removes the most important item from this source and returns it. The
42 // returned item must be in the right format to be sent to the javascript,
43 // which you typically get by calling NewTabUI::SetUrlTitleAndDirection. If
44 // the source is empty this method returns null.
45 // The caller takes ownership of the returned item.
46 virtual base::DictionaryValue
* PopItem() = 0;
48 // Requests that the source fetch its items. If the source is already fetching
49 // it does not have to reset and can continue fetching.
50 virtual void FetchItems(Profile
* profile
) = 0;
52 // Sets the combiner holding this suggestion source. This method can only
54 virtual void SetCombiner(SuggestionsCombiner
* combiner
) = 0;
57 DISALLOW_COPY_AND_ASSIGN(SuggestionsSource
);
60 #endif // CHROME_BROWSER_UI_WEBUI_NTP_SUGGESTIONS_SOURCE_H_