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

Side by Side Diff: chrome/browser/android/most_visited_sites.h

Issue 473123002: [Most Visited] Check for Sync state when using SuggestionsService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: clean Created 6 years, 4 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 | Annotate | Revision Log
OLDNEW
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 "base/android/scoped_java_ref.h" 10 #include "base/android/scoped_java_ref.h"
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
13 #include "chrome/browser/history/history_types.h" 13 #include "chrome/browser/history/history_types.h"
14 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/browser/sync/profile_sync_service_observer.h"
15 #include "components/suggestions/proto/suggestions.pb.h" 16 #include "components/suggestions/proto/suggestions.pb.h"
16 #include "content/public/browser/notification_observer.h" 17 #include "content/public/browser/notification_observer.h"
17 #include "content/public/browser/notification_registrar.h" 18 #include "content/public/browser/notification_registrar.h"
18 19
19 namespace suggestions { 20 namespace suggestions {
20 class SuggestionsService; 21 class SuggestionsService;
21 } 22 }
22 23
23 // Provides the list of most visited sites and their thumbnails to Java. 24 // Provides the list of most visited sites and their thumbnails to Java.
24 class MostVisitedSites : public content::NotificationObserver { 25 class MostVisitedSites : public ProfileSyncServiceObserver,
26 public content::NotificationObserver {
25 public: 27 public:
26 typedef base::Callback< 28 typedef base::Callback<
27 void(base::android::ScopedJavaGlobalRef<jobject>* bitmap, 29 void(base::android::ScopedJavaGlobalRef<jobject>* bitmap,
28 base::android::ScopedJavaGlobalRef<jobject>* j_callback)> 30 base::android::ScopedJavaGlobalRef<jobject>* j_callback)>
29 LookupSuccessCallback; 31 LookupSuccessCallback;
30 32
31 explicit MostVisitedSites(Profile* profile); 33 explicit MostVisitedSites(Profile* profile);
32 void Destroy(JNIEnv* env, jobject obj); 34 void Destroy(JNIEnv* env, jobject obj);
33 void OnLoadingComplete(JNIEnv* env, jobject obj); 35 void OnLoadingComplete(JNIEnv* env, jobject obj);
34 void SetMostVisitedURLsObserver(JNIEnv* env, 36 void SetMostVisitedURLsObserver(JNIEnv* env,
35 jobject obj, 37 jobject obj,
36 jobject j_observer, 38 jobject j_observer,
37 jint num_sites); 39 jint num_sites);
38 void GetURLThumbnail(JNIEnv* env, 40 void GetURLThumbnail(JNIEnv* env,
39 jobject obj, 41 jobject obj,
40 jstring url, 42 jstring url,
41 jobject j_callback); 43 jobject j_callback);
42 void BlacklistUrl(JNIEnv* env, jobject obj, jstring j_url); 44 void BlacklistUrl(JNIEnv* env, jobject obj, jstring j_url);
43 void RecordOpenedMostVisitedItem(JNIEnv* env, jobject obj, jint index); 45 void RecordOpenedMostVisitedItem(JNIEnv* env, jobject obj, jint index);
44 46
45 // content::NotificationObserver implementation. 47 // content::NotificationObserver implementation.
46 virtual void Observe(int type, 48 virtual void Observe(int type,
47 const content::NotificationSource& source, 49 const content::NotificationSource& source,
48 const content::NotificationDetails& details) OVERRIDE; 50 const content::NotificationDetails& details) OVERRIDE;
49 51
52 // ProfileSyncServiceObserver implementation.
53 virtual void OnStateChanged() OVERRIDE;
54
50 // Registers JNI methods. 55 // Registers JNI methods.
51 static bool Register(JNIEnv* env); 56 static bool Register(JNIEnv* env);
52 57
53 private: 58 private:
54 virtual ~MostVisitedSites(); 59 virtual ~MostVisitedSites();
55 void QueryMostVisitedURLs(); 60 void QueryMostVisitedURLs();
56 61
57 // Initialize the query to Top Sites. Called if the SuggestionsService is not 62 // Initialize the query to Top Sites. Called if the SuggestionsService is not
58 // enabled, or if it returns no data. 63 // enabled, or if it returns no data.
59 void InitiateTopSitesQuery(); 64 void InitiateTopSitesQuery();
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 96
92 // The profile whose most visited sites will be queried. 97 // The profile whose most visited sites will be queried.
93 Profile* profile_; 98 Profile* profile_;
94 99
95 // The observer to be notified when the list of most visited sites changes. 100 // The observer to be notified when the list of most visited sites changes.
96 base::android::ScopedJavaGlobalRef<jobject> observer_; 101 base::android::ScopedJavaGlobalRef<jobject> observer_;
97 102
98 // The maximum number of most visited sites to return. 103 // The maximum number of most visited sites to return.
99 int num_sites_; 104 int num_sites_;
100 105
106 // Whether the sync service is initialized.
107 bool sync_initialized_;
108
101 // Whether the user is in a control group for the purposes of logging. 109 // Whether the user is in a control group for the purposes of logging.
102 bool is_control_group_; 110 bool is_control_group_;
103 111
104 // Counters for UMA metrics. 112 // Counters for UMA metrics.
105 113
106 // Number of tiles using a local thumbnail image for this NTP session. 114 // Number of tiles using a local thumbnail image for this NTP session.
107 int num_local_thumbs_; 115 int num_local_thumbs_;
108 // Number of tiles for which a server thumbnail is provided. 116 // Number of tiles for which a server thumbnail is provided.
109 int num_server_thumbs_; 117 int num_server_thumbs_;
110 // Number of tiles for which no thumbnail is found/specified and a gray tile 118 // Number of tiles for which no thumbnail is found/specified and a gray tile
(...skipping 12 matching lines...) Expand all
123 enum MostVisitedSource { 131 enum MostVisitedSource {
124 TOP_SITES, 132 TOP_SITES,
125 SUGGESTIONS_SERVICE 133 SUGGESTIONS_SERVICE
126 }; 134 };
127 MostVisitedSource mv_source_; 135 MostVisitedSource mv_source_;
128 136
129 DISALLOW_COPY_AND_ASSIGN(MostVisitedSites); 137 DISALLOW_COPY_AND_ASSIGN(MostVisitedSites);
130 }; 138 };
131 139
132 #endif // CHROME_BROWSER_ANDROID_MOST_VISITED_SITES_H_ 140 #endif // CHROME_BROWSER_ANDROID_MOST_VISITED_SITES_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/android/most_visited_sites.cc » ('j') | chrome/browser/android/most_visited_sites.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698