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 13 matching lines...) Expand all Loading... |
24 // The C++ counterpart to SnippetsBridge.java. Enables Java code to access | 24 // The C++ counterpart to SnippetsBridge.java. Enables Java code to access |
25 // the list of snippets to show on the NTP. | 25 // the list of snippets to show on the NTP. |
26 // | 26 // |
27 // This bridge is instantiated, owned, and destroyed from Java. There is one | 27 // This bridge is instantiated, owned, and destroyed from Java. There is one |
28 // instance for each NTP, and it is destroyed when the NTP is destroyed e.g. | 28 // instance for each NTP, and it is destroyed when the NTP is destroyed e.g. |
29 // when the user navigates away from it. | 29 // when the user navigates away from it. |
30 class NTPSnippetsBridge | 30 class NTPSnippetsBridge |
31 : public ntp_snippets::ContentSuggestionsService::Observer { | 31 : public ntp_snippets::ContentSuggestionsService::Observer { |
32 public: | 32 public: |
33 NTPSnippetsBridge(JNIEnv* env, | 33 NTPSnippetsBridge(JNIEnv* env, |
| 34 const base::android::JavaParamRef<jobject>& j_bridge, |
34 const base::android::JavaParamRef<jobject>& j_profile); | 35 const base::android::JavaParamRef<jobject>& j_profile); |
35 void Destroy(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj); | 36 void Destroy(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj); |
36 | 37 |
37 void SetObserver(JNIEnv* env, | |
38 const base::android::JavaParamRef<jobject>& obj, | |
39 const base::android::JavaParamRef<jobject>& j_observer); | |
40 | |
41 base::android::ScopedJavaLocalRef<jintArray> GetCategories( | 38 base::android::ScopedJavaLocalRef<jintArray> GetCategories( |
42 JNIEnv* env, | 39 JNIEnv* env, |
43 const base::android::JavaParamRef<jobject>& obj); | 40 const base::android::JavaParamRef<jobject>& obj); |
44 | 41 |
45 int GetCategoryStatus(JNIEnv* env, | 42 int GetCategoryStatus(JNIEnv* env, |
46 const base::android::JavaParamRef<jobject>& obj, | 43 const base::android::JavaParamRef<jobject>& obj, |
47 jint j_category_id); | 44 jint j_category_id); |
48 | 45 |
49 base::android::ScopedJavaLocalRef<jobject> GetCategoryInfo( | 46 base::android::ScopedJavaLocalRef<jobject> GetCategoryInfo( |
50 JNIEnv* env, | 47 JNIEnv* env, |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 std::vector<ntp_snippets::ContentSuggestion> suggestions); | 154 std::vector<ntp_snippets::ContentSuggestion> suggestions); |
158 | 155 |
159 ntp_snippets::ContentSuggestionsService* content_suggestions_service_; | 156 ntp_snippets::ContentSuggestionsService* content_suggestions_service_; |
160 history::HistoryService* history_service_; | 157 history::HistoryService* history_service_; |
161 base::CancelableTaskTracker tracker_; | 158 base::CancelableTaskTracker tracker_; |
162 | 159 |
163 ScopedObserver<ntp_snippets::ContentSuggestionsService, | 160 ScopedObserver<ntp_snippets::ContentSuggestionsService, |
164 ntp_snippets::ContentSuggestionsService::Observer> | 161 ntp_snippets::ContentSuggestionsService::Observer> |
165 content_suggestions_service_observer_; | 162 content_suggestions_service_observer_; |
166 | 163 |
167 // Used to notify the Java side when new snippets have been fetched. | 164 // The Java SnippetsBridge. |
168 base::android::ScopedJavaGlobalRef<jobject> observer_; | 165 base::android::ScopedJavaGlobalRef<jobject> bridge_; |
169 | 166 |
170 base::WeakPtrFactory<NTPSnippetsBridge> weak_ptr_factory_; | 167 base::WeakPtrFactory<NTPSnippetsBridge> weak_ptr_factory_; |
171 | 168 |
172 DISALLOW_COPY_AND_ASSIGN(NTPSnippetsBridge); | 169 DISALLOW_COPY_AND_ASSIGN(NTPSnippetsBridge); |
173 }; | 170 }; |
174 | 171 |
175 #endif // CHROME_BROWSER_ANDROID_NTP_NTP_SNIPPETS_BRIDGE_H_ | 172 #endif // CHROME_BROWSER_ANDROID_NTP_NTP_SNIPPETS_BRIDGE_H_ |
OLD | NEW |