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

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

Issue 2201183002: Add a group id to PwsResult (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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
Index: chrome/android/java/src/org/chromium/chrome/browser/physicalweb/PwsResult.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/physicalweb/PwsResult.java b/chrome/android/java/src/org/chromium/chrome/browser/physicalweb/PwsResult.java
index 4ecf2f429af4f309aa7adeea1fca6ed7716b4f51..87d7fc583af152a7b4a51bf20d033cb9b9200b91 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/physicalweb/PwsResult.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/physicalweb/PwsResult.java
@@ -3,6 +3,11 @@
// found in the LICENSE file.
package org.chromium.chrome.browser.physicalweb;
+import org.chromium.base.Log;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
/**
* A result from the Physical Web Server.
*
@@ -11,6 +16,8 @@ package org.chromium.chrome.browser.physicalweb;
* URLs.
*/
class PwsResult {
+ private static final String TAG = "PhysicalWeb";
+
/**
* The URL that was set in the request to the PWS.
*/
@@ -37,14 +44,32 @@ class PwsResult {
public final String description;
/**
+ * The group id as determined by the PWS.
+ * This value is useful for associating multiple URLs that refer to similar content in the same
+ * bucket.
+ */
+ public final String groupId;
+
+ /**
* Construct a PwsResult.
- * @param requestUrl The URL that was sent in the request to the PWS.
*/
- PwsResult(String requestUrl, String siteUrl, String iconUrl, String title, String description) {
+ PwsResult(String requestUrl, String siteUrl, String iconUrl, String title, String description,
+ String groupId) {
this.requestUrl = requestUrl;
this.siteUrl = siteUrl;
this.iconUrl = iconUrl;
this.title = title;
this.description = description;
+
+ String groupIdToSet = groupId;
+ if (groupId == null) {
+ try {
+ groupIdToSet = new URL(siteUrl).getHost() + title;
+ } catch (MalformedURLException e) {
+ Log.e(TAG, "PwsResult created with a malformed URL", e);
+ groupIdToSet = siteUrl + title;
+ }
+ }
+ this.groupId = groupIdToSet;
}
}

Powered by Google App Engine
This is Rietveld 408576698