Index: chrome/browser/android/ntp_snippets_bridge.h |
diff --git a/chrome/browser/android/ntp_snippets_bridge.h b/chrome/browser/android/ntp_snippets_bridge.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..915555b39892beb7d3262cc8247793fbf3cbbfd9 |
--- /dev/null |
+++ b/chrome/browser/android/ntp_snippets_bridge.h |
@@ -0,0 +1,46 @@ |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CHROME_BROWSER_ANDROID_NTP_SNIPPETS_BRIDGE_H_ |
+#define CHROME_BROWSER_ANDROID_NTP_SNIPPETS_BRIDGE_H_ |
+ |
+#include <jni.h> |
+ |
+#include "base/android/scoped_java_ref.h" |
+#include "base/scoped_observer.h" |
+#include "components/ntp_snippets/ntp_snippets_service.h" |
+ |
+using ntp_snippets::NTPSnippetsService; |
Marc Treib
2016/02/10 10:44:43
No "using" in headers
May
2016/02/10 18:16:46
Done.
|
+using ntp_snippets::NTPSnippetsServiceObserver; |
+ |
+// The C++ counterpart to NTPSnippetsBridge.java. Enables Java code to access |
+// the list of snippets to show on the NTP |
+class NTPSnippetsBridge : public NTPSnippetsServiceObserver { |
+ public: |
+ explicit NTPSnippetsBridge(jobject j_profile); |
+ void Destroy(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj); |
+ void SetSnippetsObserver( |
+ JNIEnv* env, |
+ const base::android::JavaParamRef<jobject>& obj, |
+ const base::android::JavaParamRef<jobject>& j_observer); |
+ |
+ static bool RegisterNTPSnippetsBridge(JNIEnv* env); |
Marc Treib
2016/02/10 10:44:43
This could just be "Register", since it'll be call
Bernhard Bauer
2016/02/10 10:48:44
Nit: I would even just call it Register() for brev
May
2016/02/10 18:16:47
Done.
May
2016/02/10 18:16:47
Done.
|
+ |
+ private: |
+ ~NTPSnippetsBridge(); |
+ |
+ // NTPSnippetsServiceObserver overrides |
+ void NTPSnippetsServiceLoaded(NTPSnippetsService* service) override; |
+ void NTPSnippetsServiceShutdown(NTPSnippetsService* service) override; |
+ |
+ NTPSnippetsService* ntp_snippets_service_; |
+ |
+ base::android::ScopedJavaGlobalRef<jobject> observer_; |
+ ScopedObserver<NTPSnippetsService, NTPSnippetsServiceObserver> |
+ snippet_service_observer_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(NTPSnippetsBridge); |
+}; |
+ |
+#endif // CHROME_BROWSER_ANDROID_NTP_SNIPPETS_BRIDGE_H_ |