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

Unified Diff: components/physical_web/data_source/physical_web_data_source.h

Issue 2561493002: Pass Physical Web metadata through a struct (Closed)
Patch Set: Add required/optional comments Created 4 years 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: components/physical_web/data_source/physical_web_data_source.h
diff --git a/components/physical_web/data_source/physical_web_data_source.h b/components/physical_web/data_source/physical_web_data_source.h
index c6310396ce1a25c4ac2a767975182c3def46f550..4c4706526d3352306f438f20ec700769f20d1e46 100644
--- a/components/physical_web/data_source/physical_web_data_source.h
+++ b/components/physical_web/data_source/physical_web_data_source.h
@@ -6,6 +6,10 @@
#define COMPONENTS_PHYSICAL_WEB_DATA_SOURCE_PHYSICAL_WEB_DATA_SOURCE_H_
#include <memory>
+#include <string>
+#include <vector>
+#include "base/time/time.h"
+#include "url/gurl.h"
namespace base {
class ListValue;
@@ -16,6 +20,7 @@ namespace physical_web {
class PhysicalWebListener;
// Dictionary keys for reading Physical Web URL metadata.
+// TODO(cco3): Remove these when we are no longer dependent.
extern const char kDescriptionKey[];
extern const char kDistanceEstimateKey[];
extern const char kGroupIdKey[];
@@ -25,6 +30,44 @@ extern const char kScanTimestampKey[];
extern const char kScannedUrlKey[];
extern const char kTitleKey[];
+// Metadata struct for associating data with Physical Web URLs.
+struct Metadata {
+ Metadata();
+ Metadata(const Metadata& other);
+ ~Metadata();
+ // The URL broadcasted by the beacon and scanned by the client device.
+ // REQUIRED
+ GURL scanned_url;
+ // The URL that the scanned_url redirects to.
+ // This is the URL that users should be directed to.
+ // REQUIRED
+ GURL resolved_url;
vitaliii 2016/12/09 09:52:49 Then PhysicalWebListener methods (e.g. OnFound) sh
cco3 2016/12/10 00:25:23 Done. Hm, good point.
+ // The favicon URL.
+ // OPTIONAL
+ GURL icon_url;
+ // The title of the web page.
+ // REQUIRED
+ std::string title;
+ // The description of the web page.
+ // OPTIONAL
vitaliii 2016/12/09 09:52:49 Could you elaborate on when one should not expect
cco3 2016/12/10 00:25:23 Done.
+ std::string description;
+ // An identifier that associates multiple resolved URLs. If two URLs have
vitaliii 2016/12/09 09:52:49 I do not understand this. Could you give an exampl
cco3 2016/12/10 00:25:23 Done.
+ // the same group id, only one should be shown (typically, the one with the
+ // smallest distance estimate).
+ // OPTIONAL: treat the item as its own unique group if this doesn't exist.
vitaliii 2016/12/09 09:52:49 s/doesn't exist/empty
cco3 2016/12/10 00:25:23 Done.
+ std::string group_id;
+ // The estimated distance between the user and the Physical Web device (e.g.,
+ // beacon) in meters.
+ // OPTIONAL: This will be a value <= 0 if no distance estimate has been
+ // calculated.
vitaliii 2016/12/09 09:52:49 An example when the distance is not estimated?
cco3 2016/12/10 00:25:23 Done.
+ double distance_estimate;
+ // The timestamp corresponding to when this URL was last scanned.
+ // REQUIRED
+ base::Time scan_timestamp;
+};
+
+using MetadataList = std::vector<Metadata>;
+
// Helper class for accessing Physical Web metadata and controlling the scanner.
class PhysicalWebDataSource {
public:
@@ -41,6 +84,14 @@ class PhysicalWebDataSource {
// requests are disabled or if discovery is not active, the list will be
// empty. The method can be called at any time to receive the current metadata
// list.
+ virtual std::unique_ptr<MetadataList> GetMetadataList() = 0;
+
+ // Returns a list of resolved URLs and associated page metadata. If network
+ // requests are disabled or if discovery is not active, the list will be
+ // empty. The method can be called at any time to receive the current metadata
+ // list.
+ // DEPRECATED
+ // TODO(cco3): Remove this when we are no longer dependent on it.
virtual std::unique_ptr<base::ListValue> GetMetadata() = 0;
// Returns boolean |true| if network requests are disabled and there are one

Powered by Google App Engine
This is Rietveld 408576698