| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_NTP_MOST_VISITED_SITES_BRIDGE_H_ | 5 #ifndef CHROME_BROWSER_ANDROID_NTP_MOST_VISITED_SITES_BRIDGE_H_ |
| 6 #define CHROME_BROWSER_ANDROID_NTP_MOST_VISITED_SITES_BRIDGE_H_ | 6 #define CHROME_BROWSER_ANDROID_NTP_MOST_VISITED_SITES_BRIDGE_H_ |
| 7 | 7 |
| 8 #include <jni.h> | 8 #include <jni.h> |
| 9 #include <stddef.h> | 9 #include <stddef.h> |
| 10 | 10 |
| 11 #include <memory> | 11 #include <memory> |
| 12 #include <string> | 12 #include <string> |
| 13 #include <vector> | 13 #include <vector> |
| 14 | 14 |
| 15 #include "base/android/scoped_java_ref.h" | 15 #include "base/android/scoped_java_ref.h" |
| 16 #include "base/macros.h" | 16 #include "base/macros.h" |
| 17 #include "chrome/browser/android/ntp/most_visited_sites.h" | 17 #include "chrome/browser/android/ntp/most_visited_sites.h" |
| 18 #include "chrome/browser/supervised_user/supervised_user_service.h" |
| 19 #include "chrome/browser/supervised_user/supervised_user_service_observer.h" |
| 18 | 20 |
| 19 class Profile; | 21 class Profile; |
| 20 | 22 |
| 21 // Provides the list of most visited sites and their thumbnails to Java. | 23 // Provides the list of most visited sites and their thumbnails to Java. |
| 22 class MostVisitedSitesBridge { | 24 class MostVisitedSitesBridge { |
| 23 public: | 25 public: |
| 24 explicit MostVisitedSitesBridge(Profile* profile); | 26 explicit MostVisitedSitesBridge(Profile* profile); |
| 25 | 27 |
| 26 void Destroy(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj); | 28 void Destroy(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj); |
| 27 | 29 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 50 const base::android::JavaParamRef<jobject>& obj, | 52 const base::android::JavaParamRef<jobject>& obj, |
| 51 jint index, | 53 jint index, |
| 52 jint tile_type); | 54 jint tile_type); |
| 53 | 55 |
| 54 // Registers JNI methods. | 56 // Registers JNI methods. |
| 55 static bool Register(JNIEnv* env); | 57 static bool Register(JNIEnv* env); |
| 56 | 58 |
| 57 private: | 59 private: |
| 58 ~MostVisitedSitesBridge(); | 60 ~MostVisitedSitesBridge(); |
| 59 | 61 |
| 60 class Observer; | 62 class JavaObserver; |
| 61 std::unique_ptr<Observer> observer_; | 63 std::unique_ptr<JavaObserver> java_observer_; |
| 64 |
| 65 class SupervisorBridge : public MostVisitedSitesSupervisor, |
| 66 public SupervisedUserServiceObserver { |
| 67 public: |
| 68 explicit SupervisorBridge(Profile* profile); |
| 69 ~SupervisorBridge() override; |
| 70 |
| 71 void SetObserver(Observer* observer) override; |
| 72 bool IsBlocked(const GURL& url) override; |
| 73 std::vector<MostVisitedSitesSupervisor::Whitelist> whitelists() override; |
| 74 bool IsChildProfile() override; |
| 75 |
| 76 // SupervisedUserServiceObserver implementation. |
| 77 void OnURLFilterChanged() override; |
| 78 |
| 79 private: |
| 80 Profile* const profile_; |
| 81 Observer* supervisor_observer_; |
| 82 ScopedObserver<SupervisedUserService, SupervisedUserServiceObserver> |
| 83 register_observer_; |
| 84 }; |
| 85 SupervisorBridge supervisor_; |
| 62 | 86 |
| 63 MostVisitedSites most_visited_; | 87 MostVisitedSites most_visited_; |
| 64 | 88 |
| 65 DISALLOW_COPY_AND_ASSIGN(MostVisitedSitesBridge); | 89 DISALLOW_COPY_AND_ASSIGN(MostVisitedSitesBridge); |
| 66 }; | 90 }; |
| 67 | 91 |
| 68 #endif // CHROME_BROWSER_ANDROID_NTP_MOST_VISITED_SITES_BRIDGE_H_ | 92 #endif // CHROME_BROWSER_ANDROID_NTP_MOST_VISITED_SITES_BRIDGE_H_ |
| OLD | NEW |