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

Side by Side Diff: chrome/browser/android/ntp/ntp_snippets_bridge.h

Issue 2230473002: Refactor and extend SnippetsBridge for multi-section support (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@categoryinfo
Patch Set: Michael's nits and renamings Created 4 years, 4 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
OLDNEW
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
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 GetURLVisited(JNIEnv* env,
67 const base::android::JavaParamRef<jobject>& obj,
68 const base::android::JavaParamRef<jobject>& callback,
69 const base::android::JavaParamRef<jstring>& jurl);
70
58 static bool Register(JNIEnv* env); 71 static bool Register(JNIEnv* env);
59 72
60 private: 73 private:
61 ~NTPSnippetsBridge() override; 74 ~NTPSnippetsBridge() override;
62 75
63 // ContentSuggestionsService::Observer overrides 76 // ContentSuggestionsService::Observer overrides
64 void OnNewSuggestions() override; 77 void OnNewSuggestions(ntp_snippets::Category category) override;
65 void OnCategoryStatusChanged( 78 void OnCategoryStatusChanged(
66 ntp_snippets::Category category, 79 ntp_snippets::Category category,
67 ntp_snippets::CategoryStatus new_status) override; 80 ntp_snippets::CategoryStatus new_status) override;
68 void ContentSuggestionsServiceShutdown() override; 81 void ContentSuggestionsServiceShutdown() override;
69 82
70 void OnImageFetched(base::android::ScopedJavaGlobalRef<jobject> callback, 83 void OnImageFetched(base::android::ScopedJavaGlobalRef<jobject> callback,
71 const std::string& snippet_id, 84 const std::string& snippet_id,
72 const gfx::Image& image); 85 const gfx::Image& image);
73 86
74 ntp_snippets::ContentSuggestionsService* content_suggestions_service_; 87 ntp_snippets::ContentSuggestionsService* content_suggestions_service_;
75 history::HistoryService* history_service_; 88 history::HistoryService* history_service_;
76 base::CancelableTaskTracker tracker_; 89 base::CancelableTaskTracker tracker_;
77 90
78 ScopedObserver<ntp_snippets::ContentSuggestionsService, 91 ScopedObserver<ntp_snippets::ContentSuggestionsService,
79 ntp_snippets::ContentSuggestionsService::Observer> 92 ntp_snippets::ContentSuggestionsService::Observer>
80 content_suggestions_service_observer_; 93 content_suggestions_service_observer_;
81 94
82 // Used to notify the Java side when new snippets have been fetched. 95 // Used to notify the Java side when new snippets have been fetched.
83 base::android::ScopedJavaGlobalRef<jobject> observer_; 96 base::android::ScopedJavaGlobalRef<jobject> observer_;
84 97
85 base::WeakPtrFactory<NTPSnippetsBridge> weak_ptr_factory_; 98 base::WeakPtrFactory<NTPSnippetsBridge> weak_ptr_factory_;
86 99
87 DISALLOW_COPY_AND_ASSIGN(NTPSnippetsBridge); 100 DISALLOW_COPY_AND_ASSIGN(NTPSnippetsBridge);
88 }; 101 };
89 102
90 #endif // CHROME_BROWSER_ANDROID_NTP_NTP_SNIPPETS_BRIDGE_H_ 103 #endif // CHROME_BROWSER_ANDROID_NTP_NTP_SNIPPETS_BRIDGE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698