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 package org.chromium.chrome.browser.engagement; | 5 package org.chromium.chrome.browser.engagement; |
6 | 6 |
7 import org.chromium.base.ThreadUtils; | 7 import org.chromium.base.ThreadUtils; |
8 import org.chromium.base.annotations.CalledByNative; | 8 import org.chromium.base.annotations.CalledByNative; |
9 | 9 |
10 import org.chromium.chrome.browser.profiles.Profile; | 10 import org.chromium.chrome.browser.profiles.Profile; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 /** | 42 /** |
43 * Sets the provided URL to have the provided engagement score. | 43 * Sets the provided URL to have the provided engagement score. |
44 * Must be called on the UI thread. | 44 * Must be called on the UI thread. |
45 */ | 45 */ |
46 public void resetBaseScoreForUrl(String url, double score) { | 46 public void resetBaseScoreForUrl(String url, double score) { |
47 assert ThreadUtils.runningOnUiThread(); | 47 assert ThreadUtils.runningOnUiThread(); |
48 if (mNativePointer == 0) return; | 48 if (mNativePointer == 0) return; |
49 nativeResetBaseScoreForURL(mNativePointer, url, score); | 49 nativeResetBaseScoreForURL(mNativePointer, url, score); |
50 } | 50 } |
51 | 51 |
| 52 /** |
| 53 * Sets site engagement param values to constants for testing. |
| 54 */ |
| 55 public static void setParamValuesForTesting() { |
| 56 nativeSetParamValuesForTesting(); |
| 57 } |
| 58 |
52 @CalledByNative | 59 @CalledByNative |
53 private static SiteEngagementService create(long nativePointer) { | 60 private static SiteEngagementService create(long nativePointer) { |
54 return new SiteEngagementService(nativePointer); | 61 return new SiteEngagementService(nativePointer); |
55 } | 62 } |
56 | 63 |
57 /** This object may only be created via the static getForProfile method. */ | 64 /** This object may only be created via the static getForProfile method. */ |
58 private SiteEngagementService(long nativePointer) { | 65 private SiteEngagementService(long nativePointer) { |
59 mNativePointer = nativePointer; | 66 mNativePointer = nativePointer; |
60 } | 67 } |
61 | 68 |
62 @CalledByNative | 69 @CalledByNative |
63 private void onNativeDestroyed() { | 70 private void onNativeDestroyed() { |
64 mNativePointer = 0; | 71 mNativePointer = 0; |
65 } | 72 } |
66 | 73 |
67 private static native SiteEngagementService nativeSiteEngagementServiceForPr
ofile( | 74 private static native SiteEngagementService nativeSiteEngagementServiceForPr
ofile( |
68 Profile profile); | 75 Profile profile); |
| 76 private static native void nativeSetParamValuesForTesting(); |
69 private native double nativeGetScore(long nativeSiteEngagementServiceAndroid
, String url); | 77 private native double nativeGetScore(long nativeSiteEngagementServiceAndroid
, String url); |
70 private native void nativeResetBaseScoreForURL( | 78 private native void nativeResetBaseScoreForURL( |
71 long nativeSiteEngagementServiceAndroid, String url, double score); | 79 long nativeSiteEngagementServiceAndroid, String url, double score); |
72 } | 80 } |
OLD | NEW |