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_NTP_SNIPPETS_BRIDGE_H_ | 5 #ifndef CHROME_BROWSER_ANDROID_NTP_NTP_SNIPPETS_BRIDGE_H_ |
6 #define CHROME_BROWSER_ANDROID_NTP_NTP_SNIPPETS_BRIDGE_H_ | 6 #define CHROME_BROWSER_ANDROID_NTP_NTP_SNIPPETS_BRIDGE_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" |
(...skipping 15 matching lines...) Expand all Loading... |
26 : public ntp_snippets::ContentSuggestionsService::Observer { | 26 : public ntp_snippets::ContentSuggestionsService::Observer { |
27 public: | 27 public: |
28 NTPSnippetsBridge(JNIEnv* env, | 28 NTPSnippetsBridge(JNIEnv* env, |
29 const base::android::JavaParamRef<jobject>& j_profile); | 29 const base::android::JavaParamRef<jobject>& j_profile); |
30 void Destroy(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj); | 30 void Destroy(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj); |
31 | 31 |
32 void SetObserver(JNIEnv* env, | 32 void SetObserver(JNIEnv* env, |
33 const base::android::JavaParamRef<jobject>& obj, | 33 const base::android::JavaParamRef<jobject>& obj, |
34 const base::android::JavaParamRef<jobject>& j_observer); | 34 const base::android::JavaParamRef<jobject>& j_observer); |
35 | 35 |
36 void FetchImage(JNIEnv* env, | 36 base::android::ScopedJavaLocalRef<jintArray> GetCategories( |
37 const base::android::JavaParamRef<jobject>& obj, | 37 JNIEnv* env, |
38 const base::android::JavaParamRef<jstring>& snippet_id, | 38 const base::android::JavaParamRef<jobject>& obj); |
39 const base::android::JavaParamRef<jobject>& j_callback); | |
40 | 39 |
41 // Discards the snippet with the given ID. | |
42 void DiscardSnippet(JNIEnv* env, | |
43 const base::android::JavaParamRef<jobject>& obj, | |
44 const base::android::JavaParamRef<jstring>& snippet_id); | |
45 | |
46 // Checks if the URL has been visited. | |
47 void SnippetVisited(JNIEnv* env, | |
48 const base::android::JavaParamRef<jobject>& obj, | |
49 const base::android::JavaParamRef<jobject>& callback, | |
50 const base::android::JavaParamRef<jstring>& jurl); | |
51 | |
52 // Returns the status of |category|. | |
53 // See CategoryStatus for more info. | |
54 int GetCategoryStatus(JNIEnv* env, | 40 int GetCategoryStatus(JNIEnv* env, |
55 const base::android::JavaParamRef<jobject>& obj, | 41 const base::android::JavaParamRef<jobject>& obj, |
56 jint category); | 42 jint category); |
57 | 43 |
| 44 base::android::ScopedJavaLocalRef<jobject> GetCategoryInfo( |
| 45 JNIEnv* env, |
| 46 const base::android::JavaParamRef<jobject>& obj, |
| 47 jint category); |
| 48 |
| 49 base::android::ScopedJavaLocalRef<jobject> GetSuggestionsForCategory( |
| 50 JNIEnv* env, |
| 51 const base::android::JavaParamRef<jobject>& obj, |
| 52 jint category); |
| 53 |
| 54 void FetchSuggestionImage( |
| 55 JNIEnv* env, |
| 56 const base::android::JavaParamRef<jobject>& obj, |
| 57 const base::android::JavaParamRef<jstring>& suggestion_id, |
| 58 const base::android::JavaParamRef<jobject>& j_callback); |
| 59 |
| 60 void DismissSuggestion( |
| 61 JNIEnv* env, |
| 62 const base::android::JavaParamRef<jobject>& obj, |
| 63 const base::android::JavaParamRef<jstring>& suggestion_id); |
| 64 |
| 65 // Checks if the URL has been visited. |
| 66 void GetSuggestionVisited( |
| 67 JNIEnv* env, |
| 68 const base::android::JavaParamRef<jobject>& obj, |
| 69 const base::android::JavaParamRef<jobject>& callback, |
| 70 const base::android::JavaParamRef<jstring>& jurl); |
| 71 |
58 static bool Register(JNIEnv* env); | 72 static bool Register(JNIEnv* env); |
59 | 73 |
60 private: | 74 private: |
61 ~NTPSnippetsBridge() override; | 75 ~NTPSnippetsBridge() override; |
62 | 76 |
63 // ContentSuggestionsService::Observer overrides | 77 // ContentSuggestionsService::Observer overrides |
64 void OnNewSuggestions() override; | 78 void OnNewSuggestions(ntp_snippets::Category category) override; |
65 void OnCategoryStatusChanged( | 79 void OnCategoryStatusChanged( |
66 ntp_snippets::Category category, | 80 ntp_snippets::Category category, |
67 ntp_snippets::CategoryStatus new_status) override; | 81 ntp_snippets::CategoryStatus new_status) override; |
68 void ContentSuggestionsServiceShutdown() override; | 82 void ContentSuggestionsServiceShutdown() override; |
69 | 83 |
70 void OnImageFetched(base::android::ScopedJavaGlobalRef<jobject> callback, | 84 void OnImageFetched(base::android::ScopedJavaGlobalRef<jobject> callback, |
71 const std::string& snippet_id, | 85 const std::string& snippet_id, |
72 const gfx::Image& image); | 86 const gfx::Image& image); |
73 | 87 |
74 ntp_snippets::ContentSuggestionsService* content_suggestions_service_; | 88 ntp_snippets::ContentSuggestionsService* content_suggestions_service_; |
75 history::HistoryService* history_service_; | 89 history::HistoryService* history_service_; |
76 base::CancelableTaskTracker tracker_; | 90 base::CancelableTaskTracker tracker_; |
77 | 91 |
78 ScopedObserver<ntp_snippets::ContentSuggestionsService, | 92 ScopedObserver<ntp_snippets::ContentSuggestionsService, |
79 ntp_snippets::ContentSuggestionsService::Observer> | 93 ntp_snippets::ContentSuggestionsService::Observer> |
80 content_suggestions_service_observer_; | 94 content_suggestions_service_observer_; |
81 | 95 |
82 // Used to notify the Java side when new snippets have been fetched. | 96 // Used to notify the Java side when new snippets have been fetched. |
83 base::android::ScopedJavaGlobalRef<jobject> observer_; | 97 base::android::ScopedJavaGlobalRef<jobject> observer_; |
84 | 98 |
85 base::WeakPtrFactory<NTPSnippetsBridge> weak_ptr_factory_; | 99 base::WeakPtrFactory<NTPSnippetsBridge> weak_ptr_factory_; |
86 | 100 |
87 DISALLOW_COPY_AND_ASSIGN(NTPSnippetsBridge); | 101 DISALLOW_COPY_AND_ASSIGN(NTPSnippetsBridge); |
88 }; | 102 }; |
89 | 103 |
90 #endif // CHROME_BROWSER_ANDROID_NTP_NTP_SNIPPETS_BRIDGE_H_ | 104 #endif // CHROME_BROWSER_ANDROID_NTP_NTP_SNIPPETS_BRIDGE_H_ |
OLD | NEW |