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_SNIPPETS_BRIDGE_H_ | 5 #ifndef CHROME_BROWSER_ANDROID_NTP_SNIPPETS_BRIDGE_H_ |
6 #define CHROME_BROWSER_ANDROID_NTP_SNIPPETS_BRIDGE_H_ | 6 #define CHROME_BROWSER_ANDROID_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" |
11 #include "base/scoped_observer.h" | 11 #include "base/scoped_observer.h" |
12 #include "components/ntp_snippets/ntp_snippets_service.h" | 12 #include "components/ntp_snippets/ntp_snippets_service.h" |
13 | 13 |
14 // The C++ counterpart to NTPSnippetsBridge.java. Enables Java code to access | 14 // The C++ counterpart to NTPSnippetsBridge.java. Enables Java code to access |
15 // the list of snippets to show on the NTP | 15 // the list of snippets to show on the NTP |
16 class NTPSnippetsBridge : public ntp_snippets::NTPSnippetsServiceObserver { | 16 class NTPSnippetsBridge : public ntp_snippets::NTPSnippetsServiceObserver { |
17 public: | 17 public: |
18 explicit NTPSnippetsBridge(JNIEnv* env, | 18 explicit NTPSnippetsBridge(JNIEnv* env, jobject j_profile); |
Bernhard Bauer
2016/02/22 14:44:01
Explicit isn't necessary for multi-argument constr
Marc Treib
2016/02/22 17:22:49
Done.
| |
19 jobject j_profile, | |
20 jobject j_observer); | |
21 void Destroy(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj); | 19 void Destroy(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj); |
22 | 20 |
21 void SetObserver(JNIEnv* env, | |
22 const base::android::JavaParamRef<jobject>& obj, | |
23 jobject j_observer); | |
24 | |
23 static bool Register(JNIEnv* env); | 25 static bool Register(JNIEnv* env); |
24 | 26 |
25 private: | 27 private: |
26 ~NTPSnippetsBridge(); | 28 ~NTPSnippetsBridge(); |
27 | 29 |
28 // NTPSnippetsServiceObserver overrides | 30 // NTPSnippetsServiceObserver overrides |
29 void NTPSnippetsServiceLoaded( | 31 void NTPSnippetsServiceLoaded( |
30 ntp_snippets::NTPSnippetsService* service) override; | 32 ntp_snippets::NTPSnippetsService* service) override; |
31 void NTPSnippetsServiceShutdown( | 33 void NTPSnippetsServiceShutdown( |
32 ntp_snippets::NTPSnippetsService* service) override; | 34 ntp_snippets::NTPSnippetsService* service) override; |
33 | 35 |
34 ntp_snippets::NTPSnippetsService* ntp_snippets_service_; | 36 ntp_snippets::NTPSnippetsService* ntp_snippets_service_; |
35 | 37 |
36 base::android::ScopedJavaGlobalRef<jobject> observer_; | 38 base::android::ScopedJavaGlobalRef<jobject> observer_; |
37 ScopedObserver<ntp_snippets::NTPSnippetsService, | 39 ScopedObserver<ntp_snippets::NTPSnippetsService, |
38 ntp_snippets::NTPSnippetsServiceObserver> | 40 ntp_snippets::NTPSnippetsServiceObserver> |
39 snippet_service_observer_; | 41 snippet_service_observer_; |
40 | 42 |
41 DISALLOW_COPY_AND_ASSIGN(NTPSnippetsBridge); | 43 DISALLOW_COPY_AND_ASSIGN(NTPSnippetsBridge); |
42 }; | 44 }; |
43 | 45 |
44 #endif // CHROME_BROWSER_ANDROID_NTP_SNIPPETS_BRIDGE_H_ | 46 #endif // CHROME_BROWSER_ANDROID_NTP_SNIPPETS_BRIDGE_H_ |
OLD | NEW |