| 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_DISCOVERY_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_NTP_SUGGESTIONS_SOURCE_DISCOVERY_H_ |
| 6 #define CHROME_BROWSER_UI_WEBUI_NTP_SUGGESTIONS_SOURCE_DISCOVERY_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_NTP_SUGGESTIONS_SOURCE_DISCOVERY_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <deque> | 9 #include <deque> |
| 10 #include <string> |
| 10 | 11 |
| 11 #include "chrome/browser/cancelable_request.h" | 12 #include "base/basictypes.h" |
| 12 #include "chrome/browser/history/history_types.h" | 13 #include "base/compiler_specific.h" |
| 13 #include "chrome/browser/ui/webui/ntp/suggestions_source.h" | 14 #include "chrome/browser/ui/webui/ntp/suggestions_source.h" |
| 14 #include "net/url_request/url_fetcher_delegate.h" | |
| 15 | 15 |
| 16 class SuggestionsCombiner; | 16 class SuggestionsCombiner; |
| 17 class Profile; | 17 class Profile; |
| 18 | 18 |
| 19 namespace base { | 19 namespace base { |
| 20 class DictionaryValue; | 20 class DictionaryValue; |
| 21 } | 21 } |
| 22 | 22 |
| 23 namespace net { | 23 // A source linked to a single extension using the discovery API to suggest |
| 24 class URLFetcher; | 24 // websites the user might find interesting. |
| 25 } | 25 class SuggestionsSourceDiscovery : public SuggestionsSource { |
| 26 | |
| 27 // A source that suggests websites the user might find interesting. | |
| 28 class SuggestionsSourceDiscovery : public SuggestionsSource, | |
| 29 public net::URLFetcherDelegate { | |
| 30 public: | 26 public: |
| 31 SuggestionsSourceDiscovery(); | 27 explicit SuggestionsSourceDiscovery(const std::string& extension_id); |
| 32 virtual ~SuggestionsSourceDiscovery(); | 28 virtual ~SuggestionsSourceDiscovery(); |
| 33 | 29 |
| 34 // net::URLFetcherDelegate override and implementation. | |
| 35 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; | |
| 36 | |
| 37 protected: | 30 protected: |
| 38 // SuggestionsSource overrides: | 31 // SuggestionsSource overrides: |
| 39 virtual int GetWeight() OVERRIDE; | 32 virtual int GetWeight() OVERRIDE; |
| 40 virtual int GetItemCount() OVERRIDE; | 33 virtual int GetItemCount() OVERRIDE; |
| 41 virtual base::DictionaryValue* PopItem() OVERRIDE; | 34 virtual base::DictionaryValue* PopItem() OVERRIDE; |
| 42 virtual void FetchItems(Profile* profile) OVERRIDE; | 35 virtual void FetchItems(Profile* profile) OVERRIDE; |
| 43 virtual void SetCombiner(SuggestionsCombiner* combiner) OVERRIDE; | 36 virtual void SetCombiner(SuggestionsCombiner* combiner) OVERRIDE; |
| 44 | 37 |
| 45 private: | 38 private: |
| 46 // Our combiner. | 39 // Our combiner. |
| 47 SuggestionsCombiner* combiner_; | 40 SuggestionsCombiner* combiner_; |
| 48 | 41 |
| 49 // Keep the results fetched from the discovery service here. | 42 // Keep the results fetched from the discovery service here. |
| 50 std::deque<base::DictionaryValue*> items_; | 43 std::deque<base::DictionaryValue*> items_; |
| 51 | 44 |
| 52 // Fetcher for the recommended pages. | 45 // The extension associated with this source. |
| 53 scoped_ptr<net::URLFetcher> recommended_fetcher_; | 46 std::string extension_id_; |
| 54 | 47 |
| 55 DISALLOW_COPY_AND_ASSIGN(SuggestionsSourceDiscovery); | 48 DISALLOW_COPY_AND_ASSIGN(SuggestionsSourceDiscovery); |
| 56 }; | 49 }; |
| 57 | 50 |
| 58 #endif // CHROME_BROWSER_UI_WEBUI_NTP_SUGGESTIONS_SOURCE_DISCOVERY_H_ | 51 #endif // CHROME_BROWSER_UI_WEBUI_NTP_SUGGESTIONS_SOURCE_DISCOVERY_H_ |
| OLD | NEW |