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 | 9 |
10 #include <string> | 10 #include <string> |
(...skipping 20 matching lines...) Expand all Loading... |
31 | 31 |
32 class PopularSites; | 32 class PopularSites; |
33 class Profile; | 33 class Profile; |
34 | 34 |
35 // Provides the list of most visited sites and their thumbnails to Java. | 35 // Provides the list of most visited sites and their thumbnails to Java. |
36 class MostVisitedSites : public sync_driver::SyncServiceObserver, | 36 class MostVisitedSites : public sync_driver::SyncServiceObserver, |
37 public history::TopSitesObserver { | 37 public history::TopSitesObserver { |
38 public: | 38 public: |
39 explicit MostVisitedSites(Profile* profile); | 39 explicit MostVisitedSites(Profile* profile); |
40 void Destroy(JNIEnv* env, jobject obj); | 40 void Destroy(JNIEnv* env, jobject obj); |
41 void OnLoadingComplete(JNIEnv* env, jobject obj); | |
42 void SetMostVisitedURLsObserver(JNIEnv* env, | 41 void SetMostVisitedURLsObserver(JNIEnv* env, |
43 jobject obj, | 42 jobject obj, |
44 jobject j_observer, | 43 jobject j_observer, |
45 jint num_sites); | 44 jint num_sites); |
46 void GetURLThumbnail(JNIEnv* env, | 45 void GetURLThumbnail(JNIEnv* env, |
47 jobject obj, | 46 jobject obj, |
48 jstring url, | 47 jstring url, |
49 jobject j_callback); | 48 jobject j_callback); |
50 | 49 |
51 void BlacklistUrl(JNIEnv* env, jobject obj, jstring j_url); | 50 void BlacklistUrl(JNIEnv* env, jobject obj, jstring j_url); |
52 void RecordOpenedMostVisitedItem(JNIEnv* env, jobject obj, jint index); | 51 void RecordTileTypeMetrics(JNIEnv* env, |
| 52 jobject obj, |
| 53 jintArray jtile_types, |
| 54 jboolean is_icon_mode); |
| 55 void RecordOpenedMostVisitedItem(JNIEnv* env, |
| 56 jobject obj, |
| 57 jint index, |
| 58 jint tile_type); |
53 | 59 |
54 // sync_driver::SyncServiceObserver implementation. | 60 // sync_driver::SyncServiceObserver implementation. |
55 void OnStateChanged() override; | 61 void OnStateChanged() override; |
56 | 62 |
57 // Registers JNI methods. | 63 // Registers JNI methods. |
58 static bool Register(JNIEnv* env); | 64 static bool Register(JNIEnv* env); |
59 | 65 |
60 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); | 66 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
61 | 67 |
62 private: | 68 private: |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 bool received_most_visited_sites_; | 194 bool received_most_visited_sites_; |
189 | 195 |
190 // Whether we have received the set of popular sites. Immediately set to true | 196 // Whether we have received the set of popular sites. Immediately set to true |
191 // if popular sites are disabled. | 197 // if popular sites are disabled. |
192 bool received_popular_sites_; | 198 bool received_popular_sites_; |
193 | 199 |
194 // Whether we have recorded one-shot UMA metrics such as impressions. They are | 200 // Whether we have recorded one-shot UMA metrics such as impressions. They are |
195 // recorded once both the previous flags are true. | 201 // recorded once both the previous flags are true. |
196 bool recorded_uma_; | 202 bool recorded_uma_; |
197 | 203 |
198 // Counters for UMA metrics. | |
199 | |
200 // Number of tiles using a local thumbnail image for this NTP session. | |
201 int num_local_thumbs_; | |
202 // Number of tiles for which a server thumbnail is provided. | |
203 int num_server_thumbs_; | |
204 // Number of tiles for which no thumbnail is found/specified. | |
205 // In this case a gray tile is used as the main tile. | |
206 int num_empty_thumbs_; | |
207 | |
208 ScopedObserver<history::TopSites, history::TopSitesObserver> scoped_observer_; | 204 ScopedObserver<history::TopSites, history::TopSitesObserver> scoped_observer_; |
209 | 205 |
210 MostVisitedSource mv_source_; | 206 MostVisitedSource mv_source_; |
211 | 207 |
212 scoped_ptr<PopularSites> popular_sites_; | 208 scoped_ptr<PopularSites> popular_sites_; |
213 | 209 |
214 ScopedVector<Suggestion> current_suggestions_; | 210 ScopedVector<Suggestion> current_suggestions_; |
215 | 211 |
216 // For callbacks may be run after destruction. | 212 // For callbacks may be run after destruction. |
217 base::WeakPtrFactory<MostVisitedSites> weak_ptr_factory_; | 213 base::WeakPtrFactory<MostVisitedSites> weak_ptr_factory_; |
218 | 214 |
219 DISALLOW_COPY_AND_ASSIGN(MostVisitedSites); | 215 DISALLOW_COPY_AND_ASSIGN(MostVisitedSites); |
220 }; | 216 }; |
221 | 217 |
222 #endif // CHROME_BROWSER_ANDROID_MOST_VISITED_SITES_H_ | 218 #endif // CHROME_BROWSER_ANDROID_MOST_VISITED_SITES_H_ |
OLD | NEW |