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 3 // found in the LICENSE file. 4 5 #ifndef CHROME_BROWSER_ANDROID_MOST_VISITED_SITES_H_ 6 #define CHROME_BROWSER_ANDROID_MOST_VISITED_SITES_H_ 7 8 #include <jni.h> 9 10 #include "base/android/scoped_java_ref.h" 11 #include "base/compiler_specific.h" 12 #include "chrome/browser/profiles/profile.h" 13 #include "content/public/browser/notification_observer.h" 14 #include "content/public/browser/notification_registrar.h" 15 16 // Provides the list of most visited sites and their thumbnails to Java. 17 class MostVisitedSites : public content::NotificationObserver { 18 public: 19 explicit MostVisitedSites(Profile* profile); 20 void Destroy(JNIEnv* env, jobject obj); 21 void SetMostVisitedURLsObserver(JNIEnv* env, 22 jobject obj, 23 jobject j_observer, 24 jint num_sites); 25 void GetURLThumbnail(JNIEnv* env, 26 jobject obj, 27 jstring url, 28 jobject j_callback); 29 void BlacklistUrl(JNIEnv* env, jobject obj, jstring j_url); 30 31 // content::NotificationObserver implementation. 32 virtual void Observe(int type, 33 const content::NotificationSource& source, 34 const content::NotificationDetails& details) OVERRIDE; 35 36 // Registers JNI methods. 37 static bool Register(JNIEnv* env); 38 39 private: 40 virtual ~MostVisitedSites(); 41 void QueryMostVisitedURLs(); 42 43 // The profile whose most visited sites will be queried. 44 Profile* profile_; 45 46 // The observer to be notified when the list of most visited sites changes. 47 base::android::ScopedJavaGlobalRef<jobject> observer_; 48 49 // The maximum number of most visited sites to return. 50 int num_sites_; 51 52 content::NotificationRegistrar registrar_; 53 54 DISALLOW_COPY_AND_ASSIGN(MostVisitedSites); 55 }; 56 57 #endif // CHROME_BROWSER_ANDROID_MOST_VISITED_SITES_H_ 58