Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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.ntp; | 5 package org.chromium.chrome.browser.ntp; |
| 6 | 6 |
| 7 import org.chromium.base.annotations.CalledByNative; | 7 import org.chromium.base.annotations.CalledByNative; |
| 8 import org.chromium.chrome.browser.profiles.Profile; | 8 import org.chromium.chrome.browser.profiles.Profile; |
| 9 | 9 |
| 10 /** | 10 /** |
| 11 * Retrieve the user's interests. | 11 * Retrieve the user's interests. |
| 12 */ | 12 */ |
| 13 public class InterestsService { | 13 public class InterestsService { |
| 14 | |
| 14 private long mNativeInterestsService; | 15 private long mNativeInterestsService; |
| 15 | 16 |
| 16 /** | 17 /** |
| 17 * A user's interest. | 18 * A user's interest. |
| 18 */ | 19 */ |
| 19 public static class Interest { | 20 public static class Interest { |
| 20 private final String mName; | 21 private final String mName; |
| 21 private final String mImageUrl; | 22 private final String mImageUrl; |
| 22 private final double mRelevance; | 23 private final double mRelevance; |
| 23 | 24 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 64 /** | 65 /** |
| 65 * Cleans up the C++ side of this class. This instance must not be used afte r calling destroy(). | 66 * Cleans up the C++ side of this class. This instance must not be used afte r calling destroy(). |
| 66 */ | 67 */ |
| 67 public void destroy() { | 68 public void destroy() { |
| 68 assert mNativeInterestsService != 0; | 69 assert mNativeInterestsService != 0; |
| 69 nativeDestroy(mNativeInterestsService); | 70 nativeDestroy(mNativeInterestsService); |
| 70 mNativeInterestsService = 0; | 71 mNativeInterestsService = 0; |
| 71 } | 72 } |
| 72 | 73 |
| 73 public void getInterests(final GetInterestsCallback callback) { | 74 public void getInterests(final GetInterestsCallback callback) { |
| 74 GetInterestsCallback wrappedCallback = new GetInterestsCallback() { | 75 GetInterestsCallback wrappedCallback = new GetInterestsCallback() { |
|
knn
2015/12/02 13:30:43
This doesn't seem to do anything. Moreover since t
PEConn
2015/12/08 17:27:50
Done.
| |
| 75 @Override | 76 @Override |
| 76 public void onInterestsAvailableCallback(Interest[] interests) { | 77 public void onInterestsAvailableCallback(Interest[] interests) { |
| 77 callback.onInterestsAvailableCallback(interests); | 78 callback.onInterestsAvailableCallback(interests); |
| 78 } | 79 } |
| 79 }; | 80 }; |
| 80 | 81 |
| 81 nativeGetInterests(mNativeInterestsService, wrappedCallback); | 82 nativeGetInterests(mNativeInterestsService, wrappedCallback); |
| 82 } | 83 } |
| 83 | 84 |
| 84 /* | 85 /* |
| 85 * Helper methods for the native part. | 86 * Helper methods for the native part. |
| 86 */ | 87 */ |
| 87 @CalledByNative | 88 @CalledByNative |
| 88 private static Interest createInterest(String name, String imageUrl, double relevance) { | 89 private static Interest createInterest(String name, String imageUrl, double relevance) { |
| 89 return new Interest(name, imageUrl, relevance); | 90 return new Interest(name, imageUrl, relevance); |
| 90 } | 91 } |
| 91 | 92 |
| 92 @CalledByNative | 93 @CalledByNative |
| 93 private static Interest[] createInterestsArray(int size) { | 94 private static Interest[] createInterestsArray(int size) { |
| 94 return new Interest[size]; | 95 return new Interest[size]; |
| 95 } | 96 } |
| 96 | 97 |
| 97 private native long nativeInit(Profile profile); | 98 private native long nativeInit(Profile profile); |
| 98 private native void nativeDestroy(long nativeInterestsService); | 99 private native void nativeDestroy(long nativeInterestsService); |
| 99 private native void nativeGetInterests( | 100 private native void nativeGetInterests( |
| 100 long nativeInterestsService, GetInterestsCallback callback); | 101 long nativeInterestsService, GetInterestsCallback callback); |
| 101 } | 102 } |
| OLD | NEW |