| 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 #ifndef CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_SERVICE_ANDROID_H_ |
| 6 #define CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_SERVICE_ANDROID_H_ |
| 7 |
| 8 #include <jni.h> |
| 9 |
| 10 #include "base/android/scoped_java_ref.h" |
| 11 #include "base/macros.h" |
| 12 #include "chrome/browser/engagement/site_engagement_service.h" |
| 13 |
| 14 // Wrapper class to expose the Site Engagement Service to Java. This object is |
| 15 // owned by the |service_| which it wraps, and is lazily created when |
| 16 // a Java-side SiteEngagementService is constructed. Once created, all future |
| 17 // Java-side requests for a SiteEngagementService will use the same native |
| 18 // object. |
| 19 // |
| 20 // This class may only be used on the UI thread. |
| 21 class SiteEngagementServiceAndroid { |
| 22 public: |
| 23 static bool Register(JNIEnv* env); |
| 24 |
| 25 // Returns the Java-side SiteEngagementService object corresponding to |
| 26 // |service|. |
| 27 static const base::android::ScopedJavaGlobalRef<jobject>& GetOrCreate( |
| 28 JNIEnv* env, |
| 29 SiteEngagementService* service); |
| 30 |
| 31 SiteEngagementServiceAndroid(JNIEnv* env, SiteEngagementService* service); |
| 32 |
| 33 ~SiteEngagementServiceAndroid(); |
| 34 |
| 35 double GetScore(JNIEnv* env, |
| 36 const base::android::JavaParamRef<jobject>& caller, |
| 37 const base::android::JavaParamRef<jstring>& jurl) const; |
| 38 |
| 39 void ResetScoreForURL(JNIEnv* env, |
| 40 const base::android::JavaParamRef<jobject>& caller, |
| 41 const base::android::JavaParamRef<jstring>& jurl, |
| 42 double score); |
| 43 |
| 44 private: |
| 45 base::android::ScopedJavaGlobalRef<jobject> java_service_; |
| 46 SiteEngagementService* service_; |
| 47 |
| 48 DISALLOW_COPY_AND_ASSIGN(SiteEngagementServiceAndroid); |
| 49 }; |
| 50 |
| 51 #endif // CHROME_BROWSER_ENGAGEMENT_SITE_ENGAGEMENT_SERVICE_ANDROID_H_ |
| OLD | NEW |