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

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

Issue 527943002: [Most Visited] Check for Sync state when using SuggestionsService. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2125
Patch Set: Created 6 years, 3 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
« no previous file with comments | « no previous file | chrome/browser/android/most_visited_sites.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 enum MostVisitedSource { 128 enum MostVisitedSource {
124 TOP_SITES, 129 TOP_SITES,
125 SUGGESTIONS_SERVICE 130 SUGGESTIONS_SERVICE
126 }; 131 };
127 MostVisitedSource mv_source_; 132 MostVisitedSource mv_source_;
128 133
129 DISALLOW_COPY_AND_ASSIGN(MostVisitedSites); 134 DISALLOW_COPY_AND_ASSIGN(MostVisitedSites);
130 }; 135 };
131 136
132 #endif // CHROME_BROWSER_ANDROID_MOST_VISITED_SITES_H_ 137 #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') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698