OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_ANDROID_MOST_VISITED_SITES_H_ | 5 #ifndef CHROME_BROWSER_ANDROID_MOST_VISITED_SITES_H_ |
6 #define CHROME_BROWSER_ANDROID_MOST_VISITED_SITES_H_ | 6 #define CHROME_BROWSER_ANDROID_MOST_VISITED_SITES_H_ |
7 | 7 |
8 #include <jni.h> | 8 #include <jni.h> |
9 #include <stddef.h> | 9 #include <stddef.h> |
10 | 10 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
83 private: | 83 private: |
84 friend class MostVisitedSitesTest; | 84 friend class MostVisitedSitesTest; |
85 | 85 |
86 // The source of the Most Visited sites. | 86 // The source of the Most Visited sites. |
87 enum MostVisitedSource { TOP_SITES, SUGGESTIONS_SERVICE, POPULAR, WHITELIST }; | 87 enum MostVisitedSource { TOP_SITES, SUGGESTIONS_SERVICE, POPULAR, WHITELIST }; |
88 | 88 |
89 struct Suggestion { | 89 struct Suggestion { |
90 base::string16 title; | 90 base::string16 title; |
91 GURL url; | 91 GURL url; |
92 MostVisitedSource source; | 92 MostVisitedSource source; |
93 // Only valid for source == WHITELIST (empty otherwise). | 93 // Will be empty for entries that do not have a whitelist associated with |
Marc Treib
2016/03/11 14:21:01
nit: "that don't have an associated whitelist", th
atanasova
2016/03/11 15:59:25
Done.
| |
94 // them. | |
94 base::FilePath large_icon_path; | 95 base::FilePath large_icon_path; |
95 // Only valid for source == SUGGESTIONS_SERVICE (-1 otherwise). | 96 // Only valid for source == SUGGESTIONS_SERVICE (-1 otherwise). |
96 int provider_index; | 97 int provider_index; |
97 | 98 |
98 Suggestion(const base::string16& title, | 99 Suggestion(const base::string16& title, |
99 const std::string& url, | |
100 MostVisitedSource source); | |
101 Suggestion(const base::string16& title, | |
102 const GURL& url, | |
103 MostVisitedSource source, | |
104 const base::FilePath& large_icon_path); | |
105 Suggestion(const base::string16& title, | |
106 const GURL& url, | 100 const GURL& url, |
107 MostVisitedSource source); | 101 MostVisitedSource source); |
108 Suggestion(const base::string16& title, | 102 Suggestion(const base::string16& title, |
109 const std::string& url, | 103 const std::string& url, |
110 MostVisitedSource source, | 104 MostVisitedSource source, |
105 const base::FilePath& large_icon_path); | |
106 Suggestion(const base::string16& title, | |
107 const GURL& url, | |
108 MostVisitedSource source, | |
109 const base::FilePath& large_icon_path); | |
110 Suggestion(const base::string16& title, | |
111 const std::string& url, | |
112 MostVisitedSource source, | |
113 const base::FilePath& large_icon_path, | |
111 int provider_index); | 114 int provider_index); |
112 ~Suggestion(); | 115 ~Suggestion(); |
113 | 116 |
114 // Get the Histogram name associated with the source. | 117 // Get the Histogram name associated with the source. |
115 std::string GetSourceHistogramName() const; | 118 std::string GetSourceHistogramName() const; |
116 | 119 |
117 private: | 120 private: |
118 DISALLOW_COPY_AND_ASSIGN(Suggestion); | 121 DISALLOW_COPY_AND_ASSIGN(Suggestion); |
119 }; | 122 }; |
120 | 123 |
121 using SuggestionsVector = std::vector<scoped_ptr<Suggestion>>; | 124 using SuggestionsVector = std::vector<scoped_ptr<Suggestion>>; |
122 | 125 |
123 ~MostVisitedSites() override; | 126 ~MostVisitedSites() override; |
124 void QueryMostVisitedURLs(); | 127 void QueryMostVisitedURLs(); |
125 | 128 |
126 // Initialize the query to Top Sites. Called if the SuggestionsService is not | 129 // Initialize the query to Top Sites. Called if the SuggestionsService is not |
127 // enabled, or if it returns no data. | 130 // enabled, or if it returns no data. |
128 void InitiateTopSitesQuery(); | 131 void InitiateTopSitesQuery(); |
129 | 132 |
133 // If there is a whitelist entry point for the URL return the large icon path | |
134 base::FilePath GetWhitelistLargeIconPath(const GURL& url); | |
135 | |
130 // Callback for when data is available from TopSites. | 136 // Callback for when data is available from TopSites. |
131 void OnMostVisitedURLsAvailable( | 137 void OnMostVisitedURLsAvailable( |
132 const history::MostVisitedURLList& visited_list); | 138 const history::MostVisitedURLList& visited_list); |
133 | 139 |
134 // Callback for when data is available from the SuggestionsService. | 140 // Callback for when data is available from the SuggestionsService. |
135 void OnSuggestionsProfileAvailable( | 141 void OnSuggestionsProfileAvailable( |
136 const suggestions::SuggestionsProfile& suggestions_profile); | 142 const suggestions::SuggestionsProfile& suggestions_profile); |
137 | 143 |
138 // Takes the personal suggestions and creates whitelist entry point | 144 // Takes the personal suggestions and creates whitelist entry point |
139 // suggestions if necessary. | 145 // suggestions if necessary. |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
244 | 250 |
245 SuggestionsVector current_suggestions_; | 251 SuggestionsVector current_suggestions_; |
246 | 252 |
247 // For callbacks may be run after destruction. | 253 // For callbacks may be run after destruction. |
248 base::WeakPtrFactory<MostVisitedSites> weak_ptr_factory_; | 254 base::WeakPtrFactory<MostVisitedSites> weak_ptr_factory_; |
249 | 255 |
250 DISALLOW_COPY_AND_ASSIGN(MostVisitedSites); | 256 DISALLOW_COPY_AND_ASSIGN(MostVisitedSites); |
251 }; | 257 }; |
252 | 258 |
253 #endif // CHROME_BROWSER_ANDROID_MOST_VISITED_SITES_H_ | 259 #endif // CHROME_BROWSER_ANDROID_MOST_VISITED_SITES_H_ |
OLD | NEW |