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_COMBINER_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_NTP_SUGGESTIONS_COMBINER_H_ |
6 #define CHROME_BROWSER_UI_WEBUI_NTP_SUGGESTIONS_COMBINER_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_NTP_SUGGESTIONS_COMBINER_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 public: | 30 public: |
31 virtual ~Delegate() {} | 31 virtual ~Delegate() {} |
32 | 32 |
33 // Method that is called when new suggestions are ready from the | 33 // Method that is called when new suggestions are ready from the |
34 // SuggestionsCombiner. | 34 // SuggestionsCombiner. |
35 virtual void OnSuggestionsReady() = 0; | 35 virtual void OnSuggestionsReady() = 0; |
36 }; | 36 }; |
37 | 37 |
38 virtual ~SuggestionsCombiner(); | 38 virtual ~SuggestionsCombiner(); |
39 | 39 |
| 40 explicit SuggestionsCombiner(SuggestionsCombiner::Delegate* delegate, |
| 41 Profile* profile); |
| 42 |
40 // Add a new source. The SuggestionsCombiner takes ownership of |source|. | 43 // Add a new source. The SuggestionsCombiner takes ownership of |source|. |
41 void AddSource(SuggestionsSource* source); | 44 void AddSource(SuggestionsSource* source); |
42 | 45 |
43 // Enables or disables debug mode. If debug mode is enabled, the sources are | 46 // Enables or disables debug mode. If debug mode is enabled, the sources are |
44 // expected to provide additional data, which could be displayed, for example, | 47 // expected to provide additional data, which could be displayed, for example, |
45 // in the chrome://suggestions-internals/ page. | 48 // in the chrome://suggestions-internals/ page. |
46 void EnableDebug(bool enable); | 49 void EnableDebug(bool enable); |
47 | 50 |
48 // Fetch a new set of items from the various suggestion sources. | 51 // Fetch a new set of items from the various suggestion sources. |
49 void FetchItems(Profile* profile); | 52 void FetchItems(Profile* profile); |
50 | 53 |
51 base::ListValue* GetPageValues(); | 54 base::ListValue* GetPageValues(); |
52 | 55 |
53 // Called by a source when its items are ready. Make sure suggestion sources | 56 // Called by a source when its items are ready. Make sure suggestion sources |
54 // call this method exactly once for each call to | 57 // call this method exactly once for each call to |
55 // SuggestionsSource::FetchItems. | 58 // SuggestionsSource::FetchItems. |
56 void OnItemsReady(); | 59 void OnItemsReady(); |
57 | 60 |
58 void SetSuggestionsCount(size_t suggestions_count); | 61 void SetSuggestionsCount(size_t suggestions_count); |
59 | 62 |
60 // Creates a new instance of the SuggestionsCombiner (owned by the callee), | 63 // Creates a new instance of the SuggestionsCombiner (owned by the callee), |
61 // and sets up the default sources. | 64 // and sets up the default sources. |
62 static SuggestionsCombiner* Create(SuggestionsCombiner::Delegate* delegate, | 65 static SuggestionsCombiner* Create(SuggestionsCombiner::Delegate* delegate, |
63 Profile* profile); | 66 Profile* profile); |
64 | 67 |
65 private: | 68 private: |
66 friend class SuggestionsCombinerTest; | 69 friend class SuggestionsCombinerTest; |
67 | 70 |
68 explicit SuggestionsCombiner(SuggestionsCombiner::Delegate* delegate, | |
69 Profile* profile); | |
70 | |
71 // Fill the page values from the suggestion sources so they can be sent to | 71 // Fill the page values from the suggestion sources so they can be sent to |
72 // the JavaScript side. This should only be called when all the suggestion | 72 // the JavaScript side. This should only be called when all the suggestion |
73 // sources have items ready. | 73 // sources have items ready. |
74 void FillPageValues(); | 74 void FillPageValues(); |
75 | 75 |
76 // Add extra information to page values that should be common across all | 76 // Add extra information to page values that should be common across all |
77 // suggestion sources. | 77 // suggestion sources. |
78 void AddExtendedInformation(base::DictionaryValue* page_value); | 78 void AddExtendedInformation(base::DictionaryValue* page_value); |
79 | 79 |
80 // Checks if a URL is already open for the current profile. URLs open in an | 80 // Checks if a URL is already open for the current profile. URLs open in an |
(...skipping 23 matching lines...) Expand all Loading... |
104 // Whether debug mode is enabled or not (debug mode provides more data in the | 104 // Whether debug mode is enabled or not (debug mode provides more data in the |
105 // results). | 105 // results). |
106 bool debug_enabled_; | 106 bool debug_enabled_; |
107 | 107 |
108 Profile* profile_; | 108 Profile* profile_; |
109 | 109 |
110 DISALLOW_COPY_AND_ASSIGN(SuggestionsCombiner); | 110 DISALLOW_COPY_AND_ASSIGN(SuggestionsCombiner); |
111 }; | 111 }; |
112 | 112 |
113 #endif // CHROME_BROWSER_UI_WEBUI_NTP_SUGGESTIONS_COMBINER_H_ | 113 #endif // CHROME_BROWSER_UI_WEBUI_NTP_SUGGESTIONS_COMBINER_H_ |
OLD | NEW |