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 "jni/SnippetsController_jni.h" | |
15 | |
16 namespace ntp_snippets { | |
17 static jlong Init(JNIEnv* env, | |
18 const JavaParamRef<jobject>& obj, | |
19 const JavaParamRef<jobject>& j_profile) { | |
20 NTPSnippetsController* snippets_bridge = new NTPSnippetsController(j_profile); | |
21 return reinterpret_cast<intptr_t>(snippets_bridge); | |
22 } | |
23 | |
24 NTPSnippetsController::NTPSnippetsController(jobject j_profile) { | |
25 Profile* profile = ProfileAndroid::FromProfileAndroid(j_profile); | |
26 if (profile) { | |
Bernhard Bauer
2016/02/08 18:19:26
Nit: no braces.
May
2016/02/09 17:38:53
Done.
| |
27 ntp_snippets_service_ = NTPSnippetsServiceFactory::GetForProfile(profile); | |
28 } | |
29 } | |
30 | |
31 void NTPSnippetsController::Destroy(JNIEnv* env, | |
32 const JavaParamRef<jobject>& obj) { | |
33 delete this; | |
34 } | |
35 | |
36 void NTPSnippetsController::FetchSnippets(JNIEnv* env, | |
Bernhard Bauer
2016/02/08 18:19:26
You could make this a static method that just take
May
2016/02/09 17:38:53
Made it static. Later (depending on how we impleme
| |
37 const JavaParamRef<jobject>& obj, | |
38 jboolean overwrite) { | |
39 ntp_snippets_service_->FetchSnippets(overwrite); | |
40 } | |
41 | |
42 // static | |
43 bool RegisterNTPSnippetsController(JNIEnv* env) { | |
44 return RegisterNativesImpl(env); | |
45 } | |
46 } // namespace ntp_snippets | |
OLD | NEW |