Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(60)

Side by Side Diff: chrome/browser/ui/webui/ntp/suggestions_combiner.h

Issue 10666009: Added already_open column to chrome://suggestions-internals. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fixed unit tests Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #pragma once 7 #pragma once
8 8
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/scoped_vector.h" 13 #include "base/memory/scoped_vector.h"
14 14
15 class GURL;
15 class SuggestionsHandler; 16 class SuggestionsHandler;
16 class SuggestionsSource; 17 class SuggestionsSource;
17 class Profile; 18 class Profile;
18 19
19 namespace base { 20 namespace base {
20 class ListValue; 21 class DictionaryValue;
22 class ListValue;
21 } 23 }
22 24
23 // Combines many different sources of suggestions and generates data from it. 25 // Combines many different sources of suggestions and generates data from it.
24 class SuggestionsCombiner { 26 class SuggestionsCombiner {
25 public: 27 public:
26 // Interface to be implemented by classes that will be notified of events from 28 // Interface to be implemented by classes that will be notified of events from
27 // the SuggestionsCombiner. 29 // the SuggestionsCombiner.
28 class Delegate { 30 class Delegate {
29 public: 31 public:
30 virtual ~Delegate() {} 32 virtual ~Delegate() {}
(...skipping 26 matching lines...) Expand all
57 void SetSuggestionsCount(size_t suggestions_count); 59 void SetSuggestionsCount(size_t suggestions_count);
58 60
59 // Creates a new instance of the SuggestionsCombiner (owned by the callee), 61 // Creates a new instance of the SuggestionsCombiner (owned by the callee),
60 // and sets up the default sources. 62 // and sets up the default sources.
61 static SuggestionsCombiner* Create(SuggestionsCombiner::Delegate* delegate, 63 static SuggestionsCombiner* Create(SuggestionsCombiner::Delegate* delegate,
62 Profile* profile); 64 Profile* profile);
63 65
64 private: 66 private:
65 friend class SuggestionsCombinerTest; 67 friend class SuggestionsCombinerTest;
66 68
67 explicit SuggestionsCombiner(SuggestionsCombiner::Delegate* delegate); 69 explicit SuggestionsCombiner(SuggestionsCombiner::Delegate* delegate,
70 Profile* profile);
68 71
69 // Fill the page values from the suggestion sources so they can be sent to 72 // Fill the page values from the suggestion sources so they can be sent to
70 // the JavaScript side. This should only be called when all the suggestion 73 // the JavaScript side. This should only be called when all the suggestion
71 // sources have items ready. 74 // sources have items ready.
72 void FillPageValues(); 75 void FillPageValues();
73 76
77 // Add extra information to page values that should be common across all
78 // suggestion sources.
79 void AddExtendedInformation(base::DictionaryValue* page_value);
80
81 // Checks if a URL is already open for the current profile. URLs open in an
82 // incognito window are not reported.
83 bool IsURLAlreadyOpen(const GURL& url);
84
74 typedef ScopedVector<SuggestionsSource> SuggestionsSources; 85 typedef ScopedVector<SuggestionsSource> SuggestionsSources;
75 86
76 // List of all the suggestions sources that will be combined to generate a 87 // List of all the suggestions sources that will be combined to generate a
77 // single list of suggestions. 88 // single list of suggestions.
78 SuggestionsSources sources_; 89 SuggestionsSources sources_;
79 90
80 // Counter tracking the number of sources that are currently asynchronously 91 // Counter tracking the number of sources that are currently asynchronously
81 // fetching their data. 92 // fetching their data.
82 int sources_fetching_count_; 93 int sources_fetching_count_;
83 94
84 // The delegate to notify once items are ready. 95 // The delegate to notify once items are ready.
85 SuggestionsCombiner::Delegate* delegate_; 96 SuggestionsCombiner::Delegate* delegate_;
86 97
87 // Number of suggestions to generate. Used to distribute the suggestions 98 // Number of suggestions to generate. Used to distribute the suggestions
88 // between the various sources. 99 // between the various sources.
89 size_t suggestions_count_; 100 size_t suggestions_count_;
90 101
91 // Informations to send to the javascript side. 102 // Informations to send to the javascript side.
92 scoped_ptr<base::ListValue> page_values_; 103 scoped_ptr<base::ListValue> page_values_;
93 104
94 // Whether debug mode is enabled or not (debug mode provides more data in the 105 // Whether debug mode is enabled or not (debug mode provides more data in the
95 // results). 106 // results).
96 bool debug_enabled_; 107 bool debug_enabled_;
97 108
109 Profile* profile_;
110
98 DISALLOW_COPY_AND_ASSIGN(SuggestionsCombiner); 111 DISALLOW_COPY_AND_ASSIGN(SuggestionsCombiner);
99 }; 112 };
100 113
101 #endif // CHROME_BROWSER_UI_WEBUI_NTP_SUGGESTIONS_COMBINER_H_ 114 #endif // CHROME_BROWSER_UI_WEBUI_NTP_SUGGESTIONS_COMBINER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698