| 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 #include "chrome/browser/android/ntp/ntp_snippets_bridge.h" | 5 #include "chrome/browser/android/ntp/ntp_snippets_bridge.h" |
| 6 | 6 |
| 7 #include <jni.h> | 7 #include <jni.h> |
| 8 | 8 |
| 9 #include "base/android/callback_android.h" | 9 #include "base/android/callback_android.h" |
| 10 #include "base/android/jni_android.h" | 10 #include "base/android/jni_android.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 } // namespace | 46 } // namespace |
| 47 | 47 |
| 48 static jlong Init(JNIEnv* env, | 48 static jlong Init(JNIEnv* env, |
| 49 const JavaParamRef<jobject>& obj, | 49 const JavaParamRef<jobject>& obj, |
| 50 const JavaParamRef<jobject>& j_profile) { | 50 const JavaParamRef<jobject>& j_profile) { |
| 51 NTPSnippetsBridge* snippets_bridge = new NTPSnippetsBridge(env, j_profile); | 51 NTPSnippetsBridge* snippets_bridge = new NTPSnippetsBridge(env, j_profile); |
| 52 return reinterpret_cast<intptr_t>(snippets_bridge); | 52 return reinterpret_cast<intptr_t>(snippets_bridge); |
| 53 } | 53 } |
| 54 | 54 |
| 55 static void FetchSnippets(JNIEnv* env, | 55 static void FetchSnippets(JNIEnv* env, |
| 56 const JavaParamRef<jclass>& caller) { | 56 const JavaParamRef<jclass>& caller, |
| 57 jboolean j_force_request) { |
| 57 Profile* profile = ProfileManager::GetLastUsedProfile(); | 58 Profile* profile = ProfileManager::GetLastUsedProfile(); |
| 58 NTPSnippetsServiceFactory::GetForProfile(profile)->FetchSnippets(); | 59 NTPSnippetsServiceFactory::GetForProfile(profile)->FetchSnippets( |
| 60 j_force_request); |
| 59 } | 61 } |
| 60 | 62 |
| 61 // Reschedules the fetching of snippets. Used to support different fetching | 63 // Reschedules the fetching of snippets. Used to support different fetching |
| 62 // intervals for different times of day. | 64 // intervals for different times of day. |
| 63 static void RescheduleFetching(JNIEnv* env, | 65 static void RescheduleFetching(JNIEnv* env, |
| 64 const JavaParamRef<jclass>& caller) { | 66 const JavaParamRef<jclass>& caller) { |
| 65 Profile* profile = ProfileManager::GetLastUsedProfile(); | 67 Profile* profile = ProfileManager::GetLastUsedProfile(); |
| 66 NTPSnippetsServiceFactory::GetForProfile(profile)->RescheduleFetching(); | 68 NTPSnippetsServiceFactory::GetForProfile(profile)->RescheduleFetching(); |
| 67 } | 69 } |
| 68 | 70 |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 if (!image.IsEmpty()) | 193 if (!image.IsEmpty()) |
| 192 j_bitmap = gfx::ConvertToJavaBitmap(image.ToSkBitmap()); | 194 j_bitmap = gfx::ConvertToJavaBitmap(image.ToSkBitmap()); |
| 193 | 195 |
| 194 base::android::RunCallbackAndroid(callback, j_bitmap); | 196 base::android::RunCallbackAndroid(callback, j_bitmap); |
| 195 } | 197 } |
| 196 | 198 |
| 197 // static | 199 // static |
| 198 bool NTPSnippetsBridge::Register(JNIEnv* env) { | 200 bool NTPSnippetsBridge::Register(JNIEnv* env) { |
| 199 return RegisterNativesImpl(env); | 201 return RegisterNativesImpl(env); |
| 200 } | 202 } |
| OLD | NEW |