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/engagement/site_engagement_service_android.h" | 5 #include "chrome/browser/engagement/site_engagement_service_android.h" |
6 | 6 |
7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
8 #include "base/android/jni_string.h" | 8 #include "base/android/jni_string.h" |
9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "chrome/browser/engagement/site_engagement_score.h" |
10 #include "chrome/browser/profiles/profile_android.h" | 11 #include "chrome/browser/profiles/profile_android.h" |
11 #include "jni/SiteEngagementService_jni.h" | 12 #include "jni/SiteEngagementService_jni.h" |
12 #include "url/gurl.h" | 13 #include "url/gurl.h" |
13 | 14 |
14 using base::android::JavaParamRef; | 15 using base::android::JavaParamRef; |
15 | 16 |
16 // static | 17 // static |
17 bool SiteEngagementServiceAndroid::Register(JNIEnv* env) { | 18 bool SiteEngagementServiceAndroid::Register(JNIEnv* env) { |
18 return RegisterNativesImpl(env); | 19 return RegisterNativesImpl(env); |
19 } | 20 } |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 JNIEnv* env, | 62 JNIEnv* env, |
62 const JavaParamRef<jobject>& caller, | 63 const JavaParamRef<jobject>& caller, |
63 const JavaParamRef<jstring>& jurl, | 64 const JavaParamRef<jstring>& jurl, |
64 double score) { | 65 double score) { |
65 if (jurl) { | 66 if (jurl) { |
66 service_->ResetBaseScoreForURL( | 67 service_->ResetBaseScoreForURL( |
67 GURL(base::android::ConvertJavaStringToUTF16(env, jurl)), score); | 68 GURL(base::android::ConvertJavaStringToUTF16(env, jurl)), score); |
68 } | 69 } |
69 } | 70 } |
70 | 71 |
| 72 void SetParamValuesForTesting(JNIEnv* env, const JavaParamRef<jclass>& clazz) { |
| 73 SiteEngagementScore::SetParamValuesForTesting(); |
| 74 } |
| 75 |
71 base::android::ScopedJavaLocalRef<jobject> SiteEngagementServiceForProfile( | 76 base::android::ScopedJavaLocalRef<jobject> SiteEngagementServiceForProfile( |
72 JNIEnv* env, | 77 JNIEnv* env, |
73 const JavaParamRef<jclass>& clazz, | 78 const JavaParamRef<jclass>& clazz, |
74 const JavaParamRef<jobject>& jprofile) { | 79 const JavaParamRef<jobject>& jprofile) { |
75 Profile* profile = ProfileAndroid::FromProfileAndroid(jprofile); | 80 Profile* profile = ProfileAndroid::FromProfileAndroid(jprofile); |
76 SiteEngagementService* service = SiteEngagementService::Get(profile); | 81 SiteEngagementService* service = SiteEngagementService::Get(profile); |
77 DCHECK(service); | 82 DCHECK(service); |
78 | 83 |
79 return base::android::ScopedJavaLocalRef<jobject>( | 84 return base::android::ScopedJavaLocalRef<jobject>( |
80 SiteEngagementServiceAndroid::GetOrCreate(env, service)); | 85 SiteEngagementServiceAndroid::GetOrCreate(env, service)); |
81 } | 86 } |
OLD | NEW |