Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1695)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/physicalweb/UrlManager.java

Issue 2403423005: Expose Physical Web metadata to native clients over JNI (Closed)
Patch Set: remove unit test Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/android/javatests/src/org/chromium/chrome/browser/physicalweb/UrlManagerTest.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/java/src/org/chromium/chrome/browser/physicalweb/UrlManager.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/physicalweb/UrlManager.java b/chrome/android/java/src/org/chromium/chrome/browser/physicalweb/UrlManager.java
index ed45d91856b7a195f0600ae26afb13bd8f18f466..adf7b4ad76b9f52c647a789857f474980775c0a4 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/physicalweb/UrlManager.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/physicalweb/UrlManager.java
@@ -260,17 +260,23 @@ class UrlManager {
}
/**
- * Gets all UrlInfos and PwsResults for nearby URLs.
- * The UrlInfos and PwsResults are returned as parallel arrays. Unresolved URLs in the UrlInfo
- * array will have a null element in the corresponding entry of the PwsResult array.
- * @return A PwCollection object containg parallel arrays of UrlInfos and PwsResults.
+ * Gets all UrlInfos and PwsResults for URLs that are nearby and resolved.
+ * @param nativePhysicalWebCollection A pointer to the native PhysicalWebCollection container
+ * which will receive the list of nearby URL metadata.
*/
- public PwCollection getPwCollection() {
- List<PwsResult> nearbyPwsResults = new ArrayList<>();
- for (String url : mNearbyUrls) {
- nearbyPwsResults.add(mPwsResultMap.get(url));
+ @CalledByNative
+ public void getPwCollection(long nativePhysicalWebCollection) {
+ List<UrlInfo> nearbyUrlInfos = getUrlInfoList(mNearbyUrls);
+ for (UrlInfo urlInfo : nearbyUrlInfos) {
+ String requestUrl = urlInfo.getUrl();
+ PwsResult pwsResult = mPwsResultMap.get(requestUrl);
+ if (pwsResult != null) {
+ nativeAppendMetadataItem(nativePhysicalWebCollection, requestUrl,
+ urlInfo.getDistance(), (int) urlInfo.getScanTimestamp(), pwsResult.siteUrl,
+ pwsResult.iconUrl, pwsResult.title, pwsResult.description,
+ pwsResult.groupId);
+ }
}
- return new PwCollection(getUrlInfoList(mNearbyUrls), nearbyPwsResults);
}
/**
@@ -714,4 +720,7 @@ class UrlManager {
}
private native long nativeInit();
+ private native void nativeAppendMetadataItem(long nativePhysicalWebCollection,
+ String requestUrl, double distanceEstimate, int scanTimestamp, String siteUrl,
+ String iconUrl, String title, String description, String groupId);
}
« no previous file with comments | « no previous file | chrome/android/javatests/src/org/chromium/chrome/browser/physicalweb/UrlManagerTest.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698