summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui/webui/ntp/suggestions_source_discovery.h
blob: 7831862e32abc1882a471715287b6cdaacfee07c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_UI_WEBUI_NTP_SUGGESTIONS_SOURCE_DISCOVERY_H_
#define CHROME_BROWSER_UI_WEBUI_NTP_SUGGESTIONS_SOURCE_DISCOVERY_H_

#include <deque>
#include <string>

#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "chrome/browser/ui/webui/ntp/suggestions_source.h"

class SuggestionsCombiner;
class Profile;

namespace base {
class DictionaryValue;
}

// A source linked to a single extension using the discovery API to suggest
// websites the user might find interesting.
class SuggestionsSourceDiscovery : public SuggestionsSource {
 public:
  explicit SuggestionsSourceDiscovery(const std::string& extension_id);
  virtual ~SuggestionsSourceDiscovery();

 protected:
  // SuggestionsSource overrides:
  virtual void SetDebug(bool enable) OVERRIDE;
  virtual int GetWeight() OVERRIDE;
  virtual int GetItemCount() OVERRIDE;
  virtual base::DictionaryValue* PopItem() OVERRIDE;
  virtual void FetchItems(Profile* profile) OVERRIDE;
  virtual void SetCombiner(SuggestionsCombiner* combiner) OVERRIDE;

 private:
  // Our combiner.
  SuggestionsCombiner* combiner_;

  // Keep the results fetched from the discovery service here.
  std::deque<base::DictionaryValue*> items_;

  // The extension associated with this source.
  std::string extension_id_;

  // Whether the source should provide additional debug information or not.
  bool debug_;

  DISALLOW_COPY_AND_ASSIGN(SuggestionsSourceDiscovery);
};

#endif  // CHROME_BROWSER_UI_WEBUI_NTP_SUGGESTIONS_SOURCE_DISCOVERY_H_