OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "chrome/browser/android/ntp_snippets_controller.h" | |
6 | |
7 #include <jni.h> | |
8 | |
9 #include "base/android/jni_android.h" | |
10 #include "base/android/scoped_java_ref.h" | |
11 #include "chrome/browser/ntp_snippets/ntp_snippets_service_factory.h" | |
12 #include "chrome/browser/profiles/profile.h" | |
13 #include "chrome/browser/profiles/profile_android.h" | |
14 #include "components/ntp_snippets/ntp_snippets_service.h" | |
15 #include "jni/SnippetsController_jni.h" | |
16 | |
17 static jlong Init(JNIEnv* env, const JavaParamRef<jobject>& obj) { | |
Marc Treib
2016/02/10 10:44:43
Put the functions in an anonymous namespace instea
Bernhard Bauer
2016/02/10 10:48:44
You don't need Init() or Destroy() anymore either
Bernhard Bauer
2016/02/10 10:51:42
That does not work for JNI bridge methods (because
Marc Treib
2016/02/10 10:58:09
Today I learned! Alright, carry on then :)
May
2016/02/10 18:16:47
Done.
| |
18 NTPSnippetsController* snippets_bridge = new NTPSnippetsController(); | |
19 return reinterpret_cast<intptr_t>(snippets_bridge); | |
20 } | |
21 | |
22 static void FetchSnippets(JNIEnv* env, | |
23 const JavaParamRef<jobject>& obj, | |
24 const JavaParamRef<jobject>& jprofile, | |
25 jboolean overwrite) { | |
26 Profile* profile = ProfileAndroid::FromProfileAndroid(jprofile); | |
27 if (profile) { | |
28 ntp_snippets::NTPSnippetsService* ntp_snippets_service = | |
29 NTPSnippetsServiceFactory::GetForProfile(profile); | |
30 ntp_snippets_service->FetchSnippets(overwrite); | |
31 } | |
32 } | |
33 | |
34 NTPSnippetsController::NTPSnippetsController() {} | |
35 | |
36 void NTPSnippetsController::Destroy(JNIEnv* env, | |
37 const JavaParamRef<jobject>& obj) { | |
38 delete this; | |
39 } | |
40 | |
41 // static | |
42 bool NTPSnippetsController::RegisterNTPSnippetsController(JNIEnv* env) { | |
43 return RegisterNativesImpl(env); | |
44 } | |
OLD | NEW |